WordPress.org

Make WordPress Core

Changeset 7913


Ignore:
Timestamp:
05/09/2008 03:59:17 PM (11 years ago)
Author:
ryan
Message:

Revisioning for pages from mdawaffe. see #6775

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-page-form.php

    r7883 r7913  
    66$messages[3] = __('Custom field deleted.');
    77$messages[4] = __('Page updated.');
    8 ?>
    9 <?php if (isset($_GET['message'])) : ?>
    10 <div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
    11 <?php endif;
     8
     9$notice = false;
     10$notices[1] = __( 'There is an autosave of this page that is more recent than the version below.  <a href="%s">View the autosave</a>.' );
    1211
    1312if (!isset($post_ID) || 0 == $post_ID) {
     
    2120    $nonce_action = 'update-page_' . $post_ID;
    2221    $form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='$post_ID' />";
     22    $autosave = wp_get_autosave( $post_id );
     23    if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt ) > mysql2date( 'U', $post->post_modified_gmt ) )
     24        $notice = sprintf( $notices[1], get_edit_post_link( $autosave->ID ) );
    2325}
    2426
     
    3133    $sendto = 'redo';
    3234?>
     35
     36<?php if ( $notice ) : ?>
     37<div id="notice" class="error"><p><?php echo $notice ?></p></div>
     38<?php endif; ?>
     39<?php if (isset($_GET['message'])) : ?>
     40<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
     41<?php endif; ?>
    3342
    3443<form name="post" action="page.php" method="post" id="post">
     
    4554<input type="hidden" id="hiddenaction" name="action" value='<?php echo $form_action ?>' />
    4655<input type="hidden" id="originalaction" name="originalaction" value="<?php echo $form_action ?>" />
     56<input type="hidden" id="post_author" name="post_author" value="<?php echo attribute_escape( $post->post_author ); ?>" />
    4757<?php echo $form_extra ?>
    4858<input type="hidden" id="post_type" name="post_type" value="<?php echo $post->post_type ?>" />
     
    283293<?php endif; ?>
    284294
     295<?php if ( isset($post_ID) && 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) : ?>
     296<div id="revisionsdiv" class="postbox <?php echo postbox_classes('revisionsdiv', 'page'); ?>">
     297<h3><?php _e('Page Revisions'); ?></h3>
     298<div class="inside">
     299<?php wp_list_post_revisions(); ?>
     300</div>
     301</div>
     302<?php endif; ?>
     303
     304
    285305<?php do_meta_boxes('page', 'advanced', $post); ?>
    286306
  • trunk/wp-admin/revision.php

    r7907 r7913  
    22
    33require_once('admin.php');
     4
     5if ( !constant('WP_POST_REVISIONS') ) {
     6    wp_redirect( 'edit.php' );
     7    exit;
     8}
    49
    510wp_reset_vars(array('revision', 'left', 'right', 'action'));
     
    914$right       = absint($right);
    1015
    11 
    1216$parent_file = $redirect = 'edit.php';
    13 $submenu_file = 'edit.php';
    14 $title = __( 'Post Revision' );
    15 
    1617
    1718switch ( $action ) :
     
    3940        break;
    4041
    41     if ( !current_user_can( 'edit_post', $left_revision->ID ) || !current_user_can( 'edit_post', $right_revision->ID ) )
     42    if ( !current_user_can( 'read_post', $left_revision->ID ) || !current_user_can( 'read_post', $right_revision->ID ) )
    4243        break;
    4344
     
    8182        break;
    8283
    83     if ( !current_user_can( 'edit_post', $revision->ID ) || !current_user_can( 'edit_post', $post->ID ) )
     84    if ( !current_user_can( 'read_post', $revision->ID ) || !current_user_can( 'read_post', $post->ID ) )
    8485        break;
    8586
     
    9697endswitch;
    9798
     99if ( !$redirect && !in_array( $post->post_type, array( 'post', 'page' ) ) )
     100    $redirect = 'edit.php';
     101
    98102if ( $redirect ) {
    99103    wp_redirect( $redirect );
    100104    exit;
     105}
     106
     107if ( 'page' == $post->post_type ) {
     108    $submenu_file = 'edit-pages.php';
     109    $title = __( 'Page Revisions' );
     110} else {
     111    $submenu_file = 'edit.php';
     112    $title = __( 'Post Revisions' );
    101113}
    102114
     
    164176<br class="clear" />
    165177
    166 <h2><?php _e( 'Post Revisions' ); ?></h2>
     178<h2><?php echo $title; ?></h2>
    167179
    168180<?php
  • trunk/wp-includes/js/autosave.js

    r7907 r7913  
    181181    if ( jQuery("#ping_status").attr("checked") )
    182182        post_data["ping_status"] = 'open';
    183     if ( jQuery("#excerpt") )
     183    if ( jQuery("#excerpt").size() )
    184184        post_data["excerpt"] = jQuery("#excerpt").val();
    185     if ( jQuery("#post_author") )
     185    if ( jQuery("#post_author").size() )
    186186        post_data["post_author"] = jQuery("#post_author").val();
    187187
  • trunk/wp-includes/post-template.php

    r7907 r7913  
    642642    $rows = '';
    643643    $class = false;
     644    $can_edit_post = current_user_can( 'edit_post', $post->ID );
    644645    foreach ( $revisions as $revision ) {
     646        if ( !current_user_can( 'read_post', $revision->ID ) )
     647            continue;
     648
    645649        $date = wp_post_revision_title( $revision );
    646650        $name = get_author_name( $revision->post_author );
     
    655659            $class = $class ? '' : " class='alternate'";
    656660
    657             if ( $post->ID != $revision->ID && current_user_can( 'edit_post', $post->ID ) )
     661            if ( $post->ID != $revision->ID && $can_edit_post )
    658662                $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>';
    659663            else
  • trunk/wp-includes/post.php

    r7907 r7913  
    957957        $wpdb->update( $wpdb->posts, $parent_data, $parent_where + array( 'post_type' => 'page' ) );
    958958    }
     959
     960    // Do raw query.  wp_get_post_revisions() is filtered
     961    $revision_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'revision'", $postid ) );
     962    // Use wp_delete_post (via wp_delete_revision) again.  Ensures any meta/misplaced data gets cleaned up.
     963    foreach ( $revision_ids as $revision_id )
     964        wp_delete_revision( $revision_id );
    959965
    960966    // Point all attachments to this post up one level
     
    30233029        return;
    30243030
     3031    if ( !constant('WP_POST_REVISIONS') )
     3032        return;
     3033
    30253034    if ( !$post = get_post( $post_id, ARRAY_A ) )
    30263035        return;
     
    32283237 */
    32293238function wp_get_post_revisions( $post_id = 0 ) {
     3239    if ( !constant('WP_POST_REVISIONS') )
     3240        return array();
    32303241    if ( ( !$post = get_post( $post_id ) ) || empty( $post->ID ) )
    32313242        return array();
  • trunk/wp-includes/script-loader.php

    r7907 r7913  
    4848        ) );
    4949
    50         $this->add( 'autosave', '/wp-includes/js/autosave.js', array('schedule', 'wp-ajax-response'), '20080507' );
     50        $this->add( 'autosave', '/wp-includes/js/autosave.js', array('schedule', 'wp-ajax-response'), '20080508' );
    5151
    5252        $this->add( 'wp-ajax', '/wp-includes/js/wp-ajax.js', array('prototype'), '20070306');
  • trunk/wp-settings.php

    r7757 r7913  
    377377do_action('plugins_loaded');
    378378
     379$default_constants = array( 'WP_POST_REVISIONS' => true );
     380foreach ( $default_constants as $c => $v )
     381    @define( $c, $v ); // will fail if the constant is already defined
     382unset($default_constants, $c, $v);
     383
    379384// If already slashed, strip.
    380385if ( get_magic_quotes_gpc() ) {
Note: See TracChangeset for help on using the changeset viewer.