Make WordPress Core


Ignore:
Timestamp:
06/06/2013 02:39:08 PM (11 years ago)
Author:
markjaquith
Message:

Restore post format previewing.

props azaozz. fixes #24483

File:
1 edited

Legend:

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

    r24397 r24414  
    445445    $post->post_excerpt = $preview->post_excerpt;
    446446
     447    add_filter( 'get_the_terms', '_wp_preview_terms_filter', 10, 3 );
     448
    447449    return $post;
    448450}
     
    464466        add_filter('the_preview', '_set_preview');
    465467    }
     468}
     469
     470/**
     471 * Filters terms lookup to set the post format.
     472 *
     473 * @since 3.6.0
     474 * @access private
     475 */
     476function _wp_preview_terms_filter( $terms, $post_id, $taxonomy ) {
     477    if ( ! $post = get_post() )
     478        return $terms;
     479
     480    if ( empty( $_REQUEST['post_format'] ) || $post->ID != $post_id || 'post_format' != $taxonomy || 'revision' == $post->post_type )
     481        return $terms;
     482
     483    if ( 'standard' == $_REQUEST['post_format'] )
     484        $terms = array();
     485    elseif ( $term = get_term_by( 'slug', 'post-format-' . sanitize_key( $_REQUEST['post_format'] ), 'post_format' ) )
     486        $terms = array( $term ); // Can only have one post format
     487
     488    return $terms;
    466489}
    467490
Note: See TracChangeset for help on using the changeset viewer.