PHP hooks reference
Every filter and action in Flipset, in the order they run, with parameters and copy-ready examples.
On this page
- The viewer pipeline
- Lifecycle
- flipset/loaded
- flipset/pro_loaded and flipset/is_pro_active
- flipset/feature_enabled
- Viewer
- flipset/viewer_atts
- flipset/pre_render_viewer
- flipset/before_viewer
- flipset/download_url
- flipset/show_branding
- flipset/viewer_file_url
- flipset/viewer_html
- flipset/translate_attachment_id
- Search, SEO and accessibility
Flipset exposes a public contract so themes and add-ons can extend the viewer without touching its code. All live hooks use slash-style names: flipset/….
The viewer pipeline#
When a viewer renders, these run in order:
- Saved-embed merge (
id) shortcode_atts()flipset/viewer_atts- Empty-file check
flipset/pre_render_viewerflipset/before_viewer- Toolbar (
flipset/download_url) flipset/show_brandingflipset/viewer_file_urlflipset/viewer_html
Lifecycle#
flipset/loaded#
Action. Fires once after every Flipset component has initialised. Use it instead of racing plugins_loaded.
add_action( 'flipset/loaded', function () {
// Flipset classes exist here.
} );
flipset/pro_loaded and flipset/is_pro_active#
An add-on announces itself by defining FLIPSET_PRO_VERSION and firing flipset/pro_loaded on plugins_loaded before priority 20. flipset/is_pro_active (filter, $pro_confirmed) overrides detection; the result is cached for the request.
flipset/feature_enabled#
Filter ( bool $enabled, string $feature_key ). Per-feature gate for add-ons. Runs only when an add-on is active; the default passed in is true.
Viewer#
flipset/viewer_atts#
Filter ( array $atts ). Change any resolved attribute — file, view, theme, size, toggles — after defaults and saved embeds are applied. The empty-file check runs after it, so you can inject a file.
add_filter( 'flipset/viewer_atts', function ( $atts ) {
if ( is_page( 'catalogue' ) ) {
$atts['view'] = 'flip';
$atts['theme'] = 'sepia';
}
return $atts;
} );
Flipset's own WPML / Polylang swap runs at priority 5; hook at 10 or later to override it.
flipset/pre_render_viewer#
Filter ( string|null $output, array $atts ). Return any non-null value to replace the PDF viewer entirely (Flipset Pro uses it for EPUB). The result still passes through flipset/viewer_html.
flipset/before_viewer#
Action ( string $instance_id, array $atts ). Echo markup into the viewer's chrome row before the toolbar.
add_action( 'flipset/before_viewer', function ( $instance_id, $atts ) {
echo '<div class="my-bar" data-for="' . esc_attr( $instance_id ) . '">…</div>';
}, 10, 2 );
flipset/download_url#
Filter ( string $download_url, array $atts ). The Download button's link — send downloads through a tracked or protected endpoint without changing what the viewer renders.
flipset/show_branding#
Filter ( bool $show ). Whether to print the “Powered by Flipset” credit. Default: the Credit link setting (off).
flipset/viewer_file_url#
Filter ( string $file_url, array $atts ). The URL the viewer loads and the no-JavaScript link uses — for signed or proxied URLs.
flipset/viewer_html#
Filter ( string $html, array $atts ). Wrap or post-process the finished markup. Escape anything you add.
add_filter( 'flipset/viewer_html', function ( $html, $atts ) {
$name = basename( wp_parse_url( $atts['file'], PHP_URL_PATH ) );
return '<figure class="my-doc"><figcaption>' . esc_html( $name ) . '</figcaption>' . $html . '</figure>';
}, 10, 2 );
flipset/translate_attachment_id#
Filter ( int $attachment_id, int $original ). Last chance to pick a different PDF attachment for the current language.
Search, SEO and accessibility#
| Hook | Parameters | Use |
|---|---|---|
flipset/extracted_text | $text, $pdf_id | Clean text extracted from a PDF before it is stored. |
flipset/extracted_text_max_chars | $max | Clip length, default 80000. |
flipset/search_index | $blob, $post_id, $ids | Combined text copied onto a post for site search. |
flipset/og_image | $url, $post_id, $pdf_id | The social-card image. |
flipset/schema_digital_document | $doc, $pdf_id, $post_id | DigitalDocument JSON-LD; return a non-array to drop it. |
flipset/pdf_tagged | $tagged, $attachment_id | Override the tagged-PDF result. |
add_filter( 'flipset/extracted_text', function ( $text, $pdf_id ) {
return str_replace( 'CONFIDENTIAL', '', $text );
}, 10, 2 );
Front-end JavaScript events and the FlipsetViewer API are in DOM events & JavaScript; Pro's hooks in Pro hooks.