wp_ajax_trash_post
Ajax handler for sending a post to the trash.
Description
wp_ajax_trash_post( (string) $action );
Parameters (1)
- 0. $action (string)
- Action to perform.
Usage
if ( !function_exists( 'wp_ajax_trash_post' ) ) { require_once ABSPATH . '/wp-admin/includes/ajax-actions.php'; } // Action to perform. $action = ''; // NOTICE! Understand what this does before running. $result = wp_ajax_trash_post($action);
Defined (1)
The function is defined in the following location(s).
- /wp-admin/includes/ajax-actions.php
- function wp_ajax_trash_post( $action ) {
- if ( empty( $action ) )
- $action = 'trash-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 ( 'trash-post' == $action )
- $done = wp_trash_post( $id );
- else
- $done = wp_untrash_post( $id );
- if ( $done )
- wp_die( 1 );
- wp_die( 0 );
- }