Skip to content

Commit

Permalink
Allow loading Google Fonts that are hosted locally only VisualCompose…
Browse files Browse the repository at this point in the history
  • Loading branch information
dmytro-kovalov committed Jul 4, 2022
1 parent 77660d3 commit 62b2d26
Showing 1 changed file with 27 additions and 12 deletions.
39 changes: 27 additions & 12 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,15 @@ function visualcomposerstarter_style() {
/* Theme stylesheet */
wp_register_style( 'visualcomposerstarter-style', get_stylesheet_uri() );

/* Enqueue styles */
if ( get_theme_mod( 'vct_overall_site_enable_bootstrap', false ) === true ) {
wp_enqueue_style( 'bootstrap' );
}
wp_enqueue_style( 'visualcomposerstarter-font' );
wp_enqueue_style( 'visualcomposerstarter-general' );
wp_enqueue_style( 'visualcomposerstarter-responsive' );
wp_enqueue_style( 'visualcomposerstarter-style' );

/* Font options */
$fonts = array(
get_theme_mod( 'vct_fonts_and_style_body_font_family', 'Roboto, sans-serif' ),
Expand All @@ -392,20 +401,26 @@ function visualcomposerstarter_style() {
get_theme_mod( 'vct_fonts_and_style_buttons_font_family', 'Montserrat' ),
);

$font_uri = VisualComposerStarter_Fonts::vct_theme_get_google_font_uri( $fonts );
/* Load Google Fonts (hosted locally) */
foreach ( $fonts as $font ) {
if ( ! VisualComposerStarter_Fonts::is_google_font( $font ) ) {
continue;
}

/* Load Google Fonts */
wp_register_style( 'visualcomposerstarter-fonts', $font_uri, array(), null, 'screen' );
if ( ! VisualComposerStarter_Fonts::is_google_font_exists_locally( $font ) ) {
continue;
}

/* Enqueue styles */
if ( get_theme_mod( 'vct_overall_site_enable_bootstrap', false ) === true ) {
wp_enqueue_style( 'bootstrap' );
$font_id = VisualComposerStarter_Fonts::get_google_font_id( $font );
$font_uri = VisualComposerStarter_Fonts::get_google_font_uri( $font );
wp_enqueue_style(
"visualcomposerstarter-font-{$font_id}",
esc_url( $font_uri ),
array(),
null,
'screen'
);
}
wp_enqueue_style( 'visualcomposerstarter-font' );
wp_enqueue_style( 'visualcomposerstarter-general' );
wp_enqueue_style( 'visualcomposerstarter-responsive' );
wp_enqueue_style( 'visualcomposerstarter-style' );
wp_enqueue_style( 'visualcomposerstarter-fonts' );
}
}// End if().
add_action( 'wp_enqueue_scripts', 'visualcomposerstarter_style' );
Expand Down Expand Up @@ -460,7 +475,7 @@ function visualcomposerstarter_script() {
* @see add_action('customize_preview_init',$func)
*/
function visualcomposerstarter_customizer_live_preview() {
wp_enqueue_script( 'visualcomposerstarter-themecustomizer', get_template_directory_uri() . '/js/customize-preview.min.js', array(
wp_enqueue_script( 'visualcomposerstarter-themecustomizer', get_template_directory_uri() . '/js/customize-preview.js', array(
'jquery',
'customize-preview',
), '', true );
Expand Down

0 comments on commit 62b2d26

Please sign in to comment.