Yoast\WP\SEO\Bulk_Editor\User_Interface
Posts_Overview_Bulk_Actions_Integration::handle_bulk_action
Handles the bulk action by sending the user to the bulk editor page with the selection carried over.
Метод класса: Posts_Overview_Bulk_Actions_Integration{}
Хуков нет.
Возвращает
string. The URL to redirect to.
Использование
$Posts_Overview_Bulk_Actions_Integration = new Posts_Overview_Bulk_Actions_Integration(); $Posts_Overview_Bulk_Actions_Integration->handle_bulk_action( $redirect_url, $action, $post_ids );
- $redirect_url(строка) (обязательный)
- The URL the overview would redirect to.
- $action(строка) (обязательный)
- The bulk action being handled.
- $post_ids(array
) (обязательный) - The selected post IDs.
Код Posts_Overview_Bulk_Actions_Integration::handle_bulk_action() Posts Overview Bulk Actions Integration::handle bulk action Yoast 28.4
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' ) );
}