| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: WpStream - Live Streaming, Video on Demand, Pay Per View |
| 4 |
* Plugin URI: http://wpstream.net |
| 5 |
* Description: WpStream is a platform that allows you to live stream, create Video-on-Demand, and offer Pay-Per-View videos. We provide an affordable and user-friendly way for businesses, non-profits, and public institutions to broadcast their content and monetize their work. |
| 6 |
* Version: 4.13.2 |
| 7 |
* Author: wpstream |
| 8 |
* Author URI: http://wpstream.net |
| 9 |
* Text Domain: wpstream |
| 10 |
* Domain Path: /languages/ |
| 11 |
*/ |
| 12 |
|
| 13 |
/** |
| 14 |
* Main plugin bootstrap file for WpStream. |
| 15 |
* |
| 16 |
* WordPress reads the header comment above to list the plugin. This file then |
| 17 |
* defines the plugin's global constants (version, remote API/player/click host |
| 18 |
* URLs, path helpers), wires activation/deactivation hooks, schedules a daily |
| 19 |
* log cleanup cron event, loads the core plugin class plus the Elementor and |
| 20 |
* streamify integrations, conditionally loads the hello-wpstream theme |
| 21 |
* framework, registers the custom broadcaster-page rewrite endpoint, and finally |
| 22 |
* instantiates and runs the Wpstream class. |
| 23 |
* |
| 24 |
* @package Wpstream |
| 25 |
*/ |
| 26 |
|
| 27 |
// If this file is called directly, abort. |
| 28 |
// WPINC is defined by WordPress core; its absence means direct access. |
| 29 |
if ( ! defined( 'WPINC' ) ) { |
| 30 |
die; |
| 31 |
} |
| 32 |
// Current plugin version (kept in sync with the header "Version" field above). |
| 33 |
define('WPSTREAM_PLUGIN_VERSION', '4.13.2'); |
| 34 |
// Base host for WpStream account/club links. |
| 35 |
define('WPSTREAM_CLUBLINK', 'wpstream.net'); |
| 36 |
// Scheme used when building club links. |
| 37 |
define('WPSTREAM_CLUBLINKSSL', 'https'); |
| 38 |
// URL to the site's plugins directory. |
| 39 |
define('WPSTREAM_PLUGIN_URL', plugins_url() ); |
| 40 |
// URL to this plugin's own directory. |
| 41 |
define('WPSTREAM_PLUGIN_DIR_URL', plugin_dir_url(__FILE__) ); |
| 42 |
// Filesystem path to this plugin's directory. |
| 43 |
define('WPSTREAM_PLUGIN_PATH', plugin_dir_path(__FILE__) ); |
| 44 |
// Plugin basename (folder/file) used for hook identification. |
| 45 |
define('WPSTREAM_PLUGIN_BASE', plugin_basename(__FILE__) ); |
| 46 |
// Remote WpStream API endpoint; guarded so it can be overridden before load. |
| 47 |
if( !defined('WPSTREAM_API' ) ) { |
| 48 |
// Default API host. |
| 49 |
define('WPSTREAM_API', 'https://baker.wpstream.net'); |
| 50 |
} |
| 51 |
// Telemetry/click-tracking host; guarded so it can be overridden. |
| 52 |
if ( !defined( 'WPSTREAM_CLICK' ) ) { |
| 53 |
// Default click-tracking host. |
| 54 |
define( 'WPSTREAM_CLICK', 'https://click.wpstream.net' ); |
| 55 |
} |
| 56 |
// Player host; guarded so it can be overridden. |
| 57 |
if ( !defined( 'WPSTREAM_PLAYER') ) { |
| 58 |
// Default player host. |
| 59 |
define ( 'WPSTREAM_PLAYER', 'https://player.wpstream.net' ); |
| 60 |
} |
| 61 |
// Prefix for live player URLs; guarded so it can be overridden. |
| 62 |
if ( !defined( 'LIVE_PLAYER_URL_PREFIX' ) ) { |
| 63 |
// Default live player URL prefix. |
| 64 |
define('LIVE_PLAYER_URL_PREFIX', 'https://player.wpstream.net/player/live'); |
| 65 |
} |
| 66 |
|
| 67 |
|
| 68 |
// Default network timeout (seconds) for remote API requests. |
| 69 |
define('WPSTREAM_TIMEOUT_CONST', 20); // in seconds |
| 70 |
|
| 71 |
/** |
| 72 |
* Cron callback that purges expired WpStream log entries. |
| 73 |
* |
| 74 |
* @return void |
| 75 |
*/ |
| 76 |
function wpstream_cleanup_logs_handler() { |
| 77 |
// Instantiate the logger. |
| 78 |
$logger = new WpStream_Logger(); |
| 79 |
// Delete log entries older than the retention window. |
| 80 |
$logger->clear_old_logs(); |
| 81 |
} |
| 82 |
// Run the cleanup handler whenever the scheduled 'wpstream_log_cleanup' event fires. |
| 83 |
add_action('wpstream_log_cleanup', 'wpstream_cleanup_logs_handler'); |
| 84 |
|
| 85 |
/** |
| 86 |
* The code that runs during plugin activation. |
| 87 |
* This action is documented in includes/class-wpstream-activator.php |
| 88 |
*/ |
| 89 |
function activate_wpstream() { |
| 90 |
// Load the activator class on demand. |
| 91 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-wpstream-activator.php'; |
| 92 |
// Run the activation routine (creates DB tables, options, etc.). |
| 93 |
Wpstream_Activator::activate(); |
| 94 |
|
| 95 |
// Schedule the daily log-cleanup cron event if it isn't already scheduled. |
| 96 |
if( !wp_next_scheduled( 'wpstream_log_cleanup' ) ) { |
| 97 |
// Register a daily recurring event starting now. |
| 98 |
wp_schedule_event( time(), 'daily', 'wpstream_log_cleanup' ); |
| 99 |
} |
| 100 |
} |
| 101 |
|
| 102 |
/** |
| 103 |
* The code that runs during plugin deactivation. |
| 104 |
* This action is documented in includes/class-wpstream-deactivator.php |
| 105 |
*/ |
| 106 |
function deactivate_wpstream() { |
| 107 |
// Load the deactivator class on demand. |
| 108 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-wpstream-deactivator.php'; |
| 109 |
// Run the deactivation routine. |
| 110 |
Wpstream_Deactivator::deactivate(); |
| 111 |
|
| 112 |
// Remove the scheduled daily log-cleanup cron event. |
| 113 |
wp_clear_scheduled_hook( 'wpstream_log_cleanup' ); |
| 114 |
} |
| 115 |
|
| 116 |
// Register the activation/deactivation callbacks with WordPress. |
| 117 |
register_activation_hook( __FILE__, 'activate_wpstream' ); |
| 118 |
register_deactivation_hook( __FILE__, 'deactivate_wpstream' ); |
| 119 |
|
| 120 |
/** |
| 121 |
* Wrapper function for wpstream_dashboard_save_channel_data to be called from theme |
| 122 |
* This provides backward compatibility for the theme |
| 123 |
*/ |
| 124 |
function wpstream_dashboard_save_channel_data_plugin() { |
| 125 |
// Reach the global plugin instance created at the bottom of this file. |
| 126 |
global $wpstream_plugin; |
| 127 |
// Only delegate if the plugin and its AJAX handler are available. |
| 128 |
if (isset($wpstream_plugin) && isset($wpstream_plugin->wpstream_ajax)) { |
| 129 |
// Forward the call to the real AJAX save-channel handler. |
| 130 |
$wpstream_plugin->wpstream_ajax->wpstream_dashboard_save_channel_data(); |
| 131 |
} |
| 132 |
} |
| 133 |
|
| 134 |
/** |
| 135 |
* The core plugin class that is used to define internationalization, |
| 136 |
* admin-specific hooks, and public-facing site hooks. |
| 137 |
*/ |
| 138 |
// Load the core plugin class (defines i18n, admin, and public hooks). |
| 139 |
require plugin_dir_path( __FILE__ ) . 'includes/class-wpstream.php'; |
| 140 |
// Load the Elementor requirement gate/integration. |
| 141 |
require plugin_dir_path( __FILE__ ) . 'wpstream-elementor.php'; |
| 142 |
// Load the streamify HLS proxy integration. |
| 143 |
require plugin_dir_path( __FILE__ ) . 'streamify/streamify.php'; |
| 144 |
|
| 145 |
// Load third-party integrations bootstrap. |
| 146 |
require plugin_dir_path( __FILE__ ) . 'integrations/integrations.php'; |
| 147 |
|
| 148 |
/** |
| 149 |
* Load the bundled hello-wpstream theme framework files. |
| 150 |
* |
| 151 |
* Hooked to after_setup_theme so the theme's helper functions, post types, |
| 152 |
* WooCommerce glue, widgets, and (when Elementor is active) Elementor pieces are |
| 153 |
* available. Missing files are logged rather than fatal. |
| 154 |
* |
| 155 |
* @return void |
| 156 |
*/ |
| 157 |
function wpstream_load_theme_functionality() { |
| 158 |
// Absolute path to the bundled hello-wpstream framework directory. |
| 159 |
define ('WPSTREAM_FRAMEWORK_BASE', plugin_dir_path(__FILE__) . 'hello-wpstream' ); |
| 160 |
|
| 161 |
// Framework files to load, relative to WPSTREAM_FRAMEWORK_BASE. |
| 162 |
$core_files = array( |
| 163 |
'/framework/metaboxes.php', |
| 164 |
'/framework/query-functions.php', |
| 165 |
'/framework/wpstream-video-functions.php', |
| 166 |
'/framework/ajax-functions.php', |
| 167 |
'/framework/dashboard-functions.php', |
| 168 |
'/framework/wpstream-help-functions.php', |
| 169 |
'/framework/video-pages-functions.php', |
| 170 |
'/framework/comments-functions.php', |
| 171 |
'/framework/gallery-functions.php', |
| 172 |
'/framework/shortcodes-functions.php', |
| 173 |
'/framework/post-types/main.php', |
| 174 |
'/framework/woocommerce-functions.php', |
| 175 |
'/framework/ajax-upload.php', |
| 176 |
'/framework/email-functions.php', |
| 177 |
'/framework/widgets/class-wpstream-widget-manager.php', |
| 178 |
'/framework/classes/class-wpstream-login-register.php', |
| 179 |
'/framework/classes/class-wpstream_theme-social-login.php', |
| 180 |
); |
| 181 |
|
| 182 |
// Load core files |
| 183 |
// Include each framework file, or log it if the file is missing. |
| 184 |
foreach ( $core_files as $file ) { |
| 185 |
// Build the absolute path to this framework file. |
| 186 |
$file_path = WPSTREAM_FRAMEWORK_BASE . $file; |
| 187 |
// Include it if present; otherwise record the missing file. |
| 188 |
if ( file_exists( $file_path ) ) { |
| 189 |
// File exists: load it once. |
| 190 |
require_once $file_path; |
| 191 |
} else { |
| 192 |
// File missing: log an error but keep loading the rest. |
| 193 |
error_log( 'Missing required file: ' . $file_path ); |
| 194 |
} |
| 195 |
} |
| 196 |
|
| 197 |
// Load Elementor integration if the plugin is active |
| 198 |
// ELEMENTOR_VERSION is only defined when Elementor is loaded. |
| 199 |
if ( defined( 'ELEMENTOR_VERSION' ) ) { |
| 200 |
|
| 201 |
// Additional framework files needed only for the Elementor integration. |
| 202 |
$elementor_files = array( |
| 203 |
'/elementor/functions/blog_functions.php', |
| 204 |
'/elementor/wpstream-elementor.php' |
| 205 |
); |
| 206 |
|
| 207 |
// Include each Elementor file, or log it if missing. |
| 208 |
foreach ( $elementor_files as $file ) { |
| 209 |
// Build the absolute path to this Elementor file. |
| 210 |
$file_path = WPSTREAM_FRAMEWORK_BASE . $file; |
| 211 |
// Include it if present; otherwise record the missing file. |
| 212 |
if ( file_exists( $file_path ) ) { |
| 213 |
// File exists: load it once. |
| 214 |
require_once $file_path; |
| 215 |
} else { |
| 216 |
// File missing: log an error but keep loading the rest. |
| 217 |
error_log( 'Missing required file: ' . $file_path ); |
| 218 |
} |
| 219 |
} |
| 220 |
} |
| 221 |
} |
| 222 |
|
| 223 |
// Load the theme framework after the active theme is set up. |
| 224 |
add_action( 'after_setup_theme', 'wpstream_load_theme_functionality' ); |
| 225 |
|
| 226 |
/** |
| 227 |
* Load js for players |
| 228 |
* |
| 229 |
* @return void |
| 230 |
*/ |
| 231 |
// Guard the definition so the theme can define its own version without collision. |
| 232 |
if ( ! function_exists( 'wpstream_load_player_js_on_demand' ) ) { |
| 233 |
/** |
| 234 |
* Enqueue player scripts only when unit cards are configured to use video. |
| 235 |
* |
| 236 |
* @return void |
| 237 |
*/ |
| 238 |
function wpstream_load_player_js_on_demand() |
| 239 |
{ |
| 240 |
// Read the customizer setting that toggles video previews on unit cards. |
| 241 |
$wpstream_unit_card_use_video = get_theme_mod('wpstream_unit_card_use_video'); |
| 242 |
// Only enqueue the player assets when that setting is enabled. |
| 243 |
if ($wpstream_unit_card_use_video) { |
| 244 |
// Video.js core. |
| 245 |
wp_enqueue_script('video.min'); |
| 246 |
// WpStream player wrapper script. |
| 247 |
wp_enqueue_script('wpstream-player'); |
| 248 |
} |
| 249 |
|
| 250 |
} |
| 251 |
} |
| 252 |
|
| 253 |
/** |
| 254 |
* Begins execution of the plugin. |
| 255 |
* |
| 256 |
* Since everything within the plugin is registered via hooks, |
| 257 |
* then kicking off the plugin from this point in the file does |
| 258 |
* not affect the page life cycle. |
| 259 |
* |
| 260 |
* @since 3.0.1 |
| 261 |
*/ |
| 262 |
|
| 263 |
// Expose the plugin instance globally so themes/helpers can reach it. |
| 264 |
global $wpstream_plugin; |
| 265 |
// Build the core plugin object. |
| 266 |
$wpstream_plugin = new Wpstream(); |
| 267 |
// Register all of the plugin's hooks and start it running. |
| 268 |
$wpstream_plugin->run(); |
| 269 |
|
| 270 |
// After any core/plugin/theme update completes, run our upgrade cleanup. |
| 271 |
add_action( 'upgrader_process_complete', 'wpstream_my_upgrate_function',10, 2); |
| 272 |
|
| 273 |
/** |
| 274 |
* Clear cached API token data after this plugin is updated. |
| 275 |
* |
| 276 |
* @param WP_Upgrader $upgrader_object The upgrader instance (unused). |
| 277 |
* @param array $options Details about what was upgraded. |
| 278 |
* @return void |
| 279 |
*/ |
| 280 |
function wpstream_my_upgrate_function( $upgrader_object, $options ) { |
| 281 |
|
| 282 |
|
| 283 |
// This plugin's basename, used to detect if it was among the updated plugins. |
| 284 |
$current_plugin_path_name = plugin_basename( __FILE__ ); |
| 285 |
|
| 286 |
// Only act on plugin update operations. |
| 287 |
if ($options['action'] == 'update' && $options['type'] == 'plugin' ) { |
| 288 |
// Guard against a missing/non-array options payload. |
| 289 |
if(is_array($options)): |
| 290 |
// Inspect every plugin that was updated in this batch. |
| 291 |
foreach($options['plugins'] as $each_plugin) { |
| 292 |
// Match against this plugin. |
| 293 |
if ($each_plugin==$current_plugin_path_name) { |
| 294 |
// Drop the cached API token transient. |
| 295 |
delete_transient('wpstream_token_api'); |
| 296 |
// Reset the stored token expiry timestamp. |
| 297 |
update_option('wp_estate_token_expire',0); |
| 298 |
// Blank out the stored current token. |
| 299 |
update_option('wp_estate_curent_token',' '); |
| 300 |
|
| 301 |
} |
| 302 |
} |
| 303 |
endif; |
| 304 |
} |
| 305 |
|
| 306 |
|
| 307 |
} |
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
// Inject Open Graph share meta tags into the document head. |
| 312 |
add_action('wp_head', 'wpstream_add_custom_meta_to_header'); |
| 313 |
|
| 314 |
/** |
| 315 |
* Output Open Graph meta tags on product / stream / VOD single pages. |
| 316 |
* |
| 317 |
* @return void |
| 318 |
*/ |
| 319 |
function wpstream_add_custom_meta_to_header(){ |
| 320 |
// The current post being displayed. |
| 321 |
global $post; |
| 322 |
|
| 323 |
|
| 324 |
// Only add share tags on WooCommerce product and WpStream product/VOD singles. |
| 325 |
if ( is_singular('product') || is_singular('wpstream_product') || is_singular('wpstream_product_vod') ){ |
| 326 |
// Featured image attachment ID for this post. |
| 327 |
$image_id = get_post_thumbnail_id(); |
| 328 |
// Full-size image source array ([0] is the URL) for og:image. |
| 329 |
$share_img = wp_get_attachment_image_src( $image_id, 'full'); |
| 330 |
// Full post object, used for the description below. |
| 331 |
$the_post = get_post($post->ID); ?> |
| 332 |
|
| 333 |
<meta property='og:title' content="<?php print esc_html(get_the_title($post->ID)); ?>"/> |
| 334 |
<?php if(isset($share_img[0])){ ?> |
| 335 |
<meta property="og:image" content="<?php print esc_url($share_img[0]); ?>"/> |
| 336 |
<meta property="og:image:secure_url" content="<?php print esc_url($share_img[0]); ?>" /> |
| 337 |
<?php }?> |
| 338 |
|
| 339 |
<meta property="og:description" content=" <?php print wp_strip_all_tags( $the_post->post_content);?>" /> |
| 340 |
<?php } |
| 341 |
|
| 342 |
|
| 343 |
} |
| 344 |
|
| 345 |
|
| 346 |
/* |
| 347 |
* |
| 348 |
* Check integrations |
| 349 |
* |
| 350 |
*/ |
| 351 |
// Only wire the One Click Demo Import (OCDI) hooks when the hello-wpstream theme is active. |
| 352 |
if ( get_template() === 'hello-wpstream' ) { |
| 353 |
// Load the theme-import helper functions referenced by the filters below. |
| 354 |
require_once plugin_dir_path( __FILE__ ) . 'integrations/hello-wpstream/theme-import.php'; |
| 355 |
// Register the set of demo import files offered by OCDI. |
| 356 |
add_filter( 'pt-ocdi/import_files', 'wpstream_ocdi_import_files' ); |
| 357 |
// Run post-import setup (menus, pages, options) after a demo import. |
| 358 |
add_action( 'pt-ocdi/after_import', 'wpstream_ocdi_after_import_setup' ); |
| 359 |
// Customize the intro text shown on the OCDI import screen. |
| 360 |
add_filter( 'pt-ocdi/plugin_intro_text', 'wpstream_ocdi_plugin_intro_text' ); |
| 361 |
// Send telemetry when a demo content import is attempted. |
| 362 |
add_action( 'ocdi/before_content_import', 'wpstream_track_ocdi_import_attempt', 10, 1 ); |
| 363 |
} |
| 364 |
|
| 365 |
|
| 366 |
// Once all plugins are loaded, evaluate which integrations should run. |
| 367 |
add_action( 'plugins_loaded', 'wpstream_check_integrations' ); |
| 368 |
|
| 369 |
|
| 370 |
/* |
| 371 |
* |
| 372 |
* Redirect on plugin activation |
| 373 |
* |
| 374 |
*/ |
| 375 |
|
| 376 |
/** |
| 377 |
* Redirect to the onboarding screen right after this plugin is activated. |
| 378 |
* |
| 379 |
* @param string $plugin Basename of the plugin that was just activated. |
| 380 |
* @return void |
| 381 |
*/ |
| 382 |
function wpstream_activation_redirect( $plugin ) { |
| 383 |
// Only redirect when it is this plugin that was activated. |
| 384 |
if( $plugin == plugin_basename( __FILE__ ) ) { |
| 385 |
// Send the admin to the onboarding page and stop further execution. |
| 386 |
exit( wp_redirect( admin_url( 'admin.php?page=wpstream_onboard' ) ) ); |
| 387 |
} |
| 388 |
} |
| 389 |
// Fire the redirect on the activated_plugin hook. |
| 390 |
add_action( 'activated_plugin', 'wpstream_activation_redirect' ); |
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
/* |
| 395 |
* |
| 396 |
* remove the style selectWoo for the theme |
| 397 |
* |
| 398 |
*/ |
| 399 |
// The existence of wpstream_get_author_id signals the wpstream theme is active. |
| 400 |
if ( function_exists( 'wpstream_get_author_id' ) ) { |
| 401 |
// only if wpstream-theme is activated |
| 402 |
|
| 403 |
remove_filter( 'pre_user_description', 'wp_filter_kses' ); // Removes the filter that applies KSES filtering for user descriptions |
| 404 |
remove_filter( 'term_description', 'wp_kses_data' ); // Removes the filter that applies KSES data filtering for term descriptions |
| 405 |
|
| 406 |
// Define the Select2 dequeue callback only once (guard against redefinition). |
| 407 |
if ( ! function_exists( 'wsis_dequeue_stylesandscripts_select2' ) ) { |
| 408 |
// Run the dequeue late (priority 100) so it overrides earlier enqueues. |
| 409 |
add_action( 'wp_enqueue_scripts', 'wsis_dequeue_stylesandscripts_select2', 100 ); |
| 410 |
/** |
| 411 |
* Remove CSS and/or JS for Select2 used by WooCommerce |
| 412 |
*/ |
| 413 |
function wsis_dequeue_stylesandscripts_select2() { |
| 414 |
// Only relevant when WooCommerce is present. |
| 415 |
if ( class_exists( 'woocommerce' ) ) { |
| 416 |
// Remove WooCommerce's selectWoo stylesheet. |
| 417 |
wp_dequeue_style( 'selectWoo' ); |
| 418 |
wp_deregister_style( 'selectWoo' ); |
| 419 |
|
| 420 |
// Remove WooCommerce's selectWoo script. |
| 421 |
wp_dequeue_script( 'selectWoo' ); |
| 422 |
wp_deregister_script( 'selectWoo' ); |
| 423 |
} |
| 424 |
} |
| 425 |
} |
| 426 |
} |
| 427 |
|
| 428 |
/** |
| 429 |
* Register broadcaster page endpoint |
| 430 |
*/ |
| 431 |
function wpstream_register_broadcaster_endpoint() { |
| 432 |
// Register the query var that flags a broadcaster page request (0 or 1). |
| 433 |
add_rewrite_tag('%broadcaster_page%', '([0-1]{1})'); |
| 434 |
// Register the numeric channel-id query var. |
| 435 |
add_rewrite_tag('%channel_id%', '([0-9]+)'); |
| 436 |
|
| 437 |
// Current stored rewrite rules, used to detect if our rule already exists. |
| 438 |
$rewrite_rules = get_option('rewrite_rules'); |
| 439 |
// Pretty-URL pattern: /broadcaster-page/{id}/ |
| 440 |
$rule_pattern = 'broadcaster-page/([0-9]+)/?$'; |
| 441 |
// Internal target that maps the captured id onto our query vars. |
| 442 |
$rule_target = 'index.php?broadcaster_page=1&channel_id=$matches[1]'; |
| 443 |
|
| 444 |
// Add the rewrite rule at the top so it takes precedence. |
| 445 |
add_rewrite_rule($rule_pattern, $rule_target, 'top'); |
| 446 |
// Flush rules only when they are missing our pattern (avoids flushing every request). |
| 447 |
if ( !is_array($rewrite_rules) || !key_exists( $rule_pattern, $rewrite_rules ) ) { |
| 448 |
// Rebuild the rewrite rules so the new endpoint works immediately. |
| 449 |
flush_rewrite_rules(); |
| 450 |
} |
| 451 |
} |
| 452 |
// Register the broadcaster endpoint on every init. |
| 453 |
add_action('init', 'wpstream_register_broadcaster_endpoint'); |
| 454 |
|
| 455 |
/** |
| 456 |
* Load broadcaster template when the custom endpoint is accessed |
| 457 |
*/ |
| 458 |
function wpstream_load_broadcaster_template($template) { |
| 459 |
// When the broadcaster_page query var is set, serve our custom template. |
| 460 |
if (get_query_var('broadcaster_page') == 1) { |
| 461 |
// Return the path to our broadcaster template |
| 462 |
return plugin_dir_path(__FILE__) . 'templates/broadcaster-template.php'; |
| 463 |
} |
| 464 |
// Otherwise fall back to the theme's normal template. |
| 465 |
return $template; |
| 466 |
} |
| 467 |
// Intercept template selection to swap in the broadcaster template when needed. |
| 468 |
add_filter('template_include', 'wpstream_load_broadcaster_template'); |
| 469 |
|
| 470 |
/** |
| 471 |
* Flush rewrite rules on plugin activation to ensure our endpoint works |
| 472 |
*/ |
| 473 |
function wpstream_flush_rewrite_rules() { |
| 474 |
// Register the endpoint's rewrite tags/rules first. |
| 475 |
wpstream_register_broadcaster_endpoint(); |
| 476 |
// Then flush so the new rules are active immediately after activation. |
| 477 |
flush_rewrite_rules(); |
| 478 |
} |
| 479 |
// Ensure rewrite rules are flushed when the plugin is activated. |
| 480 |
register_activation_hook(__FILE__, 'wpstream_flush_rewrite_rules'); |
| 481 |
|