'woocommerce-home', 'title' => __( 'Home', 'woocommerce-admin' ), 'parent' => 'woocommerce', 'path' => self::MENU_SLUG, 'is_top_level' => true, 'order' => 0, ) ); } /** * Update the WooCommerce menu structure to make our main dashboard/handler * the top level link for 'WooCommerce'. */ public function update_link_structure() { global $submenu; // User does not have capabilites to see the submenu. if ( ! current_user_can( 'manage_woocommerce' ) || empty( $submenu['woocommerce'] ) ) { return; } $wc_admin_key = null; foreach ( $submenu['woocommerce'] as $submenu_key => $submenu_item ) { if ( self::MENU_SLUG === $submenu_item[2] ) { $wc_admin_key = $submenu_key; break; } } if ( ! $wc_admin_key ) { return; } $menu = $submenu['woocommerce'][ $wc_admin_key ]; // Move menu item to top of array. unset( $submenu['woocommerce'][ $wc_admin_key ] ); array_unshift( $submenu['woocommerce'], $menu ); } /** * Gets an array of plugins that can be installed & activated via the home screen. * * @param array $plugins Array of plugin slugs to be allowed. * * @return array */ public static function get_homescreen_allowed_plugins( $plugins ) { $homescreen_plugins = array( 'jetpack' => 'jetpack/jetpack.php', ); return array_merge( $plugins, $homescreen_plugins ); } /** * Preload options to prime state of the application. * * @param array $options Array of options to preload. * @return array */ public function preload_options( $options ) { $options[] = 'woocommerce_default_homepage_layout'; return $options; } /** * Add data to the shared component settings. * * @param array $settings Shared component settings. */ public function component_settings( $settings ) { $allowed_statuses = Loader::get_order_statuses( wc_get_order_statuses() ); // Remove the Draft Order status (from the Checkout Block). unset( $allowed_statuses['checkout-draft'] ); $status_counts = array_map( 'wc_orders_count', array_keys( $allowed_statuses ) ); $settings['orderCount'] = array_sum( $status_counts ); return $settings; } }