// in functions.php function pixnext_video_shortcode( $atts ) { $atts = shortcode_atts( [ 'file' => '' ], $atts ); if ( empty( $atts['file'] ) ) { return ''; } $file = $atts['file']; // full URL or proxy if ( filter_var( $file, FILTER_VALIDATE_URL ) ) { $proxy_url = $file; } else { $proxy_url = 'https://pixnext.vip/proxy.php?file=' . $file; } $resolved = pixnext_resolve_stream_url( $proxy_url ); if ( ! $resolved ) { return ''; } return ''; } add_shortcode( 'pixnext_video', 'pixnext_video_shortcode' ); // 1) Register a pretty URL structure add_action( 'init', function() { add_rewrite_rule( '^videos/([^/]+\.mp4)$', // URL pattern 'index.php?pnx_video_file=$matches[1]', // internal query var 'top' ); add_rewrite_tag( '%pnx_video_file%', '(.+)' ); }); // 2) Catch that query var and serve the proxy add_action( 'template_redirect', function() { $file = get_query_var( 'pnx_video_file' ); if ( $file ) { // You may want to validate/sanitize $file here include __DIR__ . '/proxy.php'; exit; } });
WordPress