wpseek.com
A WordPress-centric search engine for devs and theme authors
wp_ajax_delete_post › WordPress Function
Since3.1.0
Deprecatedn/a
› wp_ajax_delete_post ( $action )
Parameters: |
|
Defined at: |
|
Codex: |
Handles deleting a post via AJAX.
Related Functions: wp_ajax_delete_tag, wp_delete_post, wp_ajax_delete_page, wp_ajax_delete_meta, wp_ajax_delete_comment
Source
function wp_ajax_delete_post( $action ) { if ( empty( $action ) ) { $action = 'delete-post'; } $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; check_ajax_referer( "{$action}_$id" ); if ( ! current_user_can( 'delete_post', $id ) ) { wp_die( -1 ); } if ( ! get_post( $id ) ) { wp_die( 1 ); } if ( wp_delete_post( $id ) ) { wp_die( 1 ); } else { wp_die( 0 ); } }