Make WordPress Core

Ticket #43069: 43069.diff

File 43069.diff, 4.0 KB (added by terriann, 7 years ago)

Improve documentation for register_meta() function

  • wp-includes/meta.php

     
    993993}
    994994
    995995/**
    996  * Registers a meta key.
     996 * Registers a meta key on all object sub-types of the specified object type.
    997997 *
     998 * Once registered the meta key can be used with WordPress's various APIs as
     999 * well as the custom post fields box and may leverage consistent input sanitization,
     1000 * capability control and rest API access.
     1001 *
    9981002 * @since 3.3.0
    9991003 * @since 4.6.0 {@link https://core.trac.wordpress.org/ticket/35658 Modified
    10001004 *              to support an array of data to attach to registered meta keys}. Previous arguments for
    10011005 *              `$sanitize_callback` and `$auth_callback` have been folded into this array.
    10021006 *
    1003  * @param string $object_type    Type of object this meta is registered to.
    1004  * @param string $meta_key       Meta key to register.
    1005  * @param array  $args {
     1007 * @param string       $object_type    Type of object the meta field is being registered to.
     1008 *                                     Valid values include 'post', 'comment', 'term', 'user' etc.
     1009 * @param string       $meta_key       Meta key to register.
     1010 * @param array        $args {
    10061011 *     Data used to describe the meta key when registered.
    10071012 *
    1008  *     @type string $type              The type of data associated with this meta key.
    1009  *                                     Valid values are 'string', 'boolean', 'integer', and 'number'.
    1010  *     @type string $description       A description of the data attached to this meta key.
    1011  *     @type bool   $single            Whether the meta key has one value per object, or an array of values per object.
    1012  *     @type string $sanitize_callback A function or method to call when sanitizing `$meta_key` data.
    1013  *     @type string $auth_callback     Optional. A function or method to call when performing edit_post_meta, add_post_meta, and delete_post_meta capability checks.
    1014  *     @type bool   $show_in_rest      Whether data associated with this meta key can be considered public.
     1013 *     @type string $type              Optional. The type of data associated with this meta key.
     1014 *                                     Valid values are 'string', 'boolean', 'integer', and 'number'. Default 'string'.
     1015 *     @type string $description       Optional. A description of the data attached to this meta key. Default empty.
     1016 *     @type bool   $single            Optional. Whether the meta key has one value per object, or an array of values per object. Default false.
     1017 *     @type string $sanitize_callback Optional. A function or method to call when sanitizing `$meta_key` data. Default null.
     1018 *     @type string $auth_callback     Optional. A function or method to call when performing edit_post_meta, add_post_meta, and delete_post_meta capability checks. Default null.
     1019 *     @type bool   $show_in_rest      Optional. Whether data associated with this meta key can be considered public for all objects of the defined object type. Default false.
    10151020 * }
    1016  * @param string|array $deprecated Deprecated. Use `$args` instead.
     1021 * @param string|array $deprecated     Deprecated. Use `$args` instead.
    10171022 *
    10181023 * @return bool True if the meta key was successfully registered in the global array, false if not.
    1019  *                       Registering a meta key with distinct sanitize and auth callbacks will fire those
    1020  *                       callbacks, but will not add to the global registry.
     1024 *              Registering a meta key with distinct sanitize and auth callbacks will fire those
     1025 *              callbacks, but will not add to the global registry.
    10211026 */
    10221027function register_meta( $object_type, $meta_key, $args, $deprecated = null ) {
    10231028        global $wp_meta_keys;
     
    10351040                'show_in_rest'      => false,
    10361041        );
    10371042
    1038         // There used to be individual args for sanitize and auth callbacks
     1043        // Back-compat: sanitize and auth callbacks were both passed as parameters before the array of arguments was added in 4.6.0.
    10391044        $has_old_sanitize_cb = false;
    10401045        $has_old_auth_cb     = false;
    10411046