WordPress.org

Make WordPress Core

Ticket #7630: patch_autosave_8941.diff

File patch_autosave_8941.diff, 1.3 KB (added by tott, 10 years ago)

simple feedback patch wp-admin/admin-ajax.php

  • wp-admin/admin-ajax.php

     
    1717require_once('../wp-load.php');
    1818require_once('includes/admin.php');
    1919
    20 if ( !is_user_logged_in() )
     20if ( !is_user_logged_in() && $_POST['action'] !== 'autosave' )
    2121        die('-1');
    2222
     23if ( !is_user_logged_in() && $_POST['action'] == 'autosave' ) {
     24        $id = isset($_POST['id'])? (int) $_POST['id'] : 0;
     25        if ( is_ssl() )
     26                $proto = 'https://';
     27        else
     28                $proto = 'http://';
     29
     30        $login_url = site_url( 'wp-login.php' );
     31        $message = sprintf( __('<b>ALERT: YOU ARE LOGGED OUT!</b> Could not save draft <a href="%s" target="blank">Login here</a>'), $login_url, date( __('g:i:s a'), current_time( 'timestamp', true ) ) );
     32        $x = new WP_Ajax_Response( array(
     33                'what' => 'autosave',
     34                'id' => $id,
     35                'data' => $message,
     36                'supplemental' => array()
     37        ) );
     38        $x->send();
     39        die('-1');
     40}
     41
    2342if ( isset($_GET['action']) && 'ajax-tag-search' == $_GET['action'] ) {
    2443        if ( !current_user_can( 'manage_categories' ) )
    2544                die('-1');
     
    828847        die('0');
    829848        break;
    830849endswitch;
    831 ?>
    832  No newline at end of file
     850?>