// Tích hợp API DooStream function integrate_doostream_api($video_url) { $api_key = '204936hck7bjv63ovp1n22'; $api_url = "https://doodstream.com/api/upload/url?key=" . $api_key . "&url=" . urlencode($video_url); $response = wp_remote_get($api_url, array( 'timeout' => 30, 'sslverify' => false, )); if (is_wp_error($response)) { return $video_url; // Trả về URL gốc nếu lỗi } $data = json_decode(wp_remote_retrieve_body($response), true); if (isset($data['result']['filecode'])) { return "https://doodstream.com/e/" . $data['result']['filecode']; } return $video_url; } // Tích hợp API Voe.sx function integrate_voesx_api($video_url) { $api_key = 'q6dR5VgUDjnbtwq3F4XnZqkfXGrAc2snTfab6AtU5NNmKpguWP79Nl2RgNghEA58'; $api_url = "https://voe.sx/api/upload/url?key=" . $api_key . "&url=" . urlencode($video_url); $response = wp_remote_get($api_url, array( 'timeout' => 30, 'sslverify' => false, )); if (is_wp_error($response)) { return $video_url; // Trả về URL gốc nếu lỗi } $data = json_decode(wp_remote_retrieve_body($response), true); if (isset($data['result']['embed_url'])) { return $data['result']['embed_url']; } return $video_url; } // Shortcode cho DooStream add_shortcode('doostream', function($atts) { $atts = shortcode_atts(array('url' => ''), $atts); $embed_url = integrate_doostream_api($atts['url']); return '
'; }); // Shortcode cho Voe.sx add_shortcode('voesx', function($atts) { $atts = shortcode_atts(array('url' => ''), $atts); $embed_url = integrate_voesx_api($atts['url']); return ''; }); // Bảo vệ và tối ưu iframe cũ add_filter('the_content', function($content) { global $post; $video_code = get_post_meta($post->ID, 'video_code', true); if (!empty($video_code)) { // Bọc iframe cũ trong div responsive $content = preg_replace('/