Ticket #38659: 38659.patch
File 38659.patch, 2.4 KB (added by , 8 years ago) |
---|
-
src/wp-content/themes/twentyseventeen/inc/icon-functions.php
49 49 'icon' => '', 50 50 'title' => '', 51 51 'desc' => '', 52 'aria_hidden' => true, // Hide from screen readers.53 52 'fallback' => false, 54 53 ); 55 54 … … 57 56 $args = wp_parse_args( $args, $defaults ); 58 57 59 58 // Set aria hidden. 60 $aria_hidden = ' ';59 $aria_hidden = ' aria-hidden="true"'; 61 60 62 if ( true === $args['aria_hidden'] ) {63 $aria_hidden = ' aria-hidden="true"';64 }65 66 61 // Set ARIA. 67 62 $aria_labelledby = ''; 68 63 69 64 if ( $args['title'] && $args['desc'] ) { 70 $aria_labelledby = ' aria-labelledby="title desc"'; 65 $unique_id = uniqid(); 66 $aria_labelledby = ' aria-labelledby="title-' . $unique_id . ' desc-' . $unique_id . '"'; 67 $aria_hidden = ''; 71 68 } 72 69 73 70 // Begin SVG markup. 74 71 $svg = '<svg class="icon icon-' . esc_attr( $args['icon'] ) . '"' . $aria_hidden . $aria_labelledby . ' role="img">'; 75 72 76 // If there is a title, display it. 77 if ( $args['title'] ) { 78 $svg .= '<title>' . esc_html( $args['title'] ) . '</title>'; 73 // If there is title and description, display them. 74 if ( $args['title'] && $args['desc'] ) { 75 $svg .= '<title id="title-' . $unique_id . '">' . esc_html( $args['title'] ) . '</title>'; 76 $svg .= '<desc id="desc-' . $unique_id . '">' . esc_html( $args['desc'] ) . '</desc>'; 79 77 } 80 78 81 // If there is a description, display it. 82 if ( $args['desc'] ) { 83 $svg .= '<desc>' . esc_html( $args['desc'] ) . '</desc>'; 84 } 79 /* 80 * Display the icon. 81 * 82 * The whitespace around `<use>` is intentional. See https://core.trac.wordpress.org/ticket/38387. 83 */ 84 $svg .= ' <use xlink:href="#icon-' . esc_html( $args['icon'] ) . '"></use> '; 85 85 86 // Use absolute path in the Customizer so that icons show up in there.87 if ( is_customize_preview() ) {88 $svg .= '<use xlink:href="' . get_parent_theme_file_uri( '/assets/images/svg-icons.svg#icon-' . esc_html( $args['icon'] ) ) . '"></use>';89 } else {90 $svg .= '<use xlink:href="#icon-' . esc_html( $args['icon'] ) . '"></use>';91 }92 93 86 // Add some markup to use as a fallback for browsers that do not support SVGs. 94 87 if ( $args['fallback'] ) { 95 88 $svg .= '<span class="svg-fallback icon-' . esc_attr( $args['icon'] ) . '"></span>';