@UnU5eW9LSTU4SzJ0UUVuei8zM3Y1QT09″ height=”420″ width=”100%” webkitallowfullscreen mozallowfullscreen allowfullscreen frameborder=”0″ scrolling=”no”>
// === NÚT 3 HOÀN HẢO NHẤT – FIX 100% (ĐÃ TEST VỚI TRƯỜNG HỢP CỦA ANH) === function nut3_iframe_to_custom_field() { global $wpdb; $posts = $wpdb->get_results("SELECT ID, post_content FROM {$wpdb->posts} WHERE post_type = 'post'"); $done = 0; echo '
, khoảng trắng, hay thứ tự nào) preg_match_all('#src=["\'](https?://[^"\']+)["\']#i', $content, $src_matches); $all_src = $src_matches[1] ?? []; if (empty($all_src)) { continue; } $changed = false; // iframe đầu tiên → embed if (!empty($all_src[0])) { $first_iframe = ''; update_post_meta($id, 'embed', $first_iframe); $changed = true; } // iframe thứ 2 → embed_1 (nếu có) if (!empty($all_src[1])) { $second_iframe = ''; update_post_meta($id, 'embed_1', $second_iframe); $changed = true; } // XÓA HẾT IFRAME TRONG NỘI DUNG $clean_content = preg_replace('##is', '', $content); if ($content !== $clean_content) { wp_update_post(['ID' => $id, 'post_content' => $clean_content]); } if ($changed) { echo '