- Timestamp:
- 02/07/2023 04:43:48 PM (19 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-content/themes/twentythirteen/functions.php
r55004 r55274 81 81 /* 82 82 * This theme styles the visual editor to resemble the theme style, 83 * specifically font, colors, icons, and column width. 84 */ 85 add_editor_style( array( 'css/editor-style.css', 'genericons/genericons.css', twentythirteen_fonts_url() ) ); 83 * specifically font, colors, icons, and column width. When fonts are 84 * self-hosted, the theme directory needs to be removed first. 85 */ 86 $font_stylesheet = str_replace( 87 array( get_template_directory_uri() . '/', get_stylesheet_directory_uri() . '/' ), 88 '', 89 twentythirteen_fonts_url() 90 ); 91 add_editor_style( array( 'css/editor-style.css', 'genericons/genericons.css', $font_stylesheet ) ); 86 92 87 93 // Load regular editor styles into the new block-based editor. … … 244 250 add_action( 'after_setup_theme', 'twentythirteen_setup' ); 245 251 246 /** 247 * Return the Google font stylesheet URL, if available. 248 * 249 * The use of Source Sans Pro and Bitter by default is localized. For languages 250 * that use characters not supported by the font, the font can be disabled. 251 * 252 * @since Twenty Thirteen 1.0 253 * 254 * @return string Font stylesheet or empty string if disabled. 255 */ 256 function twentythirteen_fonts_url() { 257 $fonts_url = ''; 258 259 /* 260 * translators: If there are characters in your language that are not supported 261 * by Source Sans Pro, translate this to 'off'. Do not translate into your own language. 262 */ 263 $source_sans_pro = _x( 'on', 'Source Sans Pro font: on or off', 'twentythirteen' ); 264 265 /* 266 * translators: If there are characters in your language that are not supported 267 * by Bitter, translate this to 'off'. Do not translate into your own language. 268 */ 269 $bitter = _x( 'on', 'Bitter font: on or off', 'twentythirteen' ); 270 271 if ( 'off' !== $source_sans_pro || 'off' !== $bitter ) { 272 $font_families = array(); 273 274 if ( 'off' !== $source_sans_pro ) { 275 $font_families[] = 'Source Sans Pro:300,400,700,300italic,400italic,700italic'; 276 } 277 278 if ( 'off' !== $bitter ) { 279 $font_families[] = 'Bitter:400,700'; 280 } 281 282 $query_args = array( 283 'family' => urlencode( implode( '|', $font_families ) ), 284 'subset' => urlencode( 'latin,latin-ext' ), 285 'display' => urlencode( 'fallback' ), 286 ); 287 $fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' ); 288 } 289 290 return $fonts_url; 291 } 252 if ( ! function_exists( 'twentythirteen_fonts_url' ) ) : 253 /** 254 * Return the font stylesheet URL, if available. 255 * 256 * The use of Source Sans Pro and Bitter by default is localized. For languages 257 * that use characters not supported by the font, the font can be disabled. 258 * 259 * @since Twenty Thirteen 1.0 260 * @since Twenty Thirteen 3.8 Replaced Google URL with self-hosted fonts. 261 * 262 * @return string Font stylesheet or empty string if disabled. 263 */ 264 function twentythirteen_fonts_url() { 265 $fonts_url = ''; 266 267 /* 268 * translators: If there are characters in your language that are not supported 269 * by Source Sans Pro, translate this to 'off'. Do not translate into your own language. 270 */ 271 $source_sans_pro = _x( 'on', 'Source Sans Pro font: on or off', 'twentythirteen' ); 272 273 /* 274 * translators: If there are characters in your language that are not supported 275 * by Bitter, translate this to 'off'. Do not translate into your own language. 276 */ 277 $bitter = _x( 'on', 'Bitter font: on or off', 'twentythirteen' ); 278 279 if ( 'off' !== $source_sans_pro || 'off' !== $bitter ) { 280 $font_families = array(); 281 282 if ( 'off' !== $source_sans_pro ) { 283 $font_families[] = 'source-sans-pro'; 284 } 285 286 if ( 'off' !== $bitter ) { 287 $font_families[] = 'bitter'; 288 } 289 290 $fonts_url = get_template_directory_uri() . '/fonts/' . implode( '-plus-', $font_families ) . '.css'; 291 } 292 293 return $fonts_url; 294 } 295 endif; 292 296 293 297 /** … … 314 318 315 319 // Add Source Sans Pro and Bitter fonts, used in the main stylesheet. 316 wp_enqueue_style( 'twentythirteen-fonts', twentythirteen_fonts_url(), array(), null ); 320 $font_version = ( 0 === strpos( (string) twentythirteen_fonts_url(), get_template_directory_uri() . '/' ) ) ? '20230328' : null; 321 wp_enqueue_style( 'twentythirteen-fonts', twentythirteen_fonts_url(), array(), $font_version ); 317 322 318 323 // Add Genericons font, used in the main stylesheet. … … 335 340 * 336 341 * @since Twenty Thirteen 2.1 342 * @deprecated Twenty Thirteen 3.8 Disabled filter because, by default, fonts are self-hosted. 337 343 * 338 344 * @param array $urls URLs to print for resource hints. … … 354 360 return $urls; 355 361 } 356 add_filter( 'wp_resource_hints', 'twentythirteen_resource_hints', 10, 2 );362 // add_filter( 'wp_resource_hints', 'twentythirteen_resource_hints', 10, 2 ); 357 363 358 364 /** … … 365 371 wp_enqueue_style( 'twentythirteen-block-editor-style', get_template_directory_uri() . '/css/editor-blocks.css', array(), '20210621' ); 366 372 // Add custom fonts. 367 wp_enqueue_style( 'twentythirteen-fonts', twentythirteen_fonts_url(), array(), null ); 373 $font_version = ( 0 === strpos( (string) twentythirteen_fonts_url(), get_template_directory_uri() . '/' ) ) ? '20230328' : null; 374 wp_enqueue_style( 'twentythirteen-fonts', twentythirteen_fonts_url(), array(), $font_version ); 368 375 } 369 376 add_action( 'enqueue_block_editor_assets', 'twentythirteen_block_editor_styles' );
Note: See TracChangeset
for help on using the changeset viewer.