twentythirteen_fonts_url

Return the Google font stylesheet URL, if available.

Description

(string) twentythirteen_fonts_url(); 

The use of Source Sans Pro and Bitter by default is localized. For languages that use characters not supported by the font, the font can be disabled.

Returns (string)

Font stylesheet or empty string if disabled.


Usage

  1. if ( !function_exists( 'twentythirteen_fonts_url' ) ) { 
  2. require_once '/functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = twentythirteen_fonts_url(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/functions.php  
  1. function twentythirteen_fonts_url() { 
  2. $fonts_url = ''; 
  3.  
  4. /** Translators: If there are characters in your language that are not 
  5. * supported by Source Sans Pro, translate this to 'off'. Do not translate 
  6. * into your own language. 
  7. */ 
  8. $source_sans_pro = _x( 'on', 'Source Sans Pro font: on or off', 'twentythirteen' ); 
  9.  
  10. /** Translators: If there are characters in your language that are not 
  11. * supported by Bitter, translate this to 'off'. Do not translate into your 
  12. * own language. 
  13. */ 
  14. $bitter = _x( 'on', 'Bitter font: on or off', 'twentythirteen' ); 
  15.  
  16. if ( 'off' !== $source_sans_pro || 'off' !== $bitter ) { 
  17. $font_families = array(); 
  18.  
  19. if ( 'off' !== $source_sans_pro ) 
  20. $font_families[] = 'Source Sans Pro:300, 400, 700, 300italic, 400italic, 700italic'; 
  21.  
  22. if ( 'off' !== $bitter ) 
  23. $font_families[] = 'Bitter:400, 700'; 
  24.  
  25. $query_args = array( 
  26. 'family' => urlencode( implode( '|', $font_families ) ),  
  27. 'subset' => urlencode( 'latin, latin-ext' ),  
  28. ); 
  29. $fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' ); 
  30.  
  31. return $fonts_url;