Ticket #24726: 24726.3.diff
| File 24726.3.diff, 2.6 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 } … … 482 482 */ 483 483 $check = apply_filters( "get_{$meta_type}_metadata", null, $object_id, $meta_key, $single ); 484 484 if ( null !== $check ) { 485 if ( $single && is_array( $check ) ) 485 if ( $single && is_array( $check ) ) { 486 486 return $check[0]; 487 else487 } else { 488 488 return $check; 489 } 489 490 } 490 491 491 $meta_cache = wp_cache_get( $object_id, $meta_type . '_meta');492 $meta_cache = wp_cache_get( $object_id, $meta_type . '_meta' ); 492 493 493 if ( ! $meta_cache ) {494 if ( ! $meta_cache ) { 494 495 $meta_cache = update_meta_cache( $meta_type, array( $object_id ) ); 495 496 $meta_cache = $meta_cache[$object_id]; 496 497 } … … 499 500 return $meta_cache; 500 501 } 501 502 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]); 503 if ( isset( $meta_cache[ $meta_key ] ) ) { 504 if ( $single ) { 505 $meta_value = maybe_unserialize( $meta_cache[ $meta_key ][0] ); 506 } else { 507 $meta_value = array_map( 'maybe_unserialize', $meta_cache[ $meta_key ] ); 508 } 509 } else { 510 if ( $single ) { 511 $meta_value = ''; 512 } else { 513 $meta_value = array(); 514 } 507 515 } 508 509 if ($single) 510 return ''; 511 else 512 return array(); 516 /** 517 * Filter whether to retrieve metadata of a specific type. 518 * 519 * The dynamic portion of the hook, `$meta_type`, refers to the meta 520 * object type (comment, post, or user) and `$meta_key` refers to Meta key. 521 * Returning a non-null value will effectively short-circuit the function. 522 * 523 * @since 4.3.0 524 * 525 * @param null|array|string $value The value get_metadata() should 526 * return - a single metadata value, 527 * or an array of values. 528 * @param int $object_id Object ID. 529 * @param string|array $single Meta value, or an array of values. 530 */ 531 return apply_filters( "get_{$meta_type}_metadata-{$meta_key}", $meta_value, $object_id, $single ); 513 532 } 514 533 515 534 /**
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)