Options, Meta APIs: Reorder the parameters of `default_{$meta_type}_metadata` filter.

This brings consistency with the `get_{$meta_type}_metadata` filter and more closely matches the `get_metadata_default()` function signature.

Follow-up to [48502].

Props spacedmonkey.
See #43941.
Built from https://develop.svn.wordpress.org/trunk@48505


git-svn-id: http://core.svn.wordpress.org/trunk@48267 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-07-17 15:15:03 +00:00
parent 4cd355c5cf
commit 38400754a1
2 changed files with 13 additions and 10 deletions

View File

@ -544,14 +544,17 @@ function get_metadata_raw( $meta_type, $object_id, $meta_key = '', $single = fal
* Returning a non-null value will effectively short-circuit the function. * Returning a non-null value will effectively short-circuit the function.
* *
* @since 3.1.0 * @since 3.1.0
* @since 5.5.0 Added the `$meta_type` parameter.
* *
* @param mixed $value The value to return, either a single metadata value or an array * @param mixed $value The value to return, either a single metadata value or an array
* of values depending on the value of `$single`. Default null. * of values depending on the value of `$single`. Default null.
* @param int $object_id ID of the object metadata is for. * @param int $object_id ID of the object metadata is for.
* @param string $meta_key Metadata key. * @param string $meta_key Metadata key.
* @param bool $single Whether to return only the first value of the specified `$meta_key`. * @param bool $single Whether to return only the first value of the specified `$meta_key`.
* @param string $meta_type Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user',
* or any other object type with an associated meta table.
*/ */
$check = apply_filters( "get_{$meta_type}_metadata", null, $object_id, $meta_key, $single ); $check = apply_filters( "get_{$meta_type}_metadata", null, $object_id, $meta_key, $single, $meta_type );
if ( null !== $check ) { if ( null !== $check ) {
if ( $single && is_array( $check ) ) { if ( $single && is_array( $check ) ) {
return $check[0]; return $check[0];
@ -618,13 +621,13 @@ function get_metadata_default( $meta_type, $object_id, $meta_key, $single = fals
* *
* @param mixed $value The value to return, either a single metadata value or an array * @param mixed $value The value to return, either a single metadata value or an array
* of values depending on the value of `$single`. * of values depending on the value of `$single`.
* @param string $meta_type Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user', * @param int $object_id ID of the object metadata is for.
* or any other object type with an associated meta table.
* @param string $meta_key Metadata key. * @param string $meta_key Metadata key.
* @param bool $single Whether to return only the first value of the specified `$meta_key`. * @param bool $single Whether to return only the first value of the specified `$meta_key`.
* @param int $object_id ID of the object metadata is for. * @param string $meta_type Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user',
* or any other object type with an associated meta table.
*/ */
$value = apply_filters( "default_{$meta_type}_metadata", $value, $meta_type, $meta_key, $single, $object_id ); $value = apply_filters( "default_{$meta_type}_metadata", $value, $object_id, $meta_key, $single, $meta_type );
if ( ! $single && ! wp_is_numeric_array( $value ) ) { if ( ! $single && ! wp_is_numeric_array( $value ) ) {
$value = array( $value ); $value = array( $value );
@ -1379,15 +1382,15 @@ function register_meta( $object_type, $meta_key, $args, $deprecated = null ) {
* @since 5.5.0 * @since 5.5.0
* *
* @param mixed $value Current value passed to filter. * @param mixed $value Current value passed to filter.
* @param string $meta_type Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user', * @param int $object_id ID of the object metadata is for.
* or any other object type with an associated meta table.
* @param string $meta_key Metadata key. * @param string $meta_key Metadata key.
* @param bool $single If true, return only the first value of the specified meta_key. * @param bool $single If true, return only the first value of the specified meta_key.
* This parameter has no effect if meta_key is not specified. * This parameter has no effect if meta_key is not specified.
* @param int $object_id ID of the object metadata is for. * @param string $meta_type Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user',
* or any other object type with an associated meta table.
* @return mixed Single metadata default, or array of defaults. * @return mixed Single metadata default, or array of defaults.
*/ */
function filter_default_metadata( $value, $meta_type, $meta_key, $single, $object_id ) { function filter_default_metadata( $value, $object_id, $meta_key, $single, $meta_type ) {
global $wp_meta_keys; global $wp_meta_keys;
if ( wp_installing() ) { if ( wp_installing() ) {

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.5-beta2-48504'; $wp_version = '5.5-beta2-48505';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.