Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/255.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 wp_kses清理正在删除有效的字体系列名称_Php_Wordpress_Sanitization - Fatal编程技术网

Php wp_kses清理正在删除有效的字体系列名称

Php wp_kses清理正在删除有效的字体系列名称,php,wordpress,sanitization,Php,Wordpress,Sanitization,在WordPress中,我有一个无法控制(用户生成)内容的字符串。例如,假设您有: $string = 'before <p class="test-class" style="font-family: &quot;Brush Script Mt&quot;;">text</p> after'; 现在它不输出了 $b = wp_kses( $string, array( 'p' => array( 'class' =>

在WordPress中,我有一个无法控制(用户生成)内容的字符串。例如,假设您有:

$string = 'before <p class="test-class" style="font-family: &quot;Brush Script Mt&quot;;">text</p> after';
现在它不输出了

$b = wp_kses( $string, array(
    'p' => array(
        'class' => array(),
        'style' => array()
    )
) );
var_dump(  $b ); // returns 'before <p class="test-class" style="font-family: Brush Script Mt">text</p> after'
$b=wp\u kses($string,array)(
'p'=>数组(
'class'=>array(),
'style'=>array()
)
) );
var_dump($b);//返回'before

text

after'
我无法更改源字体系列,它将始终在字体系列名称(“)周围带有引号,并且我还需要在字符串上使用wp_kses


有没有办法让wp_kses接受带有“?”的字体系列

您不应该试图让
wp\u kses()
接受损坏的HTML。您可能应该用单引号(撇号)替换
”,或者删除它们

如果你想让它留下这些引语,你会得到:

before <p class="test-class" style="font-family: "Brush Script Mt";">text</p> after

这是一个很好的方法。
$b = wp_kses( $string, array(
    'p' => array(
        'class' => array(),
        'style' => array()
    )
) );
var_dump(  $b ); // returns 'before <p class="test-class" style="font-family: Brush Script Mt">text</p> after'
before <p class="test-class" style="font-family: "Brush Script Mt";">text</p> after
$string = str_replace( "&quot;",  "", $string );