Ticket #23216: 23216-3.patch
File 23216-3.patch, 3.7 KB (added by , 11 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 } … … 2075 2075 $response = array(); 2076 2076 2077 2077 // screen_id is the same as $current_screen->id and the JS global 'pagenow' 2078 if ( ! empty($_POST['screen id']) )2079 $screen_id = sanitize_key($_POST['screen id']);2078 if ( ! empty($_POST['screen_id']) ) 2079 $screen_id = sanitize_key($_POST['screen_id']); 2080 2080 else 2081 $screen_id = ' site';2081 $screen_id = 'front'; 2082 2082 2083 2083 if ( ! empty($_POST['data']) ) { 2084 2084 $data = (array) $_POST['data']; 2085 // todo: how much to sanitize and preset and what to leave to be accessed from $data or $_POST..?2086 $user = wp_get_current_user();2087 $data['user_id'] = $user->exists() ? $user->ID : 0;2088 2085 2089 2086 // todo: separate filters: 'heartbeat_[action]' so we call different callbacks only when there is data for them, 2090 2087 // or all callbacks listen to one filter and run when there is something for them in $data? … … 2097 2094 do_action( 'heartbeat_tick', $response, $screen_id ); 2098 2095 2099 2096 // send the current time acording to the server 2100 $response['server time'] = time();2097 $response['server_time'] = time(); 2101 2098 2102 2099 wp_send_json($response); 2103 2100 } -
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;