Automattic\WooCommerce\Admin\Features\OnboardingTasks

TaskLists::set_active_task()public staticWC 1.0

Temporarily store the active task to persist across page loads when neccessary. Most tasks do not need this.

{} It's a method of the class: TaskLists{}

No Hooks.

Return

null. Nothing.

Usage

$result = TaskLists::set_active_task();

Code of TaskLists::set_active_task() WC 6.6.1

public static function set_active_task() {
	if ( ! isset( $_GET[ Task::ACTIVE_TASK_TRANSIENT ] ) || ! current_user_can( 'manage_woocommerce' ) ) { // phpcs:ignore csrf ok.
		return;
	}
	$referer = wp_get_referer();
	if ( ! $referer || 0 !== strpos( $referer, wc_admin_url() ) ) {
		return;
	}

	$task_id = sanitize_title_with_dashes( wp_unslash( $_GET[ Task::ACTIVE_TASK_TRANSIENT ] ) ); // phpcs:ignore csrf ok.

	$task = self::get_task( $task_id );

	if ( ! $task ) {
		return;
	}

	$task->set_active();
}