|
11 | 11 |
|
12 | 12 | wp_enqueue_script('list-revisions'); |
13 | 13 |
|
14 | | -wp_reset_vars(array('revision', 'left', 'right', 'diff', 'action')); |
| 14 | +wp_reset_vars(array('revision', 'left', 'right', 'action')); |
15 | 15 |
|
16 | 16 | $revision_id = absint($revision); |
17 | | -$diff = absint($diff); |
18 | 17 | $left = absint($left); |
19 | 18 | $right = absint($right); |
20 | 19 |
|
|
29 | 28 | if ( !$post = get_post( $revision->post_parent ) ) |
30 | 29 | break; |
31 | 30 |
|
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; |
33 | 34 | break; |
| 35 | + } |
34 | 36 |
|
35 | 37 | check_admin_referer( "restore-post_$post->ID|$revision->ID" ); |
36 | 38 |
|
|
68 | 70 | else |
69 | 71 | break; // Don't diff two unrelated revisions |
70 | 72 |
|
71 | | - if ( ! WP_POST_REVISIONS ) { // Revisions disabled |
| 73 | + if ( ! WP_POST_REVISIONS || !post_type_supports($post->post_type, 'revisions') ) { // Revisions disabled |
72 | 74 | if ( |
73 | 75 | // we're not looking at an autosave |
74 | 76 | ( !wp_is_post_autosave( $left_revision ) && !wp_is_post_autosave( $right_revision ) ) |
75 | 77 | || |
76 | 78 | // we're not comparing an autosave to the current post |
77 | 79 | ( $post->ID !== $left_revision->ID && $post->ID !== $right_revision->ID ) |
78 | | - ) |
| 80 | + ) { |
| 81 | + $redirect = 'edit.php?post_type=' . $post->post_type; |
79 | 82 | break; |
| 83 | + } |
80 | 84 | } |
81 | 85 |
|
82 | 86 | if ( |
|
90 | 94 |
|
91 | 95 | $post_title = '<a href="' . get_edit_post_link() . '">' . get_the_title() . '</a>'; |
92 | 96 | $h2 = sprintf( __( 'Compare Revisions of “%1$s”' ), $post_title ); |
| 97 | + $title = __( 'Revisions' ); |
93 | 98 |
|
94 | 99 | $left = $left_revision->ID; |
95 | 100 | $right = $right_revision->ID; |
|
106 | 111 | if ( !current_user_can( 'read_post', $revision->ID ) || !current_user_can( 'read_post', $post->ID ) ) |
107 | 112 | break; |
108 | 113 |
|
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; |
110 | 117 | break; |
111 | | - |
112 | | - $post_type_object = get_post_type_object($post->post_type); |
| 118 | + } |
113 | 119 |
|
114 | 120 | $post_title = '<a href="' . get_edit_post_link() . '">' . get_the_title() . '</a>'; |
115 | 121 | $revision_title = wp_post_revision_title( $revision, false ); |
|
124 | 130 | break; |
125 | 131 | endswitch; |
126 | 132 |
|
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. |
| 134 | +if ( !$redirect && empty($post->post_type) ) |
| 135 | + $redirect = 'edit.php'; |
133 | 136 |
|
134 | 137 | if ( !empty($redirect) ) { |
135 | 138 | wp_redirect( $redirect ); |
|
207 | 210 | <?php |
208 | 211 |
|
209 | 212 | $args = array( 'format' => 'form-table', 'parent' => true, 'right' => $right, 'left' => $left ); |
210 | | -if ( ! WP_POST_REVISIONS ) |
| 213 | +if ( ! WP_POST_REVISIONS || !post_type_supports($post->post_type, 'revisions') ) |
211 | 214 | $args['type'] = 'autosave'; |
212 | 215 |
|
213 | 216 | wp_list_post_revisions( $post, $args ); |
|
217 | 220 | </div> |
218 | 221 |
|
219 | 222 | <?php |
220 | | - |
221 | 223 | require_once( './admin-footer.php' ); |
0 commit comments