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
git-svn-id: http://core.svn.wordpress.org/trunk@23692 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
5398ac438c
commit
d46102d258
|
@ -66,7 +66,6 @@ if ( ! empty( $_GET['action'] ) && in_array( $_GET['action'], $core_actions_get
|
|||
if ( ! empty( $_POST['action'] ) && in_array( $_POST['action'], $core_actions_post ) )
|
||||
add_action( 'wp_ajax_' . $_POST['action'], 'wp_ajax_' . str_replace( '-', '_', $_POST['action'] ), 1 );
|
||||
|
||||
add_action( 'wp_ajax_nopriv_autosave', 'wp_ajax_nopriv_autosave', 1 );
|
||||
add_action( 'wp_ajax_nopriv_heartbeat', 'wp_ajax_nopriv_heartbeat', 1 );
|
||||
|
||||
if ( is_user_logged_in() )
|
||||
|
|
|
@ -9,20 +9,29 @@
|
|||
/*
|
||||
* No-privilege Ajax handlers.
|
||||
*/
|
||||
function wp_ajax_nopriv_heartbeat() {
|
||||
$response = array();
|
||||
|
||||
function wp_ajax_nopriv_autosave() {
|
||||
$id = isset( $_POST['post_ID'] ) ? (int) $_POST['post_ID'] : 0;
|
||||
// screen_id is the same as $current_screen->id and the JS global 'pagenow'
|
||||
if ( ! empty($_POST['screenid']) )
|
||||
$screen_id = sanitize_key($_POST['screenid']);
|
||||
else
|
||||
$screen_id = 'site';
|
||||
|
||||
if ( ! $id )
|
||||
wp_die( -1 );
|
||||
if ( ! empty($_POST['data']) ) {
|
||||
$data = wp_unslash( (array) $_POST['data'] );
|
||||
$response = apply_filters( 'heartbeat_nopriv_received', $response, $data, $screen_id );
|
||||
}
|
||||
|
||||
$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() );
|
||||
$x = new WP_Ajax_Response( array(
|
||||
'what' => 'autosave',
|
||||
'id' => $id,
|
||||
'data' => $message
|
||||
) );
|
||||
$x->send();
|
||||
$response = apply_filters( 'heartbeat_nopriv_send', $response, $screen_id );
|
||||
|
||||
// Allow the transport to be replaced with long-polling easily
|
||||
do_action( 'heartbeat_nopriv_tick', $response, $screen_id );
|
||||
|
||||
// send the current time according to the server
|
||||
$response['servertime'] = time();
|
||||
|
||||
wp_send_json($response);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2098,31 +2107,6 @@ function wp_ajax_heartbeat() {
|
|||
wp_send_json($response);
|
||||
}
|
||||
|
||||
function wp_ajax_nopriv_heartbeat() {
|
||||
$response = array();
|
||||
|
||||
// screen_id is the same as $current_screen->id and the JS global 'pagenow'
|
||||
if ( ! empty($_POST['screenid']) )
|
||||
$screen_id = sanitize_key($_POST['screenid']);
|
||||
else
|
||||
$screen_id = 'site';
|
||||
|
||||
if ( ! empty($_POST['data']) ) {
|
||||
$data = wp_unslash( (array) $_POST['data'] );
|
||||
$response = apply_filters( 'heartbeat_nopriv_received', $response, $data, $screen_id );
|
||||
}
|
||||
|
||||
$response = apply_filters( 'heartbeat_nopriv_send', $response, $screen_id );
|
||||
|
||||
// Allow the transport to be replaced with long-polling easily
|
||||
do_action( 'heartbeat_nopriv_tick', $response, $screen_id );
|
||||
|
||||
// send the current time acording to the server
|
||||
$response['servertime'] = time();
|
||||
|
||||
wp_send_json($response);
|
||||
}
|
||||
|
||||
function wp_ajax_revisions_data() {
|
||||
check_ajax_referer( 'revisions-ajax-nonce', 'nonce' );
|
||||
|
||||
|
|
Loading…
Reference in New Issue