![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /proc/self/cwd/wp-content/plugins/colibri-page-builder/extend-builder/ |
<?php namespace ExtendBuilder; use ColibriWP\PageBuilder\GoogleFontsLocalLoader; add_filter('extend_builder/google_fonts', function ($fonts) { $page_fonts = array(); $data = get_current_data(); foreach ($data['partials'] as $partial_type => $partial) { $partial_fonts = array_get_value($partial, 'meta.fonts.google'); if ($partial_fonts) { $page_fonts = array_merge_recursive($page_fonts, $partial_fonts); } } //global fonts// $theme_fonts = array_get_value($data, 'options.theme.fonts.google'); $fonts = array_merge_recursive($page_fonts, $theme_fonts); return $fonts; }); function enqueue_google_fonts() { $fonts = array(); $fonts = apply_filters("extend_builder/google_fonts", $fonts); if (!count($fonts)) { return; } $fontQuery = array(); foreach ($fonts as $family => $font) { $fontQuery[] = $family . ":" . implode(',', $font['weights']); } $data = get_current_data(); $use_local_fonts = array_get_value($data, 'options.theme.global.googleFonts.serveLocally', false); if(!$use_local_fonts) { $query_args = array( 'family' => urlencode(implode('|', $fontQuery)), 'subset' => urlencode('latin,latin-ext'), 'display'=> 'swap' ); $fontsURL = add_query_arg($query_args, 'https://fonts.googleapis.com/css'); wp_enqueue_style(prefix() . '-fonts', $fontsURL, array(), null); } else { $fontsQueryString = implode('|', $fontQuery); GoogleFontsLocalLoader::enqueuLocalGoogleFonts( $fontsQueryString ); } } add_action('wp_enqueue_scripts', '\ExtendBuilder\enqueue_google_fonts');