@@ -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 | /* |
64 | 64 | * The `.dropdown-menu` container needs to have a labelledby |
@@ -69,11 +69,11 @@ discard block |
||
69 | 69 | */ |
70 | 70 | $labelledby = ''; |
71 | 71 | // Find all links with an id in the output. |
72 | - preg_match_all( '/(<a.*?id=\"|\')(.*?)\"|\'.*?>/im', $output, $matches ); |
|
72 | + preg_match_all('/(<a.*?id=\"|\')(.*?)\"|\'.*?>/im', $output, $matches); |
|
73 | 73 | // With pointer at end of array check if we got an ID match. |
74 | - if ( end( $matches[2] ) ) { |
|
74 | + if (end($matches[2])) { |
|
75 | 75 | // Build a string to use as aria-labelledby. |
76 | - $labelledby = 'aria-labelledby="' . esc_attr( end( $matches[2] ) ) . '"'; |
|
76 | + $labelledby = 'aria-labelledby="' . esc_attr(end($matches[2])) . '"'; |
|
77 | 77 | } |
78 | 78 | $output .= "{$n}{$indent}<ul$class_names $labelledby role=\"menu\">{$n}"; |
79 | 79 | } |
@@ -92,17 +92,17 @@ discard block |
||
92 | 92 | * @param stdClass $args An object of wp_nav_menu() arguments. |
93 | 93 | * @param int $id Current item ID. |
94 | 94 | */ |
95 | - public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { |
|
96 | - if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) { |
|
95 | + public function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { |
|
96 | + if (isset($args->item_spacing) && 'discard' === $args->item_spacing) { |
|
97 | 97 | $t = ''; |
98 | 98 | $n = ''; |
99 | 99 | } else { |
100 | 100 | $t = "\t"; |
101 | 101 | $n = "\n"; |
102 | 102 | } |
103 | - $indent = ( $depth ) ? str_repeat( $t, $depth ) : ''; |
|
103 | + $indent = ($depth) ? str_repeat($t, $depth) : ''; |
|
104 | 104 | |
105 | - $classes = empty( $item->classes ) ? array() : (array) $item->classes; |
|
105 | + $classes = empty($item->classes) ? array() : (array) $item->classes; |
|
106 | 106 | |
107 | 107 | /* |
108 | 108 | * Initialize some holder variables to store specially handled item |
@@ -117,10 +117,10 @@ discard block |
||
117 | 117 | * NOTE: linkmod and icon class arrays are passed by reference and |
118 | 118 | * are maybe modified before being used later in this function. |
119 | 119 | */ |
120 | - $classes = self::separate_linkmods_and_icons_from_classes( $classes, $linkmod_classes, $icon_classes, $depth ); |
|
120 | + $classes = self::separate_linkmods_and_icons_from_classes($classes, $linkmod_classes, $icon_classes, $depth); |
|
121 | 121 | |
122 | 122 | // Join any icon classes plucked from $classes into a string. |
123 | - $icon_class_string = join( ' ', $icon_classes ); |
|
123 | + $icon_class_string = join(' ', $icon_classes); |
|
124 | 124 | |
125 | 125 | /** |
126 | 126 | * Filters the arguments for a single nav menu item. |
@@ -131,13 +131,13 @@ discard block |
||
131 | 131 | * @param WP_Post $item Menu item data object. |
132 | 132 | * @param int $depth Depth of menu item. Used for padding. |
133 | 133 | */ |
134 | - $args = apply_filters( 'nav_menu_item_args', $args, $item, $depth ); |
|
134 | + $args = apply_filters('nav_menu_item_args', $args, $item, $depth); |
|
135 | 135 | |
136 | 136 | // Add .dropdown or .active classes where they are needed. |
137 | - if ( isset( $args->has_children ) && $args->has_children ) { |
|
137 | + if (isset($args->has_children) && $args->has_children) { |
|
138 | 138 | $classes[] = 'dropdown'; |
139 | 139 | } |
140 | - if ( in_array( 'current-menu-item', $classes, true ) || in_array( 'current-menu-parent', $classes, true ) ) { |
|
140 | + if (in_array('current-menu-item', $classes, true) || in_array('current-menu-parent', $classes, true)) { |
|
141 | 141 | $classes[] = 'active'; |
142 | 142 | } |
143 | 143 | |
@@ -146,11 +146,11 @@ discard block |
||
146 | 146 | $classes[] = 'nav-item'; |
147 | 147 | |
148 | 148 | // Allow filtering the classes. |
149 | - $classes = apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args, $depth ); |
|
149 | + $classes = apply_filters('nav_menu_css_class', array_filter($classes), $item, $args, $depth); |
|
150 | 150 | |
151 | 151 | // Form a string of classes in format: class="class_names". |
152 | - $class_names = join( ' ', $classes ); |
|
153 | - $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : ''; |
|
152 | + $class_names = join(' ', $classes); |
|
153 | + $class_names = $class_names ? ' class="' . esc_attr($class_names) . '"' : ''; |
|
154 | 154 | |
155 | 155 | /** |
156 | 156 | * Filters the ID applied to a menu item's list item element. |
@@ -163,8 +163,8 @@ discard block |
||
163 | 163 | * @param stdClass $args An object of wp_nav_menu() arguments. |
164 | 164 | * @param int $depth Depth of menu item. Used for padding. |
165 | 165 | */ |
166 | - $id = apply_filters( 'nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args, $depth ); |
|
167 | - $id = $id ? ' id="' . esc_attr( $id ) . '"' : ''; |
|
166 | + $id = apply_filters('nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args, $depth); |
|
167 | + $id = $id ? ' id="' . esc_attr($id) . '"' : ''; |
|
168 | 168 | |
169 | 169 | // Add role attribute if menu item is part of a submenu |
170 | 170 | $role = $depth > 0 ? ' role="menuitem"' : ''; |
@@ -178,16 +178,16 @@ discard block |
||
178 | 178 | * Set title from item to the $atts array - if title is empty then |
179 | 179 | * default to item title. |
180 | 180 | */ |
181 | - if ( empty( $item->attr_title ) ) { |
|
182 | - $atts['title'] = ! empty( $item->title ) ? strip_tags( $item->title ) : ''; |
|
181 | + if (empty($item->attr_title)) { |
|
182 | + $atts['title'] = ! empty($item->title) ? strip_tags($item->title) : ''; |
|
183 | 183 | } else { |
184 | 184 | $atts['title'] = $item->attr_title; |
185 | 185 | } |
186 | 186 | |
187 | - $atts['target'] = ! empty( $item->target ) ? $item->target : ''; |
|
188 | - $atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : ''; |
|
187 | + $atts['target'] = ! empty($item->target) ? $item->target : ''; |
|
188 | + $atts['rel'] = ! empty($item->xfn) ? $item->xfn : ''; |
|
189 | 189 | // If the item has children, add atts to the <a>. |
190 | - if ( isset( $args->has_children ) && $args->has_children && 0 === $depth && $args->depth > 1 ) { |
|
190 | + if (isset($args->has_children) && $args->has_children && 0 === $depth && $args->depth > 1) { |
|
191 | 191 | $atts['href'] = '#'; |
192 | 192 | $atts['data-toggle'] = 'dropdown'; |
193 | 193 | $atts['aria-haspopup'] = 'true'; |
@@ -195,9 +195,9 @@ discard block |
||
195 | 195 | $atts['class'] = 'dropdown-toggle nav-link'; |
196 | 196 | $atts['id'] = 'menu-item-dropdown-' . $item->ID; |
197 | 197 | } else { |
198 | - $atts['href'] = ! empty( $item->url ) ? $item->url : '#'; |
|
198 | + $atts['href'] = ! empty($item->url) ? $item->url : '#'; |
|
199 | 199 | // For items in dropdowns use .dropdown-item instead of .nav-link. |
200 | - if ( $depth > 0 ) { |
|
200 | + if ($depth > 0) { |
|
201 | 201 | $atts['class'] = 'dropdown-item'; |
202 | 202 | } else { |
203 | 203 | $atts['class'] = 'nav-link'; |
@@ -207,32 +207,32 @@ discard block |
||
207 | 207 | $atts['aria-current'] = $item->current ? 'page' : ''; |
208 | 208 | |
209 | 209 | // Update atts of this item based on any custom linkmod classes. |
210 | - $atts = self::update_atts_for_linkmod_type( $atts, $linkmod_classes ); |
|
210 | + $atts = self::update_atts_for_linkmod_type($atts, $linkmod_classes); |
|
211 | 211 | // Allow filtering of the $atts array before using it. |
212 | - $atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ); |
|
212 | + $atts = apply_filters('nav_menu_link_attributes', $atts, $item, $args, $depth); |
|
213 | 213 | |
214 | 214 | // Build a string of html containing all the atts for the item. |
215 | 215 | $attributes = ''; |
216 | - foreach ( $atts as $attr => $value ) { |
|
217 | - if ( ! empty( $value ) ) { |
|
218 | - $value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value ); |
|
216 | + foreach ($atts as $attr => $value) { |
|
217 | + if ( ! empty($value)) { |
|
218 | + $value = ('href' === $attr) ? esc_url($value) : esc_attr($value); |
|
219 | 219 | $attributes .= ' ' . $attr . '="' . $value . '"'; |
220 | 220 | } |
221 | 221 | } |
222 | 222 | |
223 | 223 | // Set a typeflag to easily test if this is a linkmod or not. |
224 | - $linkmod_type = self::get_linkmod_type( $linkmod_classes ); |
|
224 | + $linkmod_type = self::get_linkmod_type($linkmod_classes); |
|
225 | 225 | |
226 | 226 | // START appending the internal item contents to the output. |
227 | - $item_output = isset( $args->before ) ? $args->before : ''; |
|
227 | + $item_output = isset($args->before) ? $args->before : ''; |
|
228 | 228 | |
229 | 229 | /* |
230 | 230 | * This is the start of the internal nav item. Depending on what |
231 | 231 | * kind of linkmod we have we may need different wrapper elements. |
232 | 232 | */ |
233 | - if ( '' !== $linkmod_type ) { |
|
233 | + if ('' !== $linkmod_type) { |
|
234 | 234 | // Is linkmod, output the required element opener. |
235 | - $item_output .= self::linkmod_element_open( $linkmod_type, $attributes ); |
|
235 | + $item_output .= self::linkmod_element_open($linkmod_type, $attributes); |
|
236 | 236 | } else { |
237 | 237 | // With no link mod type set this must be a standard <a> tag. |
238 | 238 | $item_output .= '<a' . $attributes . '>'; |
@@ -244,13 +244,13 @@ discard block |
||
244 | 244 | * output inside of the item before the $title (the link text). |
245 | 245 | */ |
246 | 246 | $icon_html = ''; |
247 | - if ( ! empty( $icon_class_string ) ) { |
|
247 | + if ( ! empty($icon_class_string)) { |
|
248 | 248 | // Append an <i> with the icon classes to what is output before links. |
249 | - $icon_html = '<i class="' . esc_attr( $icon_class_string ) . '" aria-hidden="true"></i> '; |
|
249 | + $icon_html = '<i class="' . esc_attr($icon_class_string) . '" aria-hidden="true"></i> '; |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** This filter is documented in wp-includes/post-template.php */ |
253 | - $title = apply_filters( 'the_title', esc_html( $item->title ), $item->ID ); |
|
253 | + $title = apply_filters('the_title', esc_html($item->title), $item->ID); |
|
254 | 254 | |
255 | 255 | /** |
256 | 256 | * Filters a menu item's title. |
@@ -262,36 +262,36 @@ discard block |
||
262 | 262 | * @param stdClass $args An object of wp_nav_menu() arguments. |
263 | 263 | * @param int $depth Depth of menu item. Used for padding. |
264 | 264 | */ |
265 | - $title = apply_filters( 'nav_menu_item_title', $title, $item, $args, $depth ); |
|
265 | + $title = apply_filters('nav_menu_item_title', $title, $item, $args, $depth); |
|
266 | 266 | |
267 | 267 | // If the .sr-only class was set apply to the nav items text only. |
268 | - if ( in_array( 'sr-only', $linkmod_classes, true ) ) { |
|
269 | - $title = self::wrap_for_screen_reader( $title ); |
|
270 | - $keys_to_unset = array_keys( $linkmod_classes, 'sr-only', true ); |
|
271 | - foreach ( $keys_to_unset as $k ) { |
|
272 | - unset( $linkmod_classes[ $k ] ); |
|
268 | + if (in_array('sr-only', $linkmod_classes, true)) { |
|
269 | + $title = self::wrap_for_screen_reader($title); |
|
270 | + $keys_to_unset = array_keys($linkmod_classes, 'sr-only', true); |
|
271 | + foreach ($keys_to_unset as $k) { |
|
272 | + unset($linkmod_classes[$k]); |
|
273 | 273 | } |
274 | 274 | } |
275 | 275 | |
276 | 276 | // Put the item contents into $output. |
277 | - $item_output .= isset( $args->link_before ) ? $args->link_before . $icon_html . $title . $args->link_after : ''; |
|
277 | + $item_output .= isset($args->link_before) ? $args->link_before . $icon_html . $title . $args->link_after : ''; |
|
278 | 278 | |
279 | 279 | /* |
280 | 280 | * This is the end of the internal nav item. We need to close the |
281 | 281 | * correct element depending on the type of link or link mod. |
282 | 282 | */ |
283 | - if ( '' !== $linkmod_type ) { |
|
283 | + if ('' !== $linkmod_type) { |
|
284 | 284 | // Is linkmod, output the required closing element. |
285 | - $item_output .= self::linkmod_element_close( $linkmod_type ); |
|
285 | + $item_output .= self::linkmod_element_close($linkmod_type); |
|
286 | 286 | } else { |
287 | 287 | // With no link mod type set this must be a standard <a> tag. |
288 | 288 | $item_output .= '</a>'; |
289 | 289 | } |
290 | 290 | |
291 | - $item_output .= isset( $args->after ) ? $args->after : ''; |
|
291 | + $item_output .= isset($args->after) ? $args->after : ''; |
|
292 | 292 | |
293 | 293 | // END appending the internal item contents to the output. |
294 | - $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args ); |
|
294 | + $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args); |
|
295 | 295 | |
296 | 296 | } |
297 | 297 | |
@@ -316,14 +316,14 @@ discard block |
||
316 | 316 | * @param array $args An array of arguments. |
317 | 317 | * @param string $output Used to append additional content (passed by reference). |
318 | 318 | */ |
319 | - public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) { |
|
320 | - if ( ! $element ) { |
|
319 | + public function display_element($element, &$children_elements, $max_depth, $depth, $args, &$output) { |
|
320 | + if ( ! $element) { |
|
321 | 321 | return; } |
322 | 322 | $id_field = $this->db_fields['id']; |
323 | 323 | // Display this element. |
324 | - if ( is_object( $args[0] ) ) { |
|
325 | - $args[0]->has_children = ! empty( $children_elements[ $element->$id_field ] ); } |
|
326 | - parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output ); |
|
324 | + if (is_object($args[0])) { |
|
325 | + $args[0]->has_children = ! empty($children_elements[$element->$id_field]); } |
|
326 | + parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | /** |
@@ -336,8 +336,8 @@ discard block |
||
336 | 336 | * |
337 | 337 | * @param array $args passed from the wp_nav_menu function. |
338 | 338 | */ |
339 | - public static function fallback( $args ) { |
|
340 | - if ( current_user_can( 'edit_theme_options' ) ) { |
|
339 | + public static function fallback($args) { |
|
340 | + if (current_user_can('edit_theme_options')) { |
|
341 | 341 | |
342 | 342 | // Get Arguments. |
343 | 343 | $container = $args['container']; |
@@ -349,30 +349,30 @@ discard block |
||
349 | 349 | // Initialize var to store fallback html. |
350 | 350 | $fallback_output = ''; |
351 | 351 | |
352 | - if ( $container ) { |
|
353 | - $fallback_output .= '<' . esc_attr( $container ); |
|
354 | - if ( $container_id ) { |
|
355 | - $fallback_output .= ' id="' . esc_attr( $container_id ) . '"'; |
|
352 | + if ($container) { |
|
353 | + $fallback_output .= '<' . esc_attr($container); |
|
354 | + if ($container_id) { |
|
355 | + $fallback_output .= ' id="' . esc_attr($container_id) . '"'; |
|
356 | 356 | } |
357 | - if ( $container_class ) { |
|
358 | - $fallback_output .= ' class="' . esc_attr( $container_class ) . '"'; |
|
357 | + if ($container_class) { |
|
358 | + $fallback_output .= ' class="' . esc_attr($container_class) . '"'; |
|
359 | 359 | } |
360 | 360 | $fallback_output .= '>'; |
361 | 361 | } |
362 | 362 | $fallback_output .= '<ul'; |
363 | - if ( $menu_id ) { |
|
364 | - $fallback_output .= ' id="' . esc_attr( $menu_id ) . '"'; } |
|
365 | - if ( $menu_class ) { |
|
366 | - $fallback_output .= ' class="' . esc_attr( $menu_class ) . '"'; } |
|
363 | + if ($menu_id) { |
|
364 | + $fallback_output .= ' id="' . esc_attr($menu_id) . '"'; } |
|
365 | + if ($menu_class) { |
|
366 | + $fallback_output .= ' class="' . esc_attr($menu_class) . '"'; } |
|
367 | 367 | $fallback_output .= '>'; |
368 | - $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>'; |
|
368 | + $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>'; |
|
369 | 369 | $fallback_output .= '</ul>'; |
370 | - if ( $container ) { |
|
371 | - $fallback_output .= '</' . esc_attr( $container ) . '>'; |
|
370 | + if ($container) { |
|
371 | + $fallback_output .= '</' . esc_attr($container) . '>'; |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | // If $args has 'echo' key and it's true echo, otherwise return. |
375 | - if ( array_key_exists( 'echo', $args ) && $args['echo'] ) { |
|
375 | + if (array_key_exists('echo', $args) && $args['echo']) { |
|
376 | 376 | echo $fallback_output; // WPCS: XSS OK. |
377 | 377 | } else { |
378 | 378 | return $fallback_output; |
@@ -398,32 +398,32 @@ discard block |
||
398 | 398 | * |
399 | 399 | * @return array $classes a maybe modified array of classnames. |
400 | 400 | */ |
401 | - private function separate_linkmods_and_icons_from_classes( $classes, &$linkmod_classes, &$icon_classes, $depth ) { |
|
401 | + private function separate_linkmods_and_icons_from_classes($classes, &$linkmod_classes, &$icon_classes, $depth) { |
|
402 | 402 | // Loop through $classes array to find linkmod or icon classes. |
403 | - foreach ( $classes as $key => $class ) { |
|
403 | + foreach ($classes as $key => $class) { |
|
404 | 404 | /* |
405 | 405 | * If any special classes are found, store the class in it's |
406 | 406 | * holder array and and unset the item from $classes. |
407 | 407 | */ |
408 | - if ( preg_match( '/^disabled|^sr-only/i', $class ) ) { |
|
408 | + if (preg_match('/^disabled|^sr-only/i', $class)) { |
|
409 | 409 | // Test for .disabled or .sr-only classes. |
410 | 410 | $linkmod_classes[] = $class; |
411 | - unset( $classes[ $key ] ); |
|
412 | - } elseif ( preg_match( '/^dropdown-header|^dropdown-divider|^dropdown-item-text/i', $class ) && $depth > 0 ) { |
|
411 | + unset($classes[$key]); |
|
412 | + } elseif (preg_match('/^dropdown-header|^dropdown-divider|^dropdown-item-text/i', $class) && $depth > 0) { |
|
413 | 413 | /* |
414 | 414 | * Test for .dropdown-header or .dropdown-divider and a |
415 | 415 | * depth greater than 0 - IE inside a dropdown. |
416 | 416 | */ |
417 | 417 | $linkmod_classes[] = $class; |
418 | - unset( $classes[ $key ] ); |
|
419 | - } elseif ( preg_match( '/^fa-(\S*)?|^fa(s|r|l|b)?(\s?)?$/i', $class ) ) { |
|
418 | + unset($classes[$key]); |
|
419 | + } elseif (preg_match('/^fa-(\S*)?|^fa(s|r|l|b)?(\s?)?$/i', $class)) { |
|
420 | 420 | // Font Awesome. |
421 | 421 | $icon_classes[] = $class; |
422 | - unset( $classes[ $key ] ); |
|
423 | - } elseif ( preg_match( '/^glyphicon-(\S*)?|^glyphicon(\s?)$/i', $class ) ) { |
|
422 | + unset($classes[$key]); |
|
423 | + } elseif (preg_match('/^glyphicon-(\S*)?|^glyphicon(\s?)$/i', $class)) { |
|
424 | 424 | // Glyphicons. |
425 | 425 | $icon_classes[] = $class; |
426 | - unset( $classes[ $key ] ); |
|
426 | + unset($classes[$key]); |
|
427 | 427 | } |
428 | 428 | } |
429 | 429 | |
@@ -440,19 +440,19 @@ discard block |
||
440 | 440 | * |
441 | 441 | * @return string empty for default, a linkmod type string otherwise. |
442 | 442 | */ |
443 | - private function get_linkmod_type( $linkmod_classes = array() ) { |
|
443 | + private function get_linkmod_type($linkmod_classes = array()) { |
|
444 | 444 | $linkmod_type = ''; |
445 | 445 | // Loop through array of linkmod classes to handle their $atts. |
446 | - if ( ! empty( $linkmod_classes ) ) { |
|
447 | - foreach ( $linkmod_classes as $link_class ) { |
|
448 | - if ( ! empty( $link_class ) ) { |
|
446 | + if ( ! empty($linkmod_classes)) { |
|
447 | + foreach ($linkmod_classes as $link_class) { |
|
448 | + if ( ! empty($link_class)) { |
|
449 | 449 | |
450 | 450 | // Check for special class types and set a flag for them. |
451 | - if ( 'dropdown-header' === $link_class ) { |
|
451 | + if ('dropdown-header' === $link_class) { |
|
452 | 452 | $linkmod_type = 'dropdown-header'; |
453 | - } elseif ( 'dropdown-divider' === $link_class ) { |
|
453 | + } elseif ('dropdown-divider' === $link_class) { |
|
454 | 454 | $linkmod_type = 'dropdown-divider'; |
455 | - } elseif ( 'dropdown-item-text' === $link_class ) { |
|
455 | + } elseif ('dropdown-item-text' === $link_class) { |
|
456 | 456 | $linkmod_type = 'dropdown-item-text'; |
457 | 457 | } |
458 | 458 | } |
@@ -471,26 +471,26 @@ discard block |
||
471 | 471 | * |
472 | 472 | * @return array maybe updated array of attributes for item. |
473 | 473 | */ |
474 | - private function update_atts_for_linkmod_type( $atts = array(), $linkmod_classes = array() ) { |
|
475 | - if ( ! empty( $linkmod_classes ) ) { |
|
476 | - foreach ( $linkmod_classes as $link_class ) { |
|
477 | - if ( ! empty( $link_class ) ) { |
|
474 | + private function update_atts_for_linkmod_type($atts = array(), $linkmod_classes = array()) { |
|
475 | + if ( ! empty($linkmod_classes)) { |
|
476 | + foreach ($linkmod_classes as $link_class) { |
|
477 | + if ( ! empty($link_class)) { |
|
478 | 478 | /* |
479 | 479 | * Update $atts with a space and the extra classname |
480 | 480 | * so long as it's not a sr-only class. |
481 | 481 | */ |
482 | - if ( 'sr-only' !== $link_class ) { |
|
483 | - $atts['class'] .= ' ' . esc_attr( $link_class ); |
|
482 | + if ('sr-only' !== $link_class) { |
|
483 | + $atts['class'] .= ' ' . esc_attr($link_class); |
|
484 | 484 | } |
485 | 485 | // Check for special class types we need additional handling for. |
486 | - if ( 'disabled' === $link_class ) { |
|
486 | + if ('disabled' === $link_class) { |
|
487 | 487 | // Convert link to '#' and unset open targets. |
488 | 488 | $atts['href'] = '#'; |
489 | - unset( $atts['target'] ); |
|
490 | - } elseif ( 'dropdown-header' === $link_class || 'dropdown-divider' === $link_class || 'dropdown-item-text' === $link_class ) { |
|
489 | + unset($atts['target']); |
|
490 | + } elseif ('dropdown-header' === $link_class || 'dropdown-divider' === $link_class || 'dropdown-item-text' === $link_class) { |
|
491 | 491 | // Store a type flag and unset href and target. |
492 | - unset( $atts['href'] ); |
|
493 | - unset( $atts['target'] ); |
|
492 | + unset($atts['href']); |
|
493 | + unset($atts['target']); |
|
494 | 494 | } |
495 | 495 | } |
496 | 496 | } |
@@ -506,8 +506,8 @@ discard block |
||
506 | 506 | * @param string $text the string of text to be wrapped in a screen reader class. |
507 | 507 | * @return string the string wrapped in a span with the class. |
508 | 508 | */ |
509 | - private function wrap_for_screen_reader( $text = '' ) { |
|
510 | - if ( $text ) { |
|
509 | + private function wrap_for_screen_reader($text = '') { |
|
510 | + if ($text) { |
|
511 | 511 | $text = '<span class="sr-only">' . $text . '</span>'; |
512 | 512 | } |
513 | 513 | return $text; |
@@ -523,17 +523,17 @@ discard block |
||
523 | 523 | * |
524 | 524 | * @return string a string with the openign tag for the element with attribibutes added. |
525 | 525 | */ |
526 | - private function linkmod_element_open( $linkmod_type, $attributes = '' ) { |
|
526 | + private function linkmod_element_open($linkmod_type, $attributes = '') { |
|
527 | 527 | $output = ''; |
528 | - if ( 'dropdown-item-text' === $linkmod_type ) { |
|
528 | + if ('dropdown-item-text' === $linkmod_type) { |
|
529 | 529 | $output .= '<span class="dropdown-item-text"' . $attributes . '>'; |
530 | - } elseif ( 'dropdown-header' === $linkmod_type ) { |
|
530 | + } elseif ('dropdown-header' === $linkmod_type) { |
|
531 | 531 | /* |
532 | 532 | * For a header use a span with the .h6 class instead of a real |
533 | 533 | * header tag so that it doesn't confuse screen readers. |
534 | 534 | */ |
535 | 535 | $output .= '<span class="dropdown-header h6"' . $attributes . '>'; |
536 | - } elseif ( 'dropdown-divider' === $linkmod_type ) { |
|
536 | + } elseif ('dropdown-divider' === $linkmod_type) { |
|
537 | 537 | // This is a divider. |
538 | 538 | $output .= '<div class="dropdown-divider"' . $attributes . '>'; |
539 | 539 | } |
@@ -549,15 +549,15 @@ discard block |
||
549 | 549 | * |
550 | 550 | * @return string a string with the closing tag for this linkmod type. |
551 | 551 | */ |
552 | - private function linkmod_element_close( $linkmod_type ) { |
|
552 | + private function linkmod_element_close($linkmod_type) { |
|
553 | 553 | $output = ''; |
554 | - if ( 'dropdown-header' === $linkmod_type || 'dropdown-item-text' === $linkmod_type ) { |
|
554 | + if ('dropdown-header' === $linkmod_type || 'dropdown-item-text' === $linkmod_type) { |
|
555 | 555 | /* |
556 | 556 | * For a header use a span with the .h6 class instead of a real |
557 | 557 | * header tag so that it doesn't confuse screen readers. |
558 | 558 | */ |
559 | 559 | $output .= '</span>'; |
560 | - } elseif ( 'dropdown-divider' === $linkmod_type ) { |
|
560 | + } elseif ('dropdown-divider' === $linkmod_type) { |
|
561 | 561 | // This is a divider. |
562 | 562 | $output .= '</div>'; |
563 | 563 | } |