Ticket #24726: 24726.2.diff
File 24726.2.diff, 1.9 KB (added by , 9 years ago) |
---|
-
src/wp-includes/meta.php
451 451 * specified meta_key. This parameter has no effect if meta_key is not specified. 452 452 * @return mixed Single metadata value, or array of values 453 453 */ 454 function get_metadata( $meta_type, $object_id, $meta_key = '', $single = false) {454 function get_metadata( $meta_type, $object_id, $meta_key = '', $single = false ) { 455 455 if ( ! $meta_type || ! is_numeric( $object_id ) ) { 456 456 return false; 457 457 } … … 479 479 */ 480 480 $check = apply_filters( "get_{$meta_type}_metadata", null, $object_id, $meta_key, $single ); 481 481 if ( null !== $check ) { 482 if ( $single && is_array( $check ) ) 482 if ( $single && is_array( $check ) ) { 483 483 return $check[0]; 484 else484 } else { 485 485 return $check; 486 } 486 487 } 487 488 488 $meta_cache = wp_cache_get( $object_id, $meta_type . '_meta');489 $meta_cache = wp_cache_get( $object_id, $meta_type . '_meta' ); 489 490 490 if ( ! $meta_cache ) {491 if ( ! $meta_cache ) { 491 492 $meta_cache = update_meta_cache( $meta_type, array( $object_id ) ); 492 493 $meta_cache = $meta_cache[$object_id]; 493 494 } … … 496 497 return $meta_cache; 497 498 } 498 499 499 if ( isset($meta_cache[$meta_key]) ) { 500 if ( $single ) 501 return maybe_unserialize( $meta_cache[$meta_key][0] ); 502 else 503 return array_map('maybe_unserialize', $meta_cache[$meta_key]); 500 if ( isset( $meta_cache[ $meta_key ] ) ) { 501 if ( $single ) { 502 $meta_value = maybe_unserialize( $meta_cache[ $meta_key ][0] ); 503 } else { 504 $meta_value = array_map( 'maybe_unserialize', $meta_cache[ $meta_key ] ); 505 } 506 } else { 507 if ( $single ) { 508 $meta_value = ''; 509 } else { 510 $meta_value = array(); 511 } 504 512 } 505 506 if ($single) 507 return ''; 508 else 509 return array(); 513 return apply_filters( "get_{$meta_type}_metadata-{$meta_key}", $meta_value, $object_id, $single ); 510 514 } 511 515 512 516 /**