Completed
Push — master ( 662027...11e3e9 )
by William
7s
created
class-wp-bootstrap-navwalker.php 1 patch
Spacing   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 */
21 21
 
22 22
 /* Check if Class Exists. */
23
-if ( ! class_exists( 'WP_Bootstrap_Navwalker' ) ) {
23
+if ( ! class_exists('WP_Bootstrap_Navwalker')) {
24 24
 	/**
25 25
 	 * WP_Bootstrap_Navwalker class.
26 26
 	 *
@@ -39,17 +39,17 @@  discard block
 block discarded – undo
39 39
 		 * @param int      $depth  Depth of menu item. Used for padding.
40 40
 		 * @param stdClass $args   An object of wp_nav_menu() arguments.
41 41
 		 */
42
-		public function start_lvl( &$output, $depth = 0, $args = array() ) {
43
-			if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
42
+		public function start_lvl(&$output, $depth = 0, $args = array()) {
43
+			if (isset($args->item_spacing) && 'discard' === $args->item_spacing) {
44 44
 				$t = '';
45 45
 				$n = '';
46 46
 			} else {
47 47
 				$t = "\t";
48 48
 				$n = "\n";
49 49
 			}
50
-			$indent = str_repeat( $t, $depth );
50
+			$indent = str_repeat($t, $depth);
51 51
 			// Default class to add to the file.
52
-			$classes = array( 'dropdown-menu' );
52
+			$classes = array('dropdown-menu');
53 53
 			/**
54 54
 			 * Filters the CSS class(es) applied to a menu list element.
55 55
 			 *
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
 			 * @param stdClass $args    An object of `wp_nav_menu()` arguments.
60 60
 			 * @param int      $depth   Depth of menu item. Used for padding.
61 61
 			 */
62
-			$class_names = join( ' ', apply_filters( 'nav_menu_submenu_css_class', $classes, $args, $depth ) );
63
-			$class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
62
+			$class_names = join(' ', apply_filters('nav_menu_submenu_css_class', $classes, $args, $depth));
63
+			$class_names = $class_names ? ' class="' . esc_attr($class_names) . '"' : '';
64 64
 			/**
65 65
 			 * The `.dropdown-menu` container needs to have a labelledby
66 66
 			 * attribute which points to it's trigger link.
@@ -70,11 +70,11 @@  discard block
 block discarded – undo
70 70
 			 */
71 71
 			$labelledby = '';
72 72
 			// find all links with an id in the output.
73
-			preg_match_all( '/(<a.*?id=\"|\')(.*?)\"|\'.*?>/im', $output, $matches );
73
+			preg_match_all('/(<a.*?id=\"|\')(.*?)\"|\'.*?>/im', $output, $matches);
74 74
 			// with pointer at end of array check if we got an ID match.
75
-			if ( end( $matches[2] ) ) {
75
+			if (end($matches[2])) {
76 76
 				// build a string to use as aria-labelledby.
77
-				$lablledby = 'aria-labelledby="' . end( $matches[2] ) . '"';
77
+				$lablledby = 'aria-labelledby="' . end($matches[2]) . '"';
78 78
 			}
79 79
 			$output .= "{$n}{$indent}<ul$class_names $lablledby role=\"menu\">{$n}";
80 80
 		}
@@ -93,17 +93,17 @@  discard block
 block discarded – undo
93 93
 		 * @param stdClass $args   An object of wp_nav_menu() arguments.
94 94
 		 * @param int      $id     Current item ID.
95 95
 		 */
96
-		public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
97
-			if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
96
+		public function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) {
97
+			if (isset($args->item_spacing) && 'discard' === $args->item_spacing) {
98 98
 				$t = '';
99 99
 				$n = '';
100 100
 			} else {
101 101
 				$t = "\t";
102 102
 				$n = "\n";
103 103
 			}
104
-			$indent = ( $depth ) ? str_repeat( $t, $depth ) : '';
104
+			$indent = ($depth) ? str_repeat($t, $depth) : '';
105 105
 
106
-			$classes = empty( $item->classes ) ? array() : (array) $item->classes;
106
+			$classes = empty($item->classes) ? array() : (array) $item->classes;
107 107
 
108 108
 			// Initialize some holder variables to store specially handled item
109 109
 			// wrappers and icons.
@@ -116,10 +116,10 @@  discard block
 block discarded – undo
116 116
 			 * NOTE: linkmod and icon class arrays are passed by reference and
117 117
 			 * are maybe modified before being used later in this function.
118 118
 			 */
119
-			$classes = self::seporate_linkmods_and_icons_from_classes( $classes, $linkmod_classes, $icon_classes, $depth );
119
+			$classes = self::seporate_linkmods_and_icons_from_classes($classes, $linkmod_classes, $icon_classes, $depth);
120 120
 
121 121
 			// Join any icon classes plucked from $classes into a string.
122
-			$icon_class_string = join( ' ', $icon_classes );
122
+			$icon_class_string = join(' ', $icon_classes);
123 123
 
124 124
 			/**
125 125
 			 * Filters the arguments for a single nav menu item.
@@ -130,13 +130,13 @@  discard block
 block discarded – undo
130 130
 			 * @param WP_Post  $item  Menu item data object.
131 131
 			 * @param int      $depth Depth of menu item. Used for padding.
132 132
 			 */
133
-			$args = apply_filters( 'nav_menu_item_args', $args, $item, $depth );
133
+			$args = apply_filters('nav_menu_item_args', $args, $item, $depth);
134 134
 
135 135
 			// Add .dropdown or .active classes where they are needed.
136
-			if ( $args->has_children ) {
136
+			if ($args->has_children) {
137 137
 				$classes[] = 'dropdown';
138 138
 			}
139
-			if ( in_array( 'current-menu-item', $classes, true ) || in_array( 'current-menu-parent', $classes, true ) ) {
139
+			if (in_array('current-menu-item', $classes, true) || in_array('current-menu-parent', $classes, true)) {
140 140
 				$classes[] = 'active';
141 141
 			}
142 142
 
@@ -145,11 +145,11 @@  discard block
 block discarded – undo
145 145
 			$classes[] = 'nav-item';
146 146
 
147 147
 			// Allow filtering the classes.
148
-			$classes = apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args, $depth );
148
+			$classes = apply_filters('nav_menu_css_class', array_filter($classes), $item, $args, $depth);
149 149
 
150 150
 			// Form a string of classes in format: class="class_names".
151
-			$class_names = join( ' ', $classes );
152
-			$class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
151
+			$class_names = join(' ', $classes);
152
+			$class_names = $class_names ? ' class="' . esc_attr($class_names) . '"' : '';
153 153
 
154 154
 			/**
155 155
 			 * Filters the ID applied to a menu item's list item element.
@@ -162,8 +162,8 @@  discard block
 block discarded – undo
162 162
 			 * @param stdClass $args    An object of wp_nav_menu() arguments.
163 163
 			 * @param int      $depth   Depth of menu item. Used for padding.
164 164
 			 */
165
-			$id = apply_filters( 'nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args, $depth );
166
-			$id = $id ? ' id="' . esc_attr( $id ) . '"' : '';
165
+			$id = apply_filters('nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args, $depth);
166
+			$id = $id ? ' id="' . esc_attr($id) . '"' : '';
167 167
 
168 168
 			$output .= $indent . '<li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement"' . $id . $class_names . '>';
169 169
 
@@ -172,16 +172,16 @@  discard block
 block discarded – undo
172 172
 
173 173
 			// Set title from item to the $atts array - if title is empty then
174 174
 			// default to item title.
175
-			if ( empty( $item->attr_title ) ) {
176
-				$atts['title'] = ! empty( $item->title ) ? strip_tags( $item->title ) : '';
175
+			if (empty($item->attr_title)) {
176
+				$atts['title'] = ! empty($item->title) ? strip_tags($item->title) : '';
177 177
 			} else {
178 178
 				$atts['title'] = $item->attr_title;
179 179
 			}
180 180
 
181
-			$atts['target'] = ! empty( $item->target ) ? $item->target : '';
182
-			$atts['rel']    = ! empty( $item->xfn ) ? $item->xfn : '';
181
+			$atts['target'] = ! empty($item->target) ? $item->target : '';
182
+			$atts['rel']    = ! empty($item->xfn) ? $item->xfn : '';
183 183
 			// If item has_children add atts to <a>.
184
-			if ( $args->has_children && 0 === $depth && $args->depth > 1 ) {
184
+			if ($args->has_children && 0 === $depth && $args->depth > 1) {
185 185
 				$atts['href']          = '#';
186 186
 				$atts['data-toggle']   = 'dropdown';
187 187
 				$atts['aria-haspopup'] = 'true';
@@ -189,9 +189,9 @@  discard block
 block discarded – undo
189 189
 				$atts['class']         = 'dropdown-toggle nav-link';
190 190
 				$atts['id']            = 'menu-item-dropdown-' . $item->ID;
191 191
 			} else {
192
-				$atts['href'] = ! empty( $item->url ) ? $item->url : '#';
192
+				$atts['href'] = ! empty($item->url) ? $item->url : '#';
193 193
 				// Items in dropdowns use .dropdown-item instead of .nav-link.
194
-				if ( $depth > 0 ) {
194
+				if ($depth > 0) {
195 195
 					$atts['class'] = 'dropdown-item';
196 196
 				} else {
197 197
 					$atts['class'] = 'nav-link';
@@ -199,15 +199,15 @@  discard block
 block discarded – undo
199 199
 			}
200 200
 
201 201
 			// update atts of this item based on any custom linkmod classes.
202
-			$atts = self::update_atts_for_linkmod_type( $atts, $linkmod_classes );
202
+			$atts = self::update_atts_for_linkmod_type($atts, $linkmod_classes);
203 203
 			// Allow filtering of the $atts array before using it.
204
-			$atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args );
204
+			$atts = apply_filters('nav_menu_link_attributes', $atts, $item, $args);
205 205
 
206 206
 			// Build a string of html containing all the atts for the item.
207 207
 			$attributes = '';
208
-			foreach ( $atts as $attr => $value ) {
209
-				if ( ! empty( $value ) ) {
210
-					$value       = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
208
+			foreach ($atts as $attr => $value) {
209
+				if ( ! empty($value)) {
210
+					$value       = ('href' === $attr) ? esc_url($value) : esc_attr($value);
211 211
 					$attributes .= ' ' . $attr . '="' . $value . '"';
212 212
 				}
213 213
 			}
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 			/**
216 216
 			 * Set a typeflag to easily test if this is a linkmod or not.
217 217
 			 */
218
-			$linkmod_type = self::get_linkmod_type( $linkmod_classes );
218
+			$linkmod_type = self::get_linkmod_type($linkmod_classes);
219 219
 
220 220
 			/**
221 221
 			 * START appending the internal item contents to the output.
@@ -226,9 +226,9 @@  discard block
 block discarded – undo
226 226
 			 * This is the start of the internal nav item. Depending on what
227 227
 			 * kind of linkmod we have we may need different wrapper elements.
228 228
 			 */
229
-			if ( '' !== $linkmod_type ) {
229
+			if ('' !== $linkmod_type) {
230 230
 				// is linkmod, output the required element opener.
231
-				$item_output .= self::linkmod_element_open( $linkmod_type, $attributes );
231
+				$item_output .= self::linkmod_element_open($linkmod_type, $attributes);
232 232
 			} else {
233 233
 				// With no link mod type set this must be a standard <a> tag.
234 234
 				$item_output .= '<a' . $attributes . '>';
@@ -240,13 +240,13 @@  discard block
 block discarded – undo
240 240
 			 * output inside of the item before the $title (the link text).
241 241
 			 */
242 242
 			$icon_html = '';
243
-			if ( ! empty( $icon_class_string ) ) {
243
+			if ( ! empty($icon_class_string)) {
244 244
 				// append an <i> with the icon classes to what is output before links.
245
-				$icon_html = '<i class="' . esc_attr( $icon_class_string ) . '" aria-hidden="true"></i> ';
245
+				$icon_html = '<i class="' . esc_attr($icon_class_string) . '" aria-hidden="true"></i> ';
246 246
 			}
247 247
 
248 248
 			/** This filter is documented in wp-includes/post-template.php */
249
-			$title = apply_filters( 'the_title', $item->title, $item->ID );
249
+			$title = apply_filters('the_title', $item->title, $item->ID);
250 250
 
251 251
 			/**
252 252
 			 * Filters a menu item's title.
@@ -258,16 +258,16 @@  discard block
 block discarded – undo
258 258
 			 * @param stdClass $args  An object of wp_nav_menu() arguments.
259 259
 			 * @param int      $depth Depth of menu item. Used for padding.
260 260
 			 */
261
-			$title = apply_filters( 'nav_menu_item_title', $title, $item, $args, $depth );
261
+			$title = apply_filters('nav_menu_item_title', $title, $item, $args, $depth);
262 262
 
263 263
 			/**
264 264
 			 * If the .sr-only class was set apply to the nav items text only.
265 265
 			 */
266
-			if ( in_array( 'sr-only', $linkmod_classes, true ) ) {
267
-				$title         = self::wrap_for_screen_reader( $title );
268
-				$keys_to_unset = array_keys( $linkmod_classes, 'sr-only' );
269
-				foreach ( $keys_to_unset as $k ) {
270
-					unset( $linkmod_classes[ $k ] );
266
+			if (in_array('sr-only', $linkmod_classes, true)) {
267
+				$title         = self::wrap_for_screen_reader($title);
268
+				$keys_to_unset = array_keys($linkmod_classes, 'sr-only');
269
+				foreach ($keys_to_unset as $k) {
270
+					unset($linkmod_classes[$k]);
271 271
 				}
272 272
 			}
273 273
 
@@ -278,9 +278,9 @@  discard block
 block discarded – undo
278 278
 			 * This is the end of the internal nav item. We need to close the
279 279
 			 * correct element depending on the type of link or link mod.
280 280
 			 */
281
-			if ( '' !== $linkmod_type ) {
281
+			if ('' !== $linkmod_type) {
282 282
 				// is linkmod, output the required element opener.
283
-				$item_output .= self::linkmod_element_close( $linkmod_type, $attributes );
283
+				$item_output .= self::linkmod_element_close($linkmod_type, $attributes);
284 284
 			} else {
285 285
 				// With no link mod type set this must be a standard <a> tag.
286 286
 				$item_output .= '</a>';
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 			 * END appending the internal item contents to the output.
292 292
 			 */
293 293
 
294
-			$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
294
+			$output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
295 295
 
296 296
 		}
297 297
 
@@ -316,14 +316,14 @@  discard block
 block discarded – undo
316 316
 		 * @param array  $args              An array of arguments.
317 317
 		 * @param string $output            Used to append additional content (passed by reference).
318 318
 		 */
319
-		public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
320
-			if ( ! $element ) {
319
+		public function display_element($element, &$children_elements, $max_depth, $depth, $args, &$output) {
320
+			if ( ! $element) {
321 321
 				return; }
322 322
 			$id_field = $this->db_fields['id'];
323 323
 			// Display this element.
324
-			if ( is_object( $args[0] ) ) {
325
-				$args[0]->has_children = ! empty( $children_elements[ $element->$id_field ] ); }
326
-			parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
324
+			if (is_object($args[0])) {
325
+				$args[0]->has_children = ! empty($children_elements[$element->$id_field]); }
326
+			parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output);
327 327
 		}
328 328
 
329 329
 		/**
@@ -336,8 +336,8 @@  discard block
 block discarded – undo
336 336
 		 *
337 337
 		 * @param array $args passed from the wp_nav_menu function.
338 338
 		 */
339
-		public static function fallback( $args ) {
340
-			if ( current_user_can( 'edit_theme_options' ) ) {
339
+		public static function fallback($args) {
340
+			if (current_user_can('edit_theme_options')) {
341 341
 
342 342
 				/* Get Arguments. */
343 343
 				$container       = $args['container'];
@@ -349,30 +349,30 @@  discard block
 block discarded – undo
349 349
 				// initialize var to store fallback html.
350 350
 				$fallback_output = '';
351 351
 
352
-				if ( $container ) {
353
-					$fallback_output .= '<' . esc_attr( $container );
354
-					if ( $container_id ) {
355
-						$fallback_output .= ' id="' . esc_attr( $container_id ) . '"';
352
+				if ($container) {
353
+					$fallback_output .= '<' . esc_attr($container);
354
+					if ($container_id) {
355
+						$fallback_output .= ' id="' . esc_attr($container_id) . '"';
356 356
 					}
357
-					if ( $container_class ) {
358
-						$fallback_output .= ' class="' . esc_attr( $container_class ) . '"';
357
+					if ($container_class) {
358
+						$fallback_output .= ' class="' . esc_attr($container_class) . '"';
359 359
 					}
360 360
 					$fallback_output .= '>';
361 361
 				}
362 362
 				$fallback_output .= '<ul';
363
-				if ( $menu_id ) {
364
-					$fallback_output .= ' id="' . esc_attr( $menu_id ) . '"'; }
365
-				if ( $menu_class ) {
366
-					$fallback_output .= ' class="' . esc_attr( $menu_class ) . '"'; }
363
+				if ($menu_id) {
364
+					$fallback_output .= ' id="' . esc_attr($menu_id) . '"'; }
365
+				if ($menu_class) {
366
+					$fallback_output .= ' class="' . esc_attr($menu_class) . '"'; }
367 367
 				$fallback_output .= '>';
368
-				$fallback_output .= '<li><a href="' . esc_url( admin_url( 'nav-menus.php' ) ) . '" title="' . esc_attr__( 'Add a menu', 'wp-bootstrap-navwalker' ) . '">' . esc_html__( 'Add a menu', 'wp-bootstrap-navwalker' ) . '</a></li>';
368
+				$fallback_output .= '<li><a href="' . esc_url(admin_url('nav-menus.php')) . '" title="' . esc_attr__('Add a menu', 'wp-bootstrap-navwalker') . '">' . esc_html__('Add a menu', 'wp-bootstrap-navwalker') . '</a></li>';
369 369
 				$fallback_output .= '</ul>';
370
-				if ( $container ) {
371
-					$fallback_output .= '</' . esc_attr( $container ) . '>';
370
+				if ($container) {
371
+					$fallback_output .= '</' . esc_attr($container) . '>';
372 372
 				}
373 373
 
374 374
 				// if $args has 'echo' key and it's true echo, otherwise return.
375
-				if ( array_key_exists( 'echo', $args ) && $args['echo'] ) {
375
+				if (array_key_exists('echo', $args) && $args['echo']) {
376 376
 					echo $fallback_output; // WPCS: XSS OK.
377 377
 				} else {
378 378
 					return $fallback_output;
@@ -398,28 +398,28 @@  discard block
 block discarded – undo
398 398
 		 *
399 399
 		 * @return array  $classes         a maybe modified array of classnames.
400 400
 		 */
401
-		private function seporate_linkmods_and_icons_from_classes( $classes, &$linkmod_classes, &$icon_classes, $depth ) {
401
+		private function seporate_linkmods_and_icons_from_classes($classes, &$linkmod_classes, &$icon_classes, $depth) {
402 402
 			// Loop through $classes array to find linkmod or icon classes.
403
-			foreach ( $classes as $key => $class ) {
403
+			foreach ($classes as $key => $class) {
404 404
 				// If any special classes are found, store the class in it's
405 405
 				// holder array and and unset the item from $classes.
406
-				if ( preg_match( '/^disabled|^sr-only/i', $class ) ) {
406
+				if (preg_match('/^disabled|^sr-only/i', $class)) {
407 407
 					// Test for .disabled or .sr-only classes.
408 408
 					$linkmod_classes[] = $class;
409
-					unset( $classes[ $key ] );
410
-				} elseif ( preg_match( '/^dropdown-header|^dropdown-divider/i', $class ) && $depth > 0 ) {
409
+					unset($classes[$key]);
410
+				} elseif (preg_match('/^dropdown-header|^dropdown-divider/i', $class) && $depth > 0) {
411 411
 					// Test for .dropdown-header or .dropdown-divider and a
412 412
 					// depth greater than 0 - IE inside a dropdown.
413 413
 					$linkmod_classes[] = $class;
414
-					unset( $classes[ $key ] );
415
-				} elseif ( preg_match( '/^fa-(\S*)?|^fa(s|r|l|b)?(\s?)?$/i', $class ) ) {
414
+					unset($classes[$key]);
415
+				} elseif (preg_match('/^fa-(\S*)?|^fa(s|r|l|b)?(\s?)?$/i', $class)) {
416 416
 					// Font Awesome.
417 417
 					$icon_classes[] = $class;
418
-					unset( $classes[ $key ] );
419
-				} elseif ( preg_match( '/^glyphicon-(\S*)?|^glyphicon(\s?)$/i', $class ) ) {
418
+					unset($classes[$key]);
419
+				} elseif (preg_match('/^glyphicon-(\S*)?|^glyphicon(\s?)$/i', $class)) {
420 420
 					// Glyphicons.
421 421
 					$icon_classes[] = $class;
422
-					unset( $classes[ $key ] );
422
+					unset($classes[$key]);
423 423
 				}
424 424
 			}
425 425
 
@@ -436,17 +436,17 @@  discard block
 block discarded – undo
436 436
 		 *
437 437
 		 * @return string                empty for default, a linkmod type string otherwise.
438 438
 		 */
439
-		private function get_linkmod_type( $linkmod_classes = array() ) {
439
+		private function get_linkmod_type($linkmod_classes = array()) {
440 440
 			$linkmod_type = '';
441 441
 			// Loop through array of linkmod classes to handle their $atts.
442
-			if ( ! empty( $linkmod_classes ) ) {
443
-				foreach ( $linkmod_classes as $link_class ) {
444
-					if ( ! empty( $link_class ) ) {
442
+			if ( ! empty($linkmod_classes)) {
443
+				foreach ($linkmod_classes as $link_class) {
444
+					if ( ! empty($link_class)) {
445 445
 
446 446
 						// check for special class types and set a flag for them.
447
-						if ( 'dropdown-header' === $link_class ) {
447
+						if ('dropdown-header' === $link_class) {
448 448
 							$linkmod_type = 'dropdown-header';
449
-						} elseif ( 'dropdown-divider' === $link_class ) {
449
+						} elseif ('dropdown-divider' === $link_class) {
450 450
 							$linkmod_type = 'dropdown-divider';
451 451
 						}
452 452
 					}
@@ -465,24 +465,24 @@  discard block
 block discarded – undo
465 465
 		 *
466 466
 		 * @return array                 maybe updated array of attributes for item.
467 467
 		 */
468
-		private function update_atts_for_linkmod_type( $atts = array(), $linkmod_classes = array() ) {
469
-			if ( ! empty( $linkmod_classes ) ) {
470
-				foreach ( $linkmod_classes as $link_class ) {
471
-					if ( ! empty( $link_class ) ) {
468
+		private function update_atts_for_linkmod_type($atts = array(), $linkmod_classes = array()) {
469
+			if ( ! empty($linkmod_classes)) {
470
+				foreach ($linkmod_classes as $link_class) {
471
+					if ( ! empty($link_class)) {
472 472
 						// update $atts with a space and the extra classname...
473 473
 						// so long as it's not a sr-only class.
474
-						if ( 'sr-only' !== $link_class ) {
475
-							$atts['class'] .= ' ' . esc_attr( $link_class );
474
+						if ('sr-only' !== $link_class) {
475
+							$atts['class'] .= ' ' . esc_attr($link_class);
476 476
 						}
477 477
 						// check for special class types we need additional handling for.
478
-						if ( 'disabled' === $link_class ) {
478
+						if ('disabled' === $link_class) {
479 479
 							// Convert link to '#' and unset open targets.
480 480
 							$atts['href'] = '#';
481
-							unset( $atts['target'] );
482
-						} elseif ( 'dropdown-header' === $link_class || 'dropdown-divider' === $link_class ) {
481
+							unset($atts['target']);
482
+						} elseif ('dropdown-header' === $link_class || 'dropdown-divider' === $link_class) {
483 483
 							// Store a type flag and unset href and target.
484
-							unset( $atts['href'] );
485
-							unset( $atts['target'] );
484
+							unset($atts['href']);
485
+							unset($atts['target']);
486 486
 						}
487 487
 					}
488 488
 				}
@@ -498,8 +498,8 @@  discard block
 block discarded – undo
498 498
 		 * @param string $text the string of text to be wrapped in a screen reader class.
499 499
 		 * @return string      the string wrapped in a span with the class.
500 500
 		 */
501
-		private function wrap_for_screen_reader( $text = '' ) {
502
-			if ( $text ) {
501
+		private function wrap_for_screen_reader($text = '') {
502
+			if ($text) {
503 503
 				$text = '<span class="sr-only">' . $text . '</span>';
504 504
 			}
505 505
 			return $text;
@@ -515,13 +515,13 @@  discard block
 block discarded – undo
515 515
 		 *
516 516
 		 * @return string              a string with the openign tag for the element with attribibutes added.
517 517
 		 */
518
-		private function linkmod_element_open( $linkmod_type, $attributes = '' ) {
518
+		private function linkmod_element_open($linkmod_type, $attributes = '') {
519 519
 			$output = '';
520
-			if ( 'dropdown-header' === $linkmod_type ) {
520
+			if ('dropdown-header' === $linkmod_type) {
521 521
 				// For a header use a span with the .h6 class instead of a real
522 522
 				// header tag so that it doesn't confuse screen readers.
523 523
 				$output .= '<span class="dropdown-header h6"' . $attributes . '>';
524
-			} elseif ( 'dropdown-divider' === $linkmod_type ) {
524
+			} elseif ('dropdown-divider' === $linkmod_type) {
525 525
 				// this is a divider.
526 526
 				$output .= '<div class="dropdown-divider"' . $attributes . '>';
527 527
 			}
@@ -537,13 +537,13 @@  discard block
 block discarded – undo
537 537
 		 *
538 538
 		 * @return string              a string with the closing tag for this linkmod type.
539 539
 		 */
540
-		private function linkmod_element_close( $linkmod_type ) {
540
+		private function linkmod_element_close($linkmod_type) {
541 541
 			$output = '';
542
-			if ( 'dropdown-header' === $linkmod_type ) {
542
+			if ('dropdown-header' === $linkmod_type) {
543 543
 				// For a header use a span with the .h6 class instead of a real
544 544
 				// header tag so that it doesn't confuse screen readers.
545 545
 				$output .= '</span>';
546
-			} elseif ( 'dropdown-divider' === $linkmod_type ) {
546
+			} elseif ('dropdown-divider' === $linkmod_type) {
547 547
 				// this is a divider.
548 548
 				$output .= '</div>';
549 549
 			}
Please login to merge, or discard this patch.