Ticket #43941: 43941.17.diff
File 43941.17.diff, 5.7 KB (added by , 4 years ago) |
---|
-
src/wp-includes/meta.php
508 508 return $value; 509 509 } 510 510 511 return get_metadata_default( $meta_type, $ meta_key, $single, $object_id);511 return get_metadata_default( $meta_type, $object_id, $meta_key, $single ); 512 512 } 513 513 514 514 /** … … 544 544 * Returning a non-null value will effectively short-circuit the function. 545 545 * 546 546 * @since 3.1.0 547 * @since 5.5.0 Added the `$meta_type` parameter. 547 548 * 548 549 * @param mixed $value The value to return, either a single metadata value or an array 549 550 * of values depending on the value of `$single`. Default null. … … 550 551 * @param int $object_id ID of the object metadata is for. 551 552 * @param string $meta_key Metadata key. 552 553 * @param bool $single Whether to return only the first value of the specified `$meta_key`. 554 * @param string $meta_type Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user', 555 * or any other object type with an associated meta table. 553 556 */ 554 $check = apply_filters( "get_{$meta_type}_metadata", null, $object_id, $meta_key, $single );557 $check = apply_filters( "get_{$meta_type}_metadata", null, $object_id, $meta_key, $single, $meta_type ); 555 558 if ( null !== $check ) { 556 559 if ( $single && is_array( $check ) ) { 557 560 return $check[0]; … … 595 598 * 596 599 * @param string $meta_type Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user', 597 600 * or any other object type with an associated meta table. 598 * @param string $meta_key Metadata key. 601 * @param int $object_id ID of the object metadata is for. 602 * @param string $meta_key Optional. Metadata key. If not specified, retrieve all metadata for 603 * the specified object. Default empty. 599 604 * @param bool $single Optional. If true, return only the first value of the specified meta_key. 600 605 * This parameter has no effect if meta_key is not specified. Default false. 601 * @param int $object_id Optional. ID of the object metadata is for. Default 0.602 606 * @return mixed Single metadata value, or array of values. 603 607 */ 604 function get_metadata_default( $meta_type, $ meta_key, $single = false, $object_id = 0) {608 function get_metadata_default( $meta_type, $object_id, $meta_key = '', $single = false ) { 605 609 if ( $single ) { 606 610 $value = ''; 607 611 } else { … … 618 622 * 619 623 * @param mixed $value The value to return, either a single metadata value or an array 620 624 * of values depending on the value of `$single`. 625 * @param int $object_id ID of the object metadata is for. 626 * @param string $meta_key Metadata key. 627 * @param bool $single Whether to return only the first value of the specified `$meta_key`. 621 628 * @param string $meta_type Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user', 622 629 * or any other object type with an associated meta table. 623 * @param string $meta_key Metadata key.624 * @param bool $single Whether to return only the first value of the specified `$meta_key`.625 * @param int $object_id ID of the object metadata is for.626 630 */ 627 $value = apply_filters( "default_{$meta_type}_metadata", $value, $ meta_type, $meta_key, $single, $object_id);631 $value = apply_filters( "default_{$meta_type}_metadata", $value, $object_id, $meta_key, $single, $meta_type ); 628 632 629 633 if ( ! $single && ! wp_is_numeric_array( $value ) ) { 630 634 $value = array( $value ); … … 1379 1383 * @since 5.5.0 1380 1384 * 1381 1385 * @param mixed $value Current value passed to filter. 1382 * @param string $meta_type Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user', 1383 * or any other object type with an associated meta table. 1386 * @param int $object_id ID of the object metadata is for. 1384 1387 * @param string $meta_key Metadata key. 1385 1388 * @param bool $single If true, return only the first value of the specified meta_key. 1386 1389 * This parameter has no effect if meta_key is not specified. 1387 * @param int $object_id ID of the object metadata is for. 1390 * @param string $meta_type Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user', 1391 * or any other object type with an associated meta table. 1388 1392 * @return mixed Single metadata default, or array of defaults. 1389 1393 */ 1390 function filter_default_metadata( $value, $ meta_type, $meta_key, $single, $object_id) {1394 function filter_default_metadata( $value, $object_id, $meta_key, $single, $meta_type ) { 1391 1395 global $wp_meta_keys; 1392 1396 1393 1397 if ( wp_installing() ) { -
tests/phpunit/tests/meta/registerMeta.php
520 520 521 521 $object_property_name = $object_type . '_id'; 522 522 $object_id = self::$$object_property_name; 523 $default_value = get_metadata_default( $object_type, $ meta_key, $single, $object_id);523 $default_value = get_metadata_default( $object_type, $object_id, $meta_key, $single ); 524 524 $this->assertSame( $default_value, $expected ); 525 525 526 526 // Check for default value. … … 567 567 568 568 $object_property_name = $object_type . '_id'; 569 569 $object_id = self::$$object_property_name; 570 $default_value = get_metadata_default( $object_type, $ meta_key, $single, $object_id);570 $default_value = get_metadata_default( $object_type, $object_id, $meta_key, $single ); 571 571 $this->assertSame( $default_value, $expected ); 572 572 } 573 573