Automattic\WooCommerce\Internal\ProductDownloads\ApprovedDirectories\Admin

UI::process_bulk_actions()privateWC 1.0

Processes actions that can be applied in bulk (requests to delete, enable or disable).

{} Это метод класса: UI{}

Хуков нет.

Возвращает

null. Ничего.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->process_bulk_actions( $ids, $action );
$ids(int[]) (обязательный)
The ID(s) to be updates.
$action(строка) (обязательный)
The action to be applied.

Код UI::process_bulk_actions() WC 6.8.0

private function process_bulk_actions( array $ids, string $action ) {
	$deletes  = 0;
	$enabled  = 0;
	$disabled = 0;
	$register = wc_get_container()->get( Register::class );

	foreach ( $ids as $id ) {
		if ( 'delete' === $action && $register->delete_by_id( $id ) ) {
			$deletes++;
		} elseif ( 'enable' === $action && $register->enable_by_id( $id ) ) {
			$enabled++;
		} elseif ( 'disable' === $action && $register->disable_by_id( $id ) ) {
			$disabled ++;
		}
	}

	$fails    = count( $ids ) - $deletes - $enabled - $disabled;
	$redirect = $this->table->get_base_url();

	if ( $deletes ) {
		$redirect = add_query_arg( 'deleted-ids', $deletes, $redirect );
	} elseif ( $enabled ) {
		$redirect = add_query_arg( 'enabled-ids', $enabled, $redirect );
	} elseif ( $disabled ) {
		$redirect = add_query_arg( 'disabled-ids', $disabled, $redirect );
	}

	if ( $fails ) {
		$redirect = add_query_arg( 'bulk-fails', $fails, $redirect );
	}

	wp_safe_redirect( $redirect );
	exit;
}