Passed
Push — master ( 99a1a4...828f73 )
by Warwick
03:18
created
includes/classes/class-lsx-bootstrap-navwalker.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@  discard block
 block discarded – undo
7 7
  * @category   bootstrap-navigation-walker
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if ( ! defined('ABSPATH')) {
11 11
 	exit;
12 12
 }
13 13
 
14
-if ( ! class_exists( 'Walker_Nav_Menu' ) ) {
14
+if ( ! class_exists('Walker_Nav_Menu')) {
15 15
 	return;
16 16
 }
17 17
 
18
-if ( ! class_exists( 'LSX_Bootstrap_Navwalker' ) ) :
18
+if ( ! class_exists('LSX_Bootstrap_Navwalker')) :
19 19
 
20 20
 	/**
21 21
 	 * Cleaner Bootstrap walker
@@ -33,15 +33,15 @@  discard block
 block discarded – undo
33 33
 		 * @param string $output Passed by reference. Used to append additional content.
34 34
 		 * @param int $depth Depth of page. Used for padding.
35 35
 		 */
36
-		public function start_lvl( &$output, $depth = 0, $args = array() ) {
37
-			$indent = str_repeat( "\t", $depth );
36
+		public function start_lvl(&$output, $depth = 0, $args = array()) {
37
+			$indent = str_repeat("\t", $depth);
38 38
 			$output .= "\n$indent<ul role=\"menu\" class=\" dropdown-menu\">\n";
39 39
 		}
40 40
 
41 41
 		/**
42 42
 		 * @param string $item Passed by reference. Used to append additional content.
43 43
 		 */
44
-		public function filter_default_pages( &$item ) {
44
+		public function filter_default_pages(&$item) {
45 45
 			return $item;
46 46
 		}
47 47
 
@@ -55,14 +55,14 @@  discard block
 block discarded – undo
55 55
 		 * @param int $current_page Menu item ID.
56 56
 		 * @param object $args
57 57
 		 */
58
-		public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
59
-			$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
58
+		public function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) {
59
+			$indent = ($depth) ? str_repeat("\t", $depth) : '';
60 60
 
61 61
 			/**
62 62
 			 * If this is a default menu being called we need to fix
63 63
 			 * the item object thats coming through.
64 64
 			 */
65
-			if ( ! isset( $item->title ) ) {
65
+			if ( ! isset($item->title)) {
66 66
 				return;
67 67
 			}
68 68
 
@@ -74,63 +74,63 @@  discard block
 block discarded – undo
74 74
 			 * comparison that is not case sensitive. The strcasecmp() function returns
75 75
 			 * a 0 if the strings are equal.
76 76
 			 */
77
-			if ( 0 == strcasecmp( $item->attr_title, 'divider' ) && 1 === $depth ) {
77
+			if (0 == strcasecmp($item->attr_title, 'divider') && 1 === $depth) {
78 78
 				$output .= $indent . '<li role="presentation" class="divider">';
79
-			} elseif ( 0 == strcasecmp( $item->title, 'divider' ) && 1 === $depth ) {
79
+			} elseif (0 == strcasecmp($item->title, 'divider') && 1 === $depth) {
80 80
 				$output .= $indent . '<li role="presentation" class="divider">';
81
-			} elseif ( 0 == strcasecmp( $item->attr_title, 'dropdown-header' ) && 1 === $depth ) {
82
-				$output .= $indent . '<li role="presentation" class="dropdown-header">' . esc_attr( $item->title );
83
-			} elseif ( 0 == strcasecmp( $item->attr_title, 'disabled' ) ) {
84
-				$output .= $indent . '<li role="presentation" class="disabled"><a href="#">' . esc_attr( $item->title ) . '</a>';
81
+			} elseif (0 == strcasecmp($item->attr_title, 'dropdown-header') && 1 === $depth) {
82
+				$output .= $indent . '<li role="presentation" class="dropdown-header">' . esc_attr($item->title);
83
+			} elseif (0 == strcasecmp($item->attr_title, 'disabled')) {
84
+				$output .= $indent . '<li role="presentation" class="disabled"><a href="#">' . esc_attr($item->title) . '</a>';
85 85
 			} else {
86 86
 				$class_names = '';
87 87
 				$value       = '';
88 88
 
89
-				$classes = empty( $item->classes ) ? array() : (array) $item->classes;
89
+				$classes = empty($item->classes) ? array() : (array) $item->classes;
90 90
 				$classes[] = 'menu-item-' . $item->ID;
91 91
 
92
-				$classes = apply_filters( 'lsx_nav_menu_css_class', array_filter( $classes ), $item, $args , $depth );
92
+				$classes = apply_filters('lsx_nav_menu_css_class', array_filter($classes), $item, $args, $depth);
93 93
 
94
-				$class_names = join( ' ', $classes );
94
+				$class_names = join(' ', $classes);
95 95
 
96
-				if ( $args->has_children )
96
+				if ($args->has_children)
97 97
 					$class_names .= ' dropdown';
98 98
 
99
-				if ( in_array( 'current-menu-item', $classes ) )
99
+				if (in_array('current-menu-item', $classes))
100 100
 					$class_names .= ' active';
101 101
 
102
-				if ( in_array( 'current-menu-parent', $classes ) )
102
+				if (in_array('current-menu-parent', $classes))
103 103
 					$class_names .= ' active';
104 104
 
105 105
 				//Check if this is ment to be a "social" type menu
106
-				$class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
106
+				$class_names = $class_names ? ' class="' . esc_attr($class_names) . '"' : '';
107 107
 
108
-				$id = apply_filters( 'nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args );
109
-				$id = $id ? ' id="' . esc_attr( $id ) . '"' : '';
108
+				$id = apply_filters('nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args);
109
+				$id = $id ? ' id="' . esc_attr($id) . '"' : '';
110 110
 
111 111
 				$output .= $indent . '<li' . $id . $value . $class_names . '>';
112 112
 
113 113
 				$atts = array();
114
-				$atts['title']  = ! empty( $item->attr_title ) ? $item->attr_title : $item->title;
115
-				$atts['target'] = ! empty( $item->target ) ? $item->target : '';
116
-				$atts['rel']    = ! empty( $item->xfn ) ? $item->xfn : '';
114
+				$atts['title']  = ! empty($item->attr_title) ? $item->attr_title : $item->title;
115
+				$atts['target'] = ! empty($item->target) ? $item->target : '';
116
+				$atts['rel']    = ! empty($item->xfn) ? $item->xfn : '';
117 117
 
118 118
 				// If item has_children add atts to a.
119
-				if ( $args->has_children ) {
120
-					$atts['href']          = ! empty( $item->url ) ? $item->url : '';
119
+				if ($args->has_children) {
120
+					$atts['href']          = ! empty($item->url) ? $item->url : '';
121 121
 					$atts['data-toggle']   = 'dropdown';
122 122
 					$atts['class']         = 'dropdown-toggle';
123 123
 					$atts['aria-haspopup'] = 'true';
124 124
 				} else {
125
-					$atts['href'] = ! empty( $item->url ) ? $item->url : '';
125
+					$atts['href'] = ! empty($item->url) ? $item->url : '';
126 126
 				}
127 127
 
128
-				$atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args );
128
+				$atts = apply_filters('nav_menu_link_attributes', $atts, $item, $args);
129 129
 
130 130
 				$attributes = '';
131
-				foreach ( $atts as $attr => $value ) {
132
-					if ( ! empty( $value ) ) {
133
-						$value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
131
+				foreach ($atts as $attr => $value) {
132
+					if ( ! empty($value)) {
133
+						$value = ('href' === $attr) ? esc_url($value) : esc_attr($value);
134 134
 						$attributes .= ' ' . $attr . '="' . $value . '"';
135 135
 					}
136 136
 				}
@@ -138,11 +138,11 @@  discard block
 block discarded – undo
138 138
 				$item_output = $args->before;
139 139
 
140 140
 				$item_output .= '<a' . $attributes . '>';
141
-				$item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
142
-				$item_output .= ( $args->has_children && 0 === $depth ) ? ' <span class="caret"></span></a>' : '</a>';
141
+				$item_output .= $args->link_before . apply_filters('the_title', $item->title, $item->ID) . $args->link_after;
142
+				$item_output .= ($args->has_children && 0 === $depth) ? ' <span class="caret"></span></a>' : '</a>';
143 143
 				$item_output .= $args->after;
144 144
 
145
-				$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
145
+				$output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
146 146
 			}
147 147
 		}
148 148
 
@@ -166,18 +166,18 @@  discard block
 block discarded – undo
166 166
 		 * @param string $output Passed by reference. Used to append additional content.
167 167
 		 * @return null Null on failure with no changes to parameters.
168 168
 		 */
169
-		public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
170
-			if ( ! $element ) {
169
+		public function display_element($element, &$children_elements, $max_depth, $depth, $args, &$output) {
170
+			if ( ! $element) {
171 171
 				return;
172 172
 			}
173 173
 
174 174
 			$id_field = $this->db_fields['id'];
175 175
 
176
-			if ( is_object( $args[0] ) ) {
177
-				$args[0]->has_children = ! empty( $children_elements[ $element->$id_field ] );
176
+			if (is_object($args[0])) {
177
+				$args[0]->has_children = ! empty($children_elements[$element->$id_field]);
178 178
 			}
179 179
 
180
-			parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
180
+			parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output);
181 181
 		}
182 182
 
183 183
 		/**
@@ -191,18 +191,18 @@  discard block
 block discarded – undo
191 191
 		 * @param array $args passed from the wp_nav_menu function.
192 192
 		 *
193 193
 		 */
194
-		public static function fallback( $args ) {
195
-			if ( current_user_can( 'manage_options' ) ) {
194
+		public static function fallback($args) {
195
+			if (current_user_can('manage_options')) {
196 196
 				$fb_output = null;
197 197
 
198
-				if ( $args['container'] ) {
198
+				if ($args['container']) {
199 199
 					$fb_output = '<' . $args['container'];
200 200
 
201
-					if ( $args['container_id'] ) {
201
+					if ($args['container_id']) {
202 202
 						$fb_output .= ' id="' . $args['container_id'] . '"';
203 203
 					}
204 204
 
205
-					if ( $args['container_class'] ) {
205
+					if ($args['container_class']) {
206 206
 						$fb_output .= ' class="' . $args['container_class'] . '"';
207 207
 					}
208 208
 
@@ -211,23 +211,23 @@  discard block
 block discarded – undo
211 211
 
212 212
 				$fb_output .= '<ul';
213 213
 
214
-				if ( $args['menu_id'] ) {
214
+				if ($args['menu_id']) {
215 215
 					$fb_output .= ' id="' . $args['menu_id'] . '"';
216 216
 				}
217 217
 
218
-				if ( $args['menu_class'] ) {
218
+				if ($args['menu_class']) {
219 219
 					$fb_output .= ' class="' . $args['menu_class'] . '"';
220 220
 				}
221 221
 
222 222
 				$fb_output .= '>';
223
-				$fb_output .= '<li><a href="' . esc_url( admin_url( 'nav-menus.php' ) ) . '">' . esc_html__( 'Add a menu', 'lsx' ) . '</a></li>';
223
+				$fb_output .= '<li><a href="' . esc_url(admin_url('nav-menus.php')) . '">' . esc_html__('Add a menu', 'lsx') . '</a></li>';
224 224
 				$fb_output .= '</ul>';
225 225
 
226
-				if ( $args['container'] ) {
226
+				if ($args['container']) {
227 227
 					$fb_output .= '</' . $args['container'] . '>';
228 228
 				}
229 229
 
230
-				echo wp_kses_post( $fb_output );
230
+				echo wp_kses_post($fb_output);
231 231
 			}
232 232
 		}
233 233
 
Please login to merge, or discard this patch.