Ticket #43069: 43069.diff
File 43069.diff, 4.0 KB (added by , 7 years ago) |
---|
-
wp-includes/meta.php
993 993 } 994 994 995 995 /** 996 * Registers a meta key .996 * Registers a meta key on all object sub-types of the specified object type. 997 997 * 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 * 998 1002 * @since 3.3.0 999 1003 * @since 4.6.0 {@link https://core.trac.wordpress.org/ticket/35658 Modified 1000 1004 * to support an array of data to attach to registered meta keys}. Previous arguments for 1001 1005 * `$sanitize_callback` and `$auth_callback` have been folded into this array. 1002 1006 * 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 { 1006 1011 * Data used to describe the meta key when registered. 1007 1012 * 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. 1015 1020 * } 1016 * @param string|array $deprecated Deprecated. Use `$args` instead.1021 * @param string|array $deprecated Deprecated. Use `$args` instead. 1017 1022 * 1018 1023 * @return bool True if the meta key was successfully registered in the global array, false if not. 1019 * 1020 * 1024 * Registering a meta key with distinct sanitize and auth callbacks will fire those 1025 * callbacks, but will not add to the global registry. 1021 1026 */ 1022 1027 function register_meta( $object_type, $meta_key, $args, $deprecated = null ) { 1023 1028 global $wp_meta_keys; … … 1035 1040 'show_in_rest' => false, 1036 1041 ); 1037 1042 1038 // There used to be individual args for sanitize and auth callbacks1043 // Back-compat: sanitize and auth callbacks were both passed as parameters before the array of arguments was added in 4.6.0. 1039 1044 $has_old_sanitize_cb = false; 1040 1045 $has_old_auth_cb = false; 1041 1046