Skip to content
Free

PHP hooks reference

Every filter and action in Flipset, in the order they run, with parameters and copy-ready examples.

3 min read Updated

On this page

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:

  1. Saved-embed merge (id)
  2. shortcode_atts()
  3. flipset/viewer_atts
  4. Empty-file check
  5. flipset/pre_render_viewer
  6. flipset/before_viewer
  7. Toolbar (flipset/download_url)
  8. flipset/show_branding
  9. flipset/viewer_file_url
  10. flipset/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#

HookParametersUse
flipset/extracted_text$text, $pdf_idClean text extracted from a PDF before it is stored.
flipset/extracted_text_max_chars$maxClip length, default 80000.
flipset/search_index$blob, $post_id, $idsCombined text copied onto a post for site search.
flipset/og_image$url, $post_id, $pdf_idThe social-card image.
flipset/schema_digital_document$doc, $pdf_id, $post_idDigitalDocument JSON-LD; return a non-array to drop it.
flipset/pdf_tagged$tagged, $attachment_idOverride 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.