Changeset 42343 for trunk/src/wp-includes/class-wp-ajax-response.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-ajax-response.php
r42201 r42343 24 24 */ 25 25 public function __construct( $args = '' ) { 26 if ( !empty($args) ) 27 $this->add($args); 26 if ( ! empty( $args ) ) { 27 $this->add( $args ); 28 } 28 29 } 29 30 … … 64 65 public function add( $args = '' ) { 65 66 $defaults = array( 66 'what' => 'object', 'action' => false, 67 'id' => '0', 'old_id' => false, 68 'position' => 1, 69 'data' => '', 'supplemental' => array() 67 'what' => 'object', 68 'action' => false, 69 'id' => '0', 70 'old_id' => false, 71 'position' => 1, 72 'data' => '', 73 'supplemental' => array(), 70 74 ); 71 75 … … 73 77 74 78 $position = preg_replace( '/[^a-z0-9:_-]/i', '', $r['position'] ); 75 $id = $r['id'];76 $what = $r['what'];77 $action = $r['action'];78 $old_id = $r['old_id'];79 $data = $r['data'];79 $id = $r['id']; 80 $what = $r['what']; 81 $action = $r['action']; 82 $old_id = $r['old_id']; 83 $data = $r['data']; 80 84 81 85 if ( is_wp_error( $id ) ) { 82 86 $data = $id; 83 $id = 0;87 $id = 0; 84 88 } 85 89 … … 87 91 if ( is_wp_error( $data ) ) { 88 92 foreach ( (array) $data->get_error_codes() as $code ) { 89 $response .= "<wp_error code='$code'><![CDATA[" . $data->get_error_message( $code ) . "]]></wp_error>";93 $response .= "<wp_error code='$code'><![CDATA[" . $data->get_error_message( $code ) . ']]></wp_error>'; 90 94 if ( ! $error_data = $data->get_error_data( $code ) ) { 91 95 continue; … … 93 97 $class = ''; 94 98 if ( is_object( $error_data ) ) { 95 $class = ' class="' . get_class( $error_data ) . '"';99 $class = ' class="' . get_class( $error_data ) . '"'; 96 100 $error_data = get_object_vars( $error_data ); 97 101 } … … 107 111 } 108 112 109 $response .= "</wp_error_data>";113 $response .= '</wp_error_data>'; 110 114 } 111 115 } else { … … 124 128 $action = $_POST['action']; 125 129 } 126 $x = '';130 $x = ''; 127 131 $x .= "<response action='{$action}_$id'>"; // The action attribute in the xml output is formatted like a nonce action 128 $x .= 129 $x .= 130 $x .= 131 $x .= 132 $x .= "</response>";132 $x .= "<$what id='$id' " . ( false === $old_id ? '' : "old_id='$old_id' " ) . "position='$position'>"; 133 $x .= $response; 134 $x .= $s; 135 $x .= "</$what>"; 136 $x .= '</response>'; 133 137 134 138 $this->responses[] = $x; … … 146 150 header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ) ); 147 151 echo "<?xml version='1.0' encoding='" . get_option( 'blog_charset' ) . "' standalone='yes'?><wp_ajax>"; 148 foreach ( (array) $this->responses as $response ) 152 foreach ( (array) $this->responses as $response ) { 149 153 echo $response; 154 } 150 155 echo '</wp_ajax>'; 151 if ( wp_doing_ajax() ) 156 if ( wp_doing_ajax() ) { 152 157 wp_die(); 153 else158 } else { 154 159 die(); 160 } 155 161 } 156 162 }
Note: See TracChangeset
for help on using the changeset viewer.