BuddyPress脚本打印为明文?

时间:2017-02-24 21:37:45

标签: buddypress

我遇到的情况是,仅在一个页面/组件上,BuddyPress脚本以文本形式打印到页面。这发生在"更改封面图像"用户个人资料的标签,我在其他任何地方都看不到这个问题。

我已经尝试使用谷歌搜索我能想到的所有关键词组合,并尝试在BuddyPress支持论坛上发帖,但是我们还没有得到任何帮助。

也许这里有人可能能够为我提供一些见解?

Here's a screenshot of what the page looks like.

模板文件如下所示:

<?php
/**
* BuddyPress Cover Images main template.
*
* This template is used to inject the BuddyPress Backbone views
* dealing with cover images.
*
* It's also used to create the common Backbone views.
*
* @since 2.4.0
*
* @package BuddyPress
* @subpackage bp-attachments
*/
?>

<div class="bp-cover-image"></div>
<div class="bp-cover-image-status"></div>
<div class="bp-cover-image-manage"></div>

<?php bp_attachments_get_template_part( 'uploader' ); ?>

<script id="tmpl-bp-cover-image-delete" type="text/html">
<# if ( 'user' === data.object ) { #>
    <p><?php _e( "If you would like to delete your current cover image but not upload a new one, please use the delete Cover Image button.", 'buddypress' ); ?></p>
    <p><a class="button edit" id="bp-delete-cover-image" href="#"><?php esc_html_e( 'Delete My Cover Image', 'buddypress' ); ?></a></p>
<# } else if ( 'group' === data.object ) { #>
    <p><?php _e( "If you would like to remove the existing group cover image but not upload a new one, please use the delete group cover image button.", 'buddypress' ); ?></p>
    <p><a class="button edit" id="bp-delete-cover-image" href="#"><?php esc_html_e( 'Delete Group Cover Image', 'buddypress' ); ?></a></p>
<# } else { #>
    <?php do_action( 'bp_attachments_cover_image_delete_template' ); ?>
<# } #>
</script>

<?php do_action( 'bp_attachments_cover_image_main_template' ); ?>

所有这些实际上在页面本身上出现两次,一次在内联脚本标记中,然后一次作为文章文本,如上面的屏幕截图所示。

我没有在控制台中看到任何javascript错误。

我非常感谢能够帮助我排除故障的任何人。

谢谢!

1 个答案:

答案 0 :(得分:0)

好吧,我这个问题已经持续了大约一个星期,但是在这里发布这个问题仅仅9个小时后,我随机偶然发现了问题的根源。我很确定这会是一个脚本加载顺序问题,但是没有 - 这是我的子主题的functions.php文件的片段,旨在删除空的HTML标记:

add_filter('the_content', 'remove_empty_tags_recursive', 20, 1);
function remove_empty_tags_recursive ($str, $repto = NULL) {
    $str = force_balance_tags($str);
    if (!is_string ($str) || trim ($str) == '')
    return $str;
    return preg_replace (
          '~\s?<p>(\s|&nbsp;)+</p>\s?~',
         !is_string ($repto) ? '' : $repto,
       $str
    );
}