Make WordPress Core


Ignore:
Timestamp:
10/01/2009 11:44:18 AM (16 years ago)
Author:
markjaquith
Message:

Surface "Move to Trash" link for posts/pages immediately after first autosave fires. Props cross country flight. fixes #10344

File:
1 edited

Legend:

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

    r11965 r11986  
    969969    check_ajax_referer( 'autosave', 'autosavenonce' );
    970970    $ID = (int) $_POST['post_ID'];
    971     if ( $_POST['post_type'] == 'post' ) {
    972         if ( current_user_can('edit_post', $ID) )
    973             die(wp_create_nonce('update-post_' . $ID));
    974     } elseif ( $_POST['post_type'] == 'page' ) {
    975         if ( current_user_can('edit_page', $ID) )
    976             die(wp_create_nonce('update-page_' . $ID));
    977     }
     971    $post_type = ( 'page' == $_POST['post_type'] ) ? 'page' : 'post';
     972    if ( current_user_can( "edit_{$post_type}", $ID ) )
     973        die( json_encode( array( 'updateNonce' => wp_create_nonce( "update-{$post_type}_{$ID}" ), 'deleteURL' => str_replace( '&', '&', wp_nonce_url( admin_url( $post_type . '.php?action=trash&post=' . $ID ), "trash-{$post_type}_{$ID}" ) ) ) ) );
    978974    do_action('autosave_generate_nonces');
    979975    die('0');
Note: See TracChangeset for help on using the changeset viewer.