Ticket #23216: 23216-4.patch
File 23216-4.patch, 6.8 KB (added by , 12 years ago) |
---|
-
wp-admin/includes/ajax-actions.php
13 13 $response = array(); 14 14 15 15 // screen_id is the same as $current_screen->id and the JS global 'pagenow' 16 if ( ! empty($_POST['screen id']) )17 $screen_id = sanitize_key($_POST['screen id']);16 if ( ! empty($_POST['screen_id']) ) 17 $screen_id = sanitize_key($_POST['screen_id']); 18 18 else 19 $screen_id = ' site';19 $screen_id = 'front'; 20 20 21 21 if ( ! empty($_POST['data']) ) { 22 22 $data = wp_unslash( (array) $_POST['data'] ); … … 29 29 do_action( 'heartbeat_nopriv_tick', $response, $screen_id ); 30 30 31 31 // send the current time according to the server 32 $response['server time'] = time();32 $response['server_time'] = time(); 33 33 34 34 wp_send_json($response); 35 35 } … … 2058 2058 $response = array(); 2059 2059 2060 2060 // screen_id is the same as $current_screen->id and the JS global 'pagenow' 2061 if ( ! empty($_POST['screen id']) )2062 $screen_id = sanitize_key($_POST['screen id']);2061 if ( ! empty($_POST['screen_id']) ) 2062 $screen_id = sanitize_key($_POST['screen_id']); 2063 2063 else 2064 $screen_id = ' site';2064 $screen_id = 'front'; 2065 2065 2066 2066 if ( ! empty($_POST['data']) ) { 2067 2067 $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;2071 2068 2072 2069 // todo: separate filters: 'heartbeat_[action]' so we call different callbacks only when there is data for them, 2073 2070 // or all callbacks listen to one filter and run when there is something for them in $data? … … 2080 2077 do_action( 'heartbeat_tick', $response, $screen_id ); 2081 2078 2082 2079 // send the current time acording to the server 2083 $response['server time'] = time();2080 $response['server_time'] = time(); 2084 2081 2085 2082 wp_send_json($response); 2086 2083 } -
wp-admin/includes/misc.php
569 569 function wp_check_locked_posts( $response, $data, $screen_id ) { 570 570 $checked = array(); 571 571 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 ( array_key_exists( 'wp-check-locked-posts', $data ) && is_array( $data['wp-check-locked-posts'] ) ) { 573 foreach ( $data['wp-check-locked-posts'] as $key ) { 574 574 $post_id = (int) substr( $key, 5 ); 575 575 576 576 if ( current_user_can( 'edit_post', $post_id ) && ( $user_id = wp_check_post_lock( $post_id ) ) && ( $user = get_userdata( $user_id ) ) ) { … … 585 585 } 586 586 587 587 if ( ! empty( $checked ) ) 588 $response['wp-check-locked '] = $checked;588 $response['wp-check-locked-posts'] = $checked; 589 589 590 590 return $response; 591 591 } … … 597 597 * @since 3.6 598 598 */ 599 599 function wp_refresh_post_lock( $response, $data, $screen_id ) { 600 if ( 'post' == $screen_id &&array_key_exists( 'wp-refresh-post-lock', $data ) ) {600 if ( array_key_exists( 'wp-refresh-post-lock', $data ) ) { 601 601 $received = $data['wp-refresh-post-lock']; 602 602 $send = array(); 603 603 604 if ( ! $post_id = absint( $received['post_id'] ) )604 if ( ! $post_id = absint( $received['post_id'] ) ) 605 605 return $response; 606 606 607 if ( ! current_user_can('edit_post', $post_id) )607 if ( ! current_user_can('edit_post', $post_id) ) 608 608 return $response; 609 609 610 610 if ( ( $user_id = wp_check_post_lock( $post_id ) ) && ( $user = get_userdata( $user_id ) ) ) { … … 636 636 * @since 3.6 637 637 */ 638 638 function wp_refresh_post_nonces( $response, $data, $screen_id ) { 639 if ( 'post' == $screen_id &&array_key_exists( 'wp-refresh-post-nonces', $data ) ) {639 if ( array_key_exists( 'wp-refresh-post-nonces', $data ) ) { 640 640 $received = $data['wp-refresh-post-nonces']; 641 641 642 642 if ( ! $post_id = absint( $received['post_id'] ) ) -
wp-admin/js/inline-edit-post.js
293 293 $( document ).ready( function(){ inlineEditPost.init(); } ); 294 294 295 295 // 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'] || {}; 298 298 299 299 $('#the-list tr').each( function(i, el) { 300 300 var key = el.id, row = $(el), lock_data, avatar; … … 315 315 row.find('.column-title .locked-avatar').empty(); 316 316 } 317 317 }); 318 }).on( 'heartbeat-send.wp-check-locked ', function( e, data ) {318 }).on( 'heartbeat-send.wp-check-locked-posts', function( e, data ) { 319 319 var check = []; 320 320 321 321 $('#the-list tr').each( function(i, el) { … … 324 324 }); 325 325 326 326 if ( check.length ) 327 data['wp-check-locked '] = check;327 data['wp-check-locked-posts'] = check; 328 328 }); 329 329 330 330 }(jQuery)); -
wp-includes/js/heartbeat.js
11 11 running, 12 12 beat, 13 13 nonce, 14 screen id = typeof pagenow != 'undefined' ? pagenow : '',14 screenId = typeof pagenow != 'undefined' ? pagenow : '', 15 15 url = typeof ajaxurl != 'undefined' ? ajaxurl : '', 16 16 settings, 17 17 tick = 0, … … 42 42 43 43 interval = settings.interval || 15; // default interval 44 44 delete settings.interval; 45 // The interval can be from 5 to 60sec.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; 48 48 else if ( interval > 60 ) 49 49 interval = 60; 50 50 51 51 interval = interval * 1000; 52 52 53 // 'screen id' can be added from settings on the front-end where the JS global 'pagenow' is not set54 screen id = screenid || settings.screenid || 'site';55 delete settings.screen id;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; 56 56 57 57 // Add or overwrite public vars 58 58 $.extend( this, settings ); … … 83 83 return false; 84 84 } 85 85 86 // Set error state and fire an event ifXHR errors or timeout86 // Set error state and fire an event on XHR errors or timeout 87 87 function errorstate( error ) { 88 88 var trigger; 89 89 … … 148 148 send.interval = interval / 1000; 149 149 send._nonce = nonce; 150 150 send.action = 'heartbeat'; 151 send.screen id = screenid;151 send.screen_id = screenId; 152 152 send.has_focus = hasFocus; 153 153 154 154 connecting = true;