]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/revision.php
Wordpress 3.0-scripts
[autoinstalls/wordpress.git] / wp-admin / revision.php
index 4820abc3c7e048c30f70f870164b2e159077cc5b..668ec484abb49480e0f5c311f9557c5cfc63c41a 100644 (file)
@@ -1,23 +1,25 @@
 <?php
 <?php
+/**
+ * Revisions administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
 
 
-require_once('admin.php');
+/** WordPress Administration Bootstrap */
+require_once('./admin.php');
+
+wp_enqueue_script('list-revisions');
 
 wp_reset_vars(array('revision', 'left', 'right', 'action'));
 
 wp_reset_vars(array('revision', 'left', 'right', 'action'));
+
 $revision_id = absint($revision);
 $revision_id = absint($revision);
-$diff        = absint($diff);
 $left        = absint($left);
 $right       = absint($right);
 
 $left        = absint($left);
 $right       = absint($right);
 
-$parent_file = $redirect = 'edit.php';
+$redirect = 'edit.php';
 
 switch ( $action ) :
 
 switch ( $action ) :
-case 'delete' : // stubs
-case 'edit' :
-       if ( constant('WP_POST_REVISIONS') ) // stub
-               $redirect = remove_query_arg( 'action' );
-       else // Revisions disabled
-               $redirect = 'edit.php';
-       break;
 case 'restore' :
        if ( !$revision = wp_get_post_revision( $revision_id ) )
                break;
 case 'restore' :
        if ( !$revision = wp_get_post_revision( $revision_id ) )
                break;
@@ -26,8 +28,11 @@ case 'restore' :
        if ( !$post = get_post( $revision->post_parent ) )
                break;
 
        if ( !$post = get_post( $revision->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;
                break;
+       }
 
        check_admin_referer( "restore-post_$post->ID|$revision->ID" );
 
 
        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 );
        // 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;
        }
 
                break;
        }
 
@@ -65,15 +70,17 @@ case 'diff' :
        else
                break; // Don't diff two unrelated revisions
 
        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 )
                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;
                        break;
+               }
        }
 
        if (
        }
 
        if (
@@ -84,9 +91,10 @@ case 'diff' :
                ( !wp_get_post_revision( $left_revision->ID ) && !wp_get_post_revision( $right_revision->ID ) )
        )
                break;
                ( !wp_get_post_revision( $left_revision->ID ) && !wp_get_post_revision( $right_revision->ID ) )
        )
                break;
-       
+
        $post_title = '<a href="' . get_edit_post_link() . '">' . get_the_title() . '</a>';
        $h2 = sprintf( __( 'Compare Revisions of &#8220;%1$s&#8221;' ), $post_title );
        $post_title = '<a href="' . get_edit_post_link() . '">' . get_the_title() . '</a>';
        $h2 = sprintf( __( 'Compare Revisions of &#8220;%1$s&#8221;' ), $post_title );
+       $title = __( 'Revisions' );
 
        $left  = $left_revision->ID;
        $right = $right_revision->ID;
 
        $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 ( !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;
                break;
+       }
 
        $post_title = '<a href="' . get_edit_post_link() . '">' . get_the_title() . '</a>';
        $revision_title = wp_post_revision_title( $revision, false );
 
        $post_title = '<a href="' . get_edit_post_link() . '">' . get_the_title() . '</a>';
        $revision_title = wp_post_revision_title( $revision, false );
-       $h2 = sprintf( __( 'Post Revision for &#8220;%1$s&#8221; created on %2$s' ), $post_title, $revision_title );
+       $h2 = sprintf( __( 'Revision for &#8220;%1$s&#8221; created on %2$s' ), $post_title, $revision_title );
+       $title = __( 'Revisions' );
 
        // Sets up the diff radio buttons
        $left  = $revision->ID;
 
        // Sets up the diff radio buttons
        $left  = $revision->ID;
@@ -118,23 +130,22 @@ default :
        break;
 endswitch;
 
        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';
 
        $redirect = 'edit.php';
 
-if ( $redirect ) {
+if ( !empty($redirect) ) {
        wp_redirect( $redirect );
        exit;
 }
 
        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' );
 </tr>
 <?php endif;
 
 </tr>
 <?php endif;
 
-// use get_post_to_edit filters? 
+// use get_post_to_edit filters?
 $identical = true;
 foreach ( _wp_post_revision_fields() as $field => $field_title ) :
        if ( 'diff' == $action ) {
 $identical = true;
 foreach ( _wp_post_revision_fields() as $field => $field_title ) :
        if ( 'diff' == $action ) {
@@ -170,7 +181,7 @@ foreach ( _wp_post_revision_fields() as $field => $field_title ) :
        ?>
 
        <tr id="revision-field-<?php echo $field; ?>">
        ?>
 
        <tr id="revision-field-<?php echo $field; ?>">
-               <th scope="row"><?php echo wp_specialchars( $field_title ); ?></th>
+               <th scope="row"><?php echo esc_html( $field_title ); ?></th>
                <td><div class="pre"><?php echo $content; ?></div></td>
        </tr>
 
                <td><div class="pre"><?php echo $content; ?></div></td>
        </tr>
 
@@ -199,7 +210,7 @@ endif;
 <?php
 
 $args = array( 'format' => 'form-table', 'parent' => true, 'right' => $right, 'left' => $left );
 <?php
 
 $args = array( 'format' => '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 );
        $args['type'] = 'autosave';
 
 wp_list_post_revisions( $post, $args );
@@ -209,5 +220,4 @@ wp_list_post_revisions( $post, $args );
 </div>
 
 <?php
 </div>
 
 <?php
-
-require_once( 'admin-footer.php' );
+require_once( './admin-footer.php' );