Make WordPress Core


Ignore:
Timestamp:
05/29/2008 10:21:36 PM (16 years ago)
Author:
ryan
Message:

Post revisions API cleanup from mdawaffe. see #6775

File:
1 edited

Legend:

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

    r7913 r8011  
    594594        $date = "<a href='$link'>$date</a>";
    595595
    596     if ( 'revision' != $revision->post_type )
     596    if ( !wp_is_post_revision( $revision ) )
    597597        $date = sprintf( $currentf, $date );
    598     elseif ( "{$revision->post_parent}-autosave" == $revision->post_name )
     598    elseif ( wp_is_post_autosave( $revision ) )
    599599        $date = sprintf( $autosavef, $date );
    600600
     
    629629        return;
    630630
    631     if ( !$revisions = wp_get_post_revisions( $post->ID ) )
    632         return;
    633 
    634     $defaults = array( 'parent' => false, 'right' => false, 'left' => false, 'format' => 'list' );
     631    $defaults = array( 'parent' => false, 'right' => false, 'left' => false, 'format' => 'list', 'type' => 'all' );
    635632    extract( wp_parse_args( $args, $defaults ), EXTR_SKIP );
     633
     634    switch ( $type ) {
     635    case 'autosave' :
     636        if ( !$autosave = wp_get_post_autosave( $post->ID ) )
     637            return;
     638        $revisions = array( $autosave );
     639        break;
     640    case 'revision' : // just revisions - remove autosave later
     641    case 'all' :
     642    default :
     643        if ( !$revisions = wp_get_post_revisions( $post->ID ) )
     644            return;
     645        break;
     646    }
    636647
    637648    $titlef = _c( '%1$s by %2$s|post revision 1:datetime, 2:name' );
     
    645656    foreach ( $revisions as $revision ) {
    646657        if ( !current_user_can( 'read_post', $revision->ID ) )
     658            continue;
     659        if ( 'revision' === $type && wp_is_post_autosave( $revision ) )
    647660            continue;
    648661
Note: See TracChangeset for help on using the changeset viewer.