Ticket #48170: 48170.7.diff
File 48170.7.diff, 23.6 KB (added by , 4 years ago) |
---|
-
src/wp-includes/nav-menu-template.php
15 15 * 16 16 * @since 3.0.0 17 17 * @since 4.7.0 Added the `item_spacing` argument. 18 * @since 5.5.0 Added the `container_aria_label` argument. 18 19 * 19 20 * @param array $args { 20 21 * Optional. Array of nav menu arguments. 21 22 * 22 * @type int|string|WP_Term $menu Desired menu. Accepts a menu ID, slug, name, or object. Default empty. 23 * @type string $menu_class CSS class to use for the ul element which forms the menu. Default 'menu'. 24 * @type string $menu_id The ID that is applied to the ul element which forms the menu. 25 * Default is the menu slug, incremented. 26 * @type string $container Whether to wrap the ul, and what to wrap it with. Default 'div'. 27 * @type string $container_class Class that is applied to the container. Default 'menu-{menu slug}-container'. 28 * @type string $container_id The ID that is applied to the container. Default empty. 29 * @type callable|bool $fallback_cb If the menu doesn't exist, a callback function will fire. 30 * Default is 'wp_page_menu'. Set to false for no fallback. 31 * @type string $before Text before the link markup. Default empty. 32 * @type string $after Text after the link markup. Default empty. 33 * @type string $link_before Text before the link text. Default empty. 34 * @type string $link_after Text after the link text. Default empty. 35 * @type bool $echo Whether to echo the menu or return it. Default true. 36 * @type int $depth How many levels of the hierarchy are to be included. 0 means all. Default 0. 37 * @type object $walker Instance of a custom walker class. Default empty. 38 * @type string $theme_location Theme location to be used. Must be registered with register_nav_menu() 39 * in order to be selectable by the user. 40 * @type string $items_wrap How the list items should be wrapped. Default is a ul with an id and class. 41 * Uses printf() format with numbered placeholders. 42 * @type string $item_spacing Whether to preserve whitespace within the menu's HTML. Accepts 'preserve' or 'discard'. Default 'preserve'. 23 * @type int|string|WP_Term $menu Desired menu. Accepts a menu ID, slug, name, or object. Default empty. 24 * @type string $menu_class CSS class to use for the ul element which forms the menu. Default 'menu'. 25 * @type string $menu_id The ID that is applied to the ul element which forms the menu. 26 * Default is the menu slug, incremented. 27 * @type string $container Whether to wrap the ul, and what to wrap it with. Default 'div'. 28 * @type string $container_class Class that is applied to the container. Default 'menu-{menu slug}-container'. 29 * @type string $container_id The ID that is applied to the container. Default empty. 30 * @type string $container_aria_label The aria-label attribute that is applied to the container when it's a nav element. Default empty. 31 * @type callable|bool $fallback_cb If the menu doesn't exist, a callback function will fire. 32 * Default is 'wp_page_menu'. Set to false for no fallback. 33 * @type string $before Text before the link markup. Default empty. 34 * @type string $after Text after the link markup. Default empty. 35 * @type string $link_before Text before the link text. Default empty. 36 * @type string $link_after Text after the link text. Default empty. 37 * @type bool $echo Whether to echo the menu or return it. Default true. 38 * @type int $depth How many levels of the hierarchy are to be included. 0 means all. Default 0. 39 * @type object $walker Instance of a custom walker class. Default empty. 40 * @type string $theme_location Theme location to be used. Must be registered with register_nav_menu() 41 * in order to be selectable by the user. 42 * @type string $items_wrap How the list items should be wrapped. Default is a ul with an id and class. 43 * Uses printf() format with numbered placeholders. 44 * @type string $item_spacing Whether to preserve whitespace within the menu's HTML. Accepts 'preserve' or 'discard'. Default 'preserve'. 43 45 * } 44 46 * @return void|string|false Void if 'echo' argument is true, menu output if 'echo' is false. 45 47 * False if there are no items or no menu was found. … … 48 50 static $menu_id_slugs = array(); 49 51 50 52 $defaults = array( 51 'menu' => '', 52 'container' => 'div', 53 'container_class' => '', 54 'container_id' => '', 55 'menu_class' => 'menu', 56 'menu_id' => '', 57 'echo' => true, 58 'fallback_cb' => 'wp_page_menu', 59 'before' => '', 60 'after' => '', 61 'link_before' => '', 62 'link_after' => '', 63 'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>', 64 'item_spacing' => 'preserve', 65 'depth' => 0, 66 'walker' => '', 67 'theme_location' => '', 53 'menu' => '', 54 'container' => 'div', 55 'container_class' => '', 56 'container_id' => '', 57 'container_aria_label' => '', 58 'menu_class' => 'menu', 59 'menu_id' => '', 60 'echo' => true, 61 'fallback_cb' => 'wp_page_menu', 62 'before' => '', 63 'after' => '', 64 'link_before' => '', 65 'link_after' => '', 66 'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>', 67 'item_spacing' => 'preserve', 68 'depth' => 0, 69 'walker' => '', 70 'theme_location' => '', 68 71 ); 69 72 70 73 $args = wp_parse_args( $args, $defaults ); … … 176 179 $show_container = true; 177 180 $class = $args->container_class ? ' class="' . esc_attr( $args->container_class ) . '"' : ' class="menu-' . $menu->slug . '-container"'; 178 181 $id = $args->container_id ? ' id="' . esc_attr( $args->container_id ) . '"' : ''; 179 $nav_menu .= '<' . $args->container . $id . $class . '>'; 182 $aria_label = ( 'nav' === $args->container && $args->container_aria_label ) ? ' aria-label="' . esc_attr( $args->container_aria_label ) . '"' : ''; 183 $nav_menu .= '<' . $args->container . $id . $class . $aria_label . '>'; 180 184 } 181 185 } 182 186 -
src/wp-includes/widgets/class-wp-nav-menu-widget.php
46 46 return; 47 47 } 48 48 49 $title = ! empty( $instance['title'] ) ? $instance['title'] : ''; 49 $default_title = __( 'Menu' ); 50 $title = ! empty( $instance['title'] ) ? $instance['title'] : ''; 50 51 51 52 /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ 52 53 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); … … 57 58 echo $args['before_title'] . $title . $args['after_title']; 58 59 } 59 60 60 $nav_menu_args = array( 61 'fallback_cb' => '', 62 'menu' => $nav_menu, 63 ); 61 $format = current_theme_supports( 'html5', 'navigation-widgets' ) ? 'html5' : 'xhtml'; 64 62 65 63 /** 64 * Filters the HTML format of widgets with navigation links. 65 * 66 * @since 5.5.0 67 * 68 * @param string $format The type of markup to use in widgets with navigation links. 69 * Accepts 'html5', 'xhtml'. 70 */ 71 $format = apply_filters( 'navigation_widgets_format', $format ); 72 73 if ( 'html5' === $format ) { 74 // The title may be filtered: Strip out HTML and make sure the aria-label is never empty. 75 $title = trim( strip_tags( $title ) ); 76 $aria_label = $title ? $title : $default_title; 77 78 $nav_menu_args = array( 79 'fallback_cb' => '', 80 'menu' => $nav_menu, 81 'container' => 'nav', 82 'container_aria_label' => $aria_label, 83 'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>', 84 ); 85 } else { 86 $nav_menu_args = array( 87 'fallback_cb' => '', 88 'menu' => $nav_menu, 89 ); 90 } 91 92 /** 66 93 * Filters the arguments for the Navigation Menu widget. 67 94 * 68 95 * @since 4.2.0 -
src/wp-includes/widgets/class-wp-widget-archives.php
40 40 * @param array $instance Settings for the current Archives widget instance. 41 41 */ 42 42 public function widget( $args, $instance ) { 43 $title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'Archives' ); 43 $default_title = __( 'Archives' ); 44 $title = ! empty( $instance['title'] ) ? $instance['title'] : $default_title; 44 45 45 46 /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ 46 47 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); … … 120 121 })(); 121 122 /* ]]> */ 122 123 </script> 124 <?php 125 } else { 126 $format = current_theme_supports( 'html5', 'navigation-widgets' ) ? 'html5' : 'xhtml'; 123 127 124 <?php } else { ?> 125 <ul> 126 <?php 127 wp_get_archives( 128 /** 129 * Filters the arguments for the Archives widget. 130 * 131 * @since 2.8.0 132 * @since 4.9.0 Added the `$instance` parameter. 133 * 134 * @see wp_get_archives() 135 * 136 * @param array $args An array of Archives option arguments. 137 * @param array $instance Array of settings for the current widget. 138 */ 139 apply_filters( 140 'widget_archives_args', 141 array( 142 'type' => 'monthly', 143 'show_post_count' => $count, 144 ), 145 $instance 146 ) 147 ); 128 /** 129 * Filters the HTML format of widgets with navigation links. 130 * 131 * @since 5.5.0 132 * 133 * @param string $format The type of markup to use in widgets with navigation links. 134 * Accepts 'html5', 'xhtml'. 135 */ 136 $format = apply_filters( 'navigation_widgets_format', $format ); 137 138 if ( 'html5' === $format ) { 139 // The title may be filtered: Strip out HTML and make sure the aria-label is never empty. 140 $title = trim( strip_tags( $title ) ); 141 $aria_label = $title ? $title : $default_title; 142 echo '<nav role="navigation" aria-label="' . esc_attr( $aria_label ) . '">'; 143 } 148 144 ?> 149 </ul> 145 146 <ul> 147 <?php 148 wp_get_archives( 149 /** 150 * Filters the arguments for the Archives widget. 151 * 152 * @since 2.8.0 153 * @since 4.9.0 Added the `$instance` parameter. 154 * 155 * @see wp_get_archives() 156 * 157 * @param array $args An array of Archives option arguments. 158 * @param array $instance Array of settings for the current widget. 159 */ 160 apply_filters( 161 'widget_archives_args', 162 array( 163 'type' => 'monthly', 164 'show_post_count' => $count, 165 ), 166 $instance 167 ) 168 ); 169 ?> 170 </ul> 171 <?php if ( 'html5' === $format ) : ?> 172 </nav> 173 <?php endif; ?> 174 150 175 <?php 176 echo $args['after_widget']; 151 177 } 152 153 echo $args['after_widget'];154 178 } 155 179 156 180 /** -
src/wp-includes/widgets/class-wp-widget-categories.php
44 44 public function widget( $args, $instance ) { 45 45 static $first_dropdown = true; 46 46 47 $title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'Categories' ); 47 $default_title = __( 'Categories' ); 48 $title = ! empty( $instance['title'] ) ? $instance['title'] : $default_title; 48 49 49 50 /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ 50 51 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); … … 109 110 110 111 <?php 111 112 } else { 112 ?> 113 <ul> 114 <?php 115 $cat_args['title_li'] = ''; 113 $format = current_theme_supports( 'html5', 'navigation-widgets' ) ? 'html5' : 'xhtml'; 116 114 117 115 /** 118 * Filters the arguments for the Categories widget.116 * Filters the HTML format of widgets with navigation links. 119 117 * 120 * @since 2.8.0 121 * @since 4.9.0 Added the `$instance` parameter. 118 * @since 5.5.0 122 119 * 123 * @param array $cat_args An array of Categories widget options.124 * @param array $instance Array of settings for the current widget.120 * @param string $format The type of markup to use in widgets with navigation links. 121 * Accepts 'html5', 'xhtml'. 125 122 */ 126 wp_list_categories( apply_filters( 'widget_categories_args', $cat_args, $instance ) ); 123 $format = apply_filters( 'navigation_widgets_format', $format ); 124 125 if ( 'html5' === $format ) { 126 // The title may be filtered: Strip out HTML and make sure the aria-label is never empty. 127 $title = trim( strip_tags( $title ) ); 128 $aria_label = $title ? $title : $default_title; 129 echo '<nav role="navigation" aria-label="' . esc_attr( $aria_label ) . '">'; 130 } 127 131 ?> 128 </ul> 132 133 <ul> 134 <?php 135 $cat_args['title_li'] = ''; 136 137 /** 138 * Filters the arguments for the Categories widget. 139 * 140 * @since 2.8.0 141 * @since 4.9.0 Added the `$instance` parameter. 142 * 143 * @param array $cat_args An array of Categories widget options. 144 * @param array $instance Array of settings for the current widget. 145 */ 146 wp_list_categories( apply_filters( 'widget_categories_args', $cat_args, $instance ) ); 147 ?> 148 </ul> 149 150 <?php if ( 'html5' === $format ) : ?> 151 </nav> 152 <?php endif; ?> 153 129 154 <?php 130 155 } 131 156 -
src/wp-includes/widgets/class-wp-widget-meta.php
42 42 * @param array $instance Settings for the current Meta widget instance. 43 43 */ 44 44 public function widget( $args, $instance ) { 45 $title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'Meta' ); 45 $default_title = __( 'Meta' ); 46 $title = ! empty( $instance['title'] ) ? $instance['title'] : $default_title; 46 47 47 48 /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ 48 49 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); … … 52 53 if ( $title ) { 53 54 echo $args['before_title'] . $title . $args['after_title']; 54 55 } 56 57 $format = current_theme_supports( 'html5', 'navigation-widgets' ) ? 'html5' : 'xhtml'; 58 59 /** 60 * Filters the HTML format of widgets with navigation links. 61 * 62 * @since 5.5.0 63 * 64 * @param string $format The type of markup to use in widgets with navigation links. 65 * Accepts 'html5', 'xhtml'. 66 */ 67 $format = apply_filters( 'navigation_widgets_format', $format ); 68 69 if ( 'html5' === $format ) { 70 // The title may be filtered: Strip out HTML and make sure the aria-label is never empty. 71 $title = trim( strip_tags( $title ) ); 72 $aria_label = $title ? $title : $default_title; 73 echo '<nav role="navigation" aria-label="' . esc_attr( $aria_label ) . '">'; 74 } 55 75 ?> 56 <ul> 76 77 78 <ul> 57 79 <?php wp_register(); ?> 58 80 <li><?php wp_loginout(); ?></li> 59 81 <li><a href="<?php echo esc_url( get_bloginfo( 'rss2_url' ) ); ?>"><?php _e( 'Entries feed' ); ?></a></li> 60 82 <li><a href="<?php echo esc_url( get_bloginfo( 'comments_rss2_url' ) ); ?>"><?php _e( 'Comments feed' ); ?></a></li> 83 61 84 <?php 62 85 /** 63 86 * Filters the "WordPress.org" list item HTML in the Meta widget. … … 80 103 81 104 wp_meta(); 82 105 ?> 83 </ul>84 <?php85 106 86 echo $args['after_widget']; 107 </ul> 108 109 <?php if ( 'html5' === $format ) : ?> 110 </nav> 111 <?php endif; ?> 112 113 <?php 114 echo $args['after_widget']; 87 115 } 88 116 89 117 /** -
src/wp-includes/widgets/class-wp-widget-pages.php
40 40 * @param array $instance Settings for the current Pages widget instance. 41 41 */ 42 42 public function widget( $args, $instance ) { 43 $title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'Pages' ); 43 $default_title = __( 'Pages' ); 44 $title = ! empty( $instance['title'] ) ? $instance['title'] : $default_title; 44 45 45 46 /** 46 47 * Filters the widget title. … … 89 90 if ( $title ) { 90 91 echo $args['before_title'] . $title . $args['after_title']; 91 92 } 93 94 $format = current_theme_supports( 'html5', 'navigation-widgets' ) ? 'html5' : 'xhtml'; 95 96 /** 97 * Filters the HTML format of widgets with navigation links. 98 * 99 * @since 5.5.0 100 * 101 * @param string $format The type of markup to use in widgets with navigation links. 102 * Accepts 'html5', 'xhtml'. 103 */ 104 $format = apply_filters( 'navigation_widgets_format', $format ); 105 106 if ( 'html5' === $format ) { 107 // The title may be filtered: Strip out HTML and make sure the aria-label is never empty. 108 $title = trim( strip_tags( $title ) ); 109 $aria_label = $title ? $title : $default_title; 110 echo '<nav role="navigation" aria-label="' . esc_attr( $aria_label ) . '">'; 111 } 92 112 ?> 93 <ul> 94 <?php echo $out; ?> 95 </ul> 113 114 <ul> 115 <?php echo $out; ?> 116 </ul> 117 118 <?php if ( 'html5' === $format ) : ?> 119 </nav> 120 <?php endif; ?> 121 96 122 <?php 97 123 echo $args['after_widget']; 98 124 } -
src/wp-includes/widgets/class-wp-widget-recent-comments.php
82 82 83 83 $output = ''; 84 84 85 $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Comments' ); 85 $default_title = __( 'Recent Comments' ); 86 $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : $default_title; 86 87 87 88 /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ 88 89 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); … … 123 124 $recent_comments_id = ( $first_instance ) ? 'recentcomments' : "recentcomments-{$this->number}"; 124 125 $first_instance = false; 125 126 127 $format = current_theme_supports( 'html5', 'navigation-widgets' ) ? 'html5' : 'xhtml'; 128 129 /** 130 * Filters the HTML format of widgets with navigation links. 131 * 132 * @since 5.5.0 133 * 134 * @param string $format The type of markup to use in widgets with navigation links. 135 * Accepts 'html5', 'xhtml'. 136 */ 137 $format = apply_filters( 'navigation_widgets_format', $format ); 138 139 if ( 'html5' === $format ) { 140 // The title may be filtered: Strip out HTML and make sure the aria-label is never empty. 141 $title = trim( strip_tags( $title ) ); 142 $aria_label = $title ? $title : $default_title; 143 $output .= '<nav role="navigation" aria-label="' . esc_attr( $aria_label ) . '">'; 144 } 145 126 146 $output .= '<ul id="' . esc_attr( $recent_comments_id ) . '">'; 127 147 if ( is_array( $comments ) && $comments ) { 128 148 // Prime cache for associated posts. (Prime post term cache if we need it for permalinks.) … … 141 161 } 142 162 } 143 163 $output .= '</ul>'; 164 165 if ( 'html5' === $format ) { 166 $output .= '</nav>'; 167 } 168 144 169 $output .= $args['after_widget']; 145 170 146 171 echo $output; -
src/wp-includes/widgets/class-wp-widget-recent-posts.php
45 45 $args['widget_id'] = $this->id; 46 46 } 47 47 48 $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Posts' ); 48 $default_title = __( 'Recent Posts' ); 49 $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : $default_title; 49 50 50 51 /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ 51 52 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); … … 84 85 return; 85 86 } 86 87 ?> 88 87 89 <?php echo $args['before_widget']; ?> 90 88 91 <?php 89 92 if ( $title ) { 90 93 echo $args['before_title'] . $title . $args['after_title']; 91 94 } 95 96 $format = current_theme_supports( 'html5', 'navigation-widgets' ) ? 'html5' : 'xhtml'; 97 98 /** 99 * Filters the HTML format of widgets with navigation links. 100 * 101 * @since 5.5.0 102 * 103 * @param string $format The type of markup to use in widgets with navigation links. 104 * Accepts 'html5', 'xhtml'. 105 */ 106 $format = apply_filters( 'navigation_widgets_format', $format ); 107 108 if ( 'html5' === $format ) { 109 // The title may be filtered: Strip out HTML and make sure the aria-label is never empty. 110 $title = trim( strip_tags( $title ) ); 111 $aria_label = $title ? $title : $default_title; 112 echo '<nav role="navigation" aria-label="' . esc_attr( $aria_label ) . '">'; 113 } 92 114 ?> 115 93 116 <ul> 94 117 <?php foreach ( $r->posts as $recent_post ) : ?> 95 118 <?php … … 109 132 </li> 110 133 <?php endforeach; ?> 111 134 </ul> 135 <?php if ( 'html5' === $format ) : ?> 136 </nav> 137 <?php endif; ?> 138 112 139 <?php 113 140 echo $args['after_widget']; 114 141 } -
src/wp-includes/widgets/class-wp-widget-rss.php
94 94 if ( $title ) { 95 95 echo $args['before_title'] . $title . $args['after_title']; 96 96 } 97 98 $format = current_theme_supports( 'html5', 'navigation-widgets' ) ? 'html5' : 'xhtml'; 99 100 /** 101 * Filters the HTML format of widgets with navigation links. 102 * 103 * @since 5.5.0 104 * 105 * @param string $format The type of markup to use in widgets with navigation links. 106 * Accepts 'html5', 'xhtml'. 107 */ 108 $format = apply_filters( 'navigation_widgets_format', $format ); 109 110 if ( 'html5' === $format ) { 111 // The title may be filtered: Strip out HTML and make sure the aria-label is never empty. 112 $title = trim( strip_tags( $title ) ); 113 $aria_label = $title ? $title : __( 'RSS Feed' ); 114 echo '<nav role="navigation" aria-label="' . esc_attr( $aria_label ) . '">'; 115 } 116 97 117 wp_widget_rss_output( $rss, $instance ); 118 119 if ( 'html5' === $format ) { 120 echo '</nav>'; 121 } 122 98 123 echo $args['after_widget']; 99 124 100 125 if ( ! is_wp_error( $rss ) ) {