Make WordPress Core


Ignore:
Timestamp:
05/16/2013 03:47:09 AM (11 years ago)
Author:
azaozz
Message:

Separate the nonces update from checking the post lock. Fix scheduling the logged out check. See #23697, see #23295.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/misc.php

    r24209 r24273  
    624624        }
    625625
     626        $response['wp-refresh-post-lock'] = $send;
     627    }
     628
     629    return $response;
     630}
     631add_filter( 'heartbeat_received', 'wp_refresh_post_lock', 10, 3 );
     632
     633/**
     634 * Check nonce expiration on the New/Edit Post screen and refresh if needed
     635 *
     636 * @since 3.6
     637 */
     638function wp_refresh_post_nonces( $response, $data, $screen_id ) {
     639    if ( 'post' == $screen_id && array_key_exists( 'wp-refresh-post-nonces', $data ) ) {
     640        $received = $data['wp-refresh-post-nonces'];
     641
     642        if ( ! $post_id = absint( $received['post_id'] ) )
     643            return $response;
     644
     645        if ( ! current_user_can('edit_post', $post_id) )
     646            return $response;
     647
    626648        if ( ! empty( $received['post_nonce'] ) && 2 === wp_verify_nonce( $received['post_nonce'], 'update-post_' . $post_id ) ) {
    627             $send['update_nonces'] = array(
     649            $response['wp-refresh-post-nonces'] = array(
    628650                'replace-autosavenonce' => wp_create_nonce('autosave'),
    629651                'replace-getpermalinknonce' => wp_create_nonce('getpermalink'),
     
    634656            );
    635657        }
    636 
    637         $response['wp-refresh-post-lock'] = $send;
    638658    }
    639659
    640660    return $response;
    641661}
    642 add_filter( 'heartbeat_received', 'wp_refresh_post_lock', 10, 3 );
     662add_filter( 'heartbeat_received', 'wp_refresh_post_nonces', 10, 3 );
    643663
    644664/**
Note: See TracChangeset for help on using the changeset viewer.