Make WordPress Core


Ignore:
Timestamp:
07/24/2013 06:08:14 AM (11 years ago)
Author:
nacin
Message:

Revisions changes.

  • Eliminates the bloated Revisions meta box in favor of 'Revisions: #' in the publish box.
  • Adds ability to compare autosave to current post, when revisions are disabled.
  • Makes autosaves stand out visually, including "Restore This Autosave".

Also:

  • Adds missing capability check for restoring a revision.
  • When no revision matches the post's current modified time, avoid marking an autosave as 'current'.
  • Fixes wp_get_post_autosave() to return an autosave even when revisions are disabled.
  • Add 'check_enabled' arg to wp_get_post_revisions(); false avoids the wp_revisions_enabled() check.
  • Adds a responsive slider that is narrower for fewer versions. props markjaquith.

see #24804.

File:
1 edited

Legend:

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

    r24787 r24790  
    110110require_once('./includes/meta-boxes.php');
    111111
     112
     113$publish_callback_args = null;
     114if ( post_type_supports($post_type, 'revisions') && 'auto-draft' != $post->post_status ) {
     115    $revisions = wp_get_post_revisions( $post_ID );
     116
     117    // Check if the revisions have been upgraded
     118    if ( ! empty( $revisions ) && _wp_get_post_revision_version( end( $revisions ) ) < 1 )
     119        _wp_upgrade_revisions_of_post( $post, $revisions );
     120
     121    // We should aim to show the revisions metabox only when there are revisions.
     122    if ( count( $revisions ) > 1 ) {
     123        reset( $revisions ); // Reset pointer for key()
     124        $publish_callback_args = array( 'revisions_count' => count( $revisions ), 'revision_id' => key( $revisions ) );
     125        // add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', null, 'normal', 'core');
     126    }
     127}
     128
    112129if ( 'attachment' == $post_type ) {
    113130    wp_enqueue_script( 'image-edit' );
     
    116133    add_action( 'edit_form_after_title', 'edit_form_image_editor' );
    117134} else {
    118     add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', null, 'side', 'core' );
     135    add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', null, 'side', 'core', $publish_callback_args );
    119136}
    120137
     
    171188    if ( is_super_admin() || current_user_can( $post_type_object->cap->edit_others_posts ) )
    172189        add_meta_box('authordiv', __('Author'), 'post_author_meta_box', null, 'normal', 'core');
    173 }
    174 
    175 if ( post_type_supports($post_type, 'revisions') && 'auto-draft' != $post->post_status ) {
    176     $revisions = wp_get_post_revisions( $post_ID );
    177 
    178     // Check if the revisions have been upgraded
    179     if ( ! empty( $revisions ) && _wp_get_post_revision_version( end( $revisions ) ) < 1 )
    180         _wp_upgrade_revisions_of_post( $post, $revisions );
    181 
    182     // We should aim to show the revisions metabox only when there are revisions.
    183     if ( count( $revisions ) > 1 )
    184         add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', null, 'normal', 'core');
    185190}
    186191
Note: See TracChangeset for help on using the changeset viewer.