Changeset 55277
- Timestamp:
- 02/07/2023 05:12:23 PM (20 months ago)
- Location:
- trunk/src/wp-content/themes/twentytwelve
- Files:
-
- 40 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-content/themes/twentytwelve/functions.php
r55004 r55277 138 138 require get_template_directory() . '/inc/block-patterns.php'; 139 139 140 /** 141 * Return the Google font stylesheet URL if available. 142 * 143 * The use of Open Sans by default is localized. For languages that use 144 * characters not supported by the font, the font can be disabled. 145 * 146 * @since Twenty Twelve 1.2 147 * 148 * @return string Font stylesheet or empty string if disabled. 149 */ 150 function twentytwelve_get_font_url() { 151 $font_url = ''; 152 153 /* 154 * translators: If there are characters in your language that are not supported 155 * by Open Sans, translate this to 'off'. Do not translate into your own language. 156 */ 157 if ( 'off' !== _x( 'on', 'Open Sans font: on or off', 'twentytwelve' ) ) { 158 $subsets = 'latin,latin-ext'; 140 if ( ! function_exists( 'twentytwelve_get_font_url' ) ) : 141 /** 142 * Return the font stylesheet URL if available. 143 * 144 * The use of Open Sans by default is localized. For languages that use 145 * characters not supported by the font, the font can be disabled. 146 * 147 * @since Twenty Twelve 1.2 148 * @since Twenty Twelve 3.9 Replaced Google URL with self-hosted font. 149 * 150 * @return string Font stylesheet or empty string if disabled. 151 */ 152 function twentytwelve_get_font_url() { 153 $font_url = ''; 159 154 160 155 /* 161 * translators: To add an additional Open Sans character subset specific to your language, 162 * translate this to 'greek', 'cyrillic' or 'vietnamese'. Do not translate into your own language. 163 */ 164 $subset = _x( 'no-subset', 'Open Sans font: add new subset (greek, cyrillic, vietnamese)', 'twentytwelve' ); 165 166 if ( 'cyrillic' === $subset ) { 167 $subsets .= ',cyrillic,cyrillic-ext'; 168 } elseif ( 'greek' === $subset ) { 169 $subsets .= ',greek,greek-ext'; 170 } elseif ( 'vietnamese' === $subset ) { 171 $subsets .= ',vietnamese'; 156 * translators: If there are characters in your language that are not supported 157 * by Open Sans, translate this to 'off'. Do not translate into your own language. 158 */ 159 if ( 'off' !== _x( 'on', 'Open Sans font: on or off', 'twentytwelve' ) ) { 160 $font_url = get_template_directory_uri() . '/fonts/font-open-sans.css'; 172 161 } 173 162 174 $query_args = array( 175 'family' => urlencode( 'Open Sans:400italic,700italic,400,700' ), 176 'subset' => urlencode( $subsets ), 177 'display' => urlencode( 'fallback' ), 178 ); 179 $font_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' ); 180 } 181 182 return $font_url; 183 } 163 return $font_url; 164 } 165 endif; 184 166 185 167 /** … … 204 186 $font_url = twentytwelve_get_font_url(); 205 187 if ( ! empty( $font_url ) ) { 206 wp_enqueue_style( 'twentytwelve-fonts', esc_url_raw( $font_url ), array(), null ); 188 $font_version = ( 0 === strpos( (string) twentytwelve_get_font_url(), get_template_directory_uri() . '/' ) ) ? '20230328' : null; 189 wp_enqueue_style( 'twentytwelve-fonts', esc_url_raw( $font_url ), array(), $font_version ); 207 190 } 208 191 … … 228 211 wp_enqueue_style( 'twentytwelve-block-editor-style', get_template_directory_uri() . '/css/editor-blocks.css', array(), '20200713' ); 229 212 // Add custom fonts. 230 wp_enqueue_style( 'twentytwelve-fonts', twentytwelve_get_font_url(), array(), null ); 213 $font_version = ( 0 === strpos( (string) twentytwelve_get_font_url(), get_template_directory_uri() . '/' ) ) ? '20230328' : null; 214 wp_enqueue_style( 'twentytwelve-fonts', twentytwelve_get_font_url(), array(), $font_version ); 231 215 } 232 216 add_action( 'enqueue_block_editor_assets', 'twentytwelve_block_editor_styles' ); … … 236 220 * 237 221 * @since Twenty Twelve 2.2 222 * @deprecated Twenty Twelve 3.9 Disabled filter because, by default, fonts are self-hosted. 238 223 * 239 224 * @param array $urls URLs to print for resource hints. … … 255 240 return $urls; 256 241 } 257 add_filter( 'wp_resource_hints', 'twentytwelve_resource_hints', 10, 2 );258 259 /** 260 * Filter TinyMCE CSS path to include Google Fonts.242 // add_filter( 'wp_resource_hints', 'twentytwelve_resource_hints', 10, 2 ); 243 244 /** 245 * Filter TinyMCE CSS path to include hosted fonts. 261 246 * 262 247 * Adds additional stylesheets to the TinyMCE editor if needed. 263 248 * 264 * @uses twentytwelve_get_font_url() To get the Google Font stylesheet URL.249 * @uses twentytwelve_get_font_url() To get the font stylesheet URL. 265 250 * 266 251 * @since Twenty Twelve 1.2 -
trunk/src/wp-content/themes/twentytwelve/readme.txt
r55024 r55277 40 40 Licenses: MIT/GPL2 41 41 Source: https://github.com/aFarkas/html5shiv 42 43 Open Sans Font 44 Copyright 2020 The Open Sans Project Authors (https://github.com/googlefonts/opensans) 45 License: SIL Open Font License, 1.1, https://opensource.org/licenses/OFL-1.1 46 Source: https://fontsource.org/fonts/open-sans 42 47 43 48 "Fall Leaf Photo" by Tim Sullivan. CC0. https://stocksnap.io/photo/fall-leaf-ZBK0NLVP2B
Note: See TracChangeset
for help on using the changeset viewer.