WordPress.org

Make WordPress Core

Changeset 37032


Ignore:
Timestamp:
03/18/2016 11:58:08 AM (4 years ago)
Author:
DrewAPicture
Message:

Docs: Document default WP_Ajax_Response::add() arguments as a hash notation.

Adds example output to the DocBlock description based on default argument values.

Props ramiy for the initial patch.
See #32246.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-ajax-response.php

    r31139 r37032  
    2929
    3030    /**
    31      * Append to XML response based on given arguments.
     31     * Appends data to an XML response based on given arguments.
    3232     *
    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     * With `$args` defaults, extra data output would be:
    3734     *
    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     *     <response action='{$action}_$id'>
     36     *      <$what id='$id' position='$position'>
     37     *          <response_data><![CDATA[$data]]></response_data>
     38     *      </$what>
     39     *     </response>
    4740     *
    4841     * @since 2.1.0
     42     * @access public
    4943     *
    50      * @param string|array $args Override defaults.
     44     * @param string|array $args {
     45     *     Optional. An array or string of XML response arguments.
     46     *
     47     *     @type string          $what         XML-RPC response type. Used as a child element of `<response>`.
     48     *                                         Default 'object' (`<object>`).
     49     *     @type string|false    $action       Value to use for the `action` attribute in `<response>`. Will be
     50     *                                         appended with `_$id` on output. If false, `$action` will default to
     51     *                                         the value of `$_POST['action']`. Default false.
     52     *     @type int|WP_Error    $id           The response ID, used as the response type `id` attribute. Also
     53     *                                         accepts a `WP_Error` object if the ID does not exist. Default 0.
     54     *     @type int|false       $old_id       The previous response ID. Used as the value for the response type
     55     *                                         `old_id` attribute. False hides the attribute. Default false.
     56     *     @type string          $position     Value of the response type `position` attribute. Accepts 1 (bottom),
     57     *                                         -1 (top), html ID (after), or -html ID (before). Default 1 (bottom).
     58     *     @type string|WP_Error $data         The response content/message. Also accepts a WP_Error object if the
     59     *                                         ID does not exist. Default empty.
     60     *     @type array           $supplemental An array of extra strings that will be output within a `<supplemental>`
     61     *                                         element as CDATA. Default empty array.
     62     * }
    5163     * @return string XML response.
    5264     */
Note: See TracChangeset for help on using the changeset viewer.