Automattic\WooCommerce\Admin\Features\OnboardingTasks
TaskLists::setup_tasks_remaining
Return number of setup tasks remaining
This is not updated immediately when a task is completed, but rather when task is marked as complete in the database to reduce performance impact.
Method of the class: TaskLists{}
No Hooks.
Returns
Int|null.
Usage
$result = TaskLists::setup_tasks_remaining();
TaskLists::setup_tasks_remaining() TaskLists::setup tasks remaining code WC 10.7.0
public static function setup_tasks_remaining() {
$setup_list = self::get_list( 'setup' );
if ( ! $setup_list || $setup_list->is_hidden() || $setup_list->has_previously_completed() ) {
return;
}
$viewable_tasks = $setup_list->get_viewable_tasks();
$completed_tasks = get_option( Task::COMPLETED_OPTION, array() );
if ( ! is_array( $completed_tasks ) ) {
$completed_tasks = array();
}
return count(
array_filter(
$viewable_tasks,
function ( $task ) use ( $completed_tasks ) {
return ! in_array( $task->get_id(), $completed_tasks, true );
}
)
);
}