Changeset 55267 for trunk/src/wp-content/themes/twentysixteen/functions.php
- Timestamp:
- 02/07/2023 03:43:01 PM (20 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-content/themes/twentysixteen/functions.php
r54492 r55267 135 135 /* 136 136 * This theme styles the visual editor to resemble the theme style, 137 * specifically font, colors, icons, and column width. 138 */ 139 add_editor_style( array( 'css/editor-style.css', twentysixteen_fonts_url() ) ); 137 * specifically font, colors, icons, and column width. When fonts are 138 * self-hosted, the theme directory needs to be removed first. 139 */ 140 $font_stylesheet = str_replace( 141 array( get_template_directory_uri() . '/', get_stylesheet_directory_uri() . '/' ), 142 '', 143 twentysixteen_fonts_url() 144 ); 145 add_editor_style( array( 'css/editor-style.css', $font_stylesheet ) ); 140 146 141 147 // Load regular editor styles into the new block-based editor. … … 242 248 * 243 249 * @since Twenty Sixteen 1.6 250 * @deprecated Twenty Sixteen 2.9 Disabled filter because, by default, fonts are self-hosted. 244 251 * 245 252 * @param array $urls URLs to print for resource hints. … … 257 264 return $urls; 258 265 } 259 add_filter( 'wp_resource_hints', 'twentysixteen_resource_hints', 10, 2 );266 // add_filter( 'wp_resource_hints', 'twentysixteen_resource_hints', 10, 2 ); 260 267 261 268 /** … … 307 314 if ( ! function_exists( 'twentysixteen_fonts_url' ) ) : 308 315 /** 309 * Register Googlefonts for Twenty Sixteen.316 * Register fonts for Twenty Sixteen. 310 317 * 311 318 * Create your own twentysixteen_fonts_url() function to override in a child theme. 312 319 * 313 320 * @since Twenty Sixteen 1.0 321 * @since Twenty Sixteen 2.9 Replaced Google URL with self-hosted fonts. 314 322 * 315 * @return string Google fonts URL for the theme.323 * @return string Fonts URL for the theme. 316 324 */ 317 325 function twentysixteen_fonts_url() { 318 326 $fonts_url = ''; 319 327 $fonts = array(); 320 $subsets = 'latin,latin-ext';321 328 322 329 /* … … 325 332 */ 326 333 if ( 'off' !== _x( 'on', 'Merriweather font: on or off', 'twentysixteen' ) ) { 327 $fonts[] = ' Merriweather:400,700,900,400italic,700italic,900italic';334 $fonts[] = 'merriweather'; 328 335 } 329 336 … … 333 340 */ 334 341 if ( 'off' !== _x( 'on', 'Montserrat font: on or off', 'twentysixteen' ) ) { 335 $fonts[] = ' Montserrat:400,700';342 $fonts[] = 'montserrat'; 336 343 } 337 344 … … 341 348 */ 342 349 if ( 'off' !== _x( 'on', 'Inconsolata font: on or off', 'twentysixteen' ) ) { 343 $fonts[] = ' Inconsolata:400';350 $fonts[] = 'inconsolata'; 344 351 } 345 352 346 353 if ( $fonts ) { 347 $fonts_url = add_query_arg( 348 array( 349 'family' => urlencode( implode( '|', $fonts ) ), 350 'subset' => urlencode( $subsets ), 351 'display' => urlencode( 'fallback' ), 352 ), 353 'https://fonts.googleapis.com/css' 354 ); 354 $fonts_url = get_template_directory_uri() . '/fonts/' . implode( '-plus-', $fonts ) . '.css'; 355 355 } 356 356 … … 378 378 function twentysixteen_scripts() { 379 379 // Add custom fonts, used in the main stylesheet. 380 wp_enqueue_style( 'twentysixteen-fonts', twentysixteen_fonts_url(), array(), null ); 380 $font_version = ( 0 === strpos( (string) twentysixteen_fonts_url(), get_template_directory_uri() . '/' ) ) ? '20230328' : null; 381 wp_enqueue_style( 'twentysixteen-fonts', twentysixteen_fonts_url(), array(), $font_version ); 381 382 382 383 // Add Genericons, used in the main stylesheet. … … 437 438 wp_enqueue_style( 'twentysixteen-block-editor-style', get_template_directory_uri() . '/css/editor-blocks.css', array(), '20221004' ); 438 439 // Add custom fonts. 439 wp_enqueue_style( 'twentysixteen-fonts', twentysixteen_fonts_url(), array(), null ); 440 $font_version = ( 0 === strpos( (string) twentysixteen_fonts_url(), get_template_directory_uri() . '/' ) ) ? '20230328' : null; 441 wp_enqueue_style( 'twentysixteen-fonts', twentysixteen_fonts_url(), array(), $font_version ); 440 442 } 441 443 add_action( 'enqueue_block_editor_assets', 'twentysixteen_block_editor_styles' );
Note: See TracChangeset
for help on using the changeset viewer.