@@ -1,5 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) return; // Exit if accessed directly |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | + return; |
|
4 | +} |
|
5 | +// Exit if accessed directly |
|
3 | 6 | |
4 | 7 | class Lsx_Bootstrap_Navwalker extends Walker_Nav_Menu { |
5 | 8 | |
@@ -71,14 +74,17 @@ discard block |
||
71 | 74 | |
72 | 75 | $class_names = join( ' ', $classes ); |
73 | 76 | |
74 | - if ( $args->has_children ) |
|
75 | - $class_names .= ' dropdown'; |
|
77 | + if ( $args->has_children ) { |
|
78 | + $class_names .= ' dropdown'; |
|
79 | + } |
|
76 | 80 | |
77 | - if ( in_array( 'current-menu-item', $classes ) ) |
|
78 | - $class_names .= ' active'; |
|
81 | + if ( in_array( 'current-menu-item', $classes ) ) { |
|
82 | + $class_names .= ' active'; |
|
83 | + } |
|
79 | 84 | |
80 | - if ( in_array( 'current-menu-parent', $classes ) ) |
|
81 | - $class_names .= ' active'; |
|
85 | + if ( in_array( 'current-menu-parent', $classes ) ) { |
|
86 | + $class_names .= ' active'; |
|
87 | + } |
|
82 | 88 | |
83 | 89 | //Check if this is ment to be a "social" type menu |
84 | 90 | $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : ''; |
@@ -159,14 +165,16 @@ discard block |
||
159 | 165 | * @return null Null on failure with no changes to parameters. |
160 | 166 | */ |
161 | 167 | public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) { |
162 | - if ( ! $element ) |
|
163 | - return; |
|
168 | + if ( ! $element ) { |
|
169 | + return; |
|
170 | + } |
|
164 | 171 | |
165 | 172 | $id_field = $this->db_fields['id']; |
166 | 173 | |
167 | 174 | // Display this element. |
168 | - if ( is_object( $args[0] ) ) |
|
169 | - $args[0]->has_children = ! empty( $children_elements[ $element->$id_field ] ); |
|
175 | + if ( is_object( $args[0] ) ) { |
|
176 | + $args[0]->has_children = ! empty( $children_elements[ $element->$id_field ] ); |
|
177 | + } |
|
170 | 178 | |
171 | 179 | parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output ); |
172 | 180 | } |
@@ -189,29 +197,34 @@ discard block |
||
189 | 197 | if ( $args['container'] ) { |
190 | 198 | $fb_output = '<' . $args['container']; |
191 | 199 | |
192 | - if ( $args['container_id'] ) |
|
193 | - $fb_output .= ' id="' . $args['container_id'] . '"'; |
|
200 | + if ( $args['container_id'] ) { |
|
201 | + $fb_output .= ' id="' . $args['container_id'] . '"'; |
|
202 | + } |
|
194 | 203 | |
195 | - if ( $args['container_class'] ) |
|
196 | - $fb_output .= ' class="' . $args['container_class'] . '"'; |
|
204 | + if ( $args['container_class'] ) { |
|
205 | + $fb_output .= ' class="' . $args['container_class'] . '"'; |
|
206 | + } |
|
197 | 207 | |
198 | 208 | $fb_output .= '>'; |
199 | 209 | } |
200 | 210 | |
201 | 211 | $fb_output .= '<ul'; |
202 | 212 | |
203 | - if ( $args['menu_id'] ) |
|
204 | - $fb_output .= ' id="' . $args['menu_id'] . '"'; |
|
213 | + if ( $args['menu_id'] ) { |
|
214 | + $fb_output .= ' id="' . $args['menu_id'] . '"'; |
|
215 | + } |
|
205 | 216 | |
206 | - if ( $args['menu_class'] ) |
|
207 | - $fb_output .= ' class="' . $args['menu_class'] . '"'; |
|
217 | + if ( $args['menu_class'] ) { |
|
218 | + $fb_output .= ' class="' . $args['menu_class'] . '"'; |
|
219 | + } |
|
208 | 220 | |
209 | 221 | $fb_output .= '>'; |
210 | 222 | $fb_output .= '<li><a href="' . admin_url( 'nav-menus.php' ) . '">' . esc_html__( 'Add a menu', 'lsx' ) . '</a></li>'; |
211 | 223 | $fb_output .= '</ul>'; |
212 | 224 | |
213 | - if ( $args['container'] ) |
|
214 | - $fb_output .= '</' . $args['container'] . '>'; |
|
225 | + if ( $args['container'] ) { |
|
226 | + $fb_output .= '</' . $args['container'] . '>'; |
|
227 | + } |
|
215 | 228 | |
216 | 229 | echo wp_kses_post( $fb_output ); |
217 | 230 | } |