Completed
Pull Request — master (#444)
by
unknown
01:10
created
class-wp-bootstrap-navwalker.php 1 patch
Spacing   +112 added lines, -112 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
 	 *
@@ -37,17 +37,17 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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 ( isset( $args->has_children ) && $args->has_children ) {
134
+			if (isset($args->has_children) && $args->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
 block discarded – undo
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
 block discarded – undo
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,20 +170,20 @@  discard block
 block discarded – undo
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
-			if ( '_blank' === $item->target && empty( $item->xfn ) ) {
179
+			$atts['target'] = ! empty($item->target) ? $item->target : '';
180
+			if ('_blank' === $item->target && empty($item->xfn)) {
181 181
 				$atts['rel'] = 'noopener noreferrer';
182 182
 			} else {
183 183
 				$atts['rel'] = $item->xfn;
184 184
 			}
185 185
 			// If item has_children add atts to <a>.
186
-			if ( isset( $args->has_children ) && $args->has_children && 0 === $depth && $args->depth > 1 ) {
186
+			if (isset($args->has_children) && $args->has_children && 0 === $depth && $args->depth > 1) {
187 187
 				$atts['href']          = '#';
188 188
 				$atts['data-toggle']   = 'dropdown';
189 189
 				$atts['aria-haspopup'] = 'true';
@@ -191,9 +191,9 @@  discard block
 block discarded – undo
191 191
 				$atts['class']         = 'dropdown-toggle nav-link';
192 192
 				$atts['id']            = 'menu-item-dropdown-' . $item->ID;
193 193
 			} else {
194
-				$atts['href'] = ! empty( $item->url ) ? $item->url : '#';
194
+				$atts['href'] = ! empty($item->url) ? $item->url : '#';
195 195
 				// Items in dropdowns use .dropdown-item instead of .nav-link.
196
-				if ( $depth > 0 ) {
196
+				if ($depth > 0) {
197 197
 					$atts['class'] = 'dropdown-item';
198 198
 				} else {
199 199
 					$atts['class'] = 'nav-link';
@@ -203,15 +203,15 @@  discard block
 block discarded – undo
203 203
 			$atts['aria-current'] = $item->current ? 'page' : '';
204 204
 
205 205
 			// update atts of this item based on any custom linkmod classes.
206
-			$atts = self::update_atts_for_linkmod_type( $atts, $linkmod_classes );
206
+			$atts = self::update_atts_for_linkmod_type($atts, $linkmod_classes);
207 207
 			// Allow filtering of the $atts array before using it.
208
-			$atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth );
208
+			$atts = apply_filters('nav_menu_link_attributes', $atts, $item, $args, $depth);
209 209
 
210 210
 			// Build a string of html containing all the atts for the item.
211 211
 			$attributes = '';
212
-			foreach ( $atts as $attr => $value ) {
213
-				if ( ! empty( $value ) ) {
214
-					$value       = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
212
+			foreach ($atts as $attr => $value) {
213
+				if ( ! empty($value)) {
214
+					$value       = ('href' === $attr) ? esc_url($value) : esc_attr($value);
215 215
 					$attributes .= ' ' . $attr . '="' . $value . '"';
216 216
 				}
217 217
 			}
@@ -219,19 +219,19 @@  discard block
 block discarded – undo
219 219
 			/**
220 220
 			 * Set a typeflag to easily test if this is a linkmod or not.
221 221
 			 */
222
-			$linkmod_type = self::get_linkmod_type( $linkmod_classes );
222
+			$linkmod_type = self::get_linkmod_type($linkmod_classes);
223 223
 
224 224
 			/**
225 225
 			 * START appending the internal item contents to the output.
226 226
 			 */
227
-			$item_output = isset( $args->before ) ? $args->before : '';
227
+			$item_output = isset($args->before) ? $args->before : '';
228 228
 			/**
229 229
 			 * This is the start of the internal nav item. Depending on what
230 230
 			 * kind of linkmod we have we may need different wrapper elements.
231 231
 			 */
232
-			if ( '' !== $linkmod_type ) {
232
+			if ('' !== $linkmod_type) {
233 233
 				// is linkmod, output the required element opener.
234
-				$item_output .= self::linkmod_element_open( $linkmod_type, $attributes );
234
+				$item_output .= self::linkmod_element_open($linkmod_type, $attributes);
235 235
 			} else {
236 236
 				// With no link mod type set this must be a standard <a> tag.
237 237
 				$item_output .= '<a' . $attributes . '>';
@@ -243,13 +243,13 @@  discard block
 block discarded – undo
243 243
 			 * output inside of the item before the $title (the link text).
244 244
 			 */
245 245
 			$icon_html = '';
246
-			if ( ! empty( $icon_class_string ) ) {
246
+			if ( ! empty($icon_class_string)) {
247 247
 				// append an <i> with the icon classes to what is output before links.
248
-				$icon_html = '<i class="' . esc_attr( $icon_class_string ) . '" aria-hidden="true"></i> ';
248
+				$icon_html = '<i class="' . esc_attr($icon_class_string) . '" aria-hidden="true"></i> ';
249 249
 			}
250 250
 
251 251
 			/** This filter is documented in wp-includes/post-template.php */
252
-			$title = apply_filters( 'the_title', esc_html( $item->title ), $item->ID );
252
+			$title = apply_filters('the_title', esc_html($item->title), $item->ID);
253 253
 
254 254
 			/**
255 255
 			 * Filters a menu item's title.
@@ -261,39 +261,39 @@  discard block
 block discarded – undo
261 261
 			 * @param stdClass $args  An object of wp_nav_menu() arguments.
262 262
 			 * @param int      $depth Depth of menu item. Used for padding.
263 263
 			 */
264
-			$title = apply_filters( 'nav_menu_item_title', $title, $item, $args, $depth );
264
+			$title = apply_filters('nav_menu_item_title', $title, $item, $args, $depth);
265 265
 
266 266
 			/**
267 267
 			 * If the .sr-only class was set apply to the nav items text only.
268 268
 			 */
269
-			if ( in_array( 'sr-only', $linkmod_classes, true ) ) {
270
-				$title         = self::wrap_for_screen_reader( $title );
271
-				$keys_to_unset = array_keys( $linkmod_classes, 'sr-only', true );
272
-				foreach ( $keys_to_unset as $k ) {
273
-					unset( $linkmod_classes[ $k ] );
269
+			if (in_array('sr-only', $linkmod_classes, true)) {
270
+				$title         = self::wrap_for_screen_reader($title);
271
+				$keys_to_unset = array_keys($linkmod_classes, 'sr-only', true);
272
+				foreach ($keys_to_unset as $k) {
273
+					unset($linkmod_classes[$k]);
274 274
 				}
275 275
 			}
276 276
 
277 277
 			// Put the item contents into $output.
278
-			$item_output .= isset( $args->link_before ) ? $args->link_before . $icon_html . $title . $args->link_after : '';
278
+			$item_output .= isset($args->link_before) ? $args->link_before . $icon_html . $title . $args->link_after : '';
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
 			/**
294 294
 			 * END appending the internal item contents to the output.
295 295
 			 */
296
-			$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
296
+			$output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
297 297
 
298 298
 		}
299 299
 
@@ -318,14 +318,14 @@  discard block
 block discarded – undo
318 318
 		 * @param array  $args              An array of arguments.
319 319
 		 * @param string $output            Used to append additional content (passed by reference).
320 320
 		 */
321
-		public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
322
-			if ( ! $element ) {
321
+		public function display_element($element, &$children_elements, $max_depth, $depth, $args, &$output) {
322
+			if ( ! $element) {
323 323
 				return; }
324 324
 			$id_field = $this->db_fields['id'];
325 325
 			// Display this element.
326
-			if ( is_object( $args[0] ) ) {
327
-				$args[0]->has_children = ! empty( $children_elements[ $element->$id_field ] ); }
328
-			parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
326
+			if (is_object($args[0])) {
327
+				$args[0]->has_children = ! empty($children_elements[$element->$id_field]); }
328
+			parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output);
329 329
 		}
330 330
 
331 331
 		/**
@@ -338,8 +338,8 @@  discard block
 block discarded – undo
338 338
 		 *
339 339
 		 * @param array $args passed from the wp_nav_menu function.
340 340
 		 */
341
-		public static function fallback( $args ) {
342
-			if ( current_user_can( 'edit_theme_options' ) ) {
341
+		public static function fallback($args) {
342
+			if (current_user_can('edit_theme_options')) {
343 343
 
344 344
 				/* Get Arguments. */
345 345
 				$container       = $args['container'];
@@ -351,30 +351,30 @@  discard block
 block discarded – undo
351 351
 				// initialize var to store fallback html.
352 352
 				$fallback_output = '';
353 353
 
354
-				if ( $container ) {
355
-					$fallback_output .= '<' . esc_attr( $container );
356
-					if ( $container_id ) {
357
-						$fallback_output .= ' id="' . esc_attr( $container_id ) . '"';
354
+				if ($container) {
355
+					$fallback_output .= '<' . esc_attr($container);
356
+					if ($container_id) {
357
+						$fallback_output .= ' id="' . esc_attr($container_id) . '"';
358 358
 					}
359
-					if ( $container_class ) {
360
-						$fallback_output .= ' class="' . esc_attr( $container_class ) . '"';
359
+					if ($container_class) {
360
+						$fallback_output .= ' class="' . esc_attr($container_class) . '"';
361 361
 					}
362 362
 					$fallback_output .= '>';
363 363
 				}
364 364
 				$fallback_output .= '<ul';
365
-				if ( $menu_id ) {
366
-					$fallback_output .= ' id="' . esc_attr( $menu_id ) . '"'; }
367
-				if ( $menu_class ) {
368
-					$fallback_output .= ' class="' . esc_attr( $menu_class ) . '"'; }
365
+				if ($menu_id) {
366
+					$fallback_output .= ' id="' . esc_attr($menu_id) . '"'; }
367
+				if ($menu_class) {
368
+					$fallback_output .= ' class="' . esc_attr($menu_class) . '"'; }
369 369
 				$fallback_output .= '>';
370
-				$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>';
370
+				$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 371
 				$fallback_output .= '</ul>';
372
-				if ( $container ) {
373
-					$fallback_output .= '</' . esc_attr( $container ) . '>';
372
+				if ($container) {
373
+					$fallback_output .= '</' . esc_attr($container) . '>';
374 374
 				}
375 375
 
376 376
 				// if $args has 'echo' key and it's true echo, otherwise return.
377
-				if ( array_key_exists( 'echo', $args ) && $args['echo'] ) {
377
+				if (array_key_exists('echo', $args) && $args['echo']) {
378 378
 					echo $fallback_output; // WPCS: XSS OK.
379 379
 				} else {
380 380
 					return $fallback_output;
@@ -400,28 +400,28 @@  discard block
 block discarded – undo
400 400
 		 *
401 401
 		 * @return array  $classes         a maybe modified array of classnames.
402 402
 		 */
403
-		private function separate_linkmods_and_icons_from_classes( $classes, &$linkmod_classes, &$icon_classes, $depth ) {
403
+		private function separate_linkmods_and_icons_from_classes($classes, &$linkmod_classes, &$icon_classes, $depth) {
404 404
 			// Loop through $classes array to find linkmod or icon classes.
405
-			foreach ( $classes as $key => $class ) {
405
+			foreach ($classes as $key => $class) {
406 406
 				// If any special classes are found, store the class in it's
407 407
 				// holder array and and unset the item from $classes.
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
 					// Test for .dropdown-header or .dropdown-divider and a
414 414
 					// depth greater than 0 - IE inside a dropdown.
415 415
 					$linkmod_classes[] = $class;
416
-					unset( $classes[ $key ] );
417
-				} elseif ( preg_match( '/^fa-(\S*)?|^fa(s|r|l|b)?(\s?)?$/i', $class ) ) {
416
+					unset($classes[$key]);
417
+				} elseif (preg_match('/^fa-(\S*)?|^fa(s|r|l|b)?(\s?)?$/i', $class)) {
418 418
 					// Font Awesome.
419 419
 					$icon_classes[] = $class;
420
-					unset( $classes[ $key ] );
421
-				} elseif ( preg_match( '/^glyphicon-(\S*)?|^glyphicon(\s?)$/i', $class ) ) {
420
+					unset($classes[$key]);
421
+				} elseif (preg_match('/^glyphicon-(\S*)?|^glyphicon(\s?)$/i', $class)) {
422 422
 					// Glyphicons.
423 423
 					$icon_classes[] = $class;
424
-					unset( $classes[ $key ] );
424
+					unset($classes[$key]);
425 425
 				}
426 426
 			}
427 427
 
@@ -438,19 +438,19 @@  discard block
 block discarded – undo
438 438
 		 *
439 439
 		 * @return string                empty for default, a linkmod type string otherwise.
440 440
 		 */
441
-		private function get_linkmod_type( $linkmod_classes = array() ) {
441
+		private function get_linkmod_type($linkmod_classes = array()) {
442 442
 			$linkmod_type = '';
443 443
 			// Loop through array of linkmod classes to handle their $atts.
444
-			if ( ! empty( $linkmod_classes ) ) {
445
-				foreach ( $linkmod_classes as $link_class ) {
446
-					if ( ! empty( $link_class ) ) {
444
+			if ( ! empty($linkmod_classes)) {
445
+				foreach ($linkmod_classes as $link_class) {
446
+					if ( ! empty($link_class)) {
447 447
 
448 448
 						// check for special class types and set a flag for them.
449
-						if ( 'dropdown-header' === $link_class ) {
449
+						if ('dropdown-header' === $link_class) {
450 450
 							$linkmod_type = 'dropdown-header';
451
-						} elseif ( 'dropdown-divider' === $link_class ) {
451
+						} elseif ('dropdown-divider' === $link_class) {
452 452
 							$linkmod_type = 'dropdown-divider';
453
-						} elseif ( 'dropdown-item-text' === $link_class ) {
453
+						} elseif ('dropdown-item-text' === $link_class) {
454 454
 							$linkmod_type = 'dropdown-item-text';
455 455
 						}
456 456
 					}
@@ -469,24 +469,24 @@  discard block
 block discarded – undo
469 469
 		 *
470 470
 		 * @return array                 maybe updated array of attributes for item.
471 471
 		 */
472
-		private function update_atts_for_linkmod_type( $atts = array(), $linkmod_classes = array() ) {
473
-			if ( ! empty( $linkmod_classes ) ) {
474
-				foreach ( $linkmod_classes as $link_class ) {
475
-					if ( ! empty( $link_class ) ) {
472
+		private function update_atts_for_linkmod_type($atts = array(), $linkmod_classes = array()) {
473
+			if ( ! empty($linkmod_classes)) {
474
+				foreach ($linkmod_classes as $link_class) {
475
+					if ( ! empty($link_class)) {
476 476
 						// update $atts with a space and the extra classname...
477 477
 						// so long as it's not a sr-only class.
478
-						if ( 'sr-only' !== $link_class ) {
479
-							$atts['class'] .= ' ' . esc_attr( $link_class );
478
+						if ('sr-only' !== $link_class) {
479
+							$atts['class'] .= ' ' . esc_attr($link_class);
480 480
 						}
481 481
 						// check for special class types we need additional handling for.
482
-						if ( 'disabled' === $link_class ) {
482
+						if ('disabled' === $link_class) {
483 483
 							// Convert link to '#' and unset open targets.
484 484
 							$atts['href'] = '#';
485
-							unset( $atts['target'] );
486
-						} elseif ( 'dropdown-header' === $link_class || 'dropdown-divider' === $link_class || 'dropdown-item-text' === $link_class ) {
485
+							unset($atts['target']);
486
+						} elseif ('dropdown-header' === $link_class || 'dropdown-divider' === $link_class || 'dropdown-item-text' === $link_class) {
487 487
 							// Store a type flag and unset href and target.
488
-							unset( $atts['href'] );
489
-							unset( $atts['target'] );
488
+							unset($atts['href']);
489
+							unset($atts['target']);
490 490
 						}
491 491
 					}
492 492
 				}
@@ -502,8 +502,8 @@  discard block
 block discarded – undo
502 502
 		 * @param string $text the string of text to be wrapped in a screen reader class.
503 503
 		 * @return string      the string wrapped in a span with the class.
504 504
 		 */
505
-		private function wrap_for_screen_reader( $text = '' ) {
506
-			if ( $text ) {
505
+		private function wrap_for_screen_reader($text = '') {
506
+			if ($text) {
507 507
 				$text = '<span class="sr-only">' . $text . '</span>';
508 508
 			}
509 509
 			return $text;
@@ -519,15 +519,15 @@  discard block
 block discarded – undo
519 519
 		 *
520 520
 		 * @return string              a string with the openign tag for the element with attribibutes added.
521 521
 		 */
522
-		private function linkmod_element_open( $linkmod_type, $attributes = '' ) {
522
+		private function linkmod_element_open($linkmod_type, $attributes = '') {
523 523
 			$output = '';
524
-			if ( 'dropdown-item-text' === $linkmod_type ) {
524
+			if ('dropdown-item-text' === $linkmod_type) {
525 525
 				$output .= '<span class="dropdown-item-text"' . $attributes . '>';
526
-			} elseif ( 'dropdown-header' === $linkmod_type ) {
526
+			} elseif ('dropdown-header' === $linkmod_type) {
527 527
 				// For a header use a span with the .h6 class instead of a real
528 528
 				// header tag so that it doesn't confuse screen readers.
529 529
 				$output .= '<span class="dropdown-header h6"' . $attributes . '>';
530
-			} elseif ( 'dropdown-divider' === $linkmod_type ) {
530
+			} elseif ('dropdown-divider' === $linkmod_type) {
531 531
 				// this is a divider.
532 532
 				$output .= '<div class="dropdown-divider"' . $attributes . '>';
533 533
 			}
@@ -543,13 +543,13 @@  discard block
 block discarded – undo
543 543
 		 *
544 544
 		 * @return string              a string with the closing tag for this linkmod type.
545 545
 		 */
546
-		private function linkmod_element_close( $linkmod_type ) {
546
+		private function linkmod_element_close($linkmod_type) {
547 547
 			$output = '';
548
-			if ( 'dropdown-header' === $linkmod_type || 'dropdown-item-text' === $linkmod_type ) {
548
+			if ('dropdown-header' === $linkmod_type || 'dropdown-item-text' === $linkmod_type) {
549 549
 				// For a header use a span with the .h6 class instead of a real
550 550
 				// header tag so that it doesn't confuse screen readers.
551 551
 				$output .= '</span>';
552
-			} elseif ( 'dropdown-divider' === $linkmod_type ) {
552
+			} elseif ('dropdown-divider' === $linkmod_type) {
553 553
 				// this is a divider.
554 554
 				$output .= '</div>';
555 555
 			}
Please login to merge, or discard this patch.