The URL to redirect to. */ public function handle_bulk_action( $redirect_url, $action, $post_ids ) { if ( $action !== self::BULK_ACTION ) { return $redirect_url; } // The filter only fires on the overview of the post type it was registered for, so the // current screen carries the content type to preselect. $screen = \get_current_screen(); if ( $screen === null || $screen->post_type === '' ) { return $redirect_url; } $args = [ 'page' => Bulk_Editor_Integration::PAGE, Bulk_Editor_Integration::CONTENT_TYPE_PARAM => $screen->post_type, ]; $ids = \array_values( \array_unique( \array_filter( \array_map( 'intval', (array) $post_ids ), static function ( $id ) { return $id > 0; }, ), ), ); if ( $ids !== [] ) { // Only the first batch can end up selected; carrying more would only risk hitting URL length limits. $args[ Bulk_Editor_Integration::POST_IDS_PARAM ] = \implode( ',', \array_slice( $ids, 0, Batch_Limit::MAX_ITEMS ) ); $args[ Bulk_Editor_Integration::SELECTED_COUNT_PARAM ] = \count( $ids ); } return \add_query_arg( $args, \admin_url( 'admin.php' ) ); } }