| 470 | /** |
| 471 | * Private filter for getting metadata for the preview. |
| 472 | * |
| 473 | * @package WordPress |
| 474 | * @subpackage Post_Revisions |
| 475 | * @since 3.6.0 |
| 476 | * |
| 477 | * @uses get_meta_data() |
| 478 | * |
| 479 | * @param unknown $value null |
| 480 | * @param int $object_id ID of the object metadata is for |
| 481 | * @param string $meta_key Optional. Metadata key. If not specified, retrieve all metadata for |
| 482 | * the specified object. |
| 483 | * @param bool $single Optional, default is false. If true, return only the first value of the |
| 484 | * specified meta_key. This parameter has no effect if meta_key is not specified. |
| 485 | * |
| 486 | * @return string|array Single metadata value, or array of values |
| 487 | */ |
| 488 | function _get_preview_meta( $value, $object_id, $meta_key, $single ) { |
| 489 | global $post_preview_id; |
| 490 | |
| 491 | if ( !$meta_key ) |
| 492 | return $value; |
| 493 | |
| 494 | $versioned_meta = apply_filters( 'versioned_meta', $versioned_meta ); |
| 495 | if ( ! in_array( $meta_key, $versioned_meta ) ) |
| 496 | return $value; |
| 497 | |
| 498 | $meta_cache = wp_cache_get( $post_preview_id, 'post_meta' ); |
| 499 | if ( ! $meta_cache ) { |
| 500 | $meta_cache = update_meta_cache( 'post', array( $object_id ) ); |
| 501 | $meta_cache = $meta_cache[$post_preview_id]; |
| 502 | } |
| 503 | if ( isset( $meta_cache[ $meta_key ] ) ) |
| 504 | return array_map( 'maybe_unserialize', $meta_cache[ $meta_key ] ); |
| 505 | |
| 506 | return $value; |
| 507 | } |
| 508 | |