WordPress.org

Make WordPress Core

Changeset 23830


Ignore:
Timestamp:
03/28/2013 12:56:44 AM (6 years ago)
Author:
azaozz
Message:

Fix wp_list_post_revisions() to include all autosaves when listing autosaves only and properly include or exclude the current post, see #23665, see #16215

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post-template.php

    r23819 r23830  
    14171417    extract( wp_parse_args( $args, $defaults ), EXTR_SKIP );
    14181418
    1419     switch ( $type ) {
    1420         case 'autosave' :
    1421             if ( !$autosave = wp_get_post_autosave( $post->ID ) )
    1422                 return;
    1423             $revisions = array( $autosave );
    1424             break;
    1425         case 'revision' : // just revisions - remove autosave later
    1426         case 'all' :
    1427         default :
    1428             if ( !$revisions = wp_get_post_revisions( $post->ID ) )
    1429                 return;
    1430             break;
    1431     }
     1419    if ( !$revisions = wp_get_post_revisions( $post->ID ) )
     1420        return;
    14321421
    14331422    /* translators: post revision: 1: when, 2: author name */
    14341423    $titlef = _x( '%1$s', 'post revision' );
    14351424
    1436     if ( $parent )
     1425    // Since 3.6 revisions include a copy of the current post data as a revision.
     1426    // The following removes that revision when $parent == false
     1427    $parent_included = wp_first_revision_matches_current_version( $post_id );
     1428    if ( $parent_included && ! $parent )
     1429        array_pop( $revisions );
     1430    elseif ( ! $parent_included && $parent )
    14371431        array_unshift( $revisions, $post );
    1438 
    1439     // since 3.6 revisions include a copy of the current post data as a revision
    1440     // the collowing removes this current revision if present from the list of
    1441     // revisions returned by wp_list_post_revisions, remove these to include the
    1442     // crrent post revision in the list of revisions
    1443     if ( wp_first_revision_matches_current_version( $post_id ) )
    1444         array_pop( $revisions );
    14451432
    14461433    $rows = $right_checked = '';
     
    14501437        if ( !current_user_can( 'read_post', $revision->ID ) )
    14511438            continue;
    1452         if ( 'revision' === $type && wp_is_post_autosave( $revision ) )
     1439       
     1440        $is_autosave = wp_is_post_autosave( $revision );
     1441        if ( ( 'revision' === $type && $is_autosave ) || ( 'autosave' === $type && ! $is_autosave ) )
    14531442            continue;
    14541443
     
    15301519
    15311520    endif;
    1532 
    1533 }
     1521}
Note: See TracChangeset for help on using the changeset viewer.