is_google_font( $font['font-family'] ) ) { $has_google_font = true; } } } /** * Do we have font-weights? */ if ( isset( $font['font-weight'] ) ) { $font_weights = ( ! isset( $font_weights ) ) ? array() : $font_weights; $font_weights[] = $font['font-weight']; } /** * Do we have font-subsets? */ if ( isset( $font['subsets'] ) ) { $font_subsets = ( ! isset( $font_subsets ) ) ? array() : $font_subsets; $font_subsets[] = $font['subsets']; } } /** * Make sure there are no empty values and define some sane defaults. */ $font_families = ( ! isset( $font_families ) || empty( $font_families ) ) ? false : $font_families; $font_weights = ( ! isset( $font_weights ) || empty( $font_weights ) ) ? array( '400' ) : $font_weights; $font_subsets = ( ! isset( $font_subsets ) || empty( $font_subsets ) ) ? array( 'all' ) : $font_subsets; /** * Get rid of duplicate values */ if ( is_array( $font_families ) && ! empty( $font_families ) ) { $font_families = array_unique( $font_families ); } if ( is_array( $font_weights ) && ! empty( $font_weights ) ) { $font_weights = array_unique( $font_weights ); } if ( is_array( $font_subsets ) && ! empty( $font_subsets ) ) { $font_subsets = array_unique( $font_subsets ); } if ( ! isset( $has_google_font ) || ! $has_google_font ) { $font_families = false; } // Return the font URL. return ( $font_families ) ? Kirki_Toolkit::fonts()->get_google_font_uri( $font_families, $font_weights, $font_subsets ) : false; } /** * Enqueue Google fonts if necessary */ public function google_font() { $config = apply_filters( 'kirki/config', array() ); /** * If we have set $config['disable_google_fonts'] to true * then do not proceed any further. */ if ( isset( $config['disable_google_fonts'] ) && true == $config['disable_google_fonts'] ) { return; } if ( $this->google_link() ) { $google_link = str_replace( '%3A', ':', $this->google_link() ); wp_enqueue_style( 'kirki_google_fonts', $google_link, array(), null ); } } }