Make WordPress Core


Ignore:
Timestamp:
03/21/2013 03:54:11 PM (12 years ago)
Author:
westi
Message:

Revisions: UI Update.

  • Refines the UI to make it clearer and easier to use
  • Introduces weighted tickmarks
  • Fixes comparison bugs.

See #23497 props adamsilverstein

File:
1 edited

Legend:

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

    r23743 r23769  
    13071307        return false;
    13081308
     1309    /* translators: revision date format, see http://php.net/date */
     1310    $datef = _x( 'j F, Y @ G:i', 'revision date format');
     1311    /* translators: 1: date */
     1312    $autosavef = __( '%1$s [Autosave]' );
     1313    /* translators: 1: date */
     1314    $currentf  = __( '%1$s [Current Revision]' );
     1315
     1316    $date = date_i18n( $datef, strtotime( $revision->post_modified ) );
     1317    if ( $link && current_user_can( 'edit_post', $revision->ID ) && $link = get_edit_post_link( $revision->ID ) )
     1318        $date = "<a href='$link'>$date</a>";
     1319
     1320    if ( !wp_is_post_revision( $revision ) )
     1321        $date = sprintf( $currentf, $date );
     1322    elseif ( wp_is_post_autosave( $revision ) )
     1323        $date = sprintf( $autosavef, $date );
     1324
     1325    return $date;
     1326}
     1327
     1328/**
     1329 * Retrieve formatted date timestamp of a revision (linked to that revisions's page).
     1330 *
     1331 * @package WordPress
     1332 * @subpackage Post_Revisions
     1333 * @since 3.6.0
     1334 *
     1335 * @uses date_i18n()
     1336 *
     1337 * @param int|object $revision Revision ID or revision object.
     1338 * @param bool $link Optional, default is true. Link to revisions's page?
     1339 * @return string gravatar, user, i18n formatted datetimestamp or localized 'Current Revision'.
     1340 */
     1341function wp_post_revision_title_expanded( $revision, $link = true ) {
     1342    if ( !$revision = get_post( $revision ) )
     1343        return $revision;
     1344
     1345    if ( !in_array( $revision->post_type, array( 'post', 'page', 'revision' ) ) )
     1346        return false;
     1347
    13091348    $author = get_the_author_meta( 'display_name', $revision->post_author );
    13101349    /* translators: revision date format, see http://php.net/date */
    13111350    $datef = _x( 'j F, Y @ G:i:s', 'revision date format');
    13121351
    1313     $gravatar = get_avatar( $revision->post_author, 18 );
     1352    $gravatar = get_avatar( $revision->post_author, 24 );
    13141353
    13151354    $date = date_i18n( $datef, strtotime( $revision->post_modified ) );
     
    13891428
    13901429    /* translators: post revision: 1: when, 2: author name */
    1391     $titlef = _x( '%1$s by %2$s', 'post revision' );
     1430    $titlef = _x( '%1$s', 'post revision' );
    13921431
    13931432    if ( $parent )
    13941433        array_unshift( $revisions, $post );
     1434
     1435    // since 3.6 revisions include a copy of the current post data as a revision
     1436    // the collowing removes this current revision if present from the list of
     1437    // revisions returned by wp_list_post_revisions, remove these to include the
     1438    // crrent post revision in the list of revisions
     1439    if ( wp_first_revision_matches_current_version( $post_id ) )
     1440        array_pop( $revisions );
    13951441
    13961442    $rows = $right_checked = '';
     
    14031449            continue;
    14041450
    1405         $date = wp_post_revision_title( $revision );
    1406         $name = get_the_author_meta( 'display_name', $revision->post_author );
    1407 
    1408         if ( 'form-table' == $format ) {
    1409             if ( $left )
    1410                 $left_checked = $left == $revision->ID ? ' checked="checked"' : '';
    1411             else
    1412                 $left_checked = $right_checked ? ' checked="checked"' : ''; // [sic] (the next one)
    1413             $right_checked = $right == $revision->ID ? ' checked="checked"' : '';
    1414 
    1415             $class = $class ? '' : " class='alternate'";
    1416 
    1417             if ( $post->ID != $revision->ID && $can_edit_post )
    1418                 $actions = '<a href="' . wp_nonce_url( add_query_arg( array( 'revision' => $revision->ID, 'action' => 'restore' ) ), "restore-post_$post->ID|$revision->ID" ) . '">' . __( 'Restore' ) . '</a>';
    1419             else
    1420                 $actions = '';
    1421 
    1422             $rows .= "<tr$class>\n";
    1423             $rows .= "\t<th style='white-space: nowrap' scope='row'><input type='radio' name='left' value='$revision->ID'$left_checked /></th>\n";
    1424             $rows .= "\t<th style='white-space: nowrap' scope='row'><input type='radio' name='right' value='$revision->ID'$right_checked /></th>\n";
    1425             $rows .= "\t<td>$date</td>\n";
    1426             $rows .= "\t<td>$name</td>\n";
    1427             $rows .= "\t<td class='action-links'>$actions</td>\n";
    1428             $rows .= "</tr>\n";
    1429         } else {
    1430             $title = sprintf( $titlef, $date, $name );
    1431             $rows .= "\t<li>$title</li>\n";
    1432         }
     1451        $date = wp_post_revision_title_expanded( $revision );
     1452
     1453        $title = sprintf( $titlef, $date );
     1454        $rows .= "\t<li>$title</li>\n";
     1455
    14331456    }
    14341457
     
    14801503        // show the restore event details
    14811504        //
    1482         if ( $restored_from_meta = get_post_meta( $post->ID, '_post_restored_from', true ) ) { 
    1483             $author = get_the_author_meta( 'display_name', $restored_from_meta[ 'restored_by_user' ] ); 
    1484             /* translators: revision date format, see http://php.net/date */ 
    1485             $datef = _x( 'j F, Y @ G:i:s', 'revision date format'); 
    1486             $date = date_i18n( $datef, strtotime( $restored_from_meta[ 'restored_time' ] ) ); 
    1487             $timesince = human_time_diff( $restored_from_meta[ 'restored_time' ], current_time( 'timestamp' ) );
    1488             ?> 
     1505        if ( $restored_from_meta = get_post_meta( $post->ID, '_post_restored_from', true ) ) {
     1506            $author = get_the_author_meta( 'display_name', $restored_from_meta[ 'restored_by_user' ] );
     1507            /* translators: revision date format, see http://php.net/date */
     1508            $datef = _x( 'j F, Y @ G:i:s', 'revision date format');
     1509            $date = date_i18n( $datef, strtotime( $restored_from_meta[ 'restored_time' ] ) );
     1510            $timesince = human_time_diff( $restored_from_meta[ 'restored_time' ], current_time( 'timestamp' ) ) ;
     1511            ?>
    14891512            <hr />
    1490             <div id="revisions-meta-restored"> 
    1491                 <?php 
     1513            <div id="revisions-meta-restored">
     1514                <?php
    14921515                /* translators: restored revision details: 1: revision ID, 2: time ago, 3: author name, 4: date */
    1493                 printf( _x( 'Previously restored from revision ID %1$d, %2$s ago by %3$s (%4$s)', 'restored revision details' ), 
    1494                 $restored_from_meta[ 'restored_revision_id'], 
    1495                 $timesince, 
    1496                 $author, 
    1497                 $date ); 
    1498                 ?> 
    1499             </div> 
    1500             <?php 
     1516                printf( _x( 'Previously restored from revision ID %1$d, %2$s ago by %3$s (%4$s)', 'restored revision details' ),
     1517                $restored_from_meta[ 'restored_revision_id'],
     1518                $timesince,
     1519                $author,
     1520                $date );
     1521                ?>
     1522            </div>
     1523            <?php
    15011524        echo "</ul>";
    1502         } 
     1525        }
    15031526
    15041527    endif;
Note: See TracChangeset for help on using the changeset viewer.