Make WordPress Core

Ticket #24213: 24213.2.patch

File 24213.2.patch, 5.6 KB (added by a.hoereth, 12 years ago)

param string $type : 'all', 'revision' or 'autosave'; deprecated $args

  • wp-includes/post-template.php

     
    13841384 * Can output either a UL with edit links or a TABLE with diff interface, and
    13851385 * restore action links.
    13861386 *
    1387  * Second argument controls parameters:
    1388  *   (bool)   parent : include the parent (the "Current Revision") in the list.
    1389  *                     Deprecated (ignored), since 3.6 the revisions always include
    1390  *                     a copy of the current post.
    1391  *   (string) format : 'list' or 'form-table'. 'list' outputs UL, 'form-table'
    1392  *                     outputs TABLE with UI.
    1393  *   (int)    right  : what revision is currently being viewed - used in
    1394  *                     form-table format.
    1395  *   (int)    left   : what revision is currently being diffed against right -
    1396  *                     used in form-table format.
    1397  *
    13981387 * @package WordPress
    13991388 * @subpackage Post_Revisions
    14001389 * @since 2.6.0
     
    14041393 * @uses get_edit_post_link()
    14051394 * @uses get_the_author_meta()
    14061395 *
    1407  * @todo split into two functions (list, form-table) ?
    1408  *
    14091396 * @param int|object $post_id Post ID or post object.
    1410  * @param string|array $args See description {@link wp_parse_args()}.
     1397 * @param string $type 'all' (default), 'revision' or 'autosave'
    14111398 * @return null
    14121399 */
    1413 function wp_list_post_revisions( $post_id = 0, $args = null ) {
    1414         if ( !$post = get_post( $post_id ) )
     1400function wp_list_post_revisions( $post_id = 0, $type = 'all' ) {
     1401        if ( ! $post = get_post( $post_id ) )
    14151402                return;
    14161403
    1417         $defaults = array( 'right' => false, 'left' => false, 'format' => 'list', 'type' => 'all' );
    1418         extract( wp_parse_args( $args, $defaults ), EXTR_SKIP );
     1404        // $args array with (parent, format, right, left, type) deprecated since 3.6
     1405        if ( is_array( $type ) ) {
     1406                $type = ! empty( $type['type'] ) ? $type['type']  : $type;
     1407                _deprecated_argument( __FUNCTION__, '3.6' );
     1408        }
    14191409
    1420         if ( !$revisions = wp_get_post_revisions( $post->ID ) )
     1410        if ( ! $revisions = wp_get_post_revisions( $post->ID ) )
    14211411                return;
    14221412
    14231413        $rows = '';
    14241414        foreach ( $revisions as $revision ) {
    1425                 if ( !current_user_can( 'read_post', $revision->ID ) )
     1415                if ( ! current_user_can( 'read_post', $revision->ID ) )
    14261416                        continue;
    14271417
    14281418                $is_autosave = wp_is_post_autosave( $revision );
     
    14321422                $rows .= "\t<li>" . wp_post_revision_title_expanded( $revision ) . "</li>\n";
    14331423        }
    14341424
    1435         if ( 'form-table' == $format ) : ?>
     1425        echo "<ul class='post-revisions'>\n";
     1426        echo $rows;
    14361427
    1437 <form action="revision.php" method="get">
    1438 
    1439 <div class="tablenav">
    1440         <div class="alignleft">
    1441                 <input type="submit" class="button-secondary" value="<?php esc_attr_e( 'Compare Revisions' ); ?>" />
    1442                 <input type="hidden" name="action" value="diff" />
    1443                 <input type="hidden" name="post_type" value="<?php echo esc_attr($post->post_type); ?>" />
    1444         </div>
    1445 </div>
    1446 
    1447 <br class="clear" />
    1448 
    1449 <table class="widefat post-revisions" cellspacing="0" id="post-revisions">
    1450         <col />
    1451         <col />
    1452         <col style="width: 33%" />
    1453         <col style="width: 33%" />
    1454         <col style="width: 33%" />
    1455 <thead>
    1456 <tr>
    1457         <th scope="col"><?php /* translators: column name in revisions */ _ex( 'Old', 'revisions column name' ); ?></th>
    1458         <th scope="col"><?php /* translators: column name in revisions */ _ex( 'New', 'revisions column name' ); ?></th>
    1459         <th scope="col"><?php /* translators: column name in revisions */ _ex( 'Date Created', 'revisions column name' ); ?></th>
    1460         <th scope="col"><?php _e( 'Author' ); ?></th>
    1461         <th scope="col" class="action-links"><?php _e( 'Actions' ); ?></th>
    1462 </tr>
    1463 </thead>
    1464 <tbody>
    1465 
    1466 <?php echo $rows; ?>
    1467 
    1468 </tbody>
    1469 </table>
    1470 
    1471 </form>
    1472 
    1473 <?php
    1474         else :
    1475                 echo "<ul class='post-revisions'>\n";
    1476                 echo $rows;
    1477 
    1478                 // if the post was previously restored from a revision
    1479                 // show the restore event details
    1480                 if ( $restored_from_meta = get_post_meta( $post->ID, '_post_restored_from', true ) ) {
    1481                         $author = get_user_by( 'id', $restored_from_meta[ 'restored_by_user' ] );
    1482                         /* translators: revision date format, see http://php.net/date */
    1483                         $datef = _x( 'j F, Y @ G:i:s', 'revision date format');
    1484                         $date = date_i18n( $datef, strtotime( $restored_from_meta[ 'restored_time' ] ) );
    1485                         $time_diff = human_time_diff( $restored_from_meta[ 'restored_time' ] ) ;
     1428        // if the post was previously restored from a revision
     1429        // show the restore event details
     1430        if ( $restored_from_meta = get_post_meta( $post->ID, '_post_restored_from', true ) ) {
     1431                $author = get_user_by( 'id', $restored_from_meta[ 'restored_by_user' ] );
     1432                /* translators: revision date format, see http://php.net/date */
     1433                $datef = _x( 'j F, Y @ G:i:s', 'revision date format');
     1434                $date = date_i18n( $datef, strtotime( $restored_from_meta[ 'restored_time' ] ) );
     1435                $time_diff = human_time_diff( $restored_from_meta[ 'restored_time' ] ) ;
     1436                ?>
     1437                <hr />
     1438                <div id="revisions-meta-restored">
     1439                        <?php
     1440                        printf(
     1441                                /* translators: restored revision details: 1: gravatar image, 2: author name, 3: time ago, 4: date */
     1442                                __( 'Previously restored by %1$s %2$s, %3$s ago (%4$s)' ),
     1443                                get_avatar( $author->ID, 24 ),
     1444                                $author->display_name,
     1445                                $time_diff,
     1446                                $date
     1447                        );
    14861448                        ?>
    1487                         <hr />
    1488                         <div id="revisions-meta-restored">
    1489                                 <?php
    1490                                 printf(
    1491                                         /* translators: restored revision details: 1: gravatar image, 2: author name, 3: time ago, 4: date */
    1492                                         __( 'Previously restored by %1$s %2$s, %3$s ago (%4$s)' ),
    1493                                         get_avatar( $author->ID, 24 ),
    1494                                         $author->display_name,
    1495                                         $time_diff,
    1496                                         $date
    1497                                 );
    1498                                 ?>
    1499                         </div>
    1500                         <?php
     1449                </div>
     1450                <?php
    15011451                echo "</ul>";
    1502                 }
     1452        }
    15031453
    1504         endif;
    15051454}