Make WordPress Core

Changeset 14749


Ignore:
Timestamp:
05/19/2010 06:36:52 PM (14 years ago)
Author:
ryan
Message:

Fix viewing autosave revision for custom post types. Props duck_. fixes #13110

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/revision.php

    r14139 r14749  
    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);
     
    3029        break;
    3130
    32     if ( ! WP_POST_REVISIONS && !wp_is_post_autosave( $revision ) ) // Revisions disabled and we're not looking at an autosave
    33         break;
     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;
     34        break;
     35    }
    3436
    3537    check_admin_referer( "restore-post_$post->ID|$revision->ID" );
     
    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
     
    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
     
    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;
     
    107112        break;
    108113
    109     if ( ! WP_POST_REVISIONS && !wp_is_post_autosave( $revision ) ) // Revisions disabled and we're not looking at an autosave
    110         break;
    111 
    112     $post_type_object = get_post_type_object($post->post_type);
     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;
     117        break;
     118    }
    113119
    114120    $post_title = '<a href="' . get_edit_post_link() . '">' . get_the_title() . '</a>';
     
    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) ) {
     
    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
     
    218221
    219222<?php
    220 
    221223require_once( './admin-footer.php' );
  • trunk/wp-includes/post-template.php

    r14687 r14749  
    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";
Note: See TracChangeset for help on using the changeset viewer.