Php 替换<;及>;代码标记之间不工作

Php 替换<;及>;代码标记之间不工作,php,wordpress,Php,Wordpress,我从中得到了答案,并根据我的需要做了一些修改,但显然不起作用 我正在修改的插件有一个函数,可以使用该函数“预清理”内容 function aiosc_preclean_content($string) { $rplc = array( "\\'"=>"'", '\\"'=>'"', "\\\\"=>"\\", ); return str_replace(array_keys($rplc),array_v

我从中得到了答案,并根据我的需要做了一些修改,但显然不起作用

我正在修改的插件有一个函数,可以使用该函数“预清理”内容

function aiosc_preclean_content($string) {

    $rplc = array(
        "\\'"=>"'",
        '\\"'=>'"',
        "\\\\"=>"\\",
    );

    return str_replace(array_keys($rplc),array_values($rplc),$string);
}
这将查找引号和多个反斜杠并替换它们。函数工作正常,所以我想修改它,以便
标记(特别是html)中具有
的任何内容都将被
替换

首先,我尝试了最初的答案,但没有成功。然后我尝试了我自己的:

function aiosc_preclean_content($string) {

    $rplc = array(
        "\\'"=>"'",
        '\\"'=>'"',
        "\\\\"=>"\\",
        "‘"=>"'",
        "’"=>"'",
        "“"=>'"',
        "”"=>'"',
    );

    $pre_returned_content = str_replace(array_keys($rplc),array_values($rplc),$string);
    $text = preg_replace_callback("~<code>(.*?)<\/code>~",'replaceInCode',$pre_returned_content);
    // $new_content = htmlspecialchars($text);
    return $text;
}

function replaceInCode($match){
    $replace = array('<' => '&lt','>' => '&gt');
    $text = str_replace(array_keys($replace),array_values($replace),$match[1]);
    return $text;
}
还是没什么

function aiosc_clean_content($string,$html_tags="", $autop = true) {
    $string = aiosc_preclean_content($string);
    if(empty($html_tags)) $html_tags = "<b><strong><em><i><br><hr><p><span><small><h1><h2><h3><h4><h5><ul><ol><li><a><del><blockquote><pre><code><script>";

    $string = strip_tags($string,$html_tags);
    if($autop) $string = wpautop($string);

    $text = preg_replace_callback("~<code>(.*?)<\/code>~",'replaceInCode',$string);

    return $text;
}
function aiosc_preclean_content($string) {
    $rplc = array(
        "\\'"=>"'",
        '\\"'=>'"',
        "\\\\"=>"\\",
        "‘"=>"'",
        "’"=>"'",
        "“"=>'"',
        "”"=>'"',
    );
    return str_replace(array_keys($rplc),array_values($rplc),$string);
}

function replaceInCode($match){
    $replace = array('<' => '&lt;','>' => '&gt;');
    $text = str_replace(array_keys($replace),array_values($replace),$match[1]);
    return '<code>'.$text.'</code>';
}