=> 'setup', 'tasks' => array( 'ExperimentalShippingRecommendation', ), 'event_prefix' => 'secret_tasklist_', 'visible' => false, ) ); } if ( ! wp_is_mobile() ) { // Permit In-App Marketplace Tour on desktops only. $tour_task = new TourInAppMarketplace(); self::add_task( 'extended', $tour_task ); } if ( has_filter( 'woocommerce_admin_experimental_onboarding_tasklists' ) ) { /** * Filter to override default task lists. * * @since 7.4 * @param array $lists Array of tasklists. */ self::$lists = apply_filters( 'woocommerce_admin_experimental_onboarding_tasklists', self::$lists ); } } /** * Initialize tasks. */ public static function init_tasks() { foreach ( self::DEFAULT_TASKS as $task ) { $class = 'Automattic\WooCommerce\Admin\Features\OnboardingTasks\Tasks\\' . $task; if ( ! method_exists( $class, 'init' ) ) { continue; } $class::init(); } } /** * Temporarily store the active task to persist across page loads when necessary. * Most tasks do not need this. */ 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(); } /** * Add a task list. * * @param array $args Task list properties. * @return \WP_Error|TaskList */ public static function add_list( $args ) { if ( isset( self::$lists[ $args['id'] ] ) ) { return new \WP_Error( 'woocommerce_task_list_exists', __( 'Task list ID already exists', 'woocommerce' ) ); } self::$lists[ $args['id'] ] = new TaskList( $args ); return self::$lists[ $args['id'] ]; } /** * Add task to a given task list. * * @param string $list_id List ID to add the task to. * @param Task $task Task object. * * @return \WP_Error|Task */ public static function add_task( $list_id, $task ) { if ( ! isset( self::$lists[ $list_id ] ) ) { return new \WP_Error( 'woocommerce_task_list_invalid_list', __( 'Task list ID does not exist', 'woocommerce' ) ); } self::$lists[ $list_id ]->add_task( $task ); } /** * Add default extended task lists. * * @param array $extended_tasks list of extended tasks. */ public static function maybe_add_extended_tasks( $extended_tasks ) { $tasks = $extended_tasks ?? array(); foreach ( self::$lists as $task_list ) { if ( 'extended' !== substr( $task_list->id, 0, 8 ) ) { continue; } foreach ( $tasks as $args ) { $task = new DeprecatedExtendedTask( $task_list, $args ); $task_list->add_task( $task ); } } } /** * Get all task lists. * * @return array */ public static function get_lists() { return self::$lists; } /** * Get all task lists. * * @param array $ids list of task list ids. * @return array */ public static function get_lists_by_ids( $ids ) { return array_filter( self::$lists, function( $list ) use ( $ids ) { return in_array( $list->get_list_id(), $ids, true ); } ); } /** * Get all task list ids. * * @return array */ public static function get_list_ids() { return array_keys( self::$lists ); } /** * Clear all task lists. */ public static function clear_lists() { self::$lists = array(); return self::$lists; } /** * Get visible task lists. */ public static function get_visible() { return array_filter( self::get_lists(), function ( $task_list ) { return $task_list->is_visible(); } ); } /** * Retrieve a task list by ID. * * @param String $id Task list ID. * * @return TaskList|null */ public static function get_list( $id ) { if ( isset( self::$lists[ $id ] ) ) { return self::$lists[ $id ]; } return null; } /** * Retrieve single task. * * @param String $id Task ID. * @param String $task_list_id Task list ID. * * @return Object */ 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; } /** * Return number of setup tasks remaining * * @return number */ public static function setup_tasks_remaining() { $setup_list = self::get_list( 'setup' ); if ( ! $setup_list || $setup_list->is_hidden() || $setup_list->is_complete() ) { return; } $remaining_tasks = array_values( array_filter( $setup_list->get_viewable_tasks(), function( $task ) { return ! $task->is_complete(); } ) ); return count( $remaining_tasks ); } /** * Add badge to homescreen menu item for remaining tasks */ public static function menu_task_count() { global $submenu; $tasks_count = self::setup_tasks_remaining(); if ( ! $tasks_count || ! isset( $submenu['woocommerce'] ) ) { return; } foreach ( $submenu['woocommerce'] as $key => $menu_item ) { if ( 0 === strpos( $menu_item[0], _x( 'Home', 'Admin menu name', 'woocommerce' ) ) ) { $submenu['woocommerce'][ $key ][0] .= ' ' . number_format_i18n( $tasks_count ) . ''; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited break; } } } /** * Add visible list ids to component settings. * * @param array $settings Component settings. * * @return array */ public static function task_list_preloaded_settings( $settings ) { $settings['visibleTaskListIds'] = array_keys( self::get_visible() ); return $settings; } }
Fatal error: Uncaught Error: Class "Automattic\WooCommerce\Admin\Features\OnboardingTasks\TaskLists" not found in /htdocs/wp-content/plugins/woocommerce/src/Admin/Features/OnboardingTasks/Init.php:36 Stack trace: #0 /htdocs/wp-content/plugins/woocommerce/src/Admin/Features/Features.php(138): Automattic\WooCommerce\Admin\Features\OnboardingTasks\Init->__construct() #1 /htdocs/wp-includes/class-wp-hook.php(310): Automattic\WooCommerce\Admin\Features\Features::load_features('') #2 /htdocs/wp-includes/class-wp-hook.php(334): WP_Hook->apply_filters(NULL, Array) #3 /htdocs/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #4 /htdocs/wp-settings.php(632): do_action('init') #5 /htdocs/wp-config.php(96): require_once('/htdocs/wp-sett...') #6 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #7 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #8 /htdocs/index.php(17): require('/htdocs/wp-blog...') #9 {main} thrown in /htdocs/wp-content/plugins/woocommerce/src/Admin/Features/OnboardingTasks/Init.php on line 36