WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/29/2013 12:08:42 PM (8 years ago)
Author:
markjaquith
Message:

Use the revisioned post format metadata when previewing.

fixes #23539. props kovshenin.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/revision.php

    r23859 r23862  
    505505    $post->post_excerpt = $preview->post_excerpt;
    506506
     507    add_filter( 'get_post_metadata', '_wp_preview_meta_filter', 10, 4 );
     508
    507509    return $post;
     510}
     511
     512/**
     513 * Filters post meta retrieval to get values from the actual autosave post,
     514 * and not its parent. Filters revisioned meta keys only.
     515 *
     516 * @since 3.6
     517 * @access private
     518 */
     519function _wp_preview_meta_filter( $value, $object_id, $meta_key, $single ) {
     520    $post = get_post();
     521
     522    if ( $post->ID != $object_id || ! in_array( $meta_key, _wp_post_revision_meta_keys() ) || 'revision' == $post->post_type )
     523        return $value;
     524
     525    $preview = wp_get_post_autosave( $post->ID );
     526    return get_post_meta( $preview->ID, $meta_key, $single );
    508527}
    509528
Note: See TracChangeset for help on using the changeset viewer.