WordPress.org

Make WordPress Core

Changeset 24042


Ignore:
Timestamp:
04/22/2013 03:08:51 AM (8 years ago)
Author:
azaozz
Message:

Post locks:

  • Show 'Saving revision...' while autosaving after a post has been taken over. Change to 'Your latest changes were saved as a revision.' when autosave completes.
  • Make sure a user exists before using $user->display_name.
  • Add 'post_lock_text' action for extending the message text.
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/css/wp-admin.css

    r24039 r24042  
    34003400    margin-left: -225px;
    34013401    background: #fff;
     3402    line-height: 1.5;
    34023403    z-index: 1000005;
    34033404}
     
    34263427#notification-dialog .post-locked-avatar {
    34273428    float: left;
    3428     margin-right: 20px;
    3429 }
    3430 
    3431 #notification-dialog .currently-editing {
    3432     margin-bottom: 20px;
     3429    margin: 0 20px 20px 0;
     3430}
     3431
     3432#notification-dialog .wp-tab-first {
    34333433    outline: 0;
    34343434}
    34353435
     3436#notification-dialog .locked-saving img {
     3437    float: left;
     3438    margin-right: 3px;
     3439}
     3440
     3441#notification-dialog-wrap.saving .locked-saving,
     3442#notification-dialog-wrap.saved .locked-saved {
     3443    display: inline;
     3444}
    34363445
    34373446/*------------------------------------------------------------------------------
  • trunk/wp-admin/includes/misc.php

    r23683 r24042  
    575575
    576576            if ( current_user_can( 'edit_post', $post_id ) && ( $user_id = wp_check_post_lock( $post_id ) ) && ( $user = get_userdata( $user_id ) ) ) {
    577                 $send = array();
     577                $send = array( 'text' => sprintf( __( '%s is currently editing' ), $user->display_name ) );
    578578
    579579                if ( ( $avatar = get_avatar( $user->ID, 18 ) ) && preg_match( "|src='([^']+)'|", $avatar, $matches ) )
    580580                    $send['avatar_src'] = $matches[1];
    581581
    582                 $send['text'] = sprintf( __( '%s is currently editing' ), $user->display_name );
    583582                $checked[$key] = $send;
    584583            }
     
    609608            return $response;
    610609
    611         if ( $user_id = wp_check_post_lock( $post_id ) ) {
    612             $user = get_userdata( $user_id );
    613 
     610        if ( ( $user_id = wp_check_post_lock( $post_id ) ) && ( $user = get_userdata( $user_id ) ) ) {
    614611            $error = array(
    615612                'text' => sprintf( __( '%s has taken over and is currently editing.' ), $user->display_name )
  • trunk/wp-admin/includes/post.php

    r24021 r24042  
    11981198        return;
    11991199
    1200     if ( $user = wp_check_post_lock( $post->ID ) ) {
    1201         $user = get_userdata( $user );
     1200    if ( ( $user_id = wp_check_post_lock( $post->ID ) ) && ( $user = get_userdata( $user_id ) ) ) {
    12021201        $locked = apply_filters( 'show_post_locked_dialog', true, $post, $user );
    12031202    } else {
     
    12301229        <div class="post-locked-avatar"><?php echo get_avatar( $user->ID, 64 ); ?></div>
    12311230        <p class="currently-editing wp-tab-first" tabindex="0"><?php esc_html_e( sprintf( __( 'This content is currently locked. If you take over, %s will be blocked from continuing to edit.' ), $user->display_name ) ); ?></p>
     1231        <?php do_action( 'post_lock_text', $post ); ?>
    12321232        <p>
    12331233        <a class="button" href="<?php echo esc_url( wp_get_referer() ); ?>"><?php _e('Go back'); ?></a>
     
    12501250        <div class="post-taken-over">
    12511251            <div class="post-locked-avatar"></div>
    1252             <p class="currently-editing wp-tab-first" tabindex="0"></p>
     1252            <p class="wp-tab-first" tabindex="0">
     1253            <span class="currently-editing"></span><br>
     1254            <span class="locked-saving hidden"><img src="images/wpspin_light-2x.gif" width="16" height="16" /> <?php _e('Saving revision...'); ?></span>
     1255            <span class="locked-saved hidden"><?php _e('Your latest changes were saved as a revision.'); ?></span>
     1256            </p>
     1257            <?php do_action( 'post_lock_text', $post ); ?>
    12531258            <p><a class="button button-primary wp-tab-last" href="<?php echo esc_url( admin_url('edit.php') ); ?>"><?php _e('Go to All Posts'); ?></a></p>
    12541259        </div>
  • trunk/wp-admin/js/post.js

    r23981 r24042  
    278278
    279279            if ( wrap.length && ! wrap.is(':visible') ) {
    280                 if ( typeof autosave == 'function' )
     280                if ( typeof autosave == 'function' ) {
     281                    $(document).on('autosave-disable-buttons.post-lock', function() {
     282                        wrap.addClass('saving');
     283                    }).on('autosave-enable-buttons.post-lock', function() {
     284                        wrap.removeClass('saving').addClass('saved');
     285                        window.onbeforeunload = null;
     286                    });
     287
     288                    // Save the latest changes and disable
    281289                    autosave();
     290                    autosave = function(){};
     291                }
    282292
    283293                if ( received.lock_error.avatar_src ) {
     
    286296                }
    287297
    288                 wrap.show().find('p.currently-editing').text( received.lock_error.text ).focus();
     298                wrap.show().find('.currently-editing').text( received.lock_error.text );
     299                wrap.find('.wp-tab-first').focus();
    289300            }
    290301        } else if ( received.new_lock ) {
  • trunk/wp-includes/js/autosave.js

    r24021 r24042  
    228228
    229229function autosave_enable_buttons() {
     230    jQuery(document).trigger('autosave-enable-buttons');
    230231    if ( ! wp.heartbeat.connectionLost ) {
    231232        // delay that a bit to avoid some rare collisions while the DOM is being updated.
     
    239240
    240241function autosave_disable_buttons() {
     242    jQuery(document).trigger('autosave-disable-buttons');
    241243    jQuery('#submitpost').find(':button, :submit').prop('disabled', true);
    242244    // Re-enable 5 sec later. Just gives autosave a head start to avoid collisions.
Note: See TracChangeset for help on using the changeset viewer.