- Timestamp:
- 02/07/2023 03:57:06 PM (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-content/themes/twentyfourteen/functions.php
r54492 r55270 68 68 load_theme_textdomain( 'twentyfourteen' ); 69 69 70 // This theme styles the visual editor to resemble the theme style. 71 add_editor_style( array( 'css/editor-style.css', twentyfourteen_font_url(), 'genericons/genericons.css' ) ); 70 /* 71 * This theme styles the visual editor to resemble the theme style. 72 * When fonts are self-hosted, the theme directory needs to be removed first. 73 */ 74 $font_stylesheet = str_replace( 75 array( get_template_directory_uri() . '/', get_stylesheet_directory_uri() . '/' ), 76 '', 77 twentyfourteen_font_url() 78 ); 79 add_editor_style( array( 'css/editor-style.css', $font_stylesheet, 'genericons/genericons.css' ) ); 72 80 73 81 // Load regular editor styles into the new block-based editor. … … 294 302 add_action( 'widgets_init', 'twentyfourteen_widgets_init' ); 295 303 296 /** 297 * Register Lato Google font for Twenty Fourteen. 298 * 299 * @since Twenty Fourteen 1.0 300 * 301 * @return string 302 */ 303 function twentyfourteen_font_url() { 304 $font_url = ''; 305 /* 306 * translators: If there are characters in your language that are not supported 307 * by Lato, translate this to 'off'. Do not translate into your own language. 304 if ( ! function_exists( 'twentyfourteen_font_url' ) ) : 305 /** 306 * Register Lato font for Twenty Fourteen. 307 * 308 * @since Twenty Fourteen 1.0 309 * @since Twenty Fourteen 3.6 Replaced Google URL with self-hosted fonts. 310 * 311 * @return string 308 312 */ 309 if ( 'off' !== _x( 'on', 'Lato font: on or off', 'twentyfourteen' ) ) { 310 $query_args = array( 311 'family' => urlencode( 'Lato:300,400,700,900,300italic,400italic,700italic' ), 312 'subset' => urlencode( 'latin,latin-ext' ), 313 'display' => urlencode( 'fallback' ), 314 ); 315 $font_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' ); 316 } 317 318 return $font_url; 319 } 313 function twentyfourteen_font_url() { 314 $font_url = ''; 315 /* 316 * translators: If there are characters in your language that are not supported 317 * by Lato, translate this to 'off'. Do not translate into your own language. 318 */ 319 if ( 'off' !== _x( 'on', 'Lato font: on or off', 'twentyfourteen' ) ) { 320 $font_url = get_template_directory_uri() . '/fonts/font-lato.css'; 321 } 322 323 return $font_url; 324 } 325 endif; 320 326 321 327 /** … … 326 332 function twentyfourteen_scripts() { 327 333 // Add Lato font, used in the main stylesheet. 328 wp_enqueue_style( 'twentyfourteen-lato', twentyfourteen_font_url(), array(), null ); 334 $font_version = ( 0 === strpos( (string) twentyfourteen_font_url(), get_template_directory_uri() . '/' ) ) ? '20230328' : null; 335 wp_enqueue_style( 'twentyfourteen-lato', twentyfourteen_font_url(), array(), $font_version ); 329 336 330 337 // Add Genericons font, used in the main stylesheet. … … 370 377 371 378 /** 372 * Enqueue Google fonts styleto admin screen for custom header display.379 * Enqueue font stylesheet to admin screen for custom header display. 373 380 * 374 381 * @since Twenty Fourteen 1.0 375 382 */ 376 383 function twentyfourteen_admin_fonts() { 377 wp_enqueue_style( 'twentyfourteen-lato', twentyfourteen_font_url(), array(), null ); 384 $font_version = ( 0 === strpos( (string) twentyfourteen_font_url(), get_template_directory_uri() . '/' ) ) ? '20230328' : null; 385 wp_enqueue_style( 'twentyfourteen-lato', twentyfourteen_font_url(), array(), $font_version ); 378 386 } 379 387 add_action( 'admin_print_scripts-appearance_page_custom-header', 'twentyfourteen_admin_fonts' ); … … 383 391 * 384 392 * @since Twenty Fourteen 1.9 393 * @deprecated Twenty Fourteen 3.6 Disabled filter because, by default, fonts are self-hosted. 385 394 * 386 395 * @param array $urls URLs to print for resource hints. … … 402 411 return $urls; 403 412 } 404 add_filter( 'wp_resource_hints', 'twentyfourteen_resource_hints', 10, 2 );413 // add_filter( 'wp_resource_hints', 'twentyfourteen_resource_hints', 10, 2 ); 405 414 406 415 /** … … 413 422 wp_enqueue_style( 'twentyfourteen-block-editor-style', get_template_directory_uri() . '/css/editor-blocks.css', array(), '20210216' ); 414 423 // Add custom fonts. 415 wp_enqueue_style( 'twentyfourteen-fonts', twentyfourteen_font_url(), array(), null ); 424 $font_version = ( 0 === strpos( (string) twentyfourteen_font_url(), get_template_directory_uri() . '/' ) ) ? '20230328' : null; 425 wp_enqueue_style( 'twentyfourteen-fonts', twentyfourteen_font_url(), array(), $font_version ); 416 426 } 417 427 add_action( 'enqueue_block_editor_assets', 'twentyfourteen_block_editor_styles' );
Note: See TracChangeset
for help on using the changeset viewer.