WP_Font_Face::get_css
Gets the @font-face CSS styles for locally-hosted font files.
This method does the following processing tasks:
1. Orchestrates an optimized `src` (with format) for browser support. 2. Generates the `@font-face` for all its fonts.
Method of the class: WP_Font_Face{}
No Hooks.
Returns
String. The @font-face CSS styles.
Usage
// private - for code of main (parent) class only $result = $this->get_css( $font_faces );
- $font_faces(array[]) (required)
- The font-faces to generate @font-face CSS styles.
Changelog
| Since 6.4.0 | Introduced. |
WP_Font_Face::get_css() WP Font Face::get css code WP 7.0
private function get_css( $font_faces ) {
$css = '';
foreach ( $font_faces as $font_face ) {
// Order the font's `src` items to optimize for browser support.
$font_face = $this->order_src( $font_face );
// Build the @font-face CSS for this font.
$css .= '@font-face{' . $this->build_font_face_css( $font_face ) . '}' . "\n";
}
// Don't print the last newline character.
return rtrim( $css, "\n" );
}