| @@ -20,9 +20,8 @@ | ||
| 20 | 20 | $fileExtension = pathinfo($path, PATHINFO_EXTENSION); |
| 21 | 21 | |
| 22 | 22 | if ($fileExtension === 'ts' || $fileExtension === 'm3u8') { |
| 23 | 23 | wpstreamify_process_hls_request($fileExtension, $cacheFile, $remoteUrl); |
| 24 | - | |
| 25 | 24 | } else { |
| 26 | 25 | wpstreamify_serve_404(); |
| 27 | 26 | } |
| 28 | 27 | } |
| @@ -117,11 +116,8 @@ | ||
| 117 | 116 | } elseif ($fileExtension === 'm3u8') { |
| 118 | 117 | header('Content-Type: application/vnd.apple.mpegurl'); |
| 119 | 118 | header('Cache-Control: public, max-age=2, must-revalidate'); |
| 120 | 119 | header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 2) . ' GMT'); |
| 121 | - if ( ! defined( 'DONOTCACHEPAGE' ) ) { | |
| 122 | - define( 'DONOTCACHEPAGE', true ); | |
| 123 | - } | |
| 124 | 120 | } |
| 125 | 121 | |
| 126 | 122 | header("WPS-Cache-Status: $cacheStatus"); |
| 127 | 123 | status_header(200); |
| @@ -344,10 +340,17 @@ | ||
| 344 | 340 | } |
| 345 | 341 | register_deactivation_hook(WP_PLUGIN_DIR . '/' . WPSTREAM_PLUGIN_BASE, 'wpstreamify_unschedule_cleanup_event'); |
| 346 | 342 | |
| 347 | 343 | function wpstreamify_add_rewrite_rules() { |
| 348 | - add_rewrite_tag('%wpstreamify_path%', '([^&]+)'); | |
| 349 | - add_rewrite_rule('^wpstreamify/(.+)$', 'index.php?wpstreamify_path=$matches[1]', 'top'); | |
| 344 | + $rewrite_rules = get_option('rewrite_rules'); | |
| 345 | + $rule_pattern = '^wpstreamify/(.+)$'; | |
| 346 | + $rule_target = 'index.php?wpstreamify_path=$matches[1]'; | |
| 347 | + | |
| 348 | + // Check if the rewrite rule already exists | |
| 349 | + if (!isset($rewrite_rules[$rule_pattern]) || $rewrite_rules[$rule_pattern] !== $rule_target) { | |
| 350 | + add_rewrite_rule($rule_pattern, $rule_target, 'top'); | |
| 351 | + flush_rewrite_rules(); | |
| 352 | + } | |
| 350 | 353 | } |
| 351 | 354 | add_action('init', 'wpstreamify_add_rewrite_rules'); |
| 352 | 355 | |
| 353 | 356 | function wpstreamify_flush_rewrite_rules() { |