- Timestamp:
- 04/26/2022 03:25:01 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-content/themes/twentytwentytwo/functions.php
r52392 r53286 55 55 ); 56 56 57 // Add styles inline.58 wp_add_inline_style( 'twentytwentytwo-style', twentytwentytwo_get_font_face_styles() );59 60 57 // Enqueue theme stylesheet. 61 58 wp_enqueue_style( 'twentytwentytwo-style' ); … … 67 64 add_action( 'wp_enqueue_scripts', 'twentytwentytwo_styles' ); 68 65 69 if ( ! function_exists( 'twentytwentytwo_editor_styles' ) ) :70 71 /**72 * Enqueue editor styles.73 *74 * @since Twenty Twenty-Two 1.075 *76 * @return void77 */78 function twentytwentytwo_editor_styles() {79 80 // Add styles inline.81 wp_add_inline_style( 'wp-block-library', twentytwentytwo_get_font_face_styles() );82 83 }84 85 endif;86 87 add_action( 'admin_init', 'twentytwentytwo_editor_styles' );88 89 90 if ( ! function_exists( 'twentytwentytwo_get_font_face_styles' ) ) :91 92 /**93 * Get font face styles.94 * Called by functions twentytwentytwo_styles() and twentytwentytwo_editor_styles() above.95 *96 * @since Twenty Twenty-Two 1.097 *98 * @return string99 */100 function twentytwentytwo_get_font_face_styles() {101 102 return "103 @font-face{104 font-family: 'Source Serif Pro';105 font-weight: 200 900;106 font-style: normal;107 font-stretch: normal;108 font-display: swap;109 src: url('" . get_theme_file_uri( 'assets/fonts/SourceSerif4Variable-Roman.ttf.woff2' ) . "') format('woff2');110 }111 112 @font-face{113 font-family: 'Source Serif Pro';114 font-weight: 200 900;115 font-style: italic;116 font-stretch: normal;117 font-display: swap;118 src: url('" . get_theme_file_uri( 'assets/fonts/SourceSerif4Variable-Italic.ttf.woff2' ) . "') format('woff2');119 }120 ";121 122 }123 124 endif;125 126 if ( ! function_exists( 'twentytwentytwo_preload_webfonts' ) ) :127 128 /**129 * Preloads the main web font to improve performance.130 *131 * Only the main web font (font-style: normal) is preloaded here since that font is always relevant (it is used132 * on every heading, for example). The other font is only needed if there is any applicable content in italic style,133 * and therefore preloading it would in most cases regress performance when that font would otherwise not be loaded134 * at all.135 *136 * @since Twenty Twenty-Two 1.0137 *138 * @return void139 */140 function twentytwentytwo_preload_webfonts() {141 ?>142 <link rel="preload" href="<?php echo esc_url( get_theme_file_uri( 'assets/fonts/SourceSerif4Variable-Roman.ttf.woff2' ) ); ?>" as="font" type="font/woff2" crossorigin>143 <?php144 }145 146 endif;147 148 add_action( 'wp_head', 'twentytwentytwo_preload_webfonts' );149 150 66 // Add block patterns 151 67 require get_template_directory() . '/inc/block-patterns.php';
Note: See TracChangeset
for help on using the changeset viewer.