BuddyPress 脚本以明文形式打印出来?

BuddyPress script printing out as plaintext?

我遇到这样一种情况,其中只有一个 page/component,BuddyPress 脚本作为文本打印到页面。这发生在用户个人资料的 "Change Cover Image" 选项卡上,我在其他任何地方都没有看到这个问题。

我尝试用谷歌搜索我能想到的每一种关键字组合,并尝试在 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 错误。

如果有人能帮我解决这个问题,我将不胜感激。

谢谢!

好吧,我遇到这个问题大约一个星期了,但是在将这个问题发布到这里仅九个小时后,我偶然发现了问题的根源。我很确定这将是一个脚本加载顺序问题,但不是——这是我子主题的 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
    );
}