Automattic\WooCommerce\Admin\Features\OnboardingTasks

TaskList::add_task()publicWC 1.0

Add task to the task list.

Метод класса: TaskList{}

No Hooks.

Return

null. Nothing.

Usage

$TaskList = new TaskList();
$TaskList->add_task( $task );
$task(Task) (required)
Task class.

Код TaskList::add_task() WC 7.1.0

public function add_task( $task ) {
	if ( ! is_subclass_of( $task, 'Automattic\WooCommerce\Admin\Features\OnboardingTasks\Task' ) ) {
		return new \WP_Error(
			'woocommerce_task_list_invalid_task',
			__( 'Task is not a subclass of `Task`', 'woocommerce' )
		);
	}
	if ( array_search( $task, $this->tasks, true ) ) {
		return;
	}

	$task_class_name                             = substr( get_class( $task ), strrpos( get_class( $task ), '\\' ) + 1 );
	$this->task_class_id_map[ $task_class_name ] = $task->get_id();
	$this->tasks[]                               = $task;
}