Contents
On this page
Hooks - Plugixa Stream
This page is for developers. The plugin fires WordPress actions and filters, all prefixed
plugixa_stream_, that you can use from a theme’s functions.php or a small plugin of your
own. Hooks marked PRO fire only when Pro is installed.
The plugin also has hooks its own modules use to talk to each other. Only the ones below are meant for site developers; the others are listed at the end and may change between versions.
Reacting to events
Series and episodes
| Action | Arguments | When it fires |
|---|---|---|
plugixa_stream_series_saved |
$series_id |
After a series or movie was created or changed in the admin app or through the API. |
plugixa_stream_episode_saved |
$episode_id |
After an episode was created or changed in the admin app or through the API. |
plugixa_stream_transcode_done PRO |
$episode_id |
When an episode’s qualities have been encoded and are ready to play. |
Both save actions pass only the id. Read the record as stored, which is already cleaned:
add_action( 'plugixa_stream_episode_saved', function ( int $episode_id ) {
$episode = get_post( $episode_id );
if ( $episode && 'publish' === $episode->post_status ) {
// Tell your newsletter tool, clear a cache, ...
}
} );
Viewers
| Action | Arguments | When it fires |
|---|---|---|
plugixa_stream_play_started |
$episode, $user_id |
Each time the server hands out a stream for an episode the viewer may play. $episode is a WP_Post; $user_id is 0 for a guest. The player also asks for the next episode in advance, so count plays with care. |
plugixa_stream_viewer_erased |
$viewer_id |
After a viewer’s history and lists were erased: an account deleted, a personal-data erase, or one of its profiles removed. |
Sales PRO
| Action | Arguments | When it fires |
|---|---|---|
plugixa_stream_checkout_started |
$order_id, $checkout_ref |
When a Stripe Checkout session or PayPal order was opened for an order. $checkout_ref is Stripe’s session id or PayPal’s order id. |
plugixa_stream_order_paid |
$order |
Once, when an order is paid. $order holds id, user_id, gateway, product (pack or vip), product_id, amount (in the currency’s smallest unit), currency, coins, bonus_coins, coupon and status. |
add_action( 'plugixa_stream_order_paid', function ( array $order ) {
$user = get_userdata( (int) $order['user_id'] );
wp_mail(
get_option( 'admin_email' ),
'New Stream order #' . $order['id'],
sprintf( '%s bought %s (%s).', $user ? $user->user_email : 'A viewer', $order['product_id'], $order['product'] )
);
} );
The plugin itself
| Action | Arguments | When it fires |
|---|---|---|
plugixa_stream_loaded |
$container |
Once the plugin has started, on every request. |
plugixa_stream_activated |
On activation, once the tables exist and before the address rules are refreshed. | |
plugixa_stream_deactivated |
On deactivation. Modules clear their scheduled jobs here. | |
plugixa_stream_migration_failed |
$failures |
When a database table could not be created or updated: module id => tables and reason. |
plugixa_stream_uninstall |
When the plugin is deleted with Delete all data on, before its tables are dropped. | |
plugixa_stream_settings_saved |
$settings |
After the settings were saved, with everything stored. |
plugixa_stream_register_rest_routes |
$namespace, $container |
While the plugin registers its REST routes, under plugixa-stream/v1. See REST API. |
plugixa_stream_admin_submenus |
$parent_slug, $render |
While the admin menu is built: add your own submenu under Plugixa Stream. |
plugixa_stream_enqueue_assets |
$hook_suffix |
On the plugin’s admin screen, after the admin app’s scripts are enqueued. |
plugixa_stream_classic_archive |
On a classic theme, inside the browse and genre page template, between your theme’s header and footer. |
Changing behavior
Who may watch
| Filter | Arguments | What it changes |
|---|---|---|
plugixa_stream_can_play |
$allowed, $episode, $user_id |
Whether a viewer may play an episode. The default is whether the episode is free. Return true to unlock it. Never return false for a free episode. |
plugixa_stream_play_gate |
$held, $episode, $user_id |
Hold back an episode the viewer may otherwise play, for a rule about the account rather than the episode. Return an array to refuse (it is sent to the player as the locked answer’s offer), or null to let it play. |
plugixa_stream_locked_offer |
$offer, $episode, $user_id |
What a viewer is offered on a locked episode. Empty in the free plugin; Pro fills it with coins and VIP. |
plugixa_stream_can_spend PRO |
$allowed, $user_id |
Whether the current viewer may spend from the account: unlock with coins, pay, check a promo code or cancel VIP. Kids profiles answer false. |
plugixa_stream_series_visible |
$visible, $series |
Whether the current viewer may see a published series in the Watch app. A hidden series answers as if it did not exist. |
plugixa_stream_ads_show PRO |
$show, $episode, $user_id |
Whether this viewer sees ads on this episode, after the built-in rules said yes. |
Every episode check goes through plugixa_stream_can_play, on the server, before a stream
address is given. To open every episode to a role of your own:
add_filter( 'plugixa_stream_can_play', function ( bool $allowed, WP_Post $episode, int $user_id ) {
return $allowed || ( $user_id > 0 && user_can( $user_id, 'my_club_member' ) );
}, 10, 3 );
To hide a series from guests:
add_filter( 'plugixa_stream_series_visible', function ( bool $visible, WP_Post $series ) {
return $visible && ( is_user_logged_in() || 'night-of-the-living-dead' !== $series->post_name );
}, 10, 2 );
Playback
| Filter | Arguments | What it changes |
|---|---|---|
plugixa_stream_playback_source |
$source, $episode, $user_id |
The stream handed to the player: type (hls, mp4 or embed), url and expires. |
plugixa_stream_self_hosted_playlist |
$source, $url |
A self-hosted .m3u8 playlist. The default is a WP_Error, so the free plugin refuses playlists; Pro answers with an hls source. |
plugixa_stream_play_response |
$body, $episode, $user_id |
The whole answer for an episode the viewer may play, last chance to add to it. |
plugixa_stream_resume_position |
$position, $episode, $user_id |
Where the episode resumes, in seconds. |
plugixa_stream_rate_limit |
$limit, $bucket |
Requests per minute per viewer. Default 60. Buckets: play, and in Pro unlock, reward, coupon, review and screens. Return 0 to switch the limit off. |
plugixa_stream_providers |
$providers |
The places video can come from. Each is an object implementing PlugixaStream\Modules\Providers\ProviderInterface. |
To raise the limit on starting episodes, for a site where many guests share one address:
add_filter( 'plugixa_stream_rate_limit', function ( int $limit, string $bucket ) {
return 'play' === $bucket ? 240 : $limit;
}, 10, 2 );
The Watch app and its screens
| Filter | Arguments | What it changes |
|---|---|---|
plugixa_stream_watch_url |
$url |
The address of the page that holds the Watch app. Links from series pages, embeds and emails use it. |
plugixa_stream_viewer_config |
$config |
The settings handed to the Watch app. They are printed on a public page: add nothing a visitor should not read. |
plugixa_stream_home |
$home, $user_id |
The home screen: hero and rows, plus continue for a signed-in viewer. |
plugixa_stream_series_detail |
$detail, $series |
What a title screen shows about the title itself, the same for every viewer. |
plugixa_stream_series_viewer_state |
$state, $series, $user_id |
What this viewer has done with a title: progress, My List, likes, and in Pro unlocks. |
plugixa_stream_row_types |
$types |
Extra home row types. A type you add must also be answered on plugixa_stream_row_series. |
plugixa_stream_row_series |
$ids, $row |
The series ids, in order, for a row type the plugin cannot answer itself. |
plugixa_stream_viewer_id |
$viewer_id, $user_id |
The id viewing data is stored under. Pro’s profiles answer it so each profile has its own history. |
A row type of your own, for example the titles of one studio, takes two filters:
add_filter( 'plugixa_stream_row_types', fn( array $types ) => array_merge( $types, array( 'blender' ) ) );
add_filter( 'plugixa_stream_row_series', function ( array $ids, array $row ) {
if ( 'blender' !== $row['type'] ) {
return $ids;
}
return get_posts( array(
'post_type' => 'pxstream_series',
'posts_per_page' => (int) $row['limit'],
'fields' => 'ids',
'tax_query' => array( array( 'taxonomy' => 'pxstream_studio', 'field' => 'slug', 'terms' => 'blender-studio' ) ),
) );
}, 10, 2 );
Settings and the API
| Filter | Arguments | What it changes |
|---|---|---|
plugixa_stream_settings_defaults |
$defaults |
Default settings. |
plugixa_stream_filter_output |
$data, $entity_type |
Every successful REST answer, before it is sent. |
plugixa_stream_user_can |
$allowed, $action, $entity_type, $record, $user_id |
Whether a user may read, create, edit or delete a record in the admin app. |
plugixa_stream_capabilities |
$map |
The permission flags handed to the admin app. |
Subtitles PRO
| Filter | Arguments | What it changes |
|---|---|---|
plugixa_stream_subtitle_types |
$types |
Extra subtitle file types the site accepts: extension => MIME type. |
plugixa_stream_subtitle_to_vtt |
$vtt, $path, $ext |
Convert a subtitle file the built-in reader could not. Return WebVTT text, or '' to give up. |
plugixa_stream_subtitle_sniffed_mimes |
$allowed, $ext |
What the content of an uploaded subtitle file may be detected as, per extension. Never HTML or XML. |
plugixa_stream_transcription_source |
$url, $episode |
A downloadable MP4 or audio address for AI subtitles from speech, for an episode whose video is not a plain MP4 address. |
Internal hooks
These connect the plugin’s own parts and may change: plugixa_stream_modules,
plugixa_stream_admin_config, plugixa_stream_admin_i18n_strings,
plugixa_stream_config_settings_keys, plugixa_stream_settings_choices,
plugixa_stream_admin_series_query, plugixa_stream_episode_array,
plugixa_stream_episode_write, plugixa_stream_dashboard_stats, plugixa_stream_fs_loaded,
and in Pro plugixa_stream_in_transaction.
Hooks are not webhooks: they run inside WordPress. Stripe and PayPal send their notices to the REST routes described on the REST API page.
Quick Links
Share