Ticket #24726: 24726.4.diff
| File 24726.4.diff, 3.7 KB (added by , 11 years ago) |
|---|
-
src/wp-includes/meta.php
454 454 * specified meta_key. This parameter has no effect if meta_key is not specified. 455 455 * @return mixed Single metadata value, or array of values 456 456 */ 457 function get_metadata( $meta_type, $object_id, $meta_key = '', $single = false) {457 function get_metadata( $meta_type, $object_id, $meta_key = '', $single = false ) { 458 458 if ( ! $meta_type || ! is_numeric( $object_id ) ) { 459 459 return false; 460 460 } … … 464 464 return false; 465 465 } 466 466 467 $check = null; 468 469 if ( $meta_key ) { 470 /** 471 * Filter whether to retrieve metadata of a specific type. 472 * 473 * The first dynamic portion of the hook, `$meta_type`, refers to the meta 474 * object type (comment, post, or user) and the second dynamic portion, 475 * `$meta_key`, refers to the Metadata key. Returning a non-null value 476 * will effectively short-circuit the function. 477 * 478 * @since 4.3.0 479 * 480 * @param null|array|string $value The value get_metadata() should 481 * return - a single metadata value, 482 * or an array of values. 483 * @param int $object_id Object ID. 484 * @param string|array $single Meta value, or an array of values. 485 */ 486 $check = apply_filters( "get_{$meta_type}_metadata_{$meta_key}", $check, $object_id, $single ); 487 } 488 467 489 /** 468 490 * Filter whether to retrieve metadata of a specific type. 469 491 * … … 480 502 * @param string $meta_key Meta key. 481 503 * @param string|array $single Meta value, or an array of values. 482 504 */ 483 $check = apply_filters( "get_{$meta_type}_metadata", null, $object_id, $meta_key, $single );505 $check = apply_filters( "get_{$meta_type}_metadata", $check, $object_id, $meta_key, $single ); 484 506 if ( null !== $check ) { 485 if ( $single && is_array( $check ) ) 507 if ( $single && is_array( $check ) ) { 486 508 return $check[0]; 487 else509 } else { 488 510 return $check; 511 } 489 512 } 490 513 491 $meta_cache = wp_cache_get( $object_id, $meta_type . '_meta');514 $meta_cache = wp_cache_get( $object_id, $meta_type . '_meta' ); 492 515 493 if ( ! $meta_cache ) {516 if ( ! $meta_cache ) { 494 517 $meta_cache = update_meta_cache( $meta_type, array( $object_id ) ); 495 518 $meta_cache = $meta_cache[$object_id]; 496 519 } … … 499 522 return $meta_cache; 500 523 } 501 524 502 if ( isset($meta_cache[$meta_key]) ) { 503 if ( $single ) 504 return maybe_unserialize( $meta_cache[$meta_key][0] ); 505 else 506 return array_map('maybe_unserialize', $meta_cache[$meta_key]); 525 if ( isset( $meta_cache[ $meta_key ] ) ) { 526 if ( $single ) { 527 $meta_value = maybe_unserialize( $meta_cache[ $meta_key ][0] ); 528 } else { 529 $meta_value = array_map( 'maybe_unserialize', $meta_cache[ $meta_key ] ); 530 } 531 } else { 532 if ( $single ) { 533 $meta_value = ''; 534 } else { 535 $meta_value = array(); 536 } 507 537 } 508 538 509 if ($single) 510 return ''; 511 else 512 return array(); 539 /** 540 * Filters the retrieved metadata value. 541 * 542 * The dynamic portion of the hook, `$meta_type`, refers to the meta 543 * object type (comment, post, or user). 544 * 545 * @since 4.3.0 546 * 547 * @param null|array|string $meta_value The value get_metadata() should 548 * return - a single metadata value, 549 * or an array of values. 550 * @param int $object_id Object ID. 551 * @param string $meta_key Meta key. 552 * @param string|array $single Meta value, or an array of values. 553 */ 554 return apply_filters( "{$meta_type}_metadata_value", $meta_value, $object_id, $meta_key, $single ); 513 555 } 514 556 515 557 /**
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)