Update WP and plugins

This commit is contained in:
Oliver Davies 2019-04-16 20:56:22 +01:00
parent 10a4713229
commit 1fb77fc4ff
864 changed files with 101724 additions and 78262 deletions

View file

@ -23,8 +23,9 @@ class WP_Ajax_Response {
* @param string|array $args Optional. Will be passed to add() method.
*/
public function __construct( $args = '' ) {
if ( !empty($args) )
$this->add($args);
if ( ! empty( $args ) ) {
$this->add( $args );
}
}
/**
@ -63,36 +64,39 @@ class WP_Ajax_Response {
*/
public function add( $args = '' ) {
$defaults = array(
'what' => 'object', 'action' => false,
'id' => '0', 'old_id' => false,
'position' => 1,
'data' => '', 'supplemental' => array()
'what' => 'object',
'action' => false,
'id' => '0',
'old_id' => false,
'position' => 1,
'data' => '',
'supplemental' => array(),
);
$r = wp_parse_args( $args, $defaults );
$position = preg_replace( '/[^a-z0-9:_-]/i', '', $r['position'] );
$id = $r['id'];
$what = $r['what'];
$action = $r['action'];
$old_id = $r['old_id'];
$data = $r['data'];
$id = $r['id'];
$what = $r['what'];
$action = $r['action'];
$old_id = $r['old_id'];
$data = $r['data'];
if ( is_wp_error( $id ) ) {
$data = $id;
$id = 0;
$id = 0;
}
$response = '';
if ( is_wp_error( $data ) ) {
foreach ( (array) $data->get_error_codes() as $code ) {
$response .= "<wp_error code='$code'><![CDATA[" . $data->get_error_message( $code ) . "]]></wp_error>";
$response .= "<wp_error code='$code'><![CDATA[" . $data->get_error_message( $code ) . ']]></wp_error>';
if ( ! $error_data = $data->get_error_data( $code ) ) {
continue;
}
$class = '';
if ( is_object( $error_data ) ) {
$class = ' class="' . get_class( $error_data ) . '"';
$class = ' class="' . get_class( $error_data ) . '"';
$error_data = get_object_vars( $error_data );
}
@ -106,7 +110,7 @@ class WP_Ajax_Response {
}
}
$response .= "</wp_error_data>";
$response .= '</wp_error_data>';
}
} else {
$response = "<response_data><![CDATA[$data]]></response_data>";
@ -123,13 +127,13 @@ class WP_Ajax_Response {
if ( false === $action ) {
$action = $_POST['action'];
}
$x = '';
$x = '';
$x .= "<response action='{$action}_$id'>"; // The action attribute in the xml output is formatted like a nonce action
$x .= "<$what id='$id' " . ( false === $old_id ? '' : "old_id='$old_id' " ) . "position='$position'>";
$x .= $response;
$x .= $s;
$x .= "</$what>";
$x .= "</response>";
$x .= "<$what id='$id' " . ( false === $old_id ? '' : "old_id='$old_id' " ) . "position='$position'>";
$x .= $response;
$x .= $s;
$x .= "</$what>";
$x .= '</response>';
$this->responses[] = $x;
return $x;
@ -145,12 +149,14 @@ class WP_Ajax_Response {
public function send() {
header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ) );
echo "<?xml version='1.0' encoding='" . get_option( 'blog_charset' ) . "' standalone='yes'?><wp_ajax>";
foreach ( (array) $this->responses as $response )
foreach ( (array) $this->responses as $response ) {
echo $response;
}
echo '</wp_ajax>';
if ( wp_doing_ajax() )
if ( wp_doing_ajax() ) {
wp_die();
else
} else {
die();
}
}
}