From 17cdcd2fdb9fefa2e1bca2ac910a26f3813299be Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Thu, 16 Oct 2008 21:59:06 +0000 Subject: [PATCH] Show warning if user is logged out while writing or editing, includes patch by tott, fixes #7630 git-svn-id: https://develop.svn.wordpress.org/trunk@9216 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/admin-ajax.php | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php index 4e98d43e18..57ae7fea7b 100644 --- a/wp-admin/admin-ajax.php +++ b/wp-admin/admin-ajax.php @@ -17,8 +17,25 @@ define('WP_ADMIN', true); require_once('../wp-load.php'); require_once('includes/admin.php'); -if ( !is_user_logged_in() ) +if ( ! is_user_logged_in() ) { + + if ( $_POST['action'] == 'autosave' ) { + $id = isset($_POST['post_ID'])? (int) $_POST['post_ID'] : 0; + + if ( ! $id ) + die('-1'); + + $message = sprintf( __('ALERT: You are logged out! Could not save draft. Please log in again.'), wp_login_url() ); + $x = new WP_Ajax_Response( array( + 'what' => 'autosave', + 'id' => $id, + 'data' => $message + ) ); + $x->send(); + } + die('-1'); +} if ( isset($_GET['action']) && 'ajax-tag-search' == $_GET['action'] ) { if ( !current_user_can( 'manage_categories' ) ) @@ -955,4 +972,4 @@ default : die('0'); break; endswitch; -?> \ No newline at end of file +?>