Php 过滤HTML以获得javascript输出

Php 过滤HTML以获得javascript输出,php,javascript,prettyphoto,Php,Javascript,Prettyphoto,我使用PrettyTo API手动打开lightbox,代码如下: api_images ['images/fullscreen/image1.jpg','images/fullscreen/image2.jpg','images/fullscreen/image3.jpg']; api_titles = ['Title 1','Title 2','Title 3']; api_descriptions = ['Description 1','Description 2','Descripti

我使用PrettyTo API手动打开lightbox,代码如下:

api_images  ['images/fullscreen/image1.jpg','images/fullscreen/image2.jpg','images/fullscreen/image3.jpg'];
api_titles = ['Title 1','Title 2','Title 3'];
api_descriptions = ['Description 1','Description 2','Description 3']
$.prettyPhoto.open(api_images,api_titles,api_descriptions);
我面临的问题是描述值来自Wordpress的WYSIWYG,代码很容易被随机html标记、标点符号等破坏

  <script type="text/javascript">
    $(document).ready(function() {
        $('#menu-item-1006').on('click', function(e) {
            e.preventDefault();
            var images = new Array();
            var descriptions = new Array();
            var titles = new Array();
<?php
$i = 0;
$images = new WP_Query(array('post_type' => 'clearance', 'showposts' => -1, 'order' => 'menu_order', 'orderby' => 'ASC'));
if ($images->have_posts()) : while ($images->have_posts()) : $images->the_post();

        $featured = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
        ?>
                            images[<?php echo $i; ?>] = '<?php echo $featured[0]; ?>';
                            titles[<?php echo $i; ?>] =  '<?php the_title(); ?>'
                            descriptions[<?php echo $i; ?>] = '<?php echo get_the_content(); ?>';

        <?php
        $i++;
    endwhile;
else:
    ?>
<?php endif; ?>

            $.prettyPhoto.open(images, titles, descriptions);
        }) 
    });    
</script>

$(文档).ready(函数(){
$('#menu-item-1006')。在('click',函数(e)上{
e、 预防默认值();
var images=新数组();
var descriptions=新数组();
var titles=新数组();
图像[]='';
标题[]=“”
说明[]='';
$.to.open(图像、标题、描述);
}) 
});    

如何过滤get_the_content()函数,使其输出w/o错误?谢谢

一个简单的解决方案可以是:

替换

<?php echo get_the_content(); ?>


一个简单的解决方案可以是:

替换

<?php echo get_the_content(); ?>


json\u encode(获取内容())有效

json_encode(get_the_content())有效

$content=获取内容();
回音条标签($content,”);
将只留下
a
img
标签。我想这就是gallery所需要的一切

$content=get_the_content();
回音条标签($content,”);
将只留下
a
img
标签。我想这就是你们画廊所需要的

$content = get_the_content();
echo strip_tags($content, '<a><img>');