WP_Ajax_Response::add

SummerySummery

Appends data to an XML response based on given arguments.

Syntax

WP_Ajax_Response::add( string|array $args = '' )

DescriptionDescription

With $args defaults, extra data output would be:

<response action='{$action}_$id'>
 <$what id='$id' position='$position'>
     <response_data><![CDATA[$data]]></response_data>
 </$what>
</response>

ParametersParameters

$args

(string|array) (Optional) An array or string of XML response arguments.

  • 'what'
    (string) XML-RPC response type. Used as a child element of <response>. Default 'object' (<object>).
  • 'action'
    (string|false) Value to use for the action attribute in <response>. Will be appended with _$id on output. If false, $action will default to the value of $_POST['action']. Default false.
  • 'id'
    (int|WP_Error) The response ID, used as the response type id attribute. Also accepts a WP_Error object if the ID does not exist. Default 0.
  • 'old_id'
    (int|false) The previous response ID. Used as the value for the response type old_id attribute. False hides the attribute. Default false.
  • 'position'
    (string) Value of the response type position attribute. Accepts 1 (bottom), -1 (top), html ID (after), or -html ID (before). Default 1 (bottom).
  • 'data'
    (string|WP_Error) The response content/message. Also accepts a WP_Error object if the ID does not exist.
  • 'supplemental'
    (array) An array of extra strings that will be output within a <supplemental> element as CDATA. Default empty array.

Default value: ''

ReturnReturn

(string) XML response.

SourceSource

File: wp-includes/class-wp-ajax-response.php


			

ChangelogChangelog

Changelog
Version Description
2.1.0 Introduced.
Scroll to Top