Ticket #32246: class-wp-ajax-response.php.patch
File class-wp-ajax-response.php.patch, 2.9 KB (added by , 9 years ago) |
---|
-
wp-includes/class-wp-ajax-response.php
30 30 /** 31 31 * Append to XML response based on given arguments. 32 32 * 33 * The arguments that can be passed in the $args parameter are below. It is 34 * also possible to pass a WP_Error object in either the 'id' or 'data' 35 * argument. The parameter isn't actually optional, content should be given 36 * in order to send the correct response. 33 * @since 2.1.0 37 34 * 38 * 'what' argument is a string that is the XMLRPC response type. 39 * 'action' argument is a boolean or string that acts like a nonce. 40 * 'id' argument can be WP_Error or an integer. 41 * 'old_id' argument is false by default or an integer of the previous ID. 42 * 'position' argument is an integer or a string with -1 = top, 1 = bottom, 43 * html ID = after, -html ID = before. 44 * 'data' argument is a string with the content or message. 45 * 'supplemental' argument is an array of strings that will be children of 46 * the supplemental element. 35 * @param string|array $args { 36 * Optional. XML response arguments to override defaults. 47 37 * 48 * @since 2.1.0 49 * 50 * @param string|array $args Override defaults. 38 * @type string $what XMLRPC response type. Default is 'object'. 39 * @type bool $action Use nonce. Default is false. 40 * @type int|WP_Error $id The id. Default is '0'. 41 * @type int|false $old_id The previous ID. Default is false. 42 * @type string $position bottom = 1 ; top = -1 ; after = html ID ; 43 * before = -html ID ; Default is 1 (bottom). 44 * @type string|WP_Error $data The content or message. Default is empty. 45 * @type array $supplemental An array of strings that will be children 46 * of the <supplemental> element. 47 * } 51 48 * @return string XML response. 52 49 */ 53 50 public function add( $args = '' ) { 54 51 $defaults = array( 55 'what' => 'object', 'action' => false, 56 'id' => '0', 'old_id' => false, 57 'position' => 1, 58 'data' => '', 'supplemental' => array() 52 'what' => 'object', 53 'action' => false, 54 'id' => '0', 55 'old_id' => false, 56 'position' => 1, 57 'data' => '', 58 'supplemental' => array() 59 59 ); 60 60 61 61 $r = wp_parse_args( $args, $defaults ); 62 62 63 63 $position = preg_replace( '/[^a-z0-9:_-]/i', '', $r['position'] ); 64 $id = $r['id'];65 $what = $r['what'];66 $action = $r['action'];67 $old_id = $r['old_id'];68 $data = $r['data'];64 $id = $r['id']; 65 $what = $r['what']; 66 $action = $r['action']; 67 $old_id = $r['old_id']; 68 $data = $r['data']; 69 69 70 70 if ( is_wp_error( $id ) ) { 71 71 $data = $id;