WordPress and encoding errors in AJAX and XMLRPC
-
When the initiative is set in php.ini encodings other than coding blog, watching the problem with the encoding of XMLRPC applications (for example – Live Writer) and in all admin-AJAX responses.
To resolve the error:
- file wp-includes/class-IXR.php, now:
function output($xml) { $xml = '<?xml version="1.0"?>'."\n".$xml; $length = strlen($xml); header('Connection: close'); header('Content-Type: text/xml;', true); header('Content-Length: '.$length); header('Date: '.date('r')); echo $xml; exit; }
correct version:
function output($xml) { $xml = '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'."\n".$xml; $length = strlen($xml); header('Connection: close'); header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true); header('Content-Length: '.$length); header('Date: '.date(DATE_RFC1123)); echo $xml; exit; }
- wp-includes/class-wp-admin-ajax-response.php, now:
function send() { header('Content-Type: text/xml'); echo "<?xml version='1.0' standalone='yes'?><wp_ajax>"; foreach ( (array) $this->responses as $response ) echo $response; echo '</wp_ajax>'; die(); }
correct version:
function send() { $xml = "<?xml version='1.0' encoding='" . get_option('blog_charset') . "' standalone='yes'?><wp_ajax>"; foreach ( (array) $this->responses as $response ) $xml .= $response; $xml .= '</wp_ajax>'; $length = strlen($xml); header('Content-Type: text/xml; charset=' . get_option('blog_charset')); header('Content-Length: '.$length); header('Date: '.date(DATE_RFC1123)); echo $xml; die(); }
- file wp-includes/class-IXR.php, now:
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘WordPress and encoding errors in AJAX and XMLRPC’ is closed to new replies.