From 72577aacd81dfc8266ee0703277736d48edf7109 Mon Sep 17 00:00:00 2001 From: azaozz 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: http://svn.automattic.com/wordpress/trunk@9216 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- 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 4e98d43e1..57ae7fea7 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 +?>