@@ -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 | */ |
@@ -35,17 +35,17 @@ discard block |
||
35 | 35 | * @param int $depth Depth of menu item. Used for padding. |
36 | 36 | * @param WP_Nav_Menu_Args $args An object of wp_nav_menu() arguments. |
37 | 37 | */ |
38 | - public function start_lvl( &$output, $depth = 0, $args = null ) { |
|
39 | - if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) { |
|
38 | + public function start_lvl(&$output, $depth = 0, $args = null) { |
|
39 | + if (isset($args->item_spacing) && 'discard' === $args->item_spacing) { |
|
40 | 40 | $t = ''; |
41 | 41 | $n = ''; |
42 | 42 | } else { |
43 | 43 | $t = "\t"; |
44 | 44 | $n = "\n"; |
45 | 45 | } |
46 | - $indent = str_repeat( $t, $depth ); |
|
46 | + $indent = str_repeat($t, $depth); |
|
47 | 47 | // Default class to add to the file. |
48 | - $classes = array( 'dropdown-menu' ); |
|
48 | + $classes = array('dropdown-menu'); |
|
49 | 49 | /** |
50 | 50 | * Filters the CSS class(es) applied to a menu list element. |
51 | 51 | * |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | * @param stdClass $args An object of `wp_nav_menu()` arguments. |
56 | 56 | * @param int $depth Depth of menu item. Used for padding. |
57 | 57 | */ |
58 | - $class_names = join( ' ', apply_filters( 'nav_menu_submenu_css_class', $classes, $args, $depth ) ); |
|
59 | - $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : ''; |
|
58 | + $class_names = join(' ', apply_filters('nav_menu_submenu_css_class', $classes, $args, $depth)); |
|
59 | + $class_names = $class_names ? ' class="' . esc_attr($class_names) . '"' : ''; |
|
60 | 60 | |
61 | 61 | /* |
62 | 62 | * The `.dropdown-menu` container needs to have a labelledby |
@@ -67,11 +67,11 @@ discard block |
||
67 | 67 | */ |
68 | 68 | $labelledby = ''; |
69 | 69 | // Find all links with an id in the output. |
70 | - preg_match_all( '/(<a.*?id=\"|\')(.*?)\"|\'.*?>/im', $output, $matches ); |
|
70 | + preg_match_all('/(<a.*?id=\"|\')(.*?)\"|\'.*?>/im', $output, $matches); |
|
71 | 71 | // With pointer at end of array check if we got an ID match. |
72 | - if ( end( $matches[2] ) ) { |
|
72 | + if (end($matches[2])) { |
|
73 | 73 | // Build a string to use as aria-labelledby. |
74 | - $labelledby = 'aria-labelledby="' . esc_attr( end( $matches[2] ) ) . '"'; |
|
74 | + $labelledby = 'aria-labelledby="' . esc_attr(end($matches[2])) . '"'; |
|
75 | 75 | } |
76 | 76 | $output .= "{$n}{$indent}<ul$class_names $labelledby role=\"menu\">{$n}"; |
77 | 77 | } |
@@ -90,17 +90,17 @@ discard block |
||
90 | 90 | * @param WP_Nav_Menu_Args $args An object of wp_nav_menu() arguments. |
91 | 91 | * @param int $id Current item ID. |
92 | 92 | */ |
93 | - public function start_el( &$output, $item, $depth = 0, $args = null, $id = 0 ) { |
|
94 | - if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) { |
|
93 | + public function start_el(&$output, $item, $depth = 0, $args = null, $id = 0) { |
|
94 | + if (isset($args->item_spacing) && 'discard' === $args->item_spacing) { |
|
95 | 95 | $t = ''; |
96 | 96 | $n = ''; |
97 | 97 | } else { |
98 | 98 | $t = "\t"; |
99 | 99 | $n = "\n"; |
100 | 100 | } |
101 | - $indent = ( $depth ) ? str_repeat( $t, $depth ) : ''; |
|
101 | + $indent = ($depth) ? str_repeat($t, $depth) : ''; |
|
102 | 102 | |
103 | - $classes = empty( $item->classes ) ? array() : (array) $item->classes; |
|
103 | + $classes = empty($item->classes) ? array() : (array) $item->classes; |
|
104 | 104 | |
105 | 105 | /* |
106 | 106 | * Initialize some holder variables to store specially handled item |
@@ -115,10 +115,10 @@ discard block |
||
115 | 115 | * NOTE: linkmod and icon class arrays are passed by reference and |
116 | 116 | * are maybe modified before being used later in this function. |
117 | 117 | */ |
118 | - $classes = self::separate_linkmods_and_icons_from_classes( $classes, $linkmod_classes, $icon_classes, $depth ); |
|
118 | + $classes = self::separate_linkmods_and_icons_from_classes($classes, $linkmod_classes, $icon_classes, $depth); |
|
119 | 119 | |
120 | 120 | // Join any icon classes plucked from $classes into a string. |
121 | - $icon_class_string = join( ' ', $icon_classes ); |
|
121 | + $icon_class_string = join(' ', $icon_classes); |
|
122 | 122 | |
123 | 123 | /** |
124 | 124 | * Filters the arguments for a single nav menu item. |
@@ -131,13 +131,13 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @var WP_Nav_Menu_Args |
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 WP_Nav_Menu_Args $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 | $output .= $indent . '<li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement"' . $id . $class_names . '>'; |
170 | 170 | |
@@ -175,16 +175,16 @@ discard block |
||
175 | 175 | * Set title from item to the $atts array - if title is empty then |
176 | 176 | * default to item title. |
177 | 177 | */ |
178 | - if ( empty( $item->attr_title ) ) { |
|
179 | - $atts['title'] = ! empty( $item->title ) ? strip_tags( $item->title ) : ''; |
|
178 | + if (empty($item->attr_title)) { |
|
179 | + $atts['title'] = ! empty($item->title) ? strip_tags($item->title) : ''; |
|
180 | 180 | } else { |
181 | 181 | $atts['title'] = $item->attr_title; |
182 | 182 | } |
183 | 183 | |
184 | - $atts['target'] = ! empty( $item->target ) ? $item->target : ''; |
|
185 | - $atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : ''; |
|
184 | + $atts['target'] = ! empty($item->target) ? $item->target : ''; |
|
185 | + $atts['rel'] = ! empty($item->xfn) ? $item->xfn : ''; |
|
186 | 186 | // If the item has children, add atts to the <a>. |
187 | - if ( isset( $args->has_children ) && $args->has_children && 0 === $depth && $args->depth > 1 ) { |
|
187 | + if (isset($args->has_children) && $args->has_children && 0 === $depth && $args->depth > 1) { |
|
188 | 188 | $atts['href'] = '#'; |
189 | 189 | $atts['data-toggle'] = 'dropdown'; |
190 | 190 | $atts['aria-haspopup'] = 'true'; |
@@ -192,9 +192,9 @@ discard block |
||
192 | 192 | $atts['class'] = 'dropdown-toggle nav-link'; |
193 | 193 | $atts['id'] = 'menu-item-dropdown-' . $item->ID; |
194 | 194 | } else { |
195 | - $atts['href'] = ! empty( $item->url ) ? $item->url : '#'; |
|
195 | + $atts['href'] = ! empty($item->url) ? $item->url : '#'; |
|
196 | 196 | // For items in dropdowns use .dropdown-item instead of .nav-link. |
197 | - if ( $depth > 0 ) { |
|
197 | + if ($depth > 0) { |
|
198 | 198 | $atts['class'] = 'dropdown-item'; |
199 | 199 | } else { |
200 | 200 | $atts['class'] = 'nav-link'; |
@@ -204,32 +204,32 @@ discard block |
||
204 | 204 | $atts['aria-current'] = $item->current ? 'page' : ''; |
205 | 205 | |
206 | 206 | // Update atts of this item based on any custom linkmod classes. |
207 | - $atts = self::update_atts_for_linkmod_type( $atts, $linkmod_classes ); |
|
207 | + $atts = self::update_atts_for_linkmod_type($atts, $linkmod_classes); |
|
208 | 208 | // Allow filtering of the $atts array before using it. |
209 | - $atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ); |
|
209 | + $atts = apply_filters('nav_menu_link_attributes', $atts, $item, $args, $depth); |
|
210 | 210 | |
211 | 211 | // Build a string of html containing all the atts for the item. |
212 | 212 | $attributes = ''; |
213 | - foreach ( $atts as $attr => $value ) { |
|
214 | - if ( ! empty( $value ) ) { |
|
215 | - $value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value ); |
|
213 | + foreach ($atts as $attr => $value) { |
|
214 | + if ( ! empty($value)) { |
|
215 | + $value = ('href' === $attr) ? esc_url($value) : esc_attr($value); |
|
216 | 216 | $attributes .= ' ' . $attr . '="' . $value . '"'; |
217 | 217 | } |
218 | 218 | } |
219 | 219 | |
220 | 220 | // Set a typeflag to easily test if this is a linkmod or not. |
221 | - $linkmod_type = self::get_linkmod_type( $linkmod_classes ); |
|
221 | + $linkmod_type = self::get_linkmod_type($linkmod_classes); |
|
222 | 222 | |
223 | 223 | // START appending the internal item contents to the output. |
224 | - $item_output = isset( $args->before ) ? $args->before : ''; |
|
224 | + $item_output = isset($args->before) ? $args->before : ''; |
|
225 | 225 | |
226 | 226 | /* |
227 | 227 | * This is the start of the internal nav item. Depending on what |
228 | 228 | * kind of linkmod we have we may need different wrapper elements. |
229 | 229 | */ |
230 | - if ( '' !== $linkmod_type ) { |
|
230 | + if ('' !== $linkmod_type) { |
|
231 | 231 | // Is linkmod, output the required element opener. |
232 | - $item_output .= self::linkmod_element_open( $linkmod_type, $attributes ); |
|
232 | + $item_output .= self::linkmod_element_open($linkmod_type, $attributes); |
|
233 | 233 | } else { |
234 | 234 | // With no link mod type set this must be a standard <a> tag. |
235 | 235 | $item_output .= '<a' . $attributes . '>'; |
@@ -241,13 +241,13 @@ discard block |
||
241 | 241 | * output inside of the item before the $title (the link text). |
242 | 242 | */ |
243 | 243 | $icon_html = ''; |
244 | - if ( ! empty( $icon_class_string ) ) { |
|
244 | + if ( ! empty($icon_class_string)) { |
|
245 | 245 | // Append an <i> with the icon classes to what is output before links. |
246 | - $icon_html = '<i class="' . esc_attr( $icon_class_string ) . '" aria-hidden="true"></i> '; |
|
246 | + $icon_html = '<i class="' . esc_attr($icon_class_string) . '" aria-hidden="true"></i> '; |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** This filter is documented in wp-includes/post-template.php */ |
250 | - $title = apply_filters( 'the_title', esc_html( $item->title ), $item->ID ); |
|
250 | + $title = apply_filters('the_title', esc_html($item->title), $item->ID); |
|
251 | 251 | |
252 | 252 | /** |
253 | 253 | * Filters a menu item's title. |
@@ -259,36 +259,36 @@ discard block |
||
259 | 259 | * @param WP_Nav_Menu_Args $args An object of wp_nav_menu() arguments. |
260 | 260 | * @param int $depth Depth of menu item. Used for padding. |
261 | 261 | */ |
262 | - $title = apply_filters( 'nav_menu_item_title', $title, $item, $args, $depth ); |
|
262 | + $title = apply_filters('nav_menu_item_title', $title, $item, $args, $depth); |
|
263 | 263 | |
264 | 264 | // If the .sr-only class was set apply to the nav items text only. |
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 | /* |
277 | 277 | * This is the end of the internal nav item. We need to close the |
278 | 278 | * correct element depending on the type of link or link mod. |
279 | 279 | */ |
280 | - if ( '' !== $linkmod_type ) { |
|
280 | + if ('' !== $linkmod_type) { |
|
281 | 281 | // Is linkmod, output the required closing element. |
282 | - $item_output .= self::linkmod_element_close( $linkmod_type ); |
|
282 | + $item_output .= self::linkmod_element_close($linkmod_type); |
|
283 | 283 | } else { |
284 | 284 | // With no link mod type set this must be a standard <a> tag. |
285 | 285 | $item_output .= '</a>'; |
286 | 286 | } |
287 | 287 | |
288 | - $item_output .= isset( $args->after ) ? $args->after : ''; |
|
288 | + $item_output .= isset($args->after) ? $args->after : ''; |
|
289 | 289 | |
290 | 290 | // END appending the internal item contents to the output. |
291 | - $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args ); |
|
291 | + $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | /** |
@@ -313,17 +313,17 @@ discard block |
||
313 | 313 | * @param string $output Used to append additional content (passed by reference). |
314 | 314 | * @return void |
315 | 315 | */ |
316 | - public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) { |
|
317 | - if ( ! is_object( $element ) ) { |
|
316 | + public function display_element($element, &$children_elements, $max_depth, $depth, $args, &$output) { |
|
317 | + if ( ! is_object($element)) { |
|
318 | 318 | return; |
319 | 319 | } |
320 | 320 | |
321 | 321 | $id_field = $this->db_fields['id']; |
322 | 322 | // Display this element. |
323 | - if ( is_object( $args[0] ) ) { |
|
324 | - $args[0]->has_children = ! empty( $children_elements[ $element->$id_field ] ); |
|
323 | + if (is_object($args[0])) { |
|
324 | + $args[0]->has_children = ! empty($children_elements[$element->$id_field]); |
|
325 | 325 | } |
326 | - parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output ); |
|
326 | + parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | /** |
@@ -337,8 +337,8 @@ discard block |
||
337 | 337 | * @param array $args passed from the wp_nav_menu function. |
338 | 338 | * @return string|void |
339 | 339 | */ |
340 | - public static function fallback( $args ) { |
|
341 | - if ( ! current_user_can( 'edit_theme_options' ) ) { |
|
340 | + public static function fallback($args) { |
|
341 | + if ( ! current_user_can('edit_theme_options')) { |
|
342 | 342 | return; |
343 | 343 | } |
344 | 344 | |
@@ -352,30 +352,30 @@ discard block |
||
352 | 352 | // Initialize var to store fallback html. |
353 | 353 | $fallback_output = ''; |
354 | 354 | |
355 | - if ( $container ) { |
|
356 | - $fallback_output .= '<' . esc_attr( $container ); |
|
357 | - if ( $container_id ) { |
|
358 | - $fallback_output .= ' id="' . esc_attr( $container_id ) . '"'; |
|
355 | + if ($container) { |
|
356 | + $fallback_output .= '<' . esc_attr($container); |
|
357 | + if ($container_id) { |
|
358 | + $fallback_output .= ' id="' . esc_attr($container_id) . '"'; |
|
359 | 359 | } |
360 | - if ( $container_class ) { |
|
361 | - $fallback_output .= ' class="' . esc_attr( $container_class ) . '"'; |
|
360 | + if ($container_class) { |
|
361 | + $fallback_output .= ' class="' . esc_attr($container_class) . '"'; |
|
362 | 362 | } |
363 | 363 | $fallback_output .= '>'; |
364 | 364 | } |
365 | 365 | $fallback_output .= '<ul'; |
366 | - if ( $menu_id ) { |
|
367 | - $fallback_output .= ' id="' . esc_attr( $menu_id ) . '"'; } |
|
368 | - if ( $menu_class ) { |
|
369 | - $fallback_output .= ' class="' . esc_attr( $menu_class ) . '"'; } |
|
366 | + if ($menu_id) { |
|
367 | + $fallback_output .= ' id="' . esc_attr($menu_id) . '"'; } |
|
368 | + if ($menu_class) { |
|
369 | + $fallback_output .= ' class="' . esc_attr($menu_class) . '"'; } |
|
370 | 370 | $fallback_output .= '>'; |
371 | - $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>'; |
|
371 | + $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>'; |
|
372 | 372 | $fallback_output .= '</ul>'; |
373 | - if ( $container ) { |
|
374 | - $fallback_output .= '</' . esc_attr( $container ) . '>'; |
|
373 | + if ($container) { |
|
374 | + $fallback_output .= '</' . esc_attr($container) . '>'; |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | // If $args has 'echo' key and it's true echo, otherwise return. |
378 | - if ( array_key_exists( 'echo', $args ) && $args['echo'] ) { |
|
378 | + if (array_key_exists('echo', $args) && $args['echo']) { |
|
379 | 379 | echo $fallback_output; // WPCS: XSS OK. |
380 | 380 | return; |
381 | 381 | } |
@@ -401,32 +401,32 @@ discard block |
||
401 | 401 | * |
402 | 402 | * @return array $classes a maybe modified array of classnames. |
403 | 403 | */ |
404 | - private function separate_linkmods_and_icons_from_classes( $classes, &$linkmod_classes, &$icon_classes, $depth ) { |
|
404 | + private function separate_linkmods_and_icons_from_classes($classes, &$linkmod_classes, &$icon_classes, $depth) { |
|
405 | 405 | // Loop through $classes array to find linkmod or icon classes. |
406 | - foreach ( $classes as $key => $class ) { |
|
406 | + foreach ($classes as $key => $class) { |
|
407 | 407 | /* |
408 | 408 | * If any special classes are found, store the class in it's |
409 | 409 | * holder array and and unset the item from $classes. |
410 | 410 | */ |
411 | - if ( preg_match( '/^disabled|^sr-only/i', $class ) ) { |
|
411 | + if (preg_match('/^disabled|^sr-only/i', $class)) { |
|
412 | 412 | // Test for .disabled or .sr-only classes. |
413 | 413 | $linkmod_classes[] = $class; |
414 | - unset( $classes[ $key ] ); |
|
415 | - } elseif ( preg_match( '/^dropdown-header|^dropdown-divider|^dropdown-item-text/i', $class ) && $depth > 0 ) { |
|
414 | + unset($classes[$key]); |
|
415 | + } elseif (preg_match('/^dropdown-header|^dropdown-divider|^dropdown-item-text/i', $class) && $depth > 0) { |
|
416 | 416 | /* |
417 | 417 | * Test for .dropdown-header or .dropdown-divider and a |
418 | 418 | * depth greater than 0 - IE inside a dropdown. |
419 | 419 | */ |
420 | 420 | $linkmod_classes[] = $class; |
421 | - unset( $classes[ $key ] ); |
|
422 | - } elseif ( preg_match( '/^fa-(\S*)?|^fa(s|r|l|b)?(\s?)?$/i', $class ) ) { |
|
421 | + unset($classes[$key]); |
|
422 | + } elseif (preg_match('/^fa-(\S*)?|^fa(s|r|l|b)?(\s?)?$/i', $class)) { |
|
423 | 423 | // Font Awesome. |
424 | 424 | $icon_classes[] = $class; |
425 | - unset( $classes[ $key ] ); |
|
426 | - } elseif ( preg_match( '/^glyphicon-(\S*)?|^glyphicon(\s?)$/i', $class ) ) { |
|
425 | + unset($classes[$key]); |
|
426 | + } elseif (preg_match('/^glyphicon-(\S*)?|^glyphicon(\s?)$/i', $class)) { |
|
427 | 427 | // Glyphicons. |
428 | 428 | $icon_classes[] = $class; |
429 | - unset( $classes[ $key ] ); |
|
429 | + unset($classes[$key]); |
|
430 | 430 | } |
431 | 431 | } |
432 | 432 | |
@@ -443,19 +443,19 @@ discard block |
||
443 | 443 | * |
444 | 444 | * @return string empty for default, a linkmod type string otherwise. |
445 | 445 | */ |
446 | - private function get_linkmod_type( $linkmod_classes = array() ) { |
|
446 | + private function get_linkmod_type($linkmod_classes = array()) { |
|
447 | 447 | $linkmod_type = ''; |
448 | 448 | // Loop through array of linkmod classes to handle their $atts. |
449 | - if ( ! empty( $linkmod_classes ) ) { |
|
450 | - foreach ( $linkmod_classes as $link_class ) { |
|
451 | - if ( ! empty( $link_class ) ) { |
|
449 | + if ( ! empty($linkmod_classes)) { |
|
450 | + foreach ($linkmod_classes as $link_class) { |
|
451 | + if ( ! empty($link_class)) { |
|
452 | 452 | |
453 | 453 | // Check for special class types and set a flag for them. |
454 | - if ( 'dropdown-header' === $link_class ) { |
|
454 | + if ('dropdown-header' === $link_class) { |
|
455 | 455 | $linkmod_type = 'dropdown-header'; |
456 | - } elseif ( 'dropdown-divider' === $link_class ) { |
|
456 | + } elseif ('dropdown-divider' === $link_class) { |
|
457 | 457 | $linkmod_type = 'dropdown-divider'; |
458 | - } elseif ( 'dropdown-item-text' === $link_class ) { |
|
458 | + } elseif ('dropdown-item-text' === $link_class) { |
|
459 | 459 | $linkmod_type = 'dropdown-item-text'; |
460 | 460 | } |
461 | 461 | } |
@@ -474,26 +474,26 @@ discard block |
||
474 | 474 | * |
475 | 475 | * @return array maybe updated array of attributes for item. |
476 | 476 | */ |
477 | - private function update_atts_for_linkmod_type( $atts = array(), $linkmod_classes = array() ) { |
|
478 | - if ( ! empty( $linkmod_classes ) ) { |
|
479 | - foreach ( $linkmod_classes as $link_class ) { |
|
480 | - if ( ! empty( $link_class ) ) { |
|
477 | + private function update_atts_for_linkmod_type($atts = array(), $linkmod_classes = array()) { |
|
478 | + if ( ! empty($linkmod_classes)) { |
|
479 | + foreach ($linkmod_classes as $link_class) { |
|
480 | + if ( ! empty($link_class)) { |
|
481 | 481 | /* |
482 | 482 | * Update $atts with a space and the extra classname |
483 | 483 | * so long as it's not a sr-only class. |
484 | 484 | */ |
485 | - if ( 'sr-only' !== $link_class ) { |
|
486 | - $atts['class'] .= ' ' . esc_attr( $link_class ); |
|
485 | + if ('sr-only' !== $link_class) { |
|
486 | + $atts['class'] .= ' ' . esc_attr($link_class); |
|
487 | 487 | } |
488 | 488 | // Check for special class types we need additional handling for. |
489 | - if ( 'disabled' === $link_class ) { |
|
489 | + if ('disabled' === $link_class) { |
|
490 | 490 | // Convert link to '#' and unset open targets. |
491 | 491 | $atts['href'] = '#'; |
492 | - unset( $atts['target'] ); |
|
493 | - } elseif ( 'dropdown-header' === $link_class || 'dropdown-divider' === $link_class || 'dropdown-item-text' === $link_class ) { |
|
492 | + unset($atts['target']); |
|
493 | + } elseif ('dropdown-header' === $link_class || 'dropdown-divider' === $link_class || 'dropdown-item-text' === $link_class) { |
|
494 | 494 | // Store a type flag and unset href and target. |
495 | - unset( $atts['href'] ); |
|
496 | - unset( $atts['target'] ); |
|
495 | + unset($atts['href']); |
|
496 | + unset($atts['target']); |
|
497 | 497 | } |
498 | 498 | } |
499 | 499 | } |
@@ -509,8 +509,8 @@ discard block |
||
509 | 509 | * @param string $text the string of text to be wrapped in a screen reader class. |
510 | 510 | * @return string the string wrapped in a span with the class. |
511 | 511 | */ |
512 | - private function wrap_for_screen_reader( $text = '' ) { |
|
513 | - if ( $text ) { |
|
512 | + private function wrap_for_screen_reader($text = '') { |
|
513 | + if ($text) { |
|
514 | 514 | $text = '<span class="sr-only">' . $text . '</span>'; |
515 | 515 | } |
516 | 516 | return $text; |
@@ -526,17 +526,17 @@ discard block |
||
526 | 526 | * |
527 | 527 | * @return string a string with the openign tag for the element with attribibutes added. |
528 | 528 | */ |
529 | - private function linkmod_element_open( $linkmod_type, $attributes = '' ) { |
|
529 | + private function linkmod_element_open($linkmod_type, $attributes = '') { |
|
530 | 530 | $output = ''; |
531 | - if ( 'dropdown-item-text' === $linkmod_type ) { |
|
531 | + if ('dropdown-item-text' === $linkmod_type) { |
|
532 | 532 | $output .= '<span class="dropdown-item-text"' . $attributes . '>'; |
533 | - } elseif ( 'dropdown-header' === $linkmod_type ) { |
|
533 | + } elseif ('dropdown-header' === $linkmod_type) { |
|
534 | 534 | /* |
535 | 535 | * For a header use a span with the .h6 class instead of a real |
536 | 536 | * header tag so that it doesn't confuse screen readers. |
537 | 537 | */ |
538 | 538 | $output .= '<span class="dropdown-header h6"' . $attributes . '>'; |
539 | - } elseif ( 'dropdown-divider' === $linkmod_type ) { |
|
539 | + } elseif ('dropdown-divider' === $linkmod_type) { |
|
540 | 540 | // This is a divider. |
541 | 541 | $output .= '<div class="dropdown-divider"' . $attributes . '>'; |
542 | 542 | } |
@@ -552,15 +552,15 @@ discard block |
||
552 | 552 | * |
553 | 553 | * @return string a string with the closing tag for this linkmod type. |
554 | 554 | */ |
555 | - private function linkmod_element_close( $linkmod_type ) { |
|
555 | + private function linkmod_element_close($linkmod_type) { |
|
556 | 556 | $output = ''; |
557 | - if ( 'dropdown-header' === $linkmod_type || 'dropdown-item-text' === $linkmod_type ) { |
|
557 | + if ('dropdown-header' === $linkmod_type || 'dropdown-item-text' === $linkmod_type) { |
|
558 | 558 | /* |
559 | 559 | * For a header use a span with the .h6 class instead of a real |
560 | 560 | * header tag so that it doesn't confuse screen readers. |
561 | 561 | */ |
562 | 562 | $output .= '</span>'; |
563 | - } elseif ( 'dropdown-divider' === $linkmod_type ) { |
|
563 | + } elseif ('dropdown-divider' === $linkmod_type) { |
|
564 | 564 | // This is a divider. |
565 | 565 | $output .= '</div>'; |
566 | 566 | } |