Iframe 如何正确地转义已过滤的内容变量?

Iframe 如何正确地转义已过滤的内容变量?,iframe,filter,escaping,embed,Iframe,Filter,Escaping,Embed,我正在运行Wordpress主题的主题检查器插件,我有以下代码片段: 1。仅获取并显示帖子内容中的第一个嵌入视频: <?php $content = apply_filters( 'the_content', $post->post_content ); $embeds = get_media_embedded_in_content( $content ); $first_embedded = $embeds[0]; echo $first_embedded; ?>

我正在运行Wordpress主题的主题检查器插件,我有以下代码片段:

1。仅获取并显示帖子内容中的第一个嵌入视频:

<?php  $content = apply_filters( 'the_content', $post->post_content );

$embeds = get_media_embedded_in_content( $content );
$first_embedded = $embeds[0];
echo $first_embedded;
  ?>
   <?php 
     $content = apply_filters( 'the_content', $post->post_content );
     $content = preg_replace("/(<iframe[^<]+<\/iframe>)/", '', $content);
     echo $content;
     ?>
我如何正确地避开这些变量? 我试过:

<?php esc_html( $first_embedded); ?>
我是初学者。问题是我需要这两个变量,因为第一个变量显示视频,以防post格式是视频类型,并用第一个嵌入视频替换post缩略图图像


第二个功能也是必需的,以便不在帖子内容中显示该视频。

我发现了一个很好的解决方法,它可以在主题检查器上顺利运行,当然也可以在WordPress页面上运行,即使用

因此,我替换了:

echo $first_embedded;
这一行:

echo html_entity_decode( esc_html( $first_embedded ) );
以及:

与:

echo html_entity_decode( esc_html($content) );

html\u entity\u decode()
函数将html实体转换为字符,这就是我们需要显示过滤后帖子内容的代码,并且在Envato或WP主题检查器中不会出现错误的地方。

请注意,我们更喜欢这里的技术写作风格。我们轻轻地劝阻问候,希望你能帮助,谢谢,提前感谢,感谢信,问候,亲切的问候,签名,请你能帮助,闲聊的材料和缩写的txtspk,恳求,你被困多久了,投票建议,元评论等。只需解释你的问题,并展示你已经尝试了什么,你期望什么,实际上发生了什么。
echo html_entity_decode( esc_html( $first_embedded ) );
echo $content;
echo html_entity_decode( esc_html($content) );