Completed
Push — master ( 6d51e4...54bfbf )
by William
01:32 queued 11s
created
class-wp-bootstrap-navwalker.php 1 patch
Spacing   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
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
 	 */
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
 		 * @since 4.2.0
39 39
 		 */
40 40
 		public function __construct() {
41
-			if ( ! has_filter( 'wp_nav_menu_args', array( $this, 'add_schema_to_navbar_ul' ) ) ) {
42
-				add_filter( 'wp_nav_menu_args', array( $this, 'add_schema_to_navbar_ul' ) );
41
+			if ( ! has_filter('wp_nav_menu_args', array($this, 'add_schema_to_navbar_ul'))) {
42
+				add_filter('wp_nav_menu_args', array($this, 'add_schema_to_navbar_ul'));
43 43
 			}
44 44
 		}
45 45
 
@@ -54,17 +54,17 @@  discard block
 block discarded – undo
54 54
 		 * @param int              $depth  Depth of menu item. Used for padding.
55 55
 		 * @param WP_Nav_Menu_Args $args   An object of wp_nav_menu() arguments.
56 56
 		 */
57
-		public function start_lvl( &$output, $depth = 0, $args = null ) {
58
-			if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
57
+		public function start_lvl(&$output, $depth = 0, $args = null) {
58
+			if (isset($args->item_spacing) && 'discard' === $args->item_spacing) {
59 59
 				$t = '';
60 60
 				$n = '';
61 61
 			} else {
62 62
 				$t = "\t";
63 63
 				$n = "\n";
64 64
 			}
65
-			$indent = str_repeat( $t, $depth );
65
+			$indent = str_repeat($t, $depth);
66 66
 			// Default class to add to the file.
67
-			$classes = array( 'dropdown-menu' );
67
+			$classes = array('dropdown-menu');
68 68
 			/**
69 69
 			 * Filters the CSS class(es) applied to a menu list element.
70 70
 			 *
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 			 * @param stdClass $args    An object of `wp_nav_menu()` arguments.
75 75
 			 * @param int      $depth   Depth of menu item. Used for padding.
76 76
 			 */
77
-			$class_names = join( ' ', apply_filters( 'nav_menu_submenu_css_class', $classes, $args, $depth ) );
78
-			$class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
77
+			$class_names = join(' ', apply_filters('nav_menu_submenu_css_class', $classes, $args, $depth));
78
+			$class_names = $class_names ? ' class="' . esc_attr($class_names) . '"' : '';
79 79
 
80 80
 			/*
81 81
 			 * The `.dropdown-menu` container needs to have a labelledby
@@ -86,11 +86,11 @@  discard block
 block discarded – undo
86 86
 			 */
87 87
 			$labelledby = '';
88 88
 			// Find all links with an id in the output.
89
-			preg_match_all( '/(<a.*?id=\"|\')(.*?)\"|\'.*?>/im', $output, $matches );
89
+			preg_match_all('/(<a.*?id=\"|\')(.*?)\"|\'.*?>/im', $output, $matches);
90 90
 			// With pointer at end of array check if we got an ID match.
91
-			if ( end( $matches[2] ) ) {
91
+			if (end($matches[2])) {
92 92
 				// Build a string to use as aria-labelledby.
93
-				$labelledby = 'aria-labelledby="' . esc_attr( end( $matches[2] ) ) . '"';
93
+				$labelledby = 'aria-labelledby="' . esc_attr(end($matches[2])) . '"';
94 94
 			}
95 95
 			$output .= "{$n}{$indent}<ul$class_names $labelledby role=\"menu\">{$n}";
96 96
 		}
@@ -109,23 +109,23 @@  discard block
 block discarded – undo
109 109
 		 * @param WP_Nav_Menu_Args $args   An object of wp_nav_menu() arguments.
110 110
 		 * @param int              $id     Current item ID.
111 111
 		 */
112
-		public function start_el( &$output, $item, $depth = 0, $args = null, $id = 0 ) {
113
-			if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
112
+		public function start_el(&$output, $item, $depth = 0, $args = null, $id = 0) {
113
+			if (isset($args->item_spacing) && 'discard' === $args->item_spacing) {
114 114
 				$t = '';
115 115
 				$n = '';
116 116
 			} else {
117 117
 				$t = "\t";
118 118
 				$n = "\n";
119 119
 			}
120
-			$indent = ( $depth ) ? str_repeat( $t, $depth ) : '';
120
+			$indent = ($depth) ? str_repeat($t, $depth) : '';
121 121
 
122
-			if ( false !== strpos( $args->items_wrap, 'itemscope' ) && false === $this->has_schema ) {
122
+			if (false !== strpos($args->items_wrap, 'itemscope') && false === $this->has_schema) {
123 123
 				$this->has_schema  = true;
124 124
 				$args->link_before = '<span itemprop="name">' . $args->link_before;
125 125
 				$args->link_after .= '</span>';
126 126
 			}
127 127
 
128
-			$classes = empty( $item->classes ) ? array() : (array) $item->classes;
128
+			$classes = empty($item->classes) ? array() : (array) $item->classes;
129 129
 
130 130
 			/*
131 131
 			 * Initialize some holder variables to store specially handled item
@@ -140,10 +140,10 @@  discard block
 block discarded – undo
140 140
 			 * NOTE: linkmod and icon class arrays are passed by reference and
141 141
 			 * are maybe modified before being used later in this function.
142 142
 			 */
143
-			$classes = self::separate_linkmods_and_icons_from_classes( $classes, $linkmod_classes, $icon_classes, $depth );
143
+			$classes = self::separate_linkmods_and_icons_from_classes($classes, $linkmod_classes, $icon_classes, $depth);
144 144
 
145 145
 			// Join any icon classes plucked from $classes into a string.
146
-			$icon_class_string = join( ' ', $icon_classes );
146
+			$icon_class_string = join(' ', $icon_classes);
147 147
 
148 148
 			/**
149 149
 			 * Filters the arguments for a single nav menu item.
@@ -156,13 +156,13 @@  discard block
 block discarded – undo
156 156
 			 *
157 157
 			 * @var WP_Nav_Menu_Args
158 158
 			 */
159
-			$args = apply_filters( 'nav_menu_item_args', $args, $item, $depth );
159
+			$args = apply_filters('nav_menu_item_args', $args, $item, $depth);
160 160
 
161 161
 			// Add .dropdown or .active classes where they are needed.
162
-			if ( isset( $args->has_children ) && $args->has_children ) {
162
+			if (isset($args->has_children) && $args->has_children) {
163 163
 				$classes[] = 'dropdown';
164 164
 			}
165
-			if ( in_array( 'current-menu-item', $classes, true ) || in_array( 'current-menu-parent', $classes, true ) ) {
165
+			if (in_array('current-menu-item', $classes, true) || in_array('current-menu-parent', $classes, true)) {
166 166
 				$classes[] = 'active';
167 167
 			}
168 168
 
@@ -171,11 +171,11 @@  discard block
 block discarded – undo
171 171
 			$classes[] = 'nav-item';
172 172
 
173 173
 			// Allow filtering the classes.
174
-			$classes = apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args, $depth );
174
+			$classes = apply_filters('nav_menu_css_class', array_filter($classes), $item, $args, $depth);
175 175
 
176 176
 			// Form a string of classes in format: class="class_names".
177
-			$class_names = join( ' ', $classes );
178
-			$class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
177
+			$class_names = join(' ', $classes);
178
+			$class_names = $class_names ? ' class="' . esc_attr($class_names) . '"' : '';
179 179
 
180 180
 			/**
181 181
 			 * Filters the ID applied to a menu item's list item element.
@@ -188,8 +188,8 @@  discard block
 block discarded – undo
188 188
 			 * @param WP_Nav_Menu_Args $args    An object of wp_nav_menu() arguments.
189 189
 			 * @param int              $depth   Depth of menu item. Used for padding.
190 190
 			 */
191
-			$id = apply_filters( 'nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args, $depth );
192
-			$id = $id ? ' id="' . esc_attr( $id ) . '"' : '';
191
+			$id = apply_filters('nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args, $depth);
192
+			$id = $id ? ' id="' . esc_attr($id) . '"' : '';
193 193
 
194 194
 			$output .= $indent . '<li ' . $id . $class_names . '>';
195 195
 
@@ -200,16 +200,16 @@  discard block
 block discarded – undo
200 200
 			 * Set title from item to the $atts array - if title is empty then
201 201
 			 * default to item title.
202 202
 			 */
203
-			if ( empty( $item->attr_title ) ) {
204
-				$atts['title'] = ! empty( $item->title ) ? strip_tags( $item->title ) : '';
203
+			if (empty($item->attr_title)) {
204
+				$atts['title'] = ! empty($item->title) ? strip_tags($item->title) : '';
205 205
 			} else {
206 206
 				$atts['title'] = $item->attr_title;
207 207
 			}
208 208
 
209
-			$atts['target'] = ! empty( $item->target ) ? $item->target : '';
210
-			$atts['rel']    = ! empty( $item->xfn ) ? $item->xfn : '';
209
+			$atts['target'] = ! empty($item->target) ? $item->target : '';
210
+			$atts['rel']    = ! empty($item->xfn) ? $item->xfn : '';
211 211
 			// If the item has children, add atts to the <a>.
212
-			if ( isset( $args->has_children ) && $args->has_children && 0 === $depth && $args->depth > 1 ) {
212
+			if (isset($args->has_children) && $args->has_children && 0 === $depth && $args->depth > 1) {
213 213
 				$atts['href']          = '#';
214 214
 				$atts['data-toggle']   = 'dropdown';
215 215
 				$atts['aria-haspopup'] = 'true';
@@ -217,13 +217,13 @@  discard block
 block discarded – undo
217 217
 				$atts['class']         = 'dropdown-toggle nav-link';
218 218
 				$atts['id']            = 'menu-item-dropdown-' . $item->ID;
219 219
 			} else {
220
-				if ( true === $this->has_schema ) {
220
+				if (true === $this->has_schema) {
221 221
 					$atts['itemprop'] = 'url';
222 222
 				}
223 223
 
224
-				$atts['href'] = ! empty( $item->url ) ? $item->url : '#';
224
+				$atts['href'] = ! empty($item->url) ? $item->url : '#';
225 225
 				// For items in dropdowns use .dropdown-item instead of .nav-link.
226
-				if ( $depth > 0 ) {
226
+				if ($depth > 0) {
227 227
 					$atts['class'] = 'dropdown-item';
228 228
 				} else {
229 229
 					$atts['class'] = 'nav-link';
@@ -233,33 +233,33 @@  discard block
 block discarded – undo
233 233
 			$atts['aria-current'] = $item->current ? 'page' : '';
234 234
 
235 235
 			// Update atts of this item based on any custom linkmod classes.
236
-			$atts = self::update_atts_for_linkmod_type( $atts, $linkmod_classes );
236
+			$atts = self::update_atts_for_linkmod_type($atts, $linkmod_classes);
237 237
 
238 238
 			// Allow filtering of the $atts array before using it.
239
-			$atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth );
239
+			$atts = apply_filters('nav_menu_link_attributes', $atts, $item, $args, $depth);
240 240
 
241 241
 			// Build a string of html containing all the atts for the item.
242 242
 			$attributes = '';
243
-			foreach ( $atts as $attr => $value ) {
244
-				if ( ! empty( $value ) ) {
245
-					$value       = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
243
+			foreach ($atts as $attr => $value) {
244
+				if ( ! empty($value)) {
245
+					$value       = ('href' === $attr) ? esc_url($value) : esc_attr($value);
246 246
 					$attributes .= ' ' . $attr . '="' . $value . '"';
247 247
 				}
248 248
 			}
249 249
 
250 250
 			// Set a typeflag to easily test if this is a linkmod or not.
251
-			$linkmod_type = self::get_linkmod_type( $linkmod_classes );
251
+			$linkmod_type = self::get_linkmod_type($linkmod_classes);
252 252
 
253 253
 			// START appending the internal item contents to the output.
254
-			$item_output = isset( $args->before ) ? $args->before : '';
254
+			$item_output = isset($args->before) ? $args->before : '';
255 255
 
256 256
 			/*
257 257
 			 * This is the start of the internal nav item. Depending on what
258 258
 			 * kind of linkmod we have we may need different wrapper elements.
259 259
 			 */
260
-			if ( '' !== $linkmod_type ) {
260
+			if ('' !== $linkmod_type) {
261 261
 				// Is linkmod, output the required element opener.
262
-				$item_output .= self::linkmod_element_open( $linkmod_type, $attributes );
262
+				$item_output .= self::linkmod_element_open($linkmod_type, $attributes);
263 263
 			} else {
264 264
 				// With no link mod type set this must be a standard <a> tag.
265 265
 				$item_output .= '<a' . $attributes . '>';
@@ -271,13 +271,13 @@  discard block
 block discarded – undo
271 271
 			 * output inside of the item before the $title (the link text).
272 272
 			 */
273 273
 			$icon_html = '';
274
-			if ( ! empty( $icon_class_string ) ) {
274
+			if ( ! empty($icon_class_string)) {
275 275
 				// Append an <i> with the icon classes to what is output before links.
276
-				$icon_html = '<i class="' . esc_attr( $icon_class_string ) . '" aria-hidden="true"></i> ';
276
+				$icon_html = '<i class="' . esc_attr($icon_class_string) . '" aria-hidden="true"></i> ';
277 277
 			}
278 278
 
279 279
 			/** This filter is documented in wp-includes/post-template.php */
280
-			$title = apply_filters( 'the_title', esc_html( $item->title ), $item->ID );
280
+			$title = apply_filters('the_title', esc_html($item->title), $item->ID);
281 281
 
282 282
 			/**
283 283
 			 * Filters a menu item's title.
@@ -289,36 +289,36 @@  discard block
 block discarded – undo
289 289
 			 * @param WP_Nav_Menu_Args $args  An object of wp_nav_menu() arguments.
290 290
 			 * @param int              $depth Depth of menu item. Used for padding.
291 291
 			 */
292
-			$title = apply_filters( 'nav_menu_item_title', $title, $item, $args, $depth );
292
+			$title = apply_filters('nav_menu_item_title', $title, $item, $args, $depth);
293 293
 
294 294
 			// If the .sr-only class was set apply to the nav items text only.
295
-			if ( in_array( 'sr-only', $linkmod_classes, true ) ) {
296
-				$title         = self::wrap_for_screen_reader( $title );
297
-				$keys_to_unset = array_keys( $linkmod_classes, 'sr-only', true );
298
-				foreach ( $keys_to_unset as $k ) {
299
-					unset( $linkmod_classes[ $k ] );
295
+			if (in_array('sr-only', $linkmod_classes, true)) {
296
+				$title         = self::wrap_for_screen_reader($title);
297
+				$keys_to_unset = array_keys($linkmod_classes, 'sr-only', true);
298
+				foreach ($keys_to_unset as $k) {
299
+					unset($linkmod_classes[$k]);
300 300
 				}
301 301
 			}
302 302
 
303 303
 			// Put the item contents into $output.
304
-			$item_output .= isset( $args->link_before ) ? $args->link_before . $icon_html . $title . $args->link_after : '';
304
+			$item_output .= isset($args->link_before) ? $args->link_before . $icon_html . $title . $args->link_after : '';
305 305
 
306 306
 			/*
307 307
 			 * This is the end of the internal nav item. We need to close the
308 308
 			 * correct element depending on the type of link or link mod.
309 309
 			 */
310
-			if ( '' !== $linkmod_type ) {
310
+			if ('' !== $linkmod_type) {
311 311
 				// Is linkmod, output the required closing element.
312
-				$item_output .= self::linkmod_element_close( $linkmod_type );
312
+				$item_output .= self::linkmod_element_close($linkmod_type);
313 313
 			} else {
314 314
 				// With no link mod type set this must be a standard <a> tag.
315 315
 				$item_output .= '</a>';
316 316
 			}
317 317
 
318
-			$item_output .= isset( $args->after ) ? $args->after : '';
318
+			$item_output .= isset($args->after) ? $args->after : '';
319 319
 
320 320
 			// END appending the internal item contents to the output.
321
-			$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
321
+			$output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
322 322
 		}
323 323
 
324 324
 		/**
@@ -343,17 +343,17 @@  discard block
 block discarded – undo
343 343
 		 * @param string $output            Used to append additional content (passed by reference).
344 344
 		 * @return void
345 345
 		 */
346
-		public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
347
-			if ( ! is_object( $element ) ) {
346
+		public function display_element($element, &$children_elements, $max_depth, $depth, $args, &$output) {
347
+			if ( ! is_object($element)) {
348 348
 				return;
349 349
 			}
350 350
 
351 351
 			$id_field = $this->db_fields['id'];
352 352
 			// Display this element.
353
-			if ( is_object( $args[0] ) ) {
354
-				$args[0]->has_children = ! empty( $children_elements[ $element->$id_field ] );
353
+			if (is_object($args[0])) {
354
+				$args[0]->has_children = ! empty($children_elements[$element->$id_field]);
355 355
 			}
356
-			parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
356
+			parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output);
357 357
 		}
358 358
 
359 359
 		/**
@@ -367,8 +367,8 @@  discard block
 block discarded – undo
367 367
 		 * @param array $args passed from the wp_nav_menu function.
368 368
 		 * @return string|void
369 369
 		 */
370
-		public static function fallback( $args ) {
371
-			if ( ! current_user_can( 'edit_theme_options' ) ) {
370
+		public static function fallback($args) {
371
+			if ( ! current_user_can('edit_theme_options')) {
372 372
 				return;
373 373
 			}
374 374
 
@@ -382,30 +382,30 @@  discard block
 block discarded – undo
382 382
 			// Initialize var to store fallback html.
383 383
 			$fallback_output = '';
384 384
 
385
-			if ( $container ) {
386
-				$fallback_output .= '<' . esc_attr( $container );
387
-				if ( $container_id ) {
388
-					$fallback_output .= ' id="' . esc_attr( $container_id ) . '"';
385
+			if ($container) {
386
+				$fallback_output .= '<' . esc_attr($container);
387
+				if ($container_id) {
388
+					$fallback_output .= ' id="' . esc_attr($container_id) . '"';
389 389
 				}
390
-				if ( $container_class ) {
391
-					$fallback_output .= ' class="' . esc_attr( $container_class ) . '"';
390
+				if ($container_class) {
391
+					$fallback_output .= ' class="' . esc_attr($container_class) . '"';
392 392
 				}
393 393
 				$fallback_output .= '>';
394 394
 			}
395 395
 			$fallback_output .= '<ul';
396
-			if ( $menu_id ) {
397
-				$fallback_output .= ' id="' . esc_attr( $menu_id ) . '"'; }
398
-			if ( $menu_class ) {
399
-				$fallback_output .= ' class="' . esc_attr( $menu_class ) . '"'; }
396
+			if ($menu_id) {
397
+				$fallback_output .= ' id="' . esc_attr($menu_id) . '"'; }
398
+			if ($menu_class) {
399
+				$fallback_output .= ' class="' . esc_attr($menu_class) . '"'; }
400 400
 			$fallback_output .= '>';
401
-			$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>';
401
+			$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>';
402 402
 			$fallback_output .= '</ul>';
403
-			if ( $container ) {
404
-				$fallback_output .= '</' . esc_attr( $container ) . '>';
403
+			if ($container) {
404
+				$fallback_output .= '</' . esc_attr($container) . '>';
405 405
 			}
406 406
 
407 407
 			// If $args has 'echo' key and it's true echo, otherwise return.
408
-			if ( array_key_exists( 'echo', $args ) && $args['echo'] ) {
408
+			if (array_key_exists('echo', $args) && $args['echo']) {
409 409
 				echo $fallback_output; // WPCS: XSS OK.
410 410
 				return;
411 411
 			}
@@ -421,10 +421,10 @@  discard block
 block discarded – undo
421 421
 		 * @param  array $args The nav instance arguments.
422 422
 		 * @return array $args The altered nav instance arguments.
423 423
 		 */
424
-		public function add_schema_to_navbar_ul( $args ) {
424
+		public function add_schema_to_navbar_ul($args) {
425 425
 			$wrap = $args['items_wrap'];
426
-			if ( strpos( $wrap, 'SiteNavigationElement' ) === false ) {
427
-				$args['items_wrap'] = preg_replace( '/(>).*>?\%3\$s/', ' itemscope itemtype="http://www.schema.org/SiteNavigationElement"$0', $wrap );
426
+			if (strpos($wrap, 'SiteNavigationElement') === false) {
427
+				$args['items_wrap'] = preg_replace('/(>).*>?\%3\$s/', ' itemscope itemtype="http://www.schema.org/SiteNavigationElement"$0', $wrap);
428 428
 			}
429 429
 
430 430
 			return $args;
@@ -448,32 +448,32 @@  discard block
 block discarded – undo
448 448
 		 *
449 449
 		 * @return array  $classes         a maybe modified array of classnames.
450 450
 		 */
451
-		private function separate_linkmods_and_icons_from_classes( $classes, &$linkmod_classes, &$icon_classes, $depth ) {
451
+		private function separate_linkmods_and_icons_from_classes($classes, &$linkmod_classes, &$icon_classes, $depth) {
452 452
 			// Loop through $classes array to find linkmod or icon classes.
453
-			foreach ( $classes as $key => $class ) {
453
+			foreach ($classes as $key => $class) {
454 454
 				/*
455 455
 				 * If any special classes are found, store the class in it's
456 456
 				 * holder array and and unset the item from $classes.
457 457
 				 */
458
-				if ( preg_match( '/^disabled|^sr-only/i', $class ) ) {
458
+				if (preg_match('/^disabled|^sr-only/i', $class)) {
459 459
 					// Test for .disabled or .sr-only classes.
460 460
 					$linkmod_classes[] = $class;
461
-					unset( $classes[ $key ] );
462
-				} elseif ( preg_match( '/^dropdown-header|^dropdown-divider|^dropdown-item-text/i', $class ) && $depth > 0 ) {
461
+					unset($classes[$key]);
462
+				} elseif (preg_match('/^dropdown-header|^dropdown-divider|^dropdown-item-text/i', $class) && $depth > 0) {
463 463
 					/*
464 464
 					 * Test for .dropdown-header or .dropdown-divider and a
465 465
 					 * depth greater than 0 - IE inside a dropdown.
466 466
 					 */
467 467
 					$linkmod_classes[] = $class;
468
-					unset( $classes[ $key ] );
469
-				} elseif ( preg_match( '/^fa-(\S*)?|^fa(s|r|l|b)?(\s?)?$/i', $class ) ) {
468
+					unset($classes[$key]);
469
+				} elseif (preg_match('/^fa-(\S*)?|^fa(s|r|l|b)?(\s?)?$/i', $class)) {
470 470
 					// Font Awesome.
471 471
 					$icon_classes[] = $class;
472
-					unset( $classes[ $key ] );
473
-				} elseif ( preg_match( '/^glyphicon-(\S*)?|^glyphicon(\s?)$/i', $class ) ) {
472
+					unset($classes[$key]);
473
+				} elseif (preg_match('/^glyphicon-(\S*)?|^glyphicon(\s?)$/i', $class)) {
474 474
 					// Glyphicons.
475 475
 					$icon_classes[] = $class;
476
-					unset( $classes[ $key ] );
476
+					unset($classes[$key]);
477 477
 				}
478 478
 			}
479 479
 
@@ -490,19 +490,19 @@  discard block
 block discarded – undo
490 490
 		 *
491 491
 		 * @return string                empty for default, a linkmod type string otherwise.
492 492
 		 */
493
-		private function get_linkmod_type( $linkmod_classes = array() ) {
493
+		private function get_linkmod_type($linkmod_classes = array()) {
494 494
 			$linkmod_type = '';
495 495
 			// Loop through array of linkmod classes to handle their $atts.
496
-			if ( ! empty( $linkmod_classes ) ) {
497
-				foreach ( $linkmod_classes as $link_class ) {
498
-					if ( ! empty( $link_class ) ) {
496
+			if ( ! empty($linkmod_classes)) {
497
+				foreach ($linkmod_classes as $link_class) {
498
+					if ( ! empty($link_class)) {
499 499
 
500 500
 						// Check for special class types and set a flag for them.
501
-						if ( 'dropdown-header' === $link_class ) {
501
+						if ('dropdown-header' === $link_class) {
502 502
 							$linkmod_type = 'dropdown-header';
503
-						} elseif ( 'dropdown-divider' === $link_class ) {
503
+						} elseif ('dropdown-divider' === $link_class) {
504 504
 							$linkmod_type = 'dropdown-divider';
505
-						} elseif ( 'dropdown-item-text' === $link_class ) {
505
+						} elseif ('dropdown-item-text' === $link_class) {
506 506
 							$linkmod_type = 'dropdown-item-text';
507 507
 						}
508 508
 					}
@@ -521,26 +521,26 @@  discard block
 block discarded – undo
521 521
 		 *
522 522
 		 * @return array                 maybe updated array of attributes for item.
523 523
 		 */
524
-		private function update_atts_for_linkmod_type( $atts = array(), $linkmod_classes = array() ) {
525
-			if ( ! empty( $linkmod_classes ) ) {
526
-				foreach ( $linkmod_classes as $link_class ) {
527
-					if ( ! empty( $link_class ) ) {
524
+		private function update_atts_for_linkmod_type($atts = array(), $linkmod_classes = array()) {
525
+			if ( ! empty($linkmod_classes)) {
526
+				foreach ($linkmod_classes as $link_class) {
527
+					if ( ! empty($link_class)) {
528 528
 						/*
529 529
 						 * Update $atts with a space and the extra classname
530 530
 						 * so long as it's not a sr-only class.
531 531
 						 */
532
-						if ( 'sr-only' !== $link_class ) {
533
-							$atts['class'] .= ' ' . esc_attr( $link_class );
532
+						if ('sr-only' !== $link_class) {
533
+							$atts['class'] .= ' ' . esc_attr($link_class);
534 534
 						}
535 535
 						// Check for special class types we need additional handling for.
536
-						if ( 'disabled' === $link_class ) {
536
+						if ('disabled' === $link_class) {
537 537
 							// Convert link to '#' and unset open targets.
538 538
 							$atts['href'] = '#';
539
-							unset( $atts['target'] );
540
-						} elseif ( 'dropdown-header' === $link_class || 'dropdown-divider' === $link_class || 'dropdown-item-text' === $link_class ) {
539
+							unset($atts['target']);
540
+						} elseif ('dropdown-header' === $link_class || 'dropdown-divider' === $link_class || 'dropdown-item-text' === $link_class) {
541 541
 							// Store a type flag and unset href and target.
542
-							unset( $atts['href'] );
543
-							unset( $atts['target'] );
542
+							unset($atts['href']);
543
+							unset($atts['target']);
544 544
 						}
545 545
 					}
546 546
 				}
@@ -556,8 +556,8 @@  discard block
 block discarded – undo
556 556
 		 * @param string $text the string of text to be wrapped in a screen reader class.
557 557
 		 * @return string      the string wrapped in a span with the class.
558 558
 		 */
559
-		private function wrap_for_screen_reader( $text = '' ) {
560
-			if ( $text ) {
559
+		private function wrap_for_screen_reader($text = '') {
560
+			if ($text) {
561 561
 				$text = '<span class="sr-only">' . $text . '</span>';
562 562
 			}
563 563
 			return $text;
@@ -573,17 +573,17 @@  discard block
 block discarded – undo
573 573
 		 *
574 574
 		 * @return string              a string with the openign tag for the element with attribibutes added.
575 575
 		 */
576
-		private function linkmod_element_open( $linkmod_type, $attributes = '' ) {
576
+		private function linkmod_element_open($linkmod_type, $attributes = '') {
577 577
 			$output = '';
578
-			if ( 'dropdown-item-text' === $linkmod_type ) {
578
+			if ('dropdown-item-text' === $linkmod_type) {
579 579
 				$output .= '<span class="dropdown-item-text"' . $attributes . '>';
580
-			} elseif ( 'dropdown-header' === $linkmod_type ) {
580
+			} elseif ('dropdown-header' === $linkmod_type) {
581 581
 				/*
582 582
 				 * For a header use a span with the .h6 class instead of a real
583 583
 				 * header tag so that it doesn't confuse screen readers.
584 584
 				 */
585 585
 				$output .= '<span class="dropdown-header h6"' . $attributes . '>';
586
-			} elseif ( 'dropdown-divider' === $linkmod_type ) {
586
+			} elseif ('dropdown-divider' === $linkmod_type) {
587 587
 				// This is a divider.
588 588
 				$output .= '<div class="dropdown-divider"' . $attributes . '>';
589 589
 			}
@@ -599,15 +599,15 @@  discard block
 block discarded – undo
599 599
 		 *
600 600
 		 * @return string              a string with the closing tag for this linkmod type.
601 601
 		 */
602
-		private function linkmod_element_close( $linkmod_type ) {
602
+		private function linkmod_element_close($linkmod_type) {
603 603
 			$output = '';
604
-			if ( 'dropdown-header' === $linkmod_type || 'dropdown-item-text' === $linkmod_type ) {
604
+			if ('dropdown-header' === $linkmod_type || 'dropdown-item-text' === $linkmod_type) {
605 605
 				/*
606 606
 				 * For a header use a span with the .h6 class instead of a real
607 607
 				 * header tag so that it doesn't confuse screen readers.
608 608
 				 */
609 609
 				$output .= '</span>';
610
-			} elseif ( 'dropdown-divider' === $linkmod_type ) {
610
+			} elseif ('dropdown-divider' === $linkmod_type) {
611 611
 				// This is a divider.
612 612
 				$output .= '</div>';
613 613
 			}
Please login to merge, or discard this patch.