26 if ( !empty($args) ) |
26 if ( !empty($args) ) |
27 $this->add($args); |
27 $this->add($args); |
28 } |
28 } |
29 |
29 |
30 /** |
30 /** |
31 * Append to XML response based on given arguments. |
31 * Appends data to an XML response based on given arguments. |
32 * |
32 * |
33 * The arguments that can be passed in the $args parameter are below. It is |
33 * With `$args` defaults, extra data output would be: |
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. |
|
37 * |
34 * |
38 * 'what' argument is a string that is the XMLRPC response type. |
35 * <response action='{$action}_$id'> |
39 * 'action' argument is a boolean or string that acts like a nonce. |
36 * <$what id='$id' position='$position'> |
40 * 'id' argument can be WP_Error or an integer. |
37 * <response_data><![CDATA[$data]]></response_data> |
41 * 'old_id' argument is false by default or an integer of the previous ID. |
38 * </$what> |
42 * 'position' argument is an integer or a string with -1 = top, 1 = bottom, |
39 * </response> |
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. |
|
47 * |
40 * |
48 * @since 2.1.0 |
41 * @since 2.1.0 |
49 * |
42 * |
50 * @param string|array $args Override defaults. |
43 * @param string|array $args { |
|
44 * Optional. An array or string of XML response arguments. |
|
45 * |
|
46 * @type string $what XML-RPC response type. Used as a child element of `<response>`. |
|
47 * Default 'object' (`<object>`). |
|
48 * @type string|false $action Value to use for the `action` attribute in `<response>`. Will be |
|
49 * appended with `_$id` on output. If false, `$action` will default to |
|
50 * the value of `$_POST['action']`. Default false. |
|
51 * @type int|WP_Error $id The response ID, used as the response type `id` attribute. Also |
|
52 * accepts a `WP_Error` object if the ID does not exist. Default 0. |
|
53 * @type int|false $old_id The previous response ID. Used as the value for the response type |
|
54 * `old_id` attribute. False hides the attribute. Default false. |
|
55 * @type string $position Value of the response type `position` attribute. Accepts 1 (bottom), |
|
56 * -1 (top), html ID (after), or -html ID (before). Default 1 (bottom). |
|
57 * @type string|WP_Error $data The response content/message. Also accepts a WP_Error object if the |
|
58 * ID does not exist. Default empty. |
|
59 * @type array $supplemental An array of extra strings that will be output within a `<supplemental>` |
|
60 * element as CDATA. Default empty array. |
|
61 * } |
51 * @return string XML response. |
62 * @return string XML response. |
52 */ |
63 */ |
53 public function add( $args = '' ) { |
64 public function add( $args = '' ) { |
54 $defaults = array( |
65 $defaults = array( |
55 'what' => 'object', 'action' => false, |
66 'what' => 'object', 'action' => false, |