Skip to content

Instantly share code, notes, and snippets.

@gvgvgvijayan
Created January 17, 2021 09:47
Show Gist options
  • Select an option

  • Save gvgvgvijayan/4b9fd90ad26ef5dba74a594c778f31f3 to your computer and use it in GitHub Desktop.

Select an option

Save gvgvgvijayan/4b9fd90ad26ef5dba74a594c778f31f3 to your computer and use it in GitHub Desktop.

Revisions

  1. gvgvgvijayan created this gist Jan 17, 2021.
    21 changes: 21 additions & 0 deletions process_bulk_action.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    <?php
    ...
    /**
    * Get bulk actions.
    *
    * @return void
    */
    public function process_bulk_action() {
    if ( 'trash' === $this->current_action() ) {
    $post_ids = filter_input( INPUT_GET, 'draft_id', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );

    if ( is_array( $post_ids ) ) {
    $post_ids = array_map( 'intval', $post_ids );

    if ( count( $post_ids ) ) {
    array_map( 'wp_trash_post', $post_ids );
    }
    }
    }
    }
    ...