WordPress.org

Make WordPress Core

Ticket #18733: revision-number.patch

File revision-number.patch, 4.8 KB (added by midhund, 7 years ago)

Revision Number Patch #18733

  • wp-admin/revision.php

     
    116116                $redirect = 'edit.php?post_type=' . $post->post_type;
    117117                break;
    118118        }
    119 
     119   
     120    $revision_num = wp_post_revision_num( $revision, false );
     121   
    120122        $post_title = '<a href="' . get_edit_post_link() . '">' . get_the_title() . '</a>';
    121123        $revision_title = wp_post_revision_title( $revision, false );
    122         $h2 = sprintf( __( 'Revision for &#8220;%1$s&#8221; created on %2$s' ), $post_title, $revision_title );
     124        $h2 = sprintf( __( 'Revision %1$s for &#8220;%2$s&#8221; created on %3$s' ), $revision_num, $post_title, $revision_title );
    123125        $title = __( 'Revisions' );
    124126
    125127        // Sets up the diff radio buttons
     
    155157
    156158<table class="form-table ie-fixed">
    157159        <col class="th" />
    158 <?php if ( 'diff' == $action ) : ?>
     160<?php
     161
     162if ( 'diff' == $action ) :
     163    $left_revision_num = wp_post_revision_num( $left_revision, true );
     164    $right_revision_num = wp_post_revision_num( $right_revision, true );
     165
     166?>
    159167<tr id="revision">
    160168        <th scope="row"></th>
    161169        <th scope="col" class="th-full">
    162                 <span class="alignleft"><?php printf( __('Older: %s'), wp_post_revision_title( $left_revision ) ); ?></span>
    163                 <span class="alignright"><?php printf( __('Newer: %s'), wp_post_revision_title( $right_revision ) ); ?></span>
     170                <span class="alignleft"><?php printf( __('Older: %s'), wp_post_revision_title( $left_revision ) ); ?>&nbsp;<?php echo $left_revision_num; ?></span>
     171                <span class="alignright"><?php printf( __('Newer: %s'), wp_post_revision_title( $right_revision ) ); ?>&nbsp;<?php echo $right_revision_num; ?></span>
    164172        </th>
    165173</tr>
    166174<?php endif;
  • wp-includes/post-template.php

     
    12991299}
    13001300
    13011301/**
     1302 * Retrieve revision id of a revision (linked to that revisions's page).
     1303 *
     1304 * @package WordPress
     1305 * @subpackage Post_Revisions
     1306 * @since 3.3
     1307 *
     1308 * @uses date_i18n()
     1309 *
     1310 * @param int|object $revision Revision ID or revision object.
     1311 * @param bool $link Optional, default is true. Link to revisions's page?
     1312 * @return string revision number or link to revision page.
     1313 */
     1314 
     1315function wp_post_revision_num($revision, $link = true) {
     1316    if ( !$revision = get_post( $revision ) )
     1317                return $revision;
     1318
     1319        if ( !in_array( $revision->post_type, array( 'post', 'page', 'revision' ) ) )
     1320                return false;
     1321   
     1322    if ( $link && current_user_can( 'edit_post', $revision->ID ) && $link = get_edit_post_link( $revision->ID ) )
     1323                $revision_num = "<a href='$link'>#$revision->ID</a>";
     1324    else
     1325        $revision_num = "#$revision->ID";
     1326   
     1327    return $revision_num;
     1328}
     1329
     1330/**
    13021331 * Display list of a post's revisions.
    13031332 *
    13041333 * Can output either a UL with edit links or a TABLE with diff interface, and
     
    13631392                        continue;
    13641393                if ( 'revision' === $type && wp_is_post_autosave( $revision ) )
    13651394                        continue;
    1366 
     1395       
     1396        $revision_num = wp_post_revision_num( $revision );
    13671397                $date = wp_post_revision_title( $revision );
    13681398                $name = get_the_author_meta( 'display_name', $revision->post_author );
    13691399
     
    13841414                        $rows .= "<tr$class>\n";
    13851415                        $rows .= "\t<th style='white-space: nowrap' scope='row'><input type='radio' name='left' value='$revision->ID'$left_checked /></th>\n";
    13861416                        $rows .= "\t<th style='white-space: nowrap' scope='row'><input type='radio' name='right' value='$revision->ID'$right_checked /></th>\n";
    1387                         $rows .= "\t<td>$date</td>\n";
     1417            $rows .= "\t<td>$revision_num</td>\n";
     1418            $rows .= "\t<td>$date</td>\n";
    13881419                        $rows .= "\t<td>$name</td>\n";
    13891420                        $rows .= "\t<td class='action-links'>$actions</td>\n";
    13901421                        $rows .= "</tr>\n";
    13911422                } else {
    13921423                        $title = sprintf( $titlef, $date, $name );
    1393                         $rows .= "\t<li>$title</li>\n";
     1424                        $rows .= "\t<li>$title $revision_num</li>\n";
    13941425                }
    13951426        }
    13961427
     
    14091440<br class="clear" />
    14101441
    14111442<table class="widefat post-revisions" cellspacing="0" id="post-revisions">
     1443    <col />
    14121444        <col />
    14131445        <col />
    14141446        <col style="width: 33%" />
     
    14181450<tr>
    14191451        <th scope="col"><?php /* translators: column name in revisons */ _ex( 'Old', 'revisions column name' ); ?></th>
    14201452        <th scope="col"><?php /* translators: column name in revisons */ _ex( 'New', 'revisions column name' ); ?></th>
     1453    <th scope="col"><?php /* translators: column name in revisons */ _ex( 'Revision', 'revisions column name' ); ?></th>
    14211454        <th scope="col"><?php /* translators: column name in revisons */ _ex( 'Date Created', 'revisions column name' ); ?></th>
    14221455        <th scope="col"><?php _e( 'Author' ); ?></th>
    14231456        <th scope="col" class="action-links"><?php _e( 'Actions' ); ?></th>