*/ class Wpstream { /** * Store plugin main class to allow public access. * * @since 3.0.1 * @var object The main class. */ public $main; /** @var Wpstream_Admin The admin-area controller instance. */ public $admin; /** * The loader that's responsible for maintaining and registering all hooks that power * the plugin. * * @since 3.0.1 * @access protected * @var Wpstream_Loader $loader Maintains and registers all hooks for the plugin. */ protected $loader; /** * The unique identifier of this plugin. * * @since 3.0.1 * @access protected * @var string $plugin_name The string used to uniquely identify this plugin. */ protected $plugin_name; /** * The current version of the plugin. * * @since 3.0.1 * @access protected * @var string $version The current version of the plugin. */ protected $version; /** * Define the core functionality of the plugin. * * Set the plugin name and the plugin version that can be used throughout the plugin. * Load the dependencies, define the locale, and set the hooks for the admin area and * the public-facing side of the site. * * @since 3.0.1 */ /** @var Wpstream_Live_Api_Connection Cloud API client for channels/quota. */ public $wpstream_live_connection; /** @var Wpstream_Player Player/rendering service. */ public $wpstream_player; /** @var Wpstream_Quota_Manager Quota cache manager. */ public $quota_manager; /** @var Wpstream_Channel_Settings Deep Module for per-Channel streaming settings. */ public $channel_settings; /** @var Wpstream_Streaming_Content_Creation Deep Module for Live Channel and VOD creation. */ public $streaming_content_creation; /** @var Wpstream_Drm_Key_Delivery Deep Module for live and VOD DRM Key delivery. */ public $drm_key_delivery; /** @var Wpstream_Media_List Deep Module for Channel and VOD lists. */ public $media_list; /** @var Wpstream_Playback_Presentation Deep Module for approved player presentation. */ public $playback_presentation; /** @var object User quota service resolved from the live connection. */ public $user_quota_service; /** @var mixed Unused/reserved property. */ public $xtest; /** @var Wpstream_Admin Admin controller (also stored in $admin). */ public $plugin_admin; /** @var Wpstream_Onboarding|null Lazily-created onboarding workflow module. */ private $onboarding; /** @var Wpstream_Live_Channel_Presentation|null Lazily-created Live Channel presentation module. */ private $live_channel_presentation; /** * Bootstrap the plugin: resolve version/name, load dependencies, then wire * all admin, public, AJAX, template, and service objects together. */ public function __construct() { // Expose this instance as the shared "main" service locator. $this->main = $this; // Resolve the plugin version from the defined constant, else fall back. if ( defined( 'WPSTREAM_PLUGIN_VERSION' ) ) { $this->version = WPSTREAM_PLUGIN_VERSION; } else { $this->version = '3.0.1'; } // Text-domain / unique plugin identifier. $this->plugin_name = 'wpstream'; // Require class files and instantiate the hook loader. $this->load_dependencies(); // Register admin-area hooks (menus, metaboxes, WooCommerce, onboarding). $this->define_admin_hooks(); // Register public-facing hooks (scripts, endpoints, shortcodes). $this->define_public_hooks(); // Register AJAX handlers. $this->define_ajax_hooks(); // Register the front-end page/single template loader. $this->wpstream_load_page_templates(); // Register the "theme update available" admin notice. $this->wpstream_load_theme_notice(); // Instantiate the cloud API connection (and user quota service). $this->wpstream_connection(); // Compose the deep Channel Settings Module with its WordPress and Baker Adapters. $this->channel_settings = new Wpstream_Channel_Settings( new Wpstream_WordPress_Channel_Settings_Storage(), new Wpstream_Baker_Channel_Settings_Adapter( $this->wpstream_live_connection ) ); $this->wpstream_live_connection->set_channel_settings( $this->channel_settings ); $this->drm_key_delivery = new Wpstream_Drm_Key_Delivery( $this->channel_settings, new Wpstream_WordPress_Drm_Key_Remote_Fetch() ); $this->media_list = new Wpstream_Media_List( new Wpstream_Baker_Media_List_Active_Catalog( $this->wpstream_live_connection ) ); $this->playback_presentation = new Wpstream_Playback_Presentation( $this ); $this->streaming_content_creation = new Wpstream_Streaming_Content_Creation( $this, $this->channel_settings, new Wpstream_Baker_Streaming_Content_Provisioning( $this->wpstream_live_connection ), new Wpstream_Baker_Streaming_Content_Recording_Catalog( $this->wpstream_live_connection ) ); $this->wpstream_live_connection->set_streaming_content_creation( $this->streaming_content_creation ); // Instantiate the player service. $this->wpstream_player(); // Instantiate the quota cache manager. $this->wpstream_init_quota_manager(); } /** * Convert a quota figure from megabytes to gigabytes. * * @param float|int $megabytes Value in megabytes. * @return float Value in gigabytes, floored to two decimals. */ public function wpstream_convert_band( $megabytes ) { // Quota payloads use binary megabytes. Never round remaining allowance up. return $this->wpstream_floor_decimals( (float) $megabytes / 1024, 2 ); } /** * Floor a number to a given number of decimal places. * * @param float $value The number to floor. * @param int $decimals Number of decimal places. * @return float */ public function wpstream_floor_decimals( $value, $decimals = 2 ) { // Clamp decimals to a non-negative integer. $decimals = max( 0, (int) $decimals ); // Scale factor for the requested precision. $factor = pow( 10, $decimals ); // Multiply, floor, divide back, then format to fixed precision. return floatval( sprintf( '%.' . $decimals . 'f', floor( (float) $value * $factor ) / $factor ) ); } /** @var WpStream_Ajax The AJAX handler service. */ public $wpstream_ajax; /** * Load and instantiate the AJAX handler service. */ private function define_ajax_hooks() { // Construct the AJAX service with the main instance (class autoloads). $this->wpstream_ajax = new WpStream_Ajax( $this->main ); } /** * Load the cloud API connection and resolve the user quota service. */ private function wpstream_connection(){ // Instantiate the live/cloud API client (class autoloads). $this->wpstream_live_connection = new Wpstream_Live_Api_Connection(); // Cache the user quota service exposed by the connection. $this->user_quota_service = $this->wpstream_live_connection->get_user_quota_service(); } /** * Load and instantiate the player service. */ private function wpstream_player(){ // Build the player service with the main instance (class autoloads). $this->wpstream_player = new Wpstream_Player($this->main); } /** * Load and instantiate the quota cache manager. */ private function wpstream_init_quota_manager() { // Build the quota cache manager with this main instance (class autoloads). $this->quota_manager = new Wpstream_Quota_Manager( $this ); } /** * Load and register the front-end template loader. */ private function wpstream_load_page_templates() { // Register the template loader's hooks by constructing it (class autoloads). new WpStream_Template_Loader(); } /** * Load and register the companion-theme update admin notice. */ private function wpstream_load_theme_notice() { // Register the notice by constructing it (class autoloads). new WPStream_Theme_Notice(); } /** * Load the dependencies the classmap autoloader cannot serve. * * Plugin classes resolve through Wpstream_Autoloader on first use, so this * only requires what an autoloader can never load: the WooCommerce product * types (kept behind a WooCommerce guard because they extend WC_Product) * and the function-only helper files. It then creates the hook loader that * the define_*_hooks() methods populate. * * @since 3.0.1 * @access private */ private function load_dependencies() { // WooCommerce product-type classes extend WC_Product, so loading them // without WooCommerce active would fatal at class-link time; they stay // behind this guard instead of the classmap. if( class_exists( 'WooCommerce' ) ){ // Paid live-stream product type. require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wc-product-live-stream.php'; // Paid video-on-demand product type. require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wc-product-video-on-demand.php'; } // Function-only helper files: no class inside, so the autoloader can // never serve them and they must be required eagerly. // Channel-ownership authorization helper (wpstream_can_manage_channel), // used by every live/broadcast handler to enforce per-channel ownership. require_once plugin_dir_path(__FILE__) . 'Helpers/wpstream-authorization.php'; // Viewing-entitlement helper (wpstream_user_entitled_for_product), // the single rule every playback access gate must call. require_once plugin_dir_path(__FILE__) . 'Helpers/wpstream-entitlement.php'; // WpStream account credential accessors (constant override + options). require_once plugin_dir_path(__FILE__) . 'Helpers/wpstream-credentials.php'; // Viewer-facing presentation strings (wpstream_not_live_message), shared by // the player, the public JS config and the bundled theme framework. require_once plugin_dir_path(__FILE__) . 'Helpers/wpstream-presentation.php'; // My Account list collector (wpstream_account_list_products) shared by the // event-list and video-list templates. require_once plugin_dir_path(__FILE__) . 'Helpers/wpstream-account-lists.php'; // Tunables (wpstream_tunable): cache TTLs, poll intervals and limits run // through their filter and are clamped in one place. require_once plugin_dir_path(__FILE__) . 'Helpers/wpstream-tunables.php'; // Create the hook loader that other define_*_hooks() methods populate. $this->loader = new Wpstream_Loader(); } /** * Register all of the hooks related to the admin area functionality * of the plugin. * * @since 3.0.1 * @access private */ /** * Whether a post edit route can present Live Channel controls. * * @param string $post_type Current post type. * @param WP_Post|null $post Current post, when one exists. * @return bool */ private function is_live_channel_admin_post( $post_type, $post = null ) { if ( 'wpstream_product' === $post_type ) { return true; } if ( 'product' !== $post_type ) { return false; } $post_id = $post instanceof WP_Post ? intval( $post->ID ) : 0; if ( ! $post_id && isset( $_GET['post'] ) ) { $post_id = absint( wp_unslash( $_GET['post'] ) ); } if ( $post_id ) { $product_type = wpstream_get_product_type_slug( $post_id ); return 'live_stream' === $product_type || ( 'subscription' === $product_type && 'yes' === get_post_meta( $post_id, '_subscript_live_event', true ) ); } return isset( $_GET['new_stream'] ) && 'new' === sanitize_key( wp_unslash( $_GET['new_stream'] ) ); } /** * Whether the current wp-admin screen presents Live Channel controls. * * @param WP_Screen|null $screen Current WordPress screen. * @return bool */ private function is_live_channel_admin_screen( $screen ) { if ( ! $screen ) { return false; } if ( 'wpstream_page_wpstream_live_channels' === $screen->base ) { return true; } global $post; return $this->is_live_channel_admin_post( $screen->post_type, $post instanceof WP_Post ? $post : null ); } private function define_admin_hooks() { // Build the admin controller and keep a reference to it. $plugin_admin = new Wpstream_Admin( $this->get_plugin_name(), $this->get_version(), $this->main ); $this->admin = $plugin_admin; // Admin CSS/JS and the plugin's admin menu (late priority). $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); add_action( 'admin_enqueue_scripts', function () { $screen = get_current_screen(); if ( $this->is_live_channel_admin_screen( $screen ) ) { $this->get_live_channel_presentation()->enqueue_assets(); } }, 20 ); $this->loader->add_action( 'admin_menu', $plugin_admin, 'wpstream_manage_admin_menu',999); // "Chat Room" metabox: bind an existing Better Messages room to a channel. new Wpstream_Chat_Room_Binding(); // Register the custom post types on init. $plugin_post_types = new Wpstream_Product(); $this->loader->add_action( 'init', $plugin_post_types, 'create_custom_post_type', 999 ); // save and render metaboxed // Register product metaboxes; persist their values on save; and, // on publish, create the remote streaming channel. $this->loader->add_action( 'add_meta_boxes', $plugin_admin, 'add_wpstream_product_metaboxes' ); $this->loader->add_action( 'save_post', $plugin_admin, 'wpstream_free_product_update_post',1,2 ); $this->loader->add_action( 'publish_wpstream_product', $plugin_admin, 'wpstream_publish_wpstream_product',1,2 ); $this->loader->add_action( 'publish_wpstream_product', $plugin_admin, 'wpstream_create_remote_channel_on_publish',20,2 ); $this->loader->add_action( 'publish_wpstream_product_vod', $plugin_admin, 'wpstream_create_remote_channel_on_publish', 20, 2 ); $this->loader->add_action( 'publish_product', $plugin_admin, 'wpstream_create_remote_channel_on_publish', 20, 2 ); // Mirror of the publish hooks above: a permanently deleted Live // Channel is deleted at the service too (trash is untouched). $this->loader->add_action( 'before_delete_post', $plugin_admin, 'wpstream_delete_remote_channel_on_delete', 10, 2 ); $this->loader->add_action( 'before_delete_post', $plugin_admin, 'wpstream_invalidate_vod_drm_on_delete', 5, 2 ); $this->loader->add_action( 'transition_post_status', $plugin_admin, 'wpstream_invalidate_vod_drm_on_status_change', 10, 3 ); // WooCommerce restores products to their previous published status. // Paid Live Channels follow the safer channel lifecycle instead: // restore as draft and require an explicit republish. $this->loader->add_filter( 'wp_untrash_post_status', $plugin_admin, 'wpstream_paid_live_untrash_status', 20, 3 ); // make product virtual $this->loader->add_action( 'save_post', $plugin_admin, 'wpstream_make_product_virtual', 99999, 2 ); // Add Live Channel controls only on edit screens that can own them. add_action( 'add_meta_boxes', function ( $post_type, $post ) { if ( $this->is_live_channel_admin_post( $post_type, $post ) ) { $this->get_live_channel_presentation()->register_metaboxes(); } }, 10, 2 ); // Load onboarding only when its page assets or one of its AJAX routes runs. add_action( 'admin_enqueue_scripts', function () { $screen = get_current_screen(); $is_quickstart = $screen && 'wpstream_page_wpstream_onboard' === $screen->base; $is_post_edit = isset( $_GET['onboard'] ) && 'yes' === $_GET['onboard']; if ( $is_quickstart || $is_post_edit ) { $this->get_onboarding()->enqueue_assets(); } }, 20 ); $onboarding_ajax_actions = array( 'wpstream_on_board_create_channel', 'wpstream_on_board_create_channel_ppv', 'wpstream_on_board_create_free_vod', 'wpstream_on_board_create_ppv_vod', 'wpstream_on_board_login', 'wpstream_on_board_register', 'wpstream_get_captcha_challenge', ); foreach ( $onboarding_ajax_actions as $onboarding_ajax_action ) { add_action( 'wp_ajax_' . $onboarding_ajax_action, function () use ( $onboarding_ajax_action ) { return $this->get_onboarding()->handle_ajax( $onboarding_ajax_action ); } ); } // Register AJAX actions for multipart uploads $this->loader->add_action( 'wp_ajax_wpstream_initiate_multipart_upload', $plugin_admin, 'handle_initiate_multipart_upload' ); $this->loader->add_action( 'wp_ajax_wpstream_complete_multipart_upload', $plugin_admin, 'handle_complete_multipart_upload' ); // General and plugin-update admin notices. $this->loader->add_action( 'admin_notices', $plugin_admin,'wpstream_admin_notice' ); $this->loader->add_action( 'admin_notices', $plugin_admin,'wpstream_plugin_update_available_notice' ); // Dismiss-cache-notice AJAX endpoint. $this->loader->add_action( 'wp_ajax_wpstream_update_cache_notice', $plugin_admin,'wpstream_update_cache_notice' ); // $this->loader->add_action( 'wp_ajax_wpstream_get_videos_list', $plugin_admin,'wpstream_get_videos_list' ); // Settings-tab "update plugin" AJAX endpoint. $this->loader->add_action( 'wp_ajax_wpstream_settings_tab_update_plugin', $plugin_admin, 'wpstream_settings_tab_update_plugin' ); // add and save category extra fields // The same add/edit/create/save callbacks are shared across every taxonomy below. $this->loader->add_action( 'category_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2); $this->loader->add_action( 'category_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function' ); $this->loader->add_action( 'created_category', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2); $this->loader->add_action( 'edited_category', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2); // Same extra fields on the WooCommerce product category taxonomy. $this->loader->add_action( 'product_cat_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2); $this->loader->add_action( 'product_cat_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function' ); $this->loader->add_action( 'created_product_cat', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2); $this->loader->add_action( 'edited_product_cat', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2); // Same extra fields on the plugin's own wpstream_category taxonomy. $this->loader->add_action( 'wpstream_category_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2); $this->loader->add_action( 'wpstream_category_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function' ); $this->loader->add_action( 'created_wpstream_category', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2); $this->loader->add_action( 'edited_wpstream_category', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2); // Same extra fields on the wpstream_actors taxonomy. $this->loader->add_action( 'wpstream_actors_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2); $this->loader->add_action( 'wpstream_actors_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function' ); $this->loader->add_action( 'created_wpstream_actors', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2); $this->loader->add_action( 'edited_wpstream_actors', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2); // Same extra fields on the wpstream_movie_rating taxonomy. $this->loader->add_action( 'wpstream_movie_rating_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2); $this->loader->add_action( 'wpstream_movie_rating_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function' ); $this->loader->add_action( 'created_wpstream_movie_rating', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2); $this->loader->add_action( 'edited_wpstream_movie_rating', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2); // WooCommerce-only admin hooks: register the custom product types, // their data tabs/fields, pricing visibility, and add-to-cart handling. // Deferred to plugins_loaded because WooCommerce may load after this // plugin, and detection uses class_exists (not the active_plugins // option) so network-activated WooCommerce on multisite is seen too. // Registered directly (not via the loader) because the loader runs // before plugins_loaded fires; every hook below fires later than // plugins_loaded, so nothing is missed by the deferral. add_action( 'plugins_loaded', function () use ( $plugin_admin ) { // Without WooCommerce none of these hooks have anything to do. if ( ! class_exists( 'WooCommerce' ) ) { return; } // Register product types and map them to their PHP classes. add_action( 'init', array( $plugin_admin, 'wpstream_add_custom_wc_products' ) ); add_filter( 'product_type_selector', array( $plugin_admin, 'wpstream_add_products' ) ); add_filter( 'woocommerce_product_class', array( $plugin_admin, 'wpstream_add_products_class' ), 10, 2 ); // Pricing-field visibility, tab hiding, and purchasability rules. add_action( 'admin_enqueue_scripts', array( $plugin_admin, 'wpstream_enqueue_wc_product_pricing_visibility' ), 20 ); add_filter( 'woocommerce_product_data_tabs', array( $plugin_admin, 'wpstream_hide_attributes_data_panel' ), 10, 1 ); add_filter( 'woocommerce_is_purchasable', array( $plugin_admin, 'wpstream_hide_buy_now_subscription_mode' ), 10, 2 ); // Custom general-tab fields (render + save) and add-to-cart wiring. add_action( 'woocommerce_product_options_general_product_data', array( $plugin_admin, 'wpstream_add_custom_general_fields' ), 20 ); add_filter( 'woocommerce_process_product_meta', array( $plugin_admin, 'wpstream_add_custom_general_fields_save' ), 10, 1 ); add_action( 'woocommerce_process_product_meta', array( $plugin_admin, 'wpstream_initialize_paid_streaming_product' ), 30, 1 ); add_action( 'woocommerce_live_stream_add_to_cart', array( $plugin_admin, 'wpstream_add_to_cart' ), 10, 1 ); add_action( 'woocommerce_video_on_demand_add_to_cart', array( $plugin_admin, 'wpstream_add_to_cart' ), 10, 1 ); add_filter( 'woocommerce_loop_add_to_cart_link', array( $plugin_admin, 'replacing_add_to_cart_button' ), 10, 2 ); } ); } /** * Register all of the hooks related to the public-facing functionality * of the plugin. * * @since 3.0.1 * @access private */ private function define_public_hooks() { // Build the public-facing controller. $plugin_public = new Wpstream_Public( $this->get_plugin_name(), $this->get_version(), $this->main ); // Front-end styles. $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); // Registered on `wp` (not `wp_enqueue_scripts`/`wp_head`) because block themes render // the Post Content block - and thus our `the_content` filter that enqueues/localizes // these scripts - before `wp_head` ever fires, leaving the handles unregistered. $this->loader->add_action( 'wp', $plugin_public, 'enqueue_scripts' ); // Custom rewrite endpoints and their query vars. $this->loader->add_action( 'init', $plugin_public,'wpstream_my_custom_endpoints' ); $this->loader->add_filter( 'query_vars',$plugin_public, 'wpstream_my_custom_query_vars', 0 ); //live stream action // Streaming cookies plus the RTMP/3rd-party/VOD streaming-key handlers. $this->loader->add_action('init',$plugin_public,'wpstream_set_cookies',0); $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key'); $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key_for_3rdparty'); $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key_vod',10); // woo action // Product-page content wrappers and order/email extras. $this->loader->add_action( 'woocommerce_before_single_product', $plugin_public,'wpstream_non_image_content_wrapper_start', 20 ); $this->loader->add_action( 'woocommerce_after_single_product', $plugin_public,'wpstream_non_image_content_wrapper_end', 20 ); $this->loader->add_action( 'woocommerce_thankyou_order_received_text', $plugin_public,'wpstream_thankyou_extra', 20,2 ); $this->loader->add_action( 'woocommerce_email_order_details', $plugin_public,'wpstream_email_order_details', 20,4 ); // My Account: add the Events/Videos menu items and their endpoint content. // Run after themes have built their account navigation so a theme that // replaces the menu cannot discard the plugin-owned Events/Videos links. $this->loader->add_filter( 'woocommerce_account_menu_items', $plugin_public, 'wpstream_custom_my_account_menu_items', 99 ); $this->loader->add_action( 'woocommerce_account_event-list_endpoint', $plugin_public,'wpstream_custom_endpoint_content_event_list' ); $this->loader->add_action( 'woocommerce_account_video-list_endpoint', $plugin_public,'wpstream_custom_endpoint_video_list' ); // Flush rewrite rules on theme switch; register plugin and WPBakery shortcodes. $this->loader->add_action( 'after_switch_theme', $plugin_public,'wpstream_custom_flush_rewrite_rules' ); $this->loader->add_action('init', $plugin_public,'wpstream_shortcodes'); $this->loader->add_action('vc_before_init', $plugin_public,'wpstream_bakery_shortcodes'); // CORS preflight check for the API (uses a plain function callback). $this->loader->add_action('wo_before_api', 'wpstream_cors_check_and_response',10,1); // Theme-integration filters/actions: search, sidebars, archives, and // author/episode/past-broadcast content resolution by post type. $this->loader->add_filter( 'wpstream_search_template_item_post_type', $plugin_public, 'wpstream_search_template_add_item_post_type' ); $this->loader->add_filter( 'wpstream_sidebar_id_by_post_type', $plugin_public, 'wpstream_sidebar_id_by_post_type' ); $this->loader->add_filter( 'wpstream_header_search_values', $plugin_public, 'wpstream_header_search_values' ); $this->loader->add_filter( 'wpstream_extend_category_archive_query_filter', $plugin_public, 'wpstream_extend_category_archive_query_filter_callback' ); $this->loader->add_filter( 'wpstream_archives_lists_taxonomy_labels', $plugin_public, 'wpstream_archives_lists_taxonomy_labels_callback' ); $this->loader->add_filter( 'wpstream_author_archive_list_taxonomy_labels', $plugin_public, 'wpstream_author_archive_list_taxonomy_labels_callback' ); $this->loader->add_action( 'wpstream_vod_attached_to_channel', $plugin_public, 'wpstream_vod_attached_to_channel' ); $this->loader->add_action( 'wpstream_additional_content_post_type', $plugin_public, 'wpstream_additional_content_post_type_callback' ); $this->loader->add_action( 'wpstream_post_author_content_post_type_list', $plugin_public, 'wpstream_post_author_content_post_type_list_callback' ); $this->loader->add_action( 'wpstream_author_content_simple_post_type_message', $plugin_public, 'wpstream_author_content_simple_post_type_message_callback', 10, 2 ); $this->loader->add_action( 'wpstream_author_content_post_type_message', $plugin_public, 'wpstream_author_content_post_type_message_callback', 10, 2 ); $this->loader->add_action( 'wpstream_show_sidebar_for_post_type', $plugin_public, 'wpstream_show_sidebar_for_post_type_callback', 10, 2 ); $this->loader->add_action( 'wpstream_video_episodes_post_type', $plugin_public, 'wpstream_video_episodes_post_type_callback' ); $this->loader->add_action( 'wpstream_video_past_broadcast_post_type', $plugin_public, 'wpstream_video_past_broadcast_post_type_callback' ); $this->loader->add_action( 'wpstream_additional_content_post_type_label', $plugin_public, 'wpstream_additional_content_post_type_label_callback', 10, 2 ); } /** * Run the loader to execute all of the hooks with WordPress. * * @since 3.0.1 */ public function run() { // Hand off to the loader, which calls add_action/add_filter for every hook. $this->loader->run(); } /** * The name of the plugin used to uniquely identify it within the context of * WordPress and to define internationalization functionality. * * @since 3.0.1 * @return string The name of the plugin. */ public function get_plugin_name() { // Return the stored text-domain / identifier string. return $this->plugin_name; } /** * The reference to the class that orchestrates the hooks with the plugin. * * @since 3.0.1 * @return Wpstream_Loader Orchestrates the hooks of the plugin. */ public function get_loader() { // Return the hook loader instance. return $this->loader; } /** * Retrieve the version number of the plugin. * * @since 3.0.1 * @return string The version number of the plugin. */ public function get_version() { // Return the resolved plugin version string. return $this->version; } /** * Return the onboarding workflow, creating it only when an onboarding route * actually needs it. * * @return Wpstream_Onboarding */ public function get_onboarding() { if ( ! $this->onboarding ) { $this->onboarding = new Wpstream_Onboarding( $this ); } return $this->onboarding; } /** * Return the Live Channel admin presentation, creating it only when a * relevant screen or shared go-live card needs it. * * @return Wpstream_Live_Channel_Presentation */ public function get_live_channel_presentation() { if ( ! $this->live_channel_presentation ) { $this->live_channel_presentation = new Wpstream_Live_Channel_Presentation( $this ); } return $this->live_channel_presentation; } /** * Whether WordPress currently reports a pending update for this plugin. * * @return bool True when an update is available in the update_plugins transient. */ public function is_plugin_outdated(){ // WordPress caches pending plugin updates in this site transient. $update_data = get_site_transient('update_plugins'); // The plugin's basename key within that transient. $plugin_path = 'wpstream/wpstream.php'; // Presence of a response entry means an update is offered. if (isset($update_data->response[$plugin_path])) { return true; } // No entry -> up to date. return false; } /** * Print the account resource summary (data/storage or hours) shown in the UI. * * @param array $pack_details Quota payload for the current account. */ public function show_user_data($pack_details){ // Branch A: data/storage (megabyte) plans - when NOT using streaming hours. if ( ! isset( $pack_details['use_streaming_hours'] ) || $pack_details['use_streaming_hours'] !== true ) { // Only render when both data and storage figures are present. if ( isset( $pack_details['available_data_mb'] ) && isset( $pack_details['available_storage_mb'] ) ) { // Convert available data MB to GB, clamping negatives to zero. $wpstream_convert_band = $this->wpstream_convert_band( $pack_details['available_data_mb'] ); if ( $wpstream_convert_band < 0 ) { $wpstream_convert_band = 0; } // Convert available storage MB to GB, clamping negatives to zero. $wpstream_convert_storage = $this->wpstream_convert_band( $pack_details['available_storage_mb'] ); if ( $wpstream_convert_storage < 0 ) { $wpstream_convert_storage = 0; } // Output the cloud data + storage summary line. print '