Make WordPress Core


Ignore:
Timestamp:
03/13/2013 11:54:12 PM (13 years ago)
Author:
azaozz
Message:

Logged out warnings, heartbeat: remove nopriv_autosave as it doubles the functionality of the logged out warnings, move wp_ajax_nopriv_heartbeat() under No-privilege Ajax handlers in ajax-actions.php, see #23295, see #23216

File:
1 edited

Legend:

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

    r23683 r23692  
    1010 * No-privilege Ajax handlers.
    1111 */
    12 
    13 function wp_ajax_nopriv_autosave() {
    14         $id = isset( $_POST['post_ID'] ) ? (int) $_POST['post_ID'] : 0;
    15 
    16         if ( ! $id )
    17                 wp_die( -1 );
    18 
    19         $message = sprintf( __('<strong>ALERT: You are logged out!</strong> Could not save draft. <a href="%s" target="_blank">Please log in again.</a>'), wp_login_url() );
    20         $x = new WP_Ajax_Response( array(
    21                 'what' => 'autosave',
    22                 'id' => $id,
    23                 'data' => $message
    24         ) );
    25         $x->send();
     12function wp_ajax_nopriv_heartbeat() {
     13        $response = array();
     14
     15        // 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']);
     18        else
     19                $screen_id = 'site';
     20
     21        if ( ! empty($_POST['data']) ) {
     22                $data = wp_unslash( (array) $_POST['data'] );
     23                $response = apply_filters( 'heartbeat_nopriv_received', $response, $data, $screen_id );
     24        }
     25
     26        $response = apply_filters( 'heartbeat_nopriv_send', $response, $screen_id );
     27
     28        // Allow the transport to be replaced with long-polling easily
     29        do_action( 'heartbeat_nopriv_tick', $response, $screen_id );
     30
     31        // send the current time according to the server
     32        $response['servertime'] = time();
     33
     34        wp_send_json($response);
    2635}
    2736
     
    20992108}
    21002109
    2101 function wp_ajax_nopriv_heartbeat() {
    2102         $response = array();
    2103 
    2104         // screen_id is the same as $current_screen->id and the JS global 'pagenow'
    2105         if ( ! empty($_POST['screenid']) )
    2106                 $screen_id = sanitize_key($_POST['screenid']);
    2107         else
    2108                 $screen_id = 'site';
    2109 
    2110         if ( ! empty($_POST['data']) ) {
    2111                 $data = wp_unslash( (array) $_POST['data'] );
    2112                 $response = apply_filters( 'heartbeat_nopriv_received', $response, $data, $screen_id );
    2113         }
    2114 
    2115         $response = apply_filters( 'heartbeat_nopriv_send', $response, $screen_id );
    2116 
    2117         // Allow the transport to be replaced with long-polling easily
    2118         do_action( 'heartbeat_nopriv_tick', $response, $screen_id );
    2119 
    2120         // send the current time acording to the server
    2121         $response['servertime'] = time();
    2122 
    2123         wp_send_json($response);
    2124 }
    2125 
    21262110function wp_ajax_revisions_data() {
    21272111        check_ajax_referer( 'revisions-ajax-nonce', 'nonce' );
Note: See TracChangeset for help on using the changeset viewer.