X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/8a06f4f9392d1ac373442f82ee40428a3cb81395..4f9d63e13cd8c6e275797c75b401b074b82937bc:/wp-admin/revision.php diff --git a/wp-admin/revision.php b/wp-admin/revision.php index 4820abc3..668ec484 100644 --- a/wp-admin/revision.php +++ b/wp-admin/revision.php @@ -1,23 +1,25 @@ post_parent ) ) break; - if ( !constant('WP_POST_REVISIONS') && !wp_is_post_autosave( $revision ) ) // Revisions disabled and we're not looking at an autosave + // Revisions disabled and we're not looking at an autosave + if ( ( ! WP_POST_REVISIONS || !post_type_supports($post->post_type, 'revisions') ) && !wp_is_post_autosave( $revision ) ) { + $redirect = 'edit.php?post_type=' . $post->post_type; break; + } check_admin_referer( "restore-post_$post->ID|$revision->ID" ); @@ -46,7 +51,7 @@ case 'diff' : // If we're comparing a revision to itself, redirect to the 'view' page for that revision or the edit page for that post if ( $left_revision->ID == $right_revision->ID ) { $redirect = get_edit_post_link( $left_revision->ID ); - include( 'js/revisions-js.php' ); + include( './js/revisions-js.php' ); break; } @@ -65,15 +70,17 @@ case 'diff' : else break; // Don't diff two unrelated revisions - if ( !constant('WP_POST_REVISIONS') ) { // Revisions disabled + if ( ! WP_POST_REVISIONS || !post_type_supports($post->post_type, 'revisions') ) { // Revisions disabled if ( // we're not looking at an autosave ( !wp_is_post_autosave( $left_revision ) && !wp_is_post_autosave( $right_revision ) ) || // we're not comparing an autosave to the current post ( $post->ID !== $left_revision->ID && $post->ID !== $right_revision->ID ) - ) + ) { + $redirect = 'edit.php?post_type=' . $post->post_type; break; + } } if ( @@ -84,9 +91,10 @@ case 'diff' : ( !wp_get_post_revision( $left_revision->ID ) && !wp_get_post_revision( $right_revision->ID ) ) ) break; - + $post_title = '' . get_the_title() . ''; $h2 = sprintf( __( 'Compare Revisions of “%1$s”' ), $post_title ); + $title = __( 'Revisions' ); $left = $left_revision->ID; $right = $right_revision->ID; @@ -103,12 +111,16 @@ default : if ( !current_user_can( 'read_post', $revision->ID ) || !current_user_can( 'read_post', $post->ID ) ) break; - if ( !constant('WP_POST_REVISIONS') && !wp_is_post_autosave( $revision ) ) // Revisions disabled and we're not looking at an autosave + // Revisions disabled and we're not looking at an autosave + if ( ( ! WP_POST_REVISIONS || !post_type_supports($post->post_type, 'revisions') ) && !wp_is_post_autosave( $revision ) ) { + $redirect = 'edit.php?post_type=' . $post->post_type; break; + } $post_title = '' . get_the_title() . ''; $revision_title = wp_post_revision_title( $revision, false ); - $h2 = sprintf( __( 'Post Revision for “%1$s” created on %2$s' ), $post_title, $revision_title ); + $h2 = sprintf( __( 'Revision for “%1$s” created on %2$s' ), $post_title, $revision_title ); + $title = __( 'Revisions' ); // Sets up the diff radio buttons $left = $revision->ID; @@ -118,23 +130,22 @@ default : break; endswitch; -if ( !$redirect && !in_array( $post->post_type, array( 'post', 'page' ) ) ) +// Empty post_type means either malformed object found, or no valid parent was found. +if ( !$redirect && empty($post->post_type) ) $redirect = 'edit.php'; -if ( $redirect ) { +if ( !empty($redirect) ) { wp_redirect( $redirect ); exit; } -if ( 'page' == $post->post_type ) { - $submenu_file = 'edit-pages.php'; - $title = __( 'Page Revisions' ); -} else { - $submenu_file = 'edit.php'; - $title = __( 'Post Revisions' ); -} +// This is so that the correct "Edit" menu item is selected. +if ( !empty($post->post_type) && 'post' != $post->post_type ) + $parent_file = $submenu_file = 'edit.php?post_type=' . $post->post_type; +else + $parent_file = $submenu_file = 'edit.php'; -require_once( 'admin-header.php' ); +require_once( './admin-header.php' ); ?> @@ -154,7 +165,7 @@ require_once( 'admin-header.php' ); $field_title ) : if ( 'diff' == $action ) { @@ -170,7 +181,7 @@ foreach ( _wp_post_revision_fields() as $field => $field_title ) : ?> - +
@@ -199,7 +210,7 @@ endif; 'form-table', 'parent' => true, 'right' => $right, 'left' => $left ); -if ( !constant( 'WP_POST_REVISIONS' ) ) +if ( ! WP_POST_REVISIONS || !post_type_supports($post->post_type, 'revisions') ) $args['type'] = 'autosave'; wp_list_post_revisions( $post, $args ); @@ -209,5 +220,4 @@ wp_list_post_revisions( $post, $args );