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.
Метод класса: TaskLists{}
Хуков нет.
Возвращает
int|null.
Использование
$result = TaskLists::setup_tasks_remaining();
Код TaskLists::setup_tasks_remaining() TaskLists::setup tasks remaining WC 11.0.1
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 );
}
)
);
}