From 7f5717ba5d1084138e2c8c67962a03a338cd28a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Helen=20Hou-Sand=C3=AD?= Date: Thu, 30 Jun 2016 21:25:27 +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. Built from https://develop.svn.wordpress.org/trunk@37934 git-svn-id: http://core.svn.wordpress.org/trunk@37875 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/meta.php | 6 ++++-- wp-includes/version.php | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/wp-includes/meta.php b/wp-includes/meta.php index 50aa75b2c5..718f42a699 100644 --- a/wp-includes/meta.php +++ b/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; } diff --git a/wp-includes/version.php b/wp-includes/version.php index 8dd1dbd727..46fd0ffe61 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.6-beta1-37933'; +$wp_version = '4.6-beta1-37934'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.