// Add otf. if ( ! empty( $src['otf'] ) ) { $src_ordered[] = array( 'url' => $src['otf'], 'format' => 'opentype', ); } $font_face['src'] = $src_ordered; return $font_face; } /** * Builds the font-family's CSS. * * @since 6.4.0 * * @param array $font_face Font face to process. * @return string This font-family's CSS. */ private function build_font_face_css( array $font_face ) { $css = ''; /* * Wrap font-family in quotes if it contains spaces * and is not already wrapped in quotes. */ if ( str_contains( $font_face['font-family'], ' ' ) && ! str_contains( $font_face['font-family'], '"' ) && ! str_contains( $font_face['font-family'], "'" ) ) { $font_face['font-family'] = '"' . $font_face['font-family'] . '"'; } foreach ( $font_face as $key => $value ) { // Compile the "src" parameter. if ( 'src' === $key ) { $value = $this->compile_src( $value ); } // If font-variation-settings is an array, convert it to a string. if ( 'font-variation-settings' === $key && is_array( $value ) ) { $value = $this->compile_variations( $value ); } if ( ! empty( $value ) ) { $css .= "$key:$value;"; } } return $css; } /** * Compiles the `src` into valid CSS. * * @since 6.4.0 * * @param array $value Value to process. * @return string The CSS. */ private function compile_src( array $value ) { $src = ''; foreach ( $value as $item ) { $src .= ( 'data' === $item['format'] ) ? ", url({$item['url']})" : ", url('{$item['url']}') format('{$item['format']}')"; } $src = ltrim( $src, ', ' ); return $src; } /** * Compiles the font variation settings. * * @since 6.4.0 * * @param array $font_variation_settings Array of font variation settings. * @return string The CSS. */ private function compile_variations( array $font_variation_settings ) { $variations = ''; foreach ( $font_variation_settings as $key => $value ) { $variations .= "$key $value"; } return $variations; } } WordCamp Cologne 2015 #wccgn ∣ {hej}Chris
Fatal error: Uncaught Error: Class "WP_Font_Face" not found in /home/christ26/public_html/hejchris/wp/wp-includes/fonts.php:51 Stack trace: #0 /home/christ26/public_html/hejchris/wp/wp-includes/class-wp-hook.php(324): wp_print_font_faces(Array) #1 /home/christ26/public_html/hejchris/wp/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('<style>.breadcr...', Array) #2 /home/christ26/public_html/hejchris/wp/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #3 /home/christ26/public_html/hejchris/wp/wp-includes/general-template.php(3050): do_action('wp_head') #4 /home/christ26/public_html/hejchris/wp/wp-includes/template-canvas.php(17): wp_head() #5 /home/christ26/public_html/hejchris/wp/wp-includes/template-loader.php(106): include('/home/christ26/...') #6 /home/christ26/public_html/hejchris/wp/wp-blog-header.php(19): require_once('/home/christ26/...') #7 /home/christ26/public_html/hejchris/wp/index.php(17): require('/home/christ26/...') #8 {main} thrown in /home/christ26/public_html/hejchris/wp/wp-includes/fonts.php on line 51