@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | */ |
19 | 19 | |
20 | 20 | /* Check if Class Exists. */ |
21 | -if ( ! class_exists( 'WP_Bootstrap_Navwalker' ) ) { |
|
21 | +if ( ! class_exists('WP_Bootstrap_Navwalker')) { |
|
22 | 22 | /** |
23 | 23 | * WP_Bootstrap_Navwalker class. |
24 | 24 | * |
@@ -37,17 +37,17 @@ discard block |
||
37 | 37 | * @param int $depth Depth of menu item. Used for padding. |
38 | 38 | * @param stdClass $args An object of wp_nav_menu() arguments. |
39 | 39 | */ |
40 | - public function start_lvl( &$output, $depth = 0, $args = array() ) { |
|
41 | - if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) { |
|
40 | + public function start_lvl(&$output, $depth = 0, $args = array()) { |
|
41 | + if (isset($args->item_spacing) && 'discard' === $args->item_spacing) { |
|
42 | 42 | $t = ''; |
43 | 43 | $n = ''; |
44 | 44 | } else { |
45 | 45 | $t = "\t"; |
46 | 46 | $n = "\n"; |
47 | 47 | } |
48 | - $indent = str_repeat( $t, $depth ); |
|
48 | + $indent = str_repeat($t, $depth); |
|
49 | 49 | // Default class to add to the file. |
50 | - $classes = array( 'dropdown-menu' ); |
|
50 | + $classes = array('dropdown-menu'); |
|
51 | 51 | /** |
52 | 52 | * Filters the CSS class(es) applied to a menu list element. |
53 | 53 | * |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | * @param stdClass $args An object of `wp_nav_menu()` arguments. |
58 | 58 | * @param int $depth Depth of menu item. Used for padding. |
59 | 59 | */ |
60 | - $class_names = join( ' ', apply_filters( 'nav_menu_submenu_css_class', $classes, $args, $depth ) ); |
|
61 | - $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : ''; |
|
60 | + $class_names = join(' ', apply_filters('nav_menu_submenu_css_class', $classes, $args, $depth)); |
|
61 | + $class_names = $class_names ? ' class="' . esc_attr($class_names) . '"' : ''; |
|
62 | 62 | /** |
63 | 63 | * The `.dropdown-menu` container needs to have a labelledby |
64 | 64 | * attribute which points to it's trigger link. |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | */ |
69 | 69 | $labelledby = ''; |
70 | 70 | // find all links with an id in the output. |
71 | - preg_match_all( '/(<a.*?id=\"|\')(.*?)\"|\'.*?>/im', $output, $matches ); |
|
71 | + preg_match_all('/(<a.*?id=\"|\')(.*?)\"|\'.*?>/im', $output, $matches); |
|
72 | 72 | // with pointer at end of array check if we got an ID match. |
73 | - if ( end( $matches[2] ) ) { |
|
73 | + if (end($matches[2])) { |
|
74 | 74 | // build a string to use as aria-labelledby. |
75 | - $labelledby = 'aria-labelledby="' . esc_attr( end( $matches[2] ) ) . '"'; |
|
75 | + $labelledby = 'aria-labelledby="' . esc_attr(end($matches[2])) . '"'; |
|
76 | 76 | } |
77 | 77 | $output .= "{$n}{$indent}<ul$class_names $labelledby role=\"menu\">{$n}"; |
78 | 78 | } |
@@ -91,17 +91,17 @@ discard block |
||
91 | 91 | * @param stdClass $args An object of wp_nav_menu() arguments. |
92 | 92 | * @param int $id Current item ID. |
93 | 93 | */ |
94 | - public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { |
|
95 | - if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) { |
|
94 | + public function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { |
|
95 | + if (isset($args->item_spacing) && 'discard' === $args->item_spacing) { |
|
96 | 96 | $t = ''; |
97 | 97 | $n = ''; |
98 | 98 | } else { |
99 | 99 | $t = "\t"; |
100 | 100 | $n = "\n"; |
101 | 101 | } |
102 | - $indent = ( $depth ) ? str_repeat( $t, $depth ) : ''; |
|
102 | + $indent = ($depth) ? str_repeat($t, $depth) : ''; |
|
103 | 103 | |
104 | - $classes = empty( $item->classes ) ? array() : (array) $item->classes; |
|
104 | + $classes = empty($item->classes) ? array() : (array) $item->classes; |
|
105 | 105 | |
106 | 106 | // Initialize some holder variables to store specially handled item |
107 | 107 | // wrappers and icons. |
@@ -114,10 +114,10 @@ discard block |
||
114 | 114 | * NOTE: linkmod and icon class arrays are passed by reference and |
115 | 115 | * are maybe modified before being used later in this function. |
116 | 116 | */ |
117 | - $classes = self::separate_linkmods_and_icons_from_classes( $classes, $linkmod_classes, $icon_classes, $depth ); |
|
117 | + $classes = self::separate_linkmods_and_icons_from_classes($classes, $linkmod_classes, $icon_classes, $depth); |
|
118 | 118 | |
119 | 119 | // Join any icon classes plucked from $classes into a string. |
120 | - $icon_class_string = join( ' ', $icon_classes ); |
|
120 | + $icon_class_string = join(' ', $icon_classes); |
|
121 | 121 | |
122 | 122 | /** |
123 | 123 | * Filters the arguments for a single nav menu item. |
@@ -128,13 +128,13 @@ discard block |
||
128 | 128 | * @param WP_Post $item Menu item data object. |
129 | 129 | * @param int $depth Depth of menu item. Used for padding. |
130 | 130 | */ |
131 | - $args = apply_filters( 'nav_menu_item_args', $args, $item, $depth ); |
|
131 | + $args = apply_filters('nav_menu_item_args', $args, $item, $depth); |
|
132 | 132 | |
133 | 133 | // Add .dropdown or .active classes where they are needed. |
134 | - if ( $this->has_children ) { |
|
134 | + if ($this->has_children) { |
|
135 | 135 | $classes[] = 'dropdown'; |
136 | 136 | } |
137 | - if ( in_array( 'current-menu-item', $classes, true ) || in_array( 'current-menu-parent', $classes, true ) ) { |
|
137 | + if (in_array('current-menu-item', $classes, true) || in_array('current-menu-parent', $classes, true)) { |
|
138 | 138 | $classes[] = 'active'; |
139 | 139 | } |
140 | 140 | |
@@ -143,11 +143,11 @@ discard block |
||
143 | 143 | $classes[] = 'nav-item'; |
144 | 144 | |
145 | 145 | // Allow filtering the classes. |
146 | - $classes = apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args, $depth ); |
|
146 | + $classes = apply_filters('nav_menu_css_class', array_filter($classes), $item, $args, $depth); |
|
147 | 147 | |
148 | 148 | // Form a string of classes in format: class="class_names". |
149 | - $class_names = join( ' ', $classes ); |
|
150 | - $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : ''; |
|
149 | + $class_names = join(' ', $classes); |
|
150 | + $class_names = $class_names ? ' class="' . esc_attr($class_names) . '"' : ''; |
|
151 | 151 | |
152 | 152 | /** |
153 | 153 | * Filters the ID applied to a menu item's list item element. |
@@ -160,8 +160,8 @@ discard block |
||
160 | 160 | * @param stdClass $args An object of wp_nav_menu() arguments. |
161 | 161 | * @param int $depth Depth of menu item. Used for padding. |
162 | 162 | */ |
163 | - $id = apply_filters( 'nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args, $depth ); |
|
164 | - $id = $id ? ' id="' . esc_attr( $id ) . '"' : ''; |
|
163 | + $id = apply_filters('nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args, $depth); |
|
164 | + $id = $id ? ' id="' . esc_attr($id) . '"' : ''; |
|
165 | 165 | |
166 | 166 | $output .= $indent . '<li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement"' . $id . $class_names . '>'; |
167 | 167 | |
@@ -170,16 +170,16 @@ discard block |
||
170 | 170 | |
171 | 171 | // Set title from item to the $atts array - if title is empty then |
172 | 172 | // default to item title. |
173 | - if ( empty( $item->attr_title ) ) { |
|
174 | - $atts['title'] = ! empty( $item->title ) ? strip_tags( $item->title ) : ''; |
|
173 | + if (empty($item->attr_title)) { |
|
174 | + $atts['title'] = ! empty($item->title) ? strip_tags($item->title) : ''; |
|
175 | 175 | } else { |
176 | 176 | $atts['title'] = $item->attr_title; |
177 | 177 | } |
178 | 178 | |
179 | - $atts['target'] = ! empty( $item->target ) ? $item->target : ''; |
|
180 | - $atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : ''; |
|
179 | + $atts['target'] = ! empty($item->target) ? $item->target : ''; |
|
180 | + $atts['rel'] = ! empty($item->xfn) ? $item->xfn : ''; |
|
181 | 181 | // If item has_children add atts to <a>. |
182 | - if ( $this->has_children && 0 === $depth && $args->depth > 1 ) { |
|
182 | + if ($this->has_children && 0 === $depth && $args->depth > 1) { |
|
183 | 183 | $atts['href'] = '#'; |
184 | 184 | $atts['data-toggle'] = 'dropdown'; |
185 | 185 | $atts['aria-haspopup'] = 'true'; |
@@ -187,9 +187,9 @@ discard block |
||
187 | 187 | $atts['class'] = 'dropdown-toggle nav-link'; |
188 | 188 | $atts['id'] = 'menu-item-dropdown-' . $item->ID; |
189 | 189 | } else { |
190 | - $atts['href'] = ! empty( $item->url ) ? $item->url : '#'; |
|
190 | + $atts['href'] = ! empty($item->url) ? $item->url : '#'; |
|
191 | 191 | // Items in dropdowns use .dropdown-item instead of .nav-link. |
192 | - if ( $depth > 0 ) { |
|
192 | + if ($depth > 0) { |
|
193 | 193 | $atts['class'] = 'dropdown-item'; |
194 | 194 | } else { |
195 | 195 | $atts['class'] = 'nav-link'; |
@@ -199,15 +199,15 @@ discard block |
||
199 | 199 | $atts['aria-current'] = $item->current ? 'page' : ''; |
200 | 200 | |
201 | 201 | // update atts of this item based on any custom linkmod classes. |
202 | - $atts = self::update_atts_for_linkmod_type( $atts, $linkmod_classes ); |
|
202 | + $atts = self::update_atts_for_linkmod_type($atts, $linkmod_classes); |
|
203 | 203 | // Allow filtering of the $atts array before using it. |
204 | - $atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ); |
|
204 | + $atts = apply_filters('nav_menu_link_attributes', $atts, $item, $args, $depth); |
|
205 | 205 | |
206 | 206 | // Build a string of html containing all the atts for the item. |
207 | 207 | $attributes = ''; |
208 | - foreach ( $atts as $attr => $value ) { |
|
209 | - if ( ! empty( $value ) ) { |
|
210 | - $value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value ); |
|
208 | + foreach ($atts as $attr => $value) { |
|
209 | + if ( ! empty($value)) { |
|
210 | + $value = ('href' === $attr) ? esc_url($value) : esc_attr($value); |
|
211 | 211 | $attributes .= ' ' . $attr . '="' . $value . '"'; |
212 | 212 | } |
213 | 213 | } |
@@ -215,19 +215,19 @@ discard block |
||
215 | 215 | /** |
216 | 216 | * Set a typeflag to easily test if this is a linkmod or not. |
217 | 217 | */ |
218 | - $linkmod_type = self::get_linkmod_type( $linkmod_classes ); |
|
218 | + $linkmod_type = self::get_linkmod_type($linkmod_classes); |
|
219 | 219 | |
220 | 220 | /** |
221 | 221 | * START appending the internal item contents to the output. |
222 | 222 | */ |
223 | - $item_output = isset( $args->before ) ? $args->before : ''; |
|
223 | + $item_output = isset($args->before) ? $args->before : ''; |
|
224 | 224 | /** |
225 | 225 | * This is the start of the internal nav item. Depending on what |
226 | 226 | * kind of linkmod we have we may need different wrapper elements. |
227 | 227 | */ |
228 | - if ( '' !== $linkmod_type ) { |
|
228 | + if ('' !== $linkmod_type) { |
|
229 | 229 | // is linkmod, output the required element opener. |
230 | - $item_output .= self::linkmod_element_open( $linkmod_type, $attributes ); |
|
230 | + $item_output .= self::linkmod_element_open($linkmod_type, $attributes); |
|
231 | 231 | } else { |
232 | 232 | // With no link mod type set this must be a standard <a> tag. |
233 | 233 | $item_output .= '<a' . $attributes . '>'; |
@@ -239,13 +239,13 @@ discard block |
||
239 | 239 | * output inside of the item before the $title (the link text). |
240 | 240 | */ |
241 | 241 | $icon_html = ''; |
242 | - if ( ! empty( $icon_class_string ) ) { |
|
242 | + if ( ! empty($icon_class_string)) { |
|
243 | 243 | // append an <i> with the icon classes to what is output before links. |
244 | - $icon_html = '<i class="' . esc_attr( $icon_class_string ) . '" aria-hidden="true"></i> '; |
|
244 | + $icon_html = '<i class="' . esc_attr($icon_class_string) . '" aria-hidden="true"></i> '; |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** This filter is documented in wp-includes/post-template.php */ |
248 | - $title = apply_filters( 'the_title', esc_html( $item->title ), $item->ID ); |
|
248 | + $title = apply_filters('the_title', esc_html($item->title), $item->ID); |
|
249 | 249 | |
250 | 250 | /** |
251 | 251 | * Filters a menu item's title. |
@@ -257,39 +257,39 @@ discard block |
||
257 | 257 | * @param stdClass $args An object of wp_nav_menu() arguments. |
258 | 258 | * @param int $depth Depth of menu item. Used for padding. |
259 | 259 | */ |
260 | - $title = apply_filters( 'nav_menu_item_title', $title, $item, $args, $depth ); |
|
260 | + $title = apply_filters('nav_menu_item_title', $title, $item, $args, $depth); |
|
261 | 261 | |
262 | 262 | /** |
263 | 263 | * If the .sr-only class was set apply to the nav items text only. |
264 | 264 | */ |
265 | - if ( in_array( 'sr-only', $linkmod_classes, true ) ) { |
|
266 | - $title = self::wrap_for_screen_reader( $title ); |
|
267 | - $keys_to_unset = array_keys( $linkmod_classes, 'sr-only', true ); |
|
268 | - foreach ( $keys_to_unset as $k ) { |
|
269 | - unset( $linkmod_classes[ $k ] ); |
|
265 | + if (in_array('sr-only', $linkmod_classes, true)) { |
|
266 | + $title = self::wrap_for_screen_reader($title); |
|
267 | + $keys_to_unset = array_keys($linkmod_classes, 'sr-only', true); |
|
268 | + foreach ($keys_to_unset as $k) { |
|
269 | + unset($linkmod_classes[$k]); |
|
270 | 270 | } |
271 | 271 | } |
272 | 272 | |
273 | 273 | // Put the item contents into $output. |
274 | - $item_output .= isset( $args->link_before ) ? $args->link_before . $icon_html . $title . $args->link_after : ''; |
|
274 | + $item_output .= isset($args->link_before) ? $args->link_before . $icon_html . $title . $args->link_after : ''; |
|
275 | 275 | /** |
276 | 276 | * This is the end of the internal nav item. We need to close the |
277 | 277 | * correct element depending on the type of link or link mod. |
278 | 278 | */ |
279 | - if ( '' !== $linkmod_type ) { |
|
279 | + if ('' !== $linkmod_type) { |
|
280 | 280 | // is linkmod, output the required closing element. |
281 | - $item_output .= self::linkmod_element_close( $linkmod_type ); |
|
281 | + $item_output .= self::linkmod_element_close($linkmod_type); |
|
282 | 282 | } else { |
283 | 283 | // With no link mod type set this must be a standard <a> tag. |
284 | 284 | $item_output .= '</a>'; |
285 | 285 | } |
286 | 286 | |
287 | - $item_output .= isset( $args->after ) ? $args->after : ''; |
|
287 | + $item_output .= isset($args->after) ? $args->after : ''; |
|
288 | 288 | |
289 | 289 | /** |
290 | 290 | * END appending the internal item contents to the output. |
291 | 291 | */ |
292 | - $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args ); |
|
292 | + $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args); |
|
293 | 293 | |
294 | 294 | } |
295 | 295 | |
@@ -303,8 +303,8 @@ discard block |
||
303 | 303 | * |
304 | 304 | * @param array $args passed from the wp_nav_menu function. |
305 | 305 | */ |
306 | - public static function fallback( $args ) { |
|
307 | - if ( current_user_can( 'edit_theme_options' ) ) { |
|
306 | + public static function fallback($args) { |
|
307 | + if (current_user_can('edit_theme_options')) { |
|
308 | 308 | |
309 | 309 | /* Get Arguments. */ |
310 | 310 | $container = $args['container']; |
@@ -316,30 +316,30 @@ discard block |
||
316 | 316 | // initialize var to store fallback html. |
317 | 317 | $fallback_output = ''; |
318 | 318 | |
319 | - if ( $container ) { |
|
320 | - $fallback_output .= '<' . esc_attr( $container ); |
|
321 | - if ( $container_id ) { |
|
322 | - $fallback_output .= ' id="' . esc_attr( $container_id ) . '"'; |
|
319 | + if ($container) { |
|
320 | + $fallback_output .= '<' . esc_attr($container); |
|
321 | + if ($container_id) { |
|
322 | + $fallback_output .= ' id="' . esc_attr($container_id) . '"'; |
|
323 | 323 | } |
324 | - if ( $container_class ) { |
|
325 | - $fallback_output .= ' class="' . esc_attr( $container_class ) . '"'; |
|
324 | + if ($container_class) { |
|
325 | + $fallback_output .= ' class="' . esc_attr($container_class) . '"'; |
|
326 | 326 | } |
327 | 327 | $fallback_output .= '>'; |
328 | 328 | } |
329 | 329 | $fallback_output .= '<ul'; |
330 | - if ( $menu_id ) { |
|
331 | - $fallback_output .= ' id="' . esc_attr( $menu_id ) . '"'; } |
|
332 | - if ( $menu_class ) { |
|
333 | - $fallback_output .= ' class="' . esc_attr( $menu_class ) . '"'; } |
|
330 | + if ($menu_id) { |
|
331 | + $fallback_output .= ' id="' . esc_attr($menu_id) . '"'; } |
|
332 | + if ($menu_class) { |
|
333 | + $fallback_output .= ' class="' . esc_attr($menu_class) . '"'; } |
|
334 | 334 | $fallback_output .= '>'; |
335 | - $fallback_output .= '<li class="nav-item"><a href="' . esc_url( admin_url( 'nav-menus.php' ) ) . '" class="nav-link" title="' . esc_attr__( 'Add a menu', 'wp-bootstrap-navwalker' ) . '">' . esc_html__( 'Add a menu', 'wp-bootstrap-navwalker' ) . '</a></li>'; |
|
335 | + $fallback_output .= '<li class="nav-item"><a href="' . esc_url(admin_url('nav-menus.php')) . '" class="nav-link" title="' . esc_attr__('Add a menu', 'wp-bootstrap-navwalker') . '">' . esc_html__('Add a menu', 'wp-bootstrap-navwalker') . '</a></li>'; |
|
336 | 336 | $fallback_output .= '</ul>'; |
337 | - if ( $container ) { |
|
338 | - $fallback_output .= '</' . esc_attr( $container ) . '>'; |
|
337 | + if ($container) { |
|
338 | + $fallback_output .= '</' . esc_attr($container) . '>'; |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | // if $args has 'echo' key and it's true echo, otherwise return. |
342 | - if ( array_key_exists( 'echo', $args ) && $args['echo'] ) { |
|
342 | + if (array_key_exists('echo', $args) && $args['echo']) { |
|
343 | 343 | echo $fallback_output; // WPCS: XSS OK. |
344 | 344 | } else { |
345 | 345 | return $fallback_output; |
@@ -365,28 +365,28 @@ discard block |
||
365 | 365 | * |
366 | 366 | * @return array $classes a maybe modified array of classnames. |
367 | 367 | */ |
368 | - private function separate_linkmods_and_icons_from_classes( $classes, &$linkmod_classes, &$icon_classes, $depth ) { |
|
368 | + private function separate_linkmods_and_icons_from_classes($classes, &$linkmod_classes, &$icon_classes, $depth) { |
|
369 | 369 | // Loop through $classes array to find linkmod or icon classes. |
370 | - foreach ( $classes as $key => $class ) { |
|
370 | + foreach ($classes as $key => $class) { |
|
371 | 371 | // If any special classes are found, store the class in it's |
372 | 372 | // holder array and and unset the item from $classes. |
373 | - if ( preg_match( '/^disabled|^sr-only/i', $class ) ) { |
|
373 | + if (preg_match('/^disabled|^sr-only/i', $class)) { |
|
374 | 374 | // Test for .disabled or .sr-only classes. |
375 | 375 | $linkmod_classes[] = $class; |
376 | - unset( $classes[ $key ] ); |
|
377 | - } elseif ( preg_match( '/^dropdown-header|^dropdown-divider|^dropdown-item-text/i', $class ) && $depth > 0 ) { |
|
376 | + unset($classes[$key]); |
|
377 | + } elseif (preg_match('/^dropdown-header|^dropdown-divider|^dropdown-item-text/i', $class) && $depth > 0) { |
|
378 | 378 | // Test for .dropdown-header or .dropdown-divider and a |
379 | 379 | // depth greater than 0 - IE inside a dropdown. |
380 | 380 | $linkmod_classes[] = $class; |
381 | - unset( $classes[ $key ] ); |
|
382 | - } elseif ( preg_match( '/^fa-(\S*)?|^fa(s|r|l|b)?(\s?)?$/i', $class ) ) { |
|
381 | + unset($classes[$key]); |
|
382 | + } elseif (preg_match('/^fa-(\S*)?|^fa(s|r|l|b)?(\s?)?$/i', $class)) { |
|
383 | 383 | // Font Awesome. |
384 | 384 | $icon_classes[] = $class; |
385 | - unset( $classes[ $key ] ); |
|
386 | - } elseif ( preg_match( '/^glyphicon-(\S*)?|^glyphicon(\s?)$/i', $class ) ) { |
|
385 | + unset($classes[$key]); |
|
386 | + } elseif (preg_match('/^glyphicon-(\S*)?|^glyphicon(\s?)$/i', $class)) { |
|
387 | 387 | // Glyphicons. |
388 | 388 | $icon_classes[] = $class; |
389 | - unset( $classes[ $key ] ); |
|
389 | + unset($classes[$key]); |
|
390 | 390 | } |
391 | 391 | } |
392 | 392 | |
@@ -403,19 +403,19 @@ discard block |
||
403 | 403 | * |
404 | 404 | * @return string empty for default, a linkmod type string otherwise. |
405 | 405 | */ |
406 | - private function get_linkmod_type( $linkmod_classes = array() ) { |
|
406 | + private function get_linkmod_type($linkmod_classes = array()) { |
|
407 | 407 | $linkmod_type = ''; |
408 | 408 | // Loop through array of linkmod classes to handle their $atts. |
409 | - if ( ! empty( $linkmod_classes ) ) { |
|
410 | - foreach ( $linkmod_classes as $link_class ) { |
|
411 | - if ( ! empty( $link_class ) ) { |
|
409 | + if ( ! empty($linkmod_classes)) { |
|
410 | + foreach ($linkmod_classes as $link_class) { |
|
411 | + if ( ! empty($link_class)) { |
|
412 | 412 | |
413 | 413 | // check for special class types and set a flag for them. |
414 | - if ( 'dropdown-header' === $link_class ) { |
|
414 | + if ('dropdown-header' === $link_class) { |
|
415 | 415 | $linkmod_type = 'dropdown-header'; |
416 | - } elseif ( 'dropdown-divider' === $link_class ) { |
|
416 | + } elseif ('dropdown-divider' === $link_class) { |
|
417 | 417 | $linkmod_type = 'dropdown-divider'; |
418 | - } elseif ( 'dropdown-item-text' === $link_class ) { |
|
418 | + } elseif ('dropdown-item-text' === $link_class) { |
|
419 | 419 | $linkmod_type = 'dropdown-item-text'; |
420 | 420 | } |
421 | 421 | } |
@@ -434,24 +434,24 @@ discard block |
||
434 | 434 | * |
435 | 435 | * @return array maybe updated array of attributes for item. |
436 | 436 | */ |
437 | - private function update_atts_for_linkmod_type( $atts = array(), $linkmod_classes = array() ) { |
|
438 | - if ( ! empty( $linkmod_classes ) ) { |
|
439 | - foreach ( $linkmod_classes as $link_class ) { |
|
440 | - if ( ! empty( $link_class ) ) { |
|
437 | + private function update_atts_for_linkmod_type($atts = array(), $linkmod_classes = array()) { |
|
438 | + if ( ! empty($linkmod_classes)) { |
|
439 | + foreach ($linkmod_classes as $link_class) { |
|
440 | + if ( ! empty($link_class)) { |
|
441 | 441 | // update $atts with a space and the extra classname... |
442 | 442 | // so long as it's not a sr-only class. |
443 | - if ( 'sr-only' !== $link_class ) { |
|
444 | - $atts['class'] .= ' ' . esc_attr( $link_class ); |
|
443 | + if ('sr-only' !== $link_class) { |
|
444 | + $atts['class'] .= ' ' . esc_attr($link_class); |
|
445 | 445 | } |
446 | 446 | // check for special class types we need additional handling for. |
447 | - if ( 'disabled' === $link_class ) { |
|
447 | + if ('disabled' === $link_class) { |
|
448 | 448 | // Convert link to '#' and unset open targets. |
449 | 449 | $atts['href'] = '#'; |
450 | - unset( $atts['target'] ); |
|
451 | - } elseif ( 'dropdown-header' === $link_class || 'dropdown-divider' === $link_class || 'dropdown-item-text' === $link_class ) { |
|
450 | + unset($atts['target']); |
|
451 | + } elseif ('dropdown-header' === $link_class || 'dropdown-divider' === $link_class || 'dropdown-item-text' === $link_class) { |
|
452 | 452 | // Store a type flag and unset href and target. |
453 | - unset( $atts['href'] ); |
|
454 | - unset( $atts['target'] ); |
|
453 | + unset($atts['href']); |
|
454 | + unset($atts['target']); |
|
455 | 455 | } |
456 | 456 | } |
457 | 457 | } |
@@ -467,8 +467,8 @@ discard block |
||
467 | 467 | * @param string $text the string of text to be wrapped in a screen reader class. |
468 | 468 | * @return string the string wrapped in a span with the class. |
469 | 469 | */ |
470 | - private function wrap_for_screen_reader( $text = '' ) { |
|
471 | - if ( $text ) { |
|
470 | + private function wrap_for_screen_reader($text = '') { |
|
471 | + if ($text) { |
|
472 | 472 | $text = '<span class="sr-only">' . $text . '</span>'; |
473 | 473 | } |
474 | 474 | return $text; |
@@ -484,15 +484,15 @@ discard block |
||
484 | 484 | * |
485 | 485 | * @return string a string with the openign tag for the element with attribibutes added. |
486 | 486 | */ |
487 | - private function linkmod_element_open( $linkmod_type, $attributes = '' ) { |
|
487 | + private function linkmod_element_open($linkmod_type, $attributes = '') { |
|
488 | 488 | $output = ''; |
489 | - if ( 'dropdown-item-text' === $linkmod_type ) { |
|
489 | + if ('dropdown-item-text' === $linkmod_type) { |
|
490 | 490 | $output .= '<span class="dropdown-item-text"' . $attributes . '>'; |
491 | - } elseif ( 'dropdown-header' === $linkmod_type ) { |
|
491 | + } elseif ('dropdown-header' === $linkmod_type) { |
|
492 | 492 | // For a header use a span with the .h6 class instead of a real |
493 | 493 | // header tag so that it doesn't confuse screen readers. |
494 | 494 | $output .= '<span class="dropdown-header h6"' . $attributes . '>'; |
495 | - } elseif ( 'dropdown-divider' === $linkmod_type ) { |
|
495 | + } elseif ('dropdown-divider' === $linkmod_type) { |
|
496 | 496 | // this is a divider. |
497 | 497 | $output .= '<div class="dropdown-divider"' . $attributes . '>'; |
498 | 498 | } |
@@ -508,13 +508,13 @@ discard block |
||
508 | 508 | * |
509 | 509 | * @return string a string with the closing tag for this linkmod type. |
510 | 510 | */ |
511 | - private function linkmod_element_close( $linkmod_type ) { |
|
511 | + private function linkmod_element_close($linkmod_type) { |
|
512 | 512 | $output = ''; |
513 | - if ( 'dropdown-header' === $linkmod_type || 'dropdown-item-text' === $linkmod_type ) { |
|
513 | + if ('dropdown-header' === $linkmod_type || 'dropdown-item-text' === $linkmod_type) { |
|
514 | 514 | // For a header use a span with the .h6 class instead of a real |
515 | 515 | // header tag so that it doesn't confuse screen readers. |
516 | 516 | $output .= '</span>'; |
517 | - } elseif ( 'dropdown-divider' === $linkmod_type ) { |
|
517 | + } elseif ('dropdown-divider' === $linkmod_type) { |
|
518 | 518 | // this is a divider. |
519 | 519 | $output .= '</div>'; |
520 | 520 | } |