--- a/wp/wp-includes/class-wp-ajax-response.php Tue Oct 22 16:11:46 2019 +0200
+++ b/wp/wp-includes/class-wp-ajax-response.php Tue Dec 15 13:49:49 2020 +0100
@@ -18,6 +18,7 @@
* Constructor - Passes args to WP_Ajax_Response::add().
*
* @since 2.1.0
+ *
* @see WP_Ajax_Response::add()
*
* @param string|array $args Optional. Will be passed to add() method.
@@ -54,7 +55,7 @@
* @type int|false $old_id The previous response ID. Used as the value for the response type
* `old_id` attribute. False hides the attribute. Default false.
* @type string $position Value of the response type `position` attribute. Accepts 1 (bottom),
- * -1 (top), html ID (after), or -html ID (before). Default 1 (bottom).
+ * -1 (top), HTML ID (after), or -HTML ID (before). Default 1 (bottom).
* @type string|WP_Error $data The response content/message. Also accepts a WP_Error object if the
* ID does not exist. Default empty.
* @type array $supplemental An array of extra strings that will be output within a `<supplemental>`
@@ -73,14 +74,14 @@
'supplemental' => array(),
);
- $r = wp_parse_args( $args, $defaults );
+ $parsed_args = 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'];
+ $position = preg_replace( '/[^a-z0-9:_-]/i', '', $parsed_args['position'] );
+ $id = $parsed_args['id'];
+ $what = $parsed_args['what'];
+ $action = $parsed_args['action'];
+ $old_id = $parsed_args['old_id'];
+ $data = $parsed_args['data'];
if ( is_wp_error( $id ) ) {
$data = $id;
@@ -90,8 +91,9 @@
$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>';
- if ( ! $error_data = $data->get_error_data( $code ) ) {
+ $response .= "<wp_error code='$code'><![CDATA[" . $data->get_error_message( $code ) . ']]></wp_error>';
+ $error_data = $data->get_error_data( $code );
+ if ( ! $error_data ) {
continue;
}
$class = '';
@@ -117,8 +119,8 @@
}
$s = '';
- if ( is_array( $r['supplemental'] ) ) {
- foreach ( $r['supplemental'] as $k => $v ) {
+ if ( is_array( $parsed_args['supplemental'] ) ) {
+ foreach ( $parsed_args['supplemental'] as $k => $v ) {
$s .= "<$k><![CDATA[$v]]></$k>";
}
$s = "<supplemental>$s</supplemental>";
@@ -128,7 +130,7 @@
$action = $_POST['action'];
}
$x = '';
- $x .= "<response action='{$action}_$id'>"; // The action attribute in the xml output is formatted like a nonce action
+ $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;