Changeset 23672 for trunk/wp-content/themes/twentythirteen/functions.php
- Timestamp:
- 03/12/2013 05:27:24 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-content/themes/twentythirteen/functions.php
r23629 r23672 101 101 102 102 /** 103 * Loads our special font CSS file.103 * Returns the Google font stylesheet URL, if available. 104 104 * 105 105 * The use of Source Sans Pro and Bitter by default is localized. For languages 106 106 * that use characters not supported by the font, the font can be disabled. 107 * 108 * @since Twenty Thirteen 1.0 109 * 110 * @return string Font stylesheet or empty string if disabled. 111 */ 112 function twentythirteen_fonts_url() { 113 $fonts_url = ''; 114 115 /* Translators: If there are characters in your language that are not 116 * supported by Source Sans Pro, translate this to 'off'. Do not translate 117 * into your own language. 118 */ 119 $source_sans_pro = _x( 'on', 'Source Sans Pro font: on or off', 'twentythirteen' ); 120 121 /* Translators: If there are characters in your language that are not 122 * supported by Bitter, translate this to 'off'. Do not translate into your 123 * own language. 124 */ 125 $bitter = _x( 'on', 'Bitter font: on or off', 'twentythirteen' ); 126 127 if ( 'off' !== $source_sans_pro || 'off' !== $bitter ) { 128 $font_families = array(); 129 130 if ( 'off' !== $source_sans_pro ) 131 $font_families[] = 'Source+Sans+Pro:400,700,300italic,400italic,700italic'; 132 133 if ( 'off' !== $bitter ) 134 $font_families[] = 'Bitter:400,700'; 135 136 $protocol = is_ssl() ? 'https' : 'http'; 137 $query_args = array( 138 'family' => implode( '|', $font_families ), 139 'subset' => 'latin,latin-ext', 140 ); 141 $fonts_url = add_query_arg( $query_args, "$protocol://fonts.googleapis.com/css" ); 142 } 143 144 return $fonts_url; 145 } 146 147 /** 148 * Loads our special font CSS file. 107 149 * 108 150 * To disable in a child theme, use wp_dequeue_style() … … 120 162 */ 121 163 function twentythirteen_fonts() { 122 123 /* Translators: If there are characters in your language that are not 124 * supported by Source Sans Pro, translate this to 'off'. Do not translate 125 * into your own language. 126 */ 127 $source_sans_pro = _x( 'on', 'Source Sans Pro font: on or off', 'twentythirteen' ); 128 129 /* Translators: If there are characters in your language that are not 130 * supported by Bitter, translate this to 'off'. Do not translate into your 131 * own language. 132 */ 133 $bitter = _x( 'on', 'Bitter font: on or off', 'twentythirteen' ); 134 135 if ( 'off' !== $source_sans_pro || 'off' !== $bitter ) { 136 $font_families = array(); 137 138 if ( 'off' !== $source_sans_pro ) 139 $font_families[] = 'Source+Sans+Pro:400,700,300italic,400italic,700italic'; 140 141 if ( 'off' !== $bitter ) 142 $font_families[] = 'Bitter:400,700'; 143 144 $protocol = is_ssl() ? 'https' : 'http'; 145 $query_args = array( 146 'family' => implode( '|', $font_families ), 147 'subset' => 'latin,latin-ext', 148 ); 149 wp_enqueue_style( 'twentythirteen-fonts', add_query_arg( $query_args, "$protocol://fonts.googleapis.com/css" ), array(), null ); 150 } 164 $fonts_url = twentythirteen_fonts_url(); 165 if ( ! empty( $fonts_url ) ) 166 wp_enqueue_style( 'twentythirteen-fonts', esc_url_raw( $fonts_url ), array(), null ); 151 167 } 152 168 add_action( 'wp_enqueue_scripts', 'twentythirteen_fonts' ); 169 170 /** 171 * Adds additional stylesheets to the TinyMCE editor if needed. 172 * 173 * @uses twentythirteen_fonts_url() to get the Google Font stylesheet URL. 174 * 175 * @since Twenty Thirteen 1.0 176 * 177 * @param string $mce_css CSS path to load in TinyMCE. 178 * @return string 179 */ 180 function twentythirteen_mce_css( $mce_css ) { 181 $fonts_url = twentythirteen_fonts_url(); 182 183 if ( empty( $fonts_url ) ) 184 return $mce_css; 185 186 if ( ! empty( $mce_css ) ) 187 $mce_css .= ','; 188 189 $mce_css .= esc_url_raw( str_replace( ',', '%2C', $fonts_url ) ); 190 191 return $mce_css; 192 } 193 add_filter( 'mce_css', 'twentythirteen_mce_css' ); 153 194 154 195 /**
Note: See TracChangeset
for help on using the changeset viewer.