WordPress Started Executing Code Inside PRE Tags Even They Are Properly Escaped

Quick Fix Answer:


Add the below code to your theme functions.php file for a quick fix. Rest still trying to find the reason for this error so if you have any then welcome to comment here so I will mark your answer as accepted.

/* ------------------------------------------------------------------------- *
 *  Stop Executing Codes Inside Pre/Code Tags
/* ------------------------------------------------------------------------- */
add_filter('the_content','pre_esc_html',1);
function pre_esc_html($content) {
    return preg_replace_callback(
    '#(<pre.*?>)(.*?)(</pre>)#imsu',
    create_function(
      '$i',
      'return $i[1].htmlspecialchars($i[2]).$i[3];'
    ),
    $content
  );
}

add_filter('the_content','code_esc_html',1);
function code_esc_html($content) {
    return preg_replace_callback(
    '#(<code.*?>)(.*?)(</code>)#imsu',
    create_function(
      '$i',
      'return $i[1].htmlspecialchars($i[2]).$i[3];'
    ),
    $content
  );
}