— go to the documentation home page
MediaFlow documentation

Filters and Hooks

Every filter MediaFlow exposes, what it changes, and the two extension points for teaching it about media it cannot find on its own.

Documents version1.5.1

Last updated

On this page

MediaFlow exposes its behaviour through WordPress filters. Nothing here requires editing plugin files.

All filters

Filter Purpose
mediaflow_capability Move a permission gate. Returning nothing falls back to manage_options.
mediaflow_license_server_url Point the client at another licence server.
mediaflow_license_public_key The Ed25519 key responses are verified against.
mediaflow_license_require_signature Defaults to true. For a staging server that does not sign.
mediaflow_license_check_interval How often an admin page load re-validates.
mediaflow_license_purchase_url Where the plugin’s upgrade links point.
mediaflow_update_check_interval How often update metadata is refreshed.
mediaflow_free_features Which features an unlicensed site gets.
mediaflow_excluded_post_types Hide post types from the settings screen.
mediaflow_post_type_taxonomy Override the taxonomy a post type is grouped by.
mediaflow_root_folder_name Override a post type’s root folder name.
mediaflow_primary_term_id Decide which term a post is filed under.
mediaflow_syncable_post_statuses Change which post statuses take part.
mediaflow_media_usage Register a media usage provider.
mediaflow_usage_coverage What the interface states was checked and not checked.
mediaflow_site_media What counts as media the site itself uses.
mediaflow_block_attachment_keys Teach the core resolver a block’s ID attribute.
mediaflow_block_attachment_ids Read IDs out of one block yourself.
mediaflow_builder_id_keys Keys the Divi/Bricks/Beaver/Breakdance resolver treats as attachment IDs.
mediaflow_import_sources Add a folder plugin to import from.

Teaching MediaFlow about your media

Four filters cover the cases where MediaFlow cannot see a relationship on its own — see What gets detected for what it finds without help.

  • mediaflow_block_attachment_keys — your custom block stores an attachment ID in an attribute MediaFlow does not know about.
  • mediaflow_block_attachment_ids — your block’s structure is unusual enough that you want to extract the IDs yourself.
  • mediaflow_builder_id_keys — a page builder stores an attachment ID under a key the shared builder resolver does not recognise.
  • mediaflow_media_usage — a whole source MediaFlow has no provider for, such as another page builder or a custom meta field.

Changing what is free

mediaflow_free_features decides which features an unlicensed site gets. It defaults to the manual-folder feature alone.

add_filter( 'mediaflow_free_features', function ( $features ) {
	$features[] = 'appearance'; // Folder colours and icons.
	return $features;
} );

Renaming a root folder

Root folder names come from the post type name and are not translated, so a folder’s identity does not change with the site language. To override one:

add_filter( 'mediaflow_root_folder_name', function ( $name, $post_type ) {
    return 'product' === $post_type ? 'shop' : $name;
}, 10, 2 );

Moving a permission gate

add_filter( 'mediaflow_capability', function ( $capability, $context ) {
    return 'manage_folders' === $context ? 'edit_others_posts' : $capability;
}, 10, 2 );

A filter that returns nothing falls back to manage_options. The gate cannot be filtered off — see Permissions.

Pointing at a staging licence server

add_filter( 'mediaflow_license_server_url', fn() => 'https://staging.example.com' );
add_filter( 'mediaflow_license_public_key', fn() => 'base64-encoded-ed25519-key' );

// Only for a staging server that does not sign at all. Never in production.
add_filter( 'mediaflow_license_require_signature', '__return_false' );

The constants MEDIAFLOW_LICENSE_SERVER_URL and MEDIAFLOW_LICENSE_PUBLIC_KEY do the same from wp-config.php.

REST routes

MediaFlow’s own interface writes through mediaflow/v1. The routes and their permission callbacks are listed in Permissions.