- Timestamp:
- 10/29/2019 04:40:34 PM (5 years ago)
- Location:
- branches/5.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.3
-
branches/5.3/src/wp-content/themes/twentytwenty/functions.php
r46571 r46614 65 65 66 66 // Custom logo. 67 $logo_id = get_theme_mod( 'custom_logo' );68 67 $logo_width = 120; 69 68 $logo_height = 90; 70 69 71 70 // If the retina setting is active, double the recommended width and height. 72 if ( get_theme_mod( ' twentytwenty_retina_logo', false ) ) {71 if ( get_theme_mod( 'retina_logo', false ) ) { 73 72 $logo_width = floor( $logo_width * 2 ); 74 73 $logo_height = floor( $logo_height * 2 ); … … 82 81 'flex-height' => true, 83 82 'flex-width' => true, 84 'header-text' => array( 'site-title', 'site-description' ),85 83 ) 86 84 ); … … 164 162 require get_template_directory() . '/classes/class-twentytwenty-script-loader.php'; 165 163 164 // Non-latin language handling. 165 require get_template_directory() . '/classes/class-twentytwenty-non-latin-languages.php'; 166 166 167 // Custom CSS. 167 168 require get_template_directory() . '/inc/custom-css.php'; … … 207 208 208 209 add_action( 'wp_enqueue_scripts', 'twentytwenty_register_scripts' ); 210 211 /** 212 * Fix skip link focus in IE11. 213 * 214 * This does not enqueue the script because it is tiny and because it is only for IE11, 215 * thus it does not warrant having an entire dedicated blocking script being loaded. 216 * 217 * @link https://git.io/vWdr2 218 */ 219 function twentytwenty_skip_link_focus_fix() { 220 // The following is minified via `terser --compress --mangle -- assets/js/skip-link-focus-fix.js`. 221 ?> 222 <script> 223 /(trident|msie)/i.test(navigator.userAgent)&&document.getElementById&&window.addEventListener&&window.addEventListener("hashchange",function(){var t,e=location.hash.substring(1);/^[A-z0-9_-]+$/.test(e)&&(t=document.getElementById(e))&&(/^(?:a|select|input|button|textarea)$/i.test(t.tagName)||(t.tabIndex=-1),t.focus())},!1); 224 </script> 225 <?php 226 } 227 add_action( 'wp_print_footer_scripts', 'twentytwenty_skip_link_focus_fix' ); 228 229 /** Enqueue non-latin language styles 230 * 231 * @since 1.0.0 232 * 233 * @return void 234 */ 235 function twentytwenty_non_latin_languages() { 236 $custom_css = TwentyTwenty_Non_Latin_Languages::get_non_latin_css( 'front-end' ); 237 238 if ( $custom_css ) { 239 wp_add_inline_style( 'twentytwenty-style', $custom_css ); 240 } 241 } 242 243 add_action( 'wp_enqueue_scripts', 'twentytwenty_non_latin_languages' ); 209 244 210 245 /** … … 263 298 ); 264 299 300 // Add a style attribute with the height, or append the height to the style attribute if the style attribute already exists. 301 if ( strpos( $html, ' style=' ) === false ) { 302 $search[] = '/(src=)/'; 303 $replace[] = "style=\"height: {$logo_height}px;\" src="; 304 } else { 305 $search[] = '/(style="[^"]*)/'; 306 $replace[] = "$1 height: {$logo_height}px;"; 307 } 308 265 309 $html = preg_replace( $search, $replace, $html ); 310 266 311 } 267 312 } … … 349 394 wp_add_inline_style( 'twentytwenty-block-editor-styles', twentytwenty_get_customizer_css( 'block-editor' ) ); 350 395 396 // Add inline style for non-latin fonts. 397 wp_add_inline_style( 'twentytwenty-block-editor-styles', TwentyTwenty_Non_Latin_Languages::get_non_latin_css( 'block-editor' ) ); 398 351 399 // Enqueue the editor script. 352 400 wp_enqueue_script( 'twentytwenty-block-editor-script', get_theme_file_uri( '/assets/js/editor-script-block.js' ), array( 'wp-blocks', 'wp-dom' ), wp_get_theme()->get( 'Version' ), true ); … … 393 441 394 442 add_filter( 'tiny_mce_before_init', 'twentytwenty_add_classic_editor_customizer_styles' ); 443 444 /** 445 * Output non-latin font styles in the classic editor. 446 * Adds styles to the head of the TinyMCE iframe. Kudos to @Otto42 for the original solution. 447 * 448 * @param array $mce_init TinyMCE styles. 449 * 450 * @return array $mce_init TinyMCE styles. 451 */ 452 function twentytwenty_add_classic_editor_non_latin_styles( $mce_init ) { 453 454 $styles = TwentyTwenty_Non_Latin_Languages::get_non_latin_css( 'classic-editor' ); 455 456 // Return if there are no styles to add. 457 if ( ! $styles ) { 458 return $mce_init; 459 } 460 461 if ( ! isset( $mce_init['content_style'] ) ) { 462 $mce_init['content_style'] = $styles . ' '; 463 } else { 464 $mce_init['content_style'] .= ' ' . $styles . ' '; 465 } 466 467 return $mce_init; 468 469 } 470 471 add_filter( 'tiny_mce_before_init', 'twentytwenty_add_classic_editor_non_latin_styles' ); 395 472 396 473 /** … … 481 558 482 559 add_action( 'after_setup_theme', 'twentytwenty_block_editor_settings' ); 560 561 /** 562 * Overwrite default more tag with styling and screen reader markup. 563 * 564 * @param string $html The default output HTML for the more tag. 565 * 566 * @return string $html 567 */ 568 function twentytwenty_read_more_tag( $html ) { 569 return preg_replace( '/<a.*>(.*)<\/a>/iU', sprintf( '<span class="faux-button">$1</span> <span class="screen-reader-text">"%1$s"</span>', get_the_title( get_the_ID() ) ), $html ); 570 } 571 572 add_filter( 'the_content_more_link', 'twentytwenty_read_more_tag' ); 483 573 484 574 /**
Note: See TracChangeset
for help on using the changeset viewer.