首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >BuddyPress脚本打印为明文?

BuddyPress脚本打印为明文?
EN

Stack Overflow用户
提问于 2017-02-24 21:37:45
回答 1查看 62关注 0票数 0

我遇到这样一种情况:仅在一个页面/组件上,一个BuddyPress脚本作为文本打印到页面上。这种情况发生在用户配置文件的“”选项卡上,我在其他任何地方都看不到这个问题。

我试着搜索我能想到的每一个组合的关键字,并尝试在BuddyPress支持论坛上发表文章,但是一直没有得到任何帮助。

也许这里有人能给我提供一点洞察力?

这是页面的截图。

模板文件如下所示:

代码语言:javascript
复制
<?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错误。

我真的很感激任何能帮我解决这个问题的人。

谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-02-25 06:50:28

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

代码语言:javascript
复制
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
    );
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42448725

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档