WordPress.org

Make WordPress Core

Changeset 24406


Ignore:
Timestamp:
06/05/2013 12:13:40 AM (5 years ago)
Author:
azaozz
Message:

Heartbeat: rename some vars/args to make them more intuitive, don't set user_id on every request, see #23216

Location:
trunk
Files:
4 edited

Legend:

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

    r24388 r24406  
    1414
    1515    // screen_id is the same as $current_screen->id and the JS global 'pagenow'
    16     if ( ! empty($_POST['screenid']) )
    17         $screen_id = sanitize_key($_POST['screenid']);
     16    if ( ! empty($_POST['screen_id']) )
     17        $screen_id = sanitize_key($_POST['screen_id']);
    1818    else
    19         $screen_id = 'site';
     19        $screen_id = 'front';
    2020
    2121    if ( ! empty($_POST['data']) ) {
     
    3030
    3131    // send the current time according to the server
    32     $response['servertime'] = time();
     32    $response['server_time'] = time();
    3333
    3434    wp_send_json($response);
     
    20592059
    20602060    // screen_id is the same as $current_screen->id and the JS global 'pagenow'
    2061     if ( ! empty($_POST['screenid']) )
    2062         $screen_id = sanitize_key($_POST['screenid']);
     2061    if ( ! empty($_POST['screen_id']) )
     2062        $screen_id = sanitize_key($_POST['screen_id']);
    20632063    else
    2064         $screen_id = 'site';
     2064        $screen_id = 'front';
    20652065
    20662066    if ( ! empty($_POST['data']) ) {
    20672067        $data = (array) $_POST['data'];
    2068         // todo: how much to sanitize and preset and what to leave to be accessed from $data or $_POST..?
    2069         $user = wp_get_current_user();
    2070         $data['user_id'] = $user->exists() ? $user->ID : 0;
    20712068
    20722069        // todo: separate filters: 'heartbeat_[action]' so we call different callbacks only when there is data for them,
     
    20812078
    20822079    // send the current time acording to the server
    2083     $response['servertime'] = time();
     2080    $response['server_time'] = time();
    20842081
    20852082    wp_send_json($response);
  • trunk/wp-admin/includes/misc.php

    r24303 r24406  
    570570    $checked = array();
    571571
    572     if ( 'edit-post' == $screen_id && array_key_exists( 'wp-check-locked', $data ) && is_array( $data['wp-check-locked'] ) ) {
    573         foreach ( $data['wp-check-locked'] as $key ) {
     572    if ( 'edit-post' == $screen_id && array_key_exists( 'wp-check-locked-posts', $data ) && is_array( $data['wp-check-locked-posts'] ) ) {
     573        foreach ( $data['wp-check-locked-posts'] as $key ) {
    574574            $post_id = (int) substr( $key, 5 );
    575575
     
    586586
    587587    if ( ! empty( $checked ) )
    588         $response['wp-check-locked'] = $checked;
     588        $response['wp-check-locked-posts'] = $checked;
    589589
    590590    return $response;
     
    602602        $send = array();
    603603
    604         if ( !$post_id = absint( $received['post_id'] ) )
     604        if ( ! $post_id = absint( $received['post_id'] ) )
    605605            return $response;
    606606
    607         if ( !current_user_can('edit_post', $post_id) )
     607        if ( ! current_user_can('edit_post', $post_id) )
    608608            return $response;
    609609
  • trunk/wp-admin/js/inline-edit-post.js

    r24299 r24406  
    294294
    295295// Show/hide locks on posts
    296 $( document ).on( 'heartbeat-tick.wp-check-locked', function( e, data ) {
    297     var locked = data['wp-check-locked'] || {};
     296$( document ).on( 'heartbeat-tick.wp-check-locked-posts', function( e, data ) {
     297    var locked = data['wp-check-locked-posts'] || {};
    298298
    299299    $('#the-list tr').each( function(i, el) {
     
    316316        }
    317317    });
    318 }).on( 'heartbeat-send.wp-check-locked', function( e, data ) {
     318}).on( 'heartbeat-send.wp-check-locked-posts', function( e, data ) {
    319319    var check = [];
    320320
     
    325325
    326326    if ( check.length )
    327         data['wp-check-locked'] = check;
     327        data['wp-check-locked-posts'] = check;
    328328});
    329329
  • trunk/wp-includes/js/heartbeat.js

    r24384 r24406  
    1212            beat,
    1313            nonce,
    14             screenid = typeof pagenow != 'undefined' ? pagenow : '',
     14            screenId = typeof pagenow != 'undefined' ? pagenow : '',
    1515            url = typeof ajaxurl != 'undefined' ? ajaxurl : '',
    1616            settings,
     
    4343            interval = settings.interval || 15; // default interval
    4444            delete settings.interval;
    45             // The interval can be from 5 to 60 sec.
    46             if ( interval < 5 )
    47                 interval = 5;
     45            // The interval can be from 15 to 60 sec. and can be set temporarily to 5 sec.
     46            if ( interval < 15 )
     47                interval = 15;
    4848            else if ( interval > 60 )
    4949                interval = 60;
     
    5151            interval = interval * 1000;
    5252
    53             // 'screenid' can be added from settings on the front-end where the JS global 'pagenow' is not set
    54             screenid = screenid || settings.screenid || 'site';
    55             delete settings.screenid;
     53            // 'screenId' can be added from settings on the front-end where the JS global 'pagenow' is not set
     54            screenId = screenId || settings.screenId || 'front';
     55            delete settings.screenId;
    5656
    5757            // Add or overwrite public vars
     
    8484        }
    8585
    86         // Set error state and fire an event if XHR errors or timeout
     86        // Set error state and fire an event on XHR errors or timeout
    8787        function errorstate( error ) {
    8888            var trigger;
     
    149149            send._nonce = nonce;
    150150            send.action = 'heartbeat';
    151             send.screenid = screenid;
     151            send.screen_id = screenId;
    152152            send.has_focus = hasFocus;
    153153
Note: See TracChangeset for help on using the changeset viewer.