array( 'label' => sprintf( '--- %s ---', esc_html__( 'Standard Fonts', 'bam' ) ) ) ); $standard_fonts = bam_get_standard_fonts(); $heading2 = array( 2 => array( 'label' => sprintf( '--- %s ---', esc_html__( 'Google Fonts', 'bam' ) ) ) ); $google_fonts = bam_get_google_fonts(); return apply_filters( 'bam_all_fonts', array_merge( $heading1, $standard_fonts, $heading2, $google_fonts ) ); } if ( ! function_exists( 'bam_get_google_font_uri' ) ) : /** * Build the HTTP request URL for Google Fonts. * * @since 1.0.0 * * @return string The URL for including Google Fonts. */ function bam_get_google_font_uri( $fonts ) { // Return if google fonts are disabled. if ( true == get_theme_mod( 'bam_disable_google_fonts' ) ) { return; } // De-dupe the fonts. $fonts = array_unique( $fonts ); // Array of google fonts. $allowed_fonts = bam_get_google_fonts(); // Array to hold font families. $family = array(); foreach( $fonts as $font ) { $font = trim( $font ); // Verify that the font exists. if ( in_array( $font, $allowed_fonts ) ) { // Build the family name and variant string (e.g., "Open+Sans:regular,italic,700") $family[] = urlencode( $font . ':' . join( ',', bam_google_font_weights( $font ) ) ); } } // Convert from array to string. if ( empty( $family ) ) { return ''; } else { $request = 'https://fonts.googleapis.com/css?family=' . implode( '|', $family ); } $subsets = get_theme_mod( 'bam_font_subsets', array( 'latin' ) ); if ( empty( $subsets ) ) { $subsets = array( 'latin' ); } // Append the subset string if ( ! empty( $subsets ) ) { $request .= urlencode( '&subset=' . join( ',', $subsets ) ); } return esc_url( $request ); } endif; function bam_google_font_weights( $font ) { // Weights $weights = array( '100', '200', '300', '400', '500', '600', '700', '800', '900' ); $weights = apply_filters( 'bam_google_font_weights', $weights, $font ); $italics = apply_filters( 'bam_google_font_enqueue_italics', true ); if ( $italics ) { $italic_weights = array(); foreach( $weights as $weight ) { $italic_weights[] = $weight . 'i'; } $weights = array_merge( $weights, $italic_weights ); } return $weights; }