ont families to install. * @param array $font_collection Font collection. * @return array */ private static function install_font_families( $slug_font_families_to_install, $font_collection ) { return array_reduce( $slug_font_families_to_install, function( $carry, $slug ) use ( $font_collection ) { $font_family_from_collection = self::get_font_family_by_slug_from_font_collection( $slug, $font_collection ); $font_family_name = $font_family_from_collection['fontFamily']; $font_family_installed = FontFamily::get_font_family_by_name( $font_family_name ); if ( $font_family_installed ) { return array_merge( $carry, array( $slug => $font_family_installed ) ); } $font_family_settings = array( 'fontFamily' => $font_family_from_collection['fontFamily'], 'preview' => $font_family_from_collection['preview'], 'slug' => $font_family_from_collection['slug'], 'name' => $font_family_from_collection['name'], ); $font_family_id = FontFamily::insert_font_family( $font_family_settings ); if ( is_wp_error( $font_family_id ) ) { if ( 'duplicate_font_family' !== $font_family_id->get_error_code() ) { wc_get_logger()->error( sprintf( 'Font Family installation error: %s', $font_family_id->get_error_message(), ), array( 'source' => self::SOURCE_LOGGER ) ); } return $carry; } return array_merge( $carry, array( $slug => get_post( $font_family_id ) ) ); }, array(), ); } /** * Install font faces. * * @param array $slug_font_families_to_install Font families to install. * @param array $installed_font_families Installed font families. * @param array $font_faces_from_collection Font faces from collection. */ private static function install_font_faces( $slug_font_families_to_install, $installed_font_families, $font_faces_from_collection ) { foreach ( $slug_font_families_to_install as $slug ) { $font_family = $installed_font_families[ $slug ]; $font_faces = $font_faces_from_collection[ $slug ]; $font_faces_to_install = self::FONT_FAMILIES_TO_INSTALL[ $slug ]['fontWeights']; foreach ( $font_faces as $font_face ) { if ( ! in_array( $font_face['fontWeight'], $font_faces_to_install, true ) ) { continue; } $slug = \WP_Font_Utils::get_font_face_slug( $font_face ); $font_face_installed = FontFace::get_installed_font_faces_by_slug( $slug ); if ( $font_face_installed ) { continue; } $wp_error = FontFace::insert_font_face( $font_face, $font_family->ID ); if ( is_wp_error( $wp_error ) ) { wc_get_logger()->error( sprintf( /* translators: %s: error message */ __( 'Font Face installation error: %s', 'woocommerce' ), $wp_error->get_error_message() ), array( 'source' => self::SOURCE_LOGGER ) ); } } } } /** * Get font faces data from font collection. * * @param array $slug_font_families_to_install Font families to install. * @param array $font_collection Font collection. * @return array */ private static function get_font_faces_data_from_font_collection( $slug_font_families_to_install, $font_collection ) { return array_reduce( $slug_font_families_to_install, function( $carry, $slug ) use ( $font_collection ) { $font_family = self::get_font_family_by_slug_from_font_collection( $slug, $font_collection ); if ( ! $font_family ) { return $carry; } return array_merge( $carry, array( $slug => $font_family['fontFace'] ) ); }, array() ); } /** * Get font family by slug from font collection. * * @param string $slug Font slug. * @param array $font_families_collection Font families collection. * @return array|null */ private static function get_font_family_by_slug_from_font_collection( $slug, $font_families_collection ) { $font_family = null; foreach ( $font_families_collection as $font_family ) { if ( $font_family['font_family_settings']['slug'] === $slug ) { $font_family = $font_family['font_family_settings']; break; } } return $font_family; } }
Fatal error: Uncaught Error: Class "Automattic\WooCommerce\Internal\Admin\Onboarding\OnboardingFonts" not found in /htdocs/wp-content/plugins/woocommerce/src/Internal/Admin/Onboarding/Onboarding.php:26 Stack trace: #0 /htdocs/wp-content/plugins/woocommerce/src/Internal/Admin/FeaturePlugin.php(160): Automattic\WooCommerce\Internal\Admin\Onboarding\Onboarding::init() #1 /htdocs/wp-content/plugins/woocommerce/src/Internal/Admin/FeaturePlugin.php(98): Automattic\WooCommerce\Internal\Admin\FeaturePlugin->includes() #2 /htdocs/wp-content/plugins/woocommerce/src/Internal/Admin/FeaturePlugin.php(81): Automattic\WooCommerce\Internal\Admin\FeaturePlugin->on_plugins_loaded() #3 /htdocs/wp-content/plugins/woocommerce/src/Admin/Composer/Package.php(65): Automattic\WooCommerce\Internal\Admin\FeaturePlugin->init() #4 [internal function]: Automattic\WooCommerce\Admin\Composer\Package::init() #5 /htdocs/wp-content/plugins/woocommerce/src/Packages.php(275): call_user_func(Array) #6 /htdocs/wp-content/plugins/woocommerce/src/Packages.php(85): Automattic\WooCommerce\Packages::initialize_packages() #7 /htdocs/wp-includes/class-wp-hook.php(324): Automattic\WooCommerce\Packages::on_init('') #8 /htdocs/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #9 /htdocs/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #10 /htdocs/wp-settings.php(559): do_action('plugins_loaded') #11 /htdocs/wp-config.php(114): require_once('/htdocs/wp-sett...') #12 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #13 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #14 /htdocs/index.php(17): require('/htdocs/wp-blog...') #15 {main} thrown in /htdocs/wp-content/plugins/woocommerce/src/Internal/Admin/Onboarding/Onboarding.php on line 26