WordPress.org

Make WordPress Core

Ticket #13110: 13110.diff

File 13110.diff, 4.9 KB (added by duck_, 8 years ago)
  • wp-admin/revision.php

     
    1111
    1212wp_enqueue_script('list-revisions');
    1313
    14 wp_reset_vars(array('revision', 'left', 'right', 'diff', 'action'));
     14wp_reset_vars(array('revision', 'left', 'right', 'action'));
    1515
    1616$revision_id = absint($revision);
    17 $diff        = absint($diff);
    1817$left        = absint($left);
    1918$right       = absint($right);
    2019
     
    2928        if ( !$post = get_post( $revision->post_parent ) )
    3029                break;
    3130
    32         if ( ! WP_POST_REVISIONS && !wp_is_post_autosave( $revision ) ) // Revisions disabled and we're not looking at an autosave
     31        // Revisions disabled and we're not looking at an autosave
     32        if ( ( ! WP_POST_REVISIONS || !post_type_supports($post->post_type, 'revisions') ) && !wp_is_post_autosave( $revision ) ) {
     33                $redirect = 'edit.php?post_type=' . $post->post_type;
    3334                break;
     35        }
    3436
    3537        check_admin_referer( "restore-post_$post->ID|$revision->ID" );
    3638
     
    6870        else
    6971                break; // Don't diff two unrelated revisions
    7072
    71         if ( ! WP_POST_REVISIONS ) { // Revisions disabled
     73        if ( ! WP_POST_REVISIONS || !post_type_supports($post->post_type, 'revisions') ) { // Revisions disabled
    7274                if (
    7375                        // we're not looking at an autosave
    7476                        ( !wp_is_post_autosave( $left_revision ) && !wp_is_post_autosave( $right_revision ) )
    7577                ||
    7678                        // we're not comparing an autosave to the current post
    7779                        ( $post->ID !== $left_revision->ID && $post->ID !== $right_revision->ID )
    78                 )
     80                ) {
     81                        $redirect = 'edit.php?post_type=' . $post->post_type;
    7982                        break;
     83                }
    8084        }
    8185
    8286        if (
     
    9094
    9195        $post_title = '<a href="' . get_edit_post_link() . '">' . get_the_title() . '</a>';
    9296        $h2 = sprintf( __( 'Compare Revisions of &#8220;%1$s&#8221;' ), $post_title );
     97        $title = __( 'Revisions' );
    9398
    9499        $left  = $left_revision->ID;
    95100        $right = $right_revision->ID;
     
    106111        if ( !current_user_can( 'read_post', $revision->ID ) || !current_user_can( 'read_post', $post->ID ) )
    107112                break;
    108113
    109         if ( ! WP_POST_REVISIONS && !wp_is_post_autosave( $revision ) ) // Revisions disabled and we're not looking at an autosave
     114        // Revisions disabled and we're not looking at an autosave
     115        if ( ( ! WP_POST_REVISIONS || !post_type_supports($post->post_type, 'revisions') ) && !wp_is_post_autosave( $revision ) ) {
     116                $redirect = 'edit.php?post_type=' . $post->post_type;
    110117                break;
     118        }
    111119
    112         $post_type_object = get_post_type_object($post->post_type);
    113 
    114120        $post_title = '<a href="' . get_edit_post_link() . '">' . get_the_title() . '</a>';
    115121        $revision_title = wp_post_revision_title( $revision, false );
    116122        $h2 = sprintf( __( 'Revision for &#8220;%1$s&#8221; created on %2$s' ), $post_title, $revision_title );
     
    124130        break;
    125131endswitch;
    126132
    127 if ( !$redirect ) {
    128         if ( empty($post->post_type) ) // Empty post_type means either malformed object found, or no valid parent was found.
    129                 $redirect = 'edit.php';
    130         elseif ( !post_type_supports($post->post_type, 'revisions') )
    131                 $redirect = 'edit.php?post_type=' . $post->post_type;
    132 }
     133// Empty post_type means either malformed object found, or no valid parent was found.
     134if ( !$redirect && empty($post->post_type) )
     135        $redirect = 'edit.php';
    133136
    134137if ( !empty($redirect) ) {
    135138        wp_redirect( $redirect );
     
    207210<?php
    208211
    209212$args = array( 'format' => 'form-table', 'parent' => true, 'right' => $right, 'left' => $left );
    210 if ( ! WP_POST_REVISIONS )
     213if ( ! WP_POST_REVISIONS || !post_type_supports($post->post_type, 'revisions') )
    211214        $args['type'] = 'autosave';
    212215
    213216wp_list_post_revisions( $post, $args );
     
    217220</div>
    218221
    219222<?php
    220 
    221223require_once( './admin-footer.php' );
  • wp-includes/post-template.php

     
    11691169                        $class = $class ? '' : " class='alternate'";
    11701170
    11711171                        if ( $post->ID != $revision->ID && $can_edit_post )
    1172                                 $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>';
     1172                                $actions = '<a href="' . wp_nonce_url( add_query_arg( array( 'revision' => $revision->ID, 'action' => 'restore' ) ), "restore-post_$post->ID|$revision->ID" ) . '">' . __( 'Restore' ) . '</a>';
    11731173                        else
    11741174                                $actions = '';
    11751175
    11761176                        $rows .= "<tr$class>\n";
    1177                         $rows .= "\t<th style='white-space: nowrap' scope='row'><input type='radio' name='left' value='$revision->ID'$left_checked />\n";
     1177                        $rows .= "\t<th style='white-space: nowrap' scope='row'><input type='radio' name='left' value='$revision->ID'$left_checked /></th>\n";
    11781178                        $rows .= "\t<th style='white-space: nowrap' scope='row'><input type='radio' name='right' value='$revision->ID'$right_checked /></th>\n";
    11791179                        $rows .= "\t<td>$date</td>\n";
    11801180                        $rows .= "\t<td>$name</td>\n";