Automattic\WooCommerce\Admin\Features\OnboardingTasks

TaskLists::get_task()public staticWC 1.0

Retrieve single task.

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

No Hooks.

Return

Object.

Usage

$result = TaskLists::get_task( $id, $task_list_id );
$id(String) (required)
Task ID.
$task_list_id(String)
Task list ID.
Default: null

Code of TaskLists::get_task() WC 6.8.2

public static function get_task( $id, $task_list_id = null ) {
	$task_list = $task_list_id ? self::get_list( $task_list_id ) : null;

	if ( $task_list_id && ! $task_list ) {
		return null;
	}

	$tasks_to_search = $task_list ? $task_list->tasks : array_reduce(
		self::get_lists(),
		function ( $all, $curr ) {
			return array_merge( $all, $curr->tasks );
		},
		array()
	);

	foreach ( $tasks_to_search as $task ) {
		if ( $id === $task->get_id() ) {
			return $task;
		}
	}

	return null;
}