Completed
Pull Request — master (#448)
by
unknown
01:13
created
class-wp-bootstrap-navwalker.php 1 patch
Spacing   +114 added lines, -114 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
 
@@ -173,24 +173,24 @@  discard block
 block discarded – undo
173 173
 			 *
174 174
 			 * @param bool $show Whether to output the default title attribute.
175 175
 			 */
176
-			$show_atts_title_default = apply_filters( 'wp_bootstrap_navwalker_show_atts_title_default', $show = true );
176
+			$show_atts_title_default = apply_filters('wp_bootstrap_navwalker_show_atts_title_default', $show = true);
177 177
 
178 178
 			/*
179 179
 			 * Set title from item to the $atts array - if title is empty and the
180 180
 			 * default title attribute is turned on then default to the item title.
181 181
 			 */
182
-			if ( empty( $item->attr_title ) ) {
183
-				if ( $show_atts_title_default ) {
184
-					$atts['title'] = ! empty( $item->title ) ? esc_attr( strip_tags( $item->title ) ) : '';
182
+			if (empty($item->attr_title)) {
183
+				if ($show_atts_title_default) {
184
+					$atts['title'] = ! empty($item->title) ? esc_attr(strip_tags($item->title)) : '';
185 185
 				}
186 186
 			} else {
187 187
 				$atts['title'] = $item->attr_title;
188 188
 			}
189 189
 
190
-			$atts['target'] = ! empty( $item->target ) ? $item->target : '';
191
-			$atts['rel']    = ! empty( $item->xfn ) ? $item->xfn : '';
190
+			$atts['target'] = ! empty($item->target) ? $item->target : '';
191
+			$atts['rel']    = ! empty($item->xfn) ? $item->xfn : '';
192 192
 			// If item has_children add atts to <a>.
193
-			if ( isset( $args->has_children ) && $args->has_children && 0 === $depth && $args->depth > 1 ) {
193
+			if (isset($args->has_children) && $args->has_children && 0 === $depth && $args->depth > 1) {
194 194
 				$atts['href']          = '#';
195 195
 				$atts['data-toggle']   = 'dropdown';
196 196
 				$atts['aria-haspopup'] = 'true';
@@ -198,9 +198,9 @@  discard block
 block discarded – undo
198 198
 				$atts['class']         = 'dropdown-toggle nav-link';
199 199
 				$atts['id']            = 'menu-item-dropdown-' . $item->ID;
200 200
 			} else {
201
-				$atts['href'] = ! empty( $item->url ) ? $item->url : '#';
201
+				$atts['href'] = ! empty($item->url) ? $item->url : '#';
202 202
 				// Items in dropdowns use .dropdown-item instead of .nav-link.
203
-				if ( $depth > 0 ) {
203
+				if ($depth > 0) {
204 204
 					$atts['class'] = 'dropdown-item';
205 205
 				} else {
206 206
 					$atts['class'] = 'nav-link';
@@ -210,15 +210,15 @@  discard block
 block discarded – undo
210 210
 			$atts['aria-current'] = $item->current ? 'page' : '';
211 211
 
212 212
 			// update atts of this item based on any custom linkmod classes.
213
-			$atts = self::update_atts_for_linkmod_type( $atts, $linkmod_classes );
213
+			$atts = self::update_atts_for_linkmod_type($atts, $linkmod_classes);
214 214
 			// Allow filtering of the $atts array before using it.
215
-			$atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth );
215
+			$atts = apply_filters('nav_menu_link_attributes', $atts, $item, $args, $depth);
216 216
 
217 217
 			// Build a string of html containing all the atts for the item.
218 218
 			$attributes = '';
219
-			foreach ( $atts as $attr => $value ) {
220
-				if ( ! empty( $value ) ) {
221
-					$value       = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
219
+			foreach ($atts as $attr => $value) {
220
+				if ( ! empty($value)) {
221
+					$value       = ('href' === $attr) ? esc_url($value) : esc_attr($value);
222 222
 					$attributes .= ' ' . $attr . '="' . $value . '"';
223 223
 				}
224 224
 			}
@@ -226,19 +226,19 @@  discard block
 block discarded – undo
226 226
 			/**
227 227
 			 * Set a typeflag to easily test if this is a linkmod or not.
228 228
 			 */
229
-			$linkmod_type = self::get_linkmod_type( $linkmod_classes );
229
+			$linkmod_type = self::get_linkmod_type($linkmod_classes);
230 230
 
231 231
 			/**
232 232
 			 * START appending the internal item contents to the output.
233 233
 			 */
234
-			$item_output = isset( $args->before ) ? $args->before : '';
234
+			$item_output = isset($args->before) ? $args->before : '';
235 235
 			/**
236 236
 			 * This is the start of the internal nav item. Depending on what
237 237
 			 * kind of linkmod we have we may need different wrapper elements.
238 238
 			 */
239
-			if ( '' !== $linkmod_type ) {
239
+			if ('' !== $linkmod_type) {
240 240
 				// is linkmod, output the required element opener.
241
-				$item_output .= self::linkmod_element_open( $linkmod_type, $attributes );
241
+				$item_output .= self::linkmod_element_open($linkmod_type, $attributes);
242 242
 			} else {
243 243
 				// With no link mod type set this must be a standard <a> tag.
244 244
 				$item_output .= '<a' . $attributes . '>';
@@ -250,13 +250,13 @@  discard block
 block discarded – undo
250 250
 			 * output inside of the item before the $title (the link text).
251 251
 			 */
252 252
 			$icon_html = '';
253
-			if ( ! empty( $icon_class_string ) ) {
253
+			if ( ! empty($icon_class_string)) {
254 254
 				// append an <i> with the icon classes to what is output before links.
255
-				$icon_html = '<i class="' . esc_attr( $icon_class_string ) . '" aria-hidden="true"></i> ';
255
+				$icon_html = '<i class="' . esc_attr($icon_class_string) . '" aria-hidden="true"></i> ';
256 256
 			}
257 257
 
258 258
 			/** This filter is documented in wp-includes/post-template.php */
259
-			$title = apply_filters( 'the_title', esc_html( $item->title ), $item->ID );
259
+			$title = apply_filters('the_title', esc_html($item->title), $item->ID);
260 260
 
261 261
 			/**
262 262
 			 * Filters a menu item's title.
@@ -268,39 +268,39 @@  discard block
 block discarded – undo
268 268
 			 * @param stdClass $args  An object of wp_nav_menu() arguments.
269 269
 			 * @param int      $depth Depth of menu item. Used for padding.
270 270
 			 */
271
-			$title = apply_filters( 'nav_menu_item_title', $title, $item, $args, $depth );
271
+			$title = apply_filters('nav_menu_item_title', $title, $item, $args, $depth);
272 272
 
273 273
 			/**
274 274
 			 * If the .sr-only class was set apply to the nav items text only.
275 275
 			 */
276
-			if ( in_array( 'sr-only', $linkmod_classes, true ) ) {
277
-				$title         = self::wrap_for_screen_reader( $title );
278
-				$keys_to_unset = array_keys( $linkmod_classes, 'sr-only', true );
279
-				foreach ( $keys_to_unset as $k ) {
280
-					unset( $linkmod_classes[ $k ] );
276
+			if (in_array('sr-only', $linkmod_classes, true)) {
277
+				$title         = self::wrap_for_screen_reader($title);
278
+				$keys_to_unset = array_keys($linkmod_classes, 'sr-only', true);
279
+				foreach ($keys_to_unset as $k) {
280
+					unset($linkmod_classes[$k]);
281 281
 				}
282 282
 			}
283 283
 
284 284
 			// Put the item contents into $output.
285
-			$item_output .= isset( $args->link_before ) ? $args->link_before . $icon_html . $title . $args->link_after : '';
285
+			$item_output .= isset($args->link_before) ? $args->link_before . $icon_html . $title . $args->link_after : '';
286 286
 			/**
287 287
 			 * This is the end of the internal nav item. We need to close the
288 288
 			 * correct element depending on the type of link or link mod.
289 289
 			 */
290
-			if ( '' !== $linkmod_type ) {
290
+			if ('' !== $linkmod_type) {
291 291
 				// is linkmod, output the required closing element.
292
-				$item_output .= self::linkmod_element_close( $linkmod_type );
292
+				$item_output .= self::linkmod_element_close($linkmod_type);
293 293
 			} else {
294 294
 				// With no link mod type set this must be a standard <a> tag.
295 295
 				$item_output .= '</a>';
296 296
 			}
297 297
 
298
-			$item_output .= isset( $args->after ) ? $args->after : '';
298
+			$item_output .= isset($args->after) ? $args->after : '';
299 299
 
300 300
 			/**
301 301
 			 * END appending the internal item contents to the output.
302 302
 			 */
303
-			$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
303
+			$output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
304 304
 
305 305
 		}
306 306
 
@@ -325,14 +325,14 @@  discard block
 block discarded – undo
325 325
 		 * @param array  $args              An array of arguments.
326 326
 		 * @param string $output            Used to append additional content (passed by reference).
327 327
 		 */
328
-		public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
329
-			if ( ! $element ) {
328
+		public function display_element($element, &$children_elements, $max_depth, $depth, $args, &$output) {
329
+			if ( ! $element) {
330 330
 				return; }
331 331
 			$id_field = $this->db_fields['id'];
332 332
 			// Display this element.
333
-			if ( is_object( $args[0] ) ) {
334
-				$args[0]->has_children = ! empty( $children_elements[ $element->$id_field ] ); }
335
-			parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
333
+			if (is_object($args[0])) {
334
+				$args[0]->has_children = ! empty($children_elements[$element->$id_field]); }
335
+			parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output);
336 336
 		}
337 337
 
338 338
 		/**
@@ -345,8 +345,8 @@  discard block
 block discarded – undo
345 345
 		 *
346 346
 		 * @param array $args passed from the wp_nav_menu function.
347 347
 		 */
348
-		public static function fallback( $args ) {
349
-			if ( current_user_can( 'edit_theme_options' ) ) {
348
+		public static function fallback($args) {
349
+			if (current_user_can('edit_theme_options')) {
350 350
 
351 351
 				/* Get Arguments. */
352 352
 				$container       = $args['container'];
@@ -358,30 +358,30 @@  discard block
 block discarded – undo
358 358
 				// initialize var to store fallback html.
359 359
 				$fallback_output = '';
360 360
 
361
-				if ( $container ) {
362
-					$fallback_output .= '<' . esc_attr( $container );
363
-					if ( $container_id ) {
364
-						$fallback_output .= ' id="' . esc_attr( $container_id ) . '"';
361
+				if ($container) {
362
+					$fallback_output .= '<' . esc_attr($container);
363
+					if ($container_id) {
364
+						$fallback_output .= ' id="' . esc_attr($container_id) . '"';
365 365
 					}
366
-					if ( $container_class ) {
367
-						$fallback_output .= ' class="' . esc_attr( $container_class ) . '"';
366
+					if ($container_class) {
367
+						$fallback_output .= ' class="' . esc_attr($container_class) . '"';
368 368
 					}
369 369
 					$fallback_output .= '>';
370 370
 				}
371 371
 				$fallback_output .= '<ul';
372
-				if ( $menu_id ) {
373
-					$fallback_output .= ' id="' . esc_attr( $menu_id ) . '"'; }
374
-				if ( $menu_class ) {
375
-					$fallback_output .= ' class="' . esc_attr( $menu_class ) . '"'; }
372
+				if ($menu_id) {
373
+					$fallback_output .= ' id="' . esc_attr($menu_id) . '"'; }
374
+				if ($menu_class) {
375
+					$fallback_output .= ' class="' . esc_attr($menu_class) . '"'; }
376 376
 				$fallback_output .= '>';
377
-				$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>';
377
+				$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>';
378 378
 				$fallback_output .= '</ul>';
379
-				if ( $container ) {
380
-					$fallback_output .= '</' . esc_attr( $container ) . '>';
379
+				if ($container) {
380
+					$fallback_output .= '</' . esc_attr($container) . '>';
381 381
 				}
382 382
 
383 383
 				// if $args has 'echo' key and it's true echo, otherwise return.
384
-				if ( array_key_exists( 'echo', $args ) && $args['echo'] ) {
384
+				if (array_key_exists('echo', $args) && $args['echo']) {
385 385
 					echo $fallback_output; // WPCS: XSS OK.
386 386
 				} else {
387 387
 					return $fallback_output;
@@ -407,28 +407,28 @@  discard block
 block discarded – undo
407 407
 		 *
408 408
 		 * @return array  $classes         a maybe modified array of classnames.
409 409
 		 */
410
-		private function separate_linkmods_and_icons_from_classes( $classes, &$linkmod_classes, &$icon_classes, $depth ) {
410
+		private function separate_linkmods_and_icons_from_classes($classes, &$linkmod_classes, &$icon_classes, $depth) {
411 411
 			// Loop through $classes array to find linkmod or icon classes.
412
-			foreach ( $classes as $key => $class ) {
412
+			foreach ($classes as $key => $class) {
413 413
 				// If any special classes are found, store the class in it's
414 414
 				// holder array and and unset the item from $classes.
415
-				if ( preg_match( '/^disabled|^sr-only/i', $class ) ) {
415
+				if (preg_match('/^disabled|^sr-only/i', $class)) {
416 416
 					// Test for .disabled or .sr-only classes.
417 417
 					$linkmod_classes[] = $class;
418
-					unset( $classes[ $key ] );
419
-				} elseif ( preg_match( '/^dropdown-header|^dropdown-divider|^dropdown-item-text/i', $class ) && $depth > 0 ) {
418
+					unset($classes[$key]);
419
+				} elseif (preg_match('/^dropdown-header|^dropdown-divider|^dropdown-item-text/i', $class) && $depth > 0) {
420 420
 					// Test for .dropdown-header or .dropdown-divider and a
421 421
 					// depth greater than 0 - IE inside a dropdown.
422 422
 					$linkmod_classes[] = $class;
423
-					unset( $classes[ $key ] );
424
-				} elseif ( preg_match( '/^fa-(\S*)?|^fa(s|r|l|b)?(\s?)?$/i', $class ) ) {
423
+					unset($classes[$key]);
424
+				} elseif (preg_match('/^fa-(\S*)?|^fa(s|r|l|b)?(\s?)?$/i', $class)) {
425 425
 					// Font Awesome.
426 426
 					$icon_classes[] = $class;
427
-					unset( $classes[ $key ] );
428
-				} elseif ( preg_match( '/^glyphicon-(\S*)?|^glyphicon(\s?)$/i', $class ) ) {
427
+					unset($classes[$key]);
428
+				} elseif (preg_match('/^glyphicon-(\S*)?|^glyphicon(\s?)$/i', $class)) {
429 429
 					// Glyphicons.
430 430
 					$icon_classes[] = $class;
431
-					unset( $classes[ $key ] );
431
+					unset($classes[$key]);
432 432
 				}
433 433
 			}
434 434
 
@@ -445,19 +445,19 @@  discard block
 block discarded – undo
445 445
 		 *
446 446
 		 * @return string                empty for default, a linkmod type string otherwise.
447 447
 		 */
448
-		private function get_linkmod_type( $linkmod_classes = array() ) {
448
+		private function get_linkmod_type($linkmod_classes = array()) {
449 449
 			$linkmod_type = '';
450 450
 			// Loop through array of linkmod classes to handle their $atts.
451
-			if ( ! empty( $linkmod_classes ) ) {
452
-				foreach ( $linkmod_classes as $link_class ) {
453
-					if ( ! empty( $link_class ) ) {
451
+			if ( ! empty($linkmod_classes)) {
452
+				foreach ($linkmod_classes as $link_class) {
453
+					if ( ! empty($link_class)) {
454 454
 
455 455
 						// check for special class types and set a flag for them.
456
-						if ( 'dropdown-header' === $link_class ) {
456
+						if ('dropdown-header' === $link_class) {
457 457
 							$linkmod_type = 'dropdown-header';
458
-						} elseif ( 'dropdown-divider' === $link_class ) {
458
+						} elseif ('dropdown-divider' === $link_class) {
459 459
 							$linkmod_type = 'dropdown-divider';
460
-						} elseif ( 'dropdown-item-text' === $link_class ) {
460
+						} elseif ('dropdown-item-text' === $link_class) {
461 461
 							$linkmod_type = 'dropdown-item-text';
462 462
 						}
463 463
 					}
@@ -476,24 +476,24 @@  discard block
 block discarded – undo
476 476
 		 *
477 477
 		 * @return array                 maybe updated array of attributes for item.
478 478
 		 */
479
-		private function update_atts_for_linkmod_type( $atts = array(), $linkmod_classes = array() ) {
480
-			if ( ! empty( $linkmod_classes ) ) {
481
-				foreach ( $linkmod_classes as $link_class ) {
482
-					if ( ! empty( $link_class ) ) {
479
+		private function update_atts_for_linkmod_type($atts = array(), $linkmod_classes = array()) {
480
+			if ( ! empty($linkmod_classes)) {
481
+				foreach ($linkmod_classes as $link_class) {
482
+					if ( ! empty($link_class)) {
483 483
 						// update $atts with a space and the extra classname...
484 484
 						// so long as it's not a sr-only class.
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
 block discarded – undo
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,15 +526,15 @@  discard block
 block discarded – undo
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
 				// For a header use a span with the .h6 class instead of a real
535 535
 				// header tag so that it doesn't confuse screen readers.
536 536
 				$output .= '<span class="dropdown-header h6"' . $attributes . '>';
537
-			} elseif ( 'dropdown-divider' === $linkmod_type ) {
537
+			} elseif ('dropdown-divider' === $linkmod_type) {
538 538
 				// this is a divider.
539 539
 				$output .= '<div class="dropdown-divider"' . $attributes . '>';
540 540
 			}
@@ -550,13 +550,13 @@  discard block
 block discarded – undo
550 550
 		 *
551 551
 		 * @return string              a string with the closing tag for this linkmod type.
552 552
 		 */
553
-		private function linkmod_element_close( $linkmod_type ) {
553
+		private function linkmod_element_close($linkmod_type) {
554 554
 			$output = '';
555
-			if ( 'dropdown-header' === $linkmod_type || 'dropdown-item-text' === $linkmod_type ) {
555
+			if ('dropdown-header' === $linkmod_type || 'dropdown-item-text' === $linkmod_type) {
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
 				$output .= '</span>';
559
-			} elseif ( 'dropdown-divider' === $linkmod_type ) {
559
+			} elseif ('dropdown-divider' === $linkmod_type) {
560 560
 				// this is a divider.
561 561
 				$output .= '</div>';
562 562
 			}
Please login to merge, or discard this patch.