Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php WordPress esc_内容上的html_Php_Wordpress_Security - Fatal编程技术网

Php WordPress esc_内容上的html

Php WordPress esc_内容上的html,php,wordpress,security,Php,Wordpress,Security,我有以下代码: the_content( sprintf( __( 'Continue reading %s', 'twentyfifteen' ), the_title( '<span class="screen-reader-text">', '</span>', false ) ) ); ( __(“继续读取%s”,“二十一五”), 标题(“”,“”为假) ) ); 如何针对

我有以下代码:

the_content( sprintf(
                __( 'Continue reading %s', 'twentyfifteen' ),
                the_title( '<span class="screen-reader-text">', '</span>', false )
            ) );
(
__(“继续读取%s”,“二十一五”),
标题(“”,“”为假)
) );
如何针对安全问题逃逸上述代码?我一直在使用下面的代码修复问题:

<?php echo esc_html(get_the_title()) ; ?>

来自:

需要注意的是,大多数WordPress函数正确地准备了输出数据,您不需要再次转义

因此,对于此函数,您不必再次转义
标题()
,因为此函数本身已经完成了转义

对于所有其他转义/清理需要,请查看。

标题()
摘录()
内容()
不会转义(
内容()
会进行一些字符串替换),这可能会导致安全问题,例如,当编辑器安装了恶意浏览器扩展时

正确的方法是将这些函数的
get.*
版本包装到
esc\u html\u e()
(它运行esc\u html(),通过文本域进行翻译,并返回结果),因此在您的情况下:


这是不正确的,未转义标题(标题|摘录|内容)。