From 0d18f5136d80cb521e9424aacd772dc603b46d62 Mon Sep 17 00:00:00 2001 From: Helen Hou-Sandi Date: Thu, 30 Jun 2016 21:24:59 +0000 Subject: [PATCH] Meta: Make retrieving registered metadata actually work. The initial implementation used a `single` argument, which has now been added to the whitelist. props Faison. see #35658. git-svn-id: https://develop.svn.wordpress.org/trunk@37934 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/meta.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/meta.php b/src/wp-includes/meta.php index 50aa75b2c5..718f42a699 100644 --- a/src/wp-includes/meta.php +++ b/src/wp-includes/meta.php @@ -997,6 +997,7 @@ function sanitize_meta( $meta_key, $meta_value, $object_type, $object_subtype = * @type string $object_subtype A subtype; e.g. if the object type is "post", the post type. * @type string $type The type of data associated with this meta key. * @type string $description A description of the data attached to this meta key. + * @type bool $single Whether the meta key has one value per object, or an array of values per object. * @type string $sanitize_callback A function or method to call when sanitizing `$meta_key` data. * @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. * @type bool $show_in_rest Whether data associated with this meta key can be considered public. @@ -1023,6 +1024,7 @@ function register_meta( $object_type, $meta_key, $args, $deprecated = null ) { 'object_subtype' => '', 'type' => 'string', 'description' => '', + 'single' => false, 'sanitize_callback' => null, 'auth_callback' => null, 'show_in_rest' => false, @@ -1225,9 +1227,9 @@ function get_registered_metadata( $object_type, $object_subtype, $object_id, $me return new WP_Error( 'invalid_meta_key', __( 'Invalid meta key. Not registered.' ) ); } $meta_keys = get_registered_meta_keys( $object_type, $object_subtype ); - $meta_key_data = $meta_keys[ $object_type ][ $object_subtype ][ $meta_key ]; + $meta_key_data = $meta_keys[ $meta_key ]; - $data = get_metadata( $object_type, $object_id, $meta_key, $meta_key_data->single ); + $data = get_metadata( $object_type, $object_id, $meta_key, $meta_key_data['single'] ); return $data; }