Make WordPress Core


Ignore:
Timestamp:
05/08/2008 05:25:07 PM (17 years ago)
Author:
ryan
Message:

Move autosave to post revisions. Props mdawaffe. see #6775

File:
1 edited

Legend:

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

    r7883 r7907  
    567567
    568568/**
    569  * wp_post_revision_time() - returns formatted datetimestamp of a revision
     569 * wp_post_revision_title() - returns formatted datetimestamp of a revision (linked to that revisions's page)
    570570 *
    571571 * @package WordPress
     
    573573 * @since 2.6
    574574 *
    575  * @uses wp_get_revision()
    576575 * @uses date_i18n()
    577576 *
    578577 * @param int|object $revision revision ID or revision object
     578 * @param bool $link optional Link to revisions's page?
    579579 * @return string i18n formatted datetimestamp or localized 'Corrent Revision'
    580580 */
    581 function wp_post_revision_time( $revision ) {
    582     if ( !$revision = wp_get_revision( $revision ) ) {
    583         if ( $revision = get_post( $revision ) )
    584             return __( 'Current Revision' );
     581function wp_post_revision_title( $revision, $link = true ) {
     582    if ( !$revision = get_post( $revision ) )
    585583        return $revision;
    586     }
    587 
    588     $datef  = _c( 'j F, Y @ G:i|revision date format');
    589     return date_i18n( $datef, strtotime( $revision->post_date_gmt . ' +0000' ) );
     584
     585    if ( !in_array( $revision->post_type, array( 'post', 'page', 'revision' ) ) )
     586        return false;
     587
     588    $datef = _c( 'j F, Y @ G:i|revision date format');
     589    $autosavef = __( '%s [Autosave]' );
     590    $currentf  = __( '%s [Current Revision]' );
     591
     592    $date = date_i18n( $datef, strtotime( $revision->post_modified_gmt . ' +0000' ) );
     593    if ( $link && current_user_can( 'edit_post', $revision->ID ) && $link = get_edit_post_link( $revision->ID ) )
     594        $date = "<a href='$link'>$date</a>";
     595
     596    if ( 'revision' != $revision->post_type )
     597        $date = sprintf( $currentf, $date );
     598    elseif ( "{$revision->post_parent}-autosave" == $revision->post_name )
     599        $date = sprintf( $autosavef, $date );
     600
     601    return $date;
    590602}
    591603
     
    606618 *
    607619 * @uses wp_get_post_revisions()
    608  * @uses wp_post_revision_time()
     620 * @uses wp_post_revision_title()
    609621 * @uses get_edit_post_link()
    610622 * @uses get_author_name()
     
    631643    $class = false;
    632644    foreach ( $revisions as $revision ) {
    633         $date = wp_post_revision_time( $revision );
    634         if ( $link = get_edit_post_link( $revision->ID ) )
    635             $date = "<a href='$link'>$date</a>";
     645        $date = wp_post_revision_title( $revision );
    636646        $name = get_author_name( $revision->post_author );
    637647
    638648        if ( 'form-table' == $format ) {
    639649            if ( $left )
    640                 $old_checked = $left == $revision->ID ? ' checked="checked"' : '';
     650                $left_checked = $left == $revision->ID ? ' checked="checked"' : '';
    641651            else
    642                 $old_checked = $new_checked ? ' checked="checked"' : '';
    643             $new_checked = $right == $revision->ID ? ' checked="checked"' : '';
     652                $left_checked = $right_checked ? ' checked="checked"' : ''; // [sic] (the next one)
     653            $right_checked = $right == $revision->ID ? ' checked="checked"' : '';
    644654
    645655            $class = $class ? '' : " class='alternate'";
    646656
    647657            if ( $post->ID != $revision->ID && current_user_can( 'edit_post', $post->ID ) )
    648                 $actions = '<a href="' . wp_nonce_url( add_query_arg( array( 'revision' => $revision->ID, 'diff' => false, 'restore' => 'restore' ) ), "restore-post_$post->ID|$revision->ID" ) . '">' . __( 'Restore' ) . '</a>';
     658                $actions = '<a href="' . wp_nonce_url( add_query_arg( array( 'revision' => $revision->ID, 'diff' => false, 'action' => 'restore' ) ), "restore-post_$post->ID|$revision->ID" ) . '">' . __( 'Restore' ) . '</a>';
    649659            else
    650660                $actions = '';
    651661
    652662            $rows .= "<tr$class>\n";
    653             $rows .= "\t<th style='white-space: nowrap' scope='row'><input type='radio' name='diff' value='$revision->ID'$old_checked /><input type='radio' name='revision' value='$revision->ID'$new_checked />\n";
     663            $rows .= "\t<th style='white-space: nowrap' scope='row'><input type='radio' name='left' value='$revision->ID'$left_checked /><input type='radio' name='right' value='$revision->ID'$right_checked />\n";
    654664            $rows .= "\t<td>$date</td>\n";
    655665            $rows .= "\t<td>$name</td>\n";
     
    657667            $rows .= "</tr>\n";
    658668        } else {
    659             $rows .= "\t<li>" . sprintf( $titlef, $date, $name ). "</li>\n";
     669            $title = sprintf( $titlef, $date, $name );
     670            $rows .= "\t<li>$title</li>\n";
    660671        }
    661672    }
     
    668679    <div class="alignleft">
    669680        <input type="submit" class="button-secondary" value="<?php _e( 'Compare Revisions' ); ?>" />
     681        <input type="hidden" name="action" value="diff" />
    670682    </div>
    671683</div>
Note: See TracChangeset for help on using the changeset viewer.