@@ -65,13 +65,13 @@ |
||
65 | 65 | $args->top_level_follow = isset($args->top_level_follow) ? $args->top_level_follow : false; |
66 | 66 | |
67 | 67 | /** |
68 | - * Dividers, Headers or Disabled |
|
69 | - * ============================= |
|
70 | - * Determine whether the item is a Divider, Header, Disabled or regular |
|
71 | - * menu item. To prevent errors we use the strcasecmp() function to so a |
|
72 | - * comparison that is not case sensitive. The strcasecmp() function returns |
|
73 | - * a 0 if the strings are equal. |
|
74 | - */ |
|
68 | + * Dividers, Headers or Disabled |
|
69 | + * ============================= |
|
70 | + * Determine whether the item is a Divider, Header, Disabled or regular |
|
71 | + * menu item. To prevent errors we use the strcasecmp() function to so a |
|
72 | + * comparison that is not case sensitive. The strcasecmp() function returns |
|
73 | + * a 0 if the strings are equal. |
|
74 | + */ |
|
75 | 75 | if ( 0 === strcasecmp( $item->attr_title, 'divider' ) && 1 === $depth ) { |
76 | 76 | $output .= $indent . '<li role="presentation" class="divider">'; |
77 | 77 | } elseif ( 0 === strcasecmp( $item->title, 'divider' ) && 1 === $depth ) { |
@@ -20,7 +20,7 @@ discard block |
||
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 | * |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | * @param array $args (default: array()) Arguments. |
41 | 41 | * @return void |
42 | 42 | */ |
43 | - public function start_lvl( &$output, $depth = 0, $args = array() ) { |
|
44 | - $indent = str_repeat( "\t", $depth ); |
|
43 | + public function start_lvl(&$output, $depth = 0, $args = array()) { |
|
44 | + $indent = str_repeat("\t", $depth); |
|
45 | 45 | $output .= "\n$indent<ul role=\"menu\" class=\" dropdown-menu\" >\n"; |
46 | 46 | } |
47 | 47 | |
@@ -59,8 +59,8 @@ discard block |
||
59 | 59 | * @param int $id (default: 0) Menu item ID. |
60 | 60 | * @return void |
61 | 61 | */ |
62 | - public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { |
|
63 | - $indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; |
|
62 | + public function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { |
|
63 | + $indent = ($depth) ? str_repeat("\t", $depth) : ''; |
|
64 | 64 | |
65 | 65 | $args->top_level_follow = isset($args->top_level_follow) ? $args->top_level_follow : false; |
66 | 66 | |
@@ -72,51 +72,51 @@ discard block |
||
72 | 72 | * comparison that is not case sensitive. The strcasecmp() function returns |
73 | 73 | * a 0 if the strings are equal. |
74 | 74 | */ |
75 | - if ( 0 === strcasecmp( $item->attr_title, 'divider' ) && 1 === $depth ) { |
|
75 | + if (0 === strcasecmp($item->attr_title, 'divider') && 1 === $depth) { |
|
76 | 76 | $output .= $indent . '<li role="presentation" class="divider">'; |
77 | - } elseif ( 0 === strcasecmp( $item->title, 'divider' ) && 1 === $depth ) { |
|
77 | + } elseif (0 === strcasecmp($item->title, 'divider') && 1 === $depth) { |
|
78 | 78 | $output .= $indent . '<li role="presentation" class="divider">'; |
79 | - } elseif ( 0 === strcasecmp( $item->attr_title, 'dropdown-header' ) && 1 === $depth ) { |
|
80 | - $output .= $indent . '<li role="presentation" class="dropdown-header">' . esc_attr( $item->title ); |
|
81 | - } elseif ( 0 === strcasecmp( $item->attr_title, 'disabled' ) ) { |
|
82 | - $output .= $indent . '<li role="presentation" class="disabled"><a href="#">' . esc_attr( $item->title ) . '</a>'; |
|
79 | + } elseif (0 === strcasecmp($item->attr_title, 'dropdown-header') && 1 === $depth) { |
|
80 | + $output .= $indent . '<li role="presentation" class="dropdown-header">' . esc_attr($item->title); |
|
81 | + } elseif (0 === strcasecmp($item->attr_title, 'disabled')) { |
|
82 | + $output .= $indent . '<li role="presentation" class="disabled"><a href="#">' . esc_attr($item->title) . '</a>'; |
|
83 | 83 | } else { |
84 | 84 | $class_names = $value = ''; |
85 | - $classes = empty( $item->classes ) ? array() : (array) $item->classes; |
|
85 | + $classes = empty($item->classes) ? array() : (array) $item->classes; |
|
86 | 86 | $classes[] = 'menu-item-' . $item->ID; |
87 | - $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) ); |
|
88 | - if ( $args->has_children ) { |
|
87 | + $class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item, $args)); |
|
88 | + if ($args->has_children) { |
|
89 | 89 | $class_names .= ' dropdown'; } |
90 | - if ( in_array( 'current-menu-item', $classes, true ) ) { |
|
90 | + if (in_array('current-menu-item', $classes, true)) { |
|
91 | 91 | $class_names .= ' active'; } |
92 | - $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : ''; |
|
93 | - $id = apply_filters( 'nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args ); |
|
94 | - $id = $id ? ' id="' . esc_attr( $id ) . '"' : ''; |
|
92 | + $class_names = $class_names ? ' class="' . esc_attr($class_names) . '"' : ''; |
|
93 | + $id = apply_filters('nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args); |
|
94 | + $id = $id ? ' id="' . esc_attr($id) . '"' : ''; |
|
95 | 95 | $output .= $indent . '<li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement"' . $id . $value . $class_names . '>'; |
96 | 96 | $atts = array(); |
97 | 97 | |
98 | - if ( empty( $item->attr_title ) ) { |
|
99 | - $atts['title'] = ! empty( $item->title ) ? strip_tags( $item->title ) : ''; |
|
98 | + if (empty($item->attr_title)) { |
|
99 | + $atts['title'] = ! empty($item->title) ? strip_tags($item->title) : ''; |
|
100 | 100 | } else { |
101 | 101 | $atts['title'] = $item->attr_title; |
102 | 102 | } |
103 | 103 | |
104 | - $atts['target'] = ! empty( $item->target ) ? $item->target : ''; |
|
105 | - $atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : ''; |
|
104 | + $atts['target'] = ! empty($item->target) ? $item->target : ''; |
|
105 | + $atts['rel'] = ! empty($item->xfn) ? $item->xfn : ''; |
|
106 | 106 | // If item has_children add atts to a. |
107 | - if ( $args->has_children && $depth === 0 && !$args->top_level_follow ) { |
|
108 | - $atts['href'] = '#'; |
|
109 | - $atts['data-toggle'] = 'dropdown'; |
|
110 | - $atts['class'] = 'dropdown-toggle'; |
|
111 | - $atts['aria-haspopup'] = 'true'; |
|
107 | + if ($args->has_children && $depth === 0 && ! $args->top_level_follow) { |
|
108 | + $atts['href'] = '#'; |
|
109 | + $atts['data-toggle'] = 'dropdown'; |
|
110 | + $atts['class'] = 'dropdown-toggle'; |
|
111 | + $atts['aria-haspopup'] = 'true'; |
|
112 | 112 | } else { |
113 | - $atts['href'] = ! empty( $item->url ) ? $item->url : ''; |
|
113 | + $atts['href'] = ! empty($item->url) ? $item->url : ''; |
|
114 | 114 | } |
115 | - $atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args ); |
|
115 | + $atts = apply_filters('nav_menu_link_attributes', $atts, $item, $args); |
|
116 | 116 | $attributes = ''; |
117 | - foreach ( $atts as $attr => $value ) { |
|
118 | - if ( ! empty( $value ) ) { |
|
119 | - $value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value ); |
|
117 | + foreach ($atts as $attr => $value) { |
|
118 | + if ( ! empty($value)) { |
|
119 | + $value = ('href' === $attr) ? esc_url($value) : esc_attr($value); |
|
120 | 120 | $attributes .= ' ' . $attr . '="' . $value . '"'; |
121 | 121 | } |
122 | 122 | } |
@@ -129,20 +129,20 @@ discard block |
||
129 | 129 | * if there is a value in the attr_title property. If the attr_title |
130 | 130 | * property is NOT null we apply it as the class name for the glyphicon. |
131 | 131 | */ |
132 | - if ( ! empty( $item->attr_title ) ) : |
|
133 | - $pos = strpos( esc_attr( $item->attr_title ), 'glyphicon' ); |
|
134 | - if ( false !== $pos ) : |
|
135 | - $item_output .= '<a' . $attributes . '><span class="glyphicon ' . esc_attr( $item->attr_title ) . '" aria-hidden="true"></span> '; |
|
132 | + if ( ! empty($item->attr_title)) : |
|
133 | + $pos = strpos(esc_attr($item->attr_title), 'glyphicon'); |
|
134 | + if (false !== $pos) : |
|
135 | + $item_output .= '<a' . $attributes . '><span class="glyphicon ' . esc_attr($item->attr_title) . '" aria-hidden="true"></span> '; |
|
136 | 136 | else : |
137 | - $item_output .= '<a' . $attributes . '><i class="fa ' . esc_attr( $item->attr_title ) . '" aria-hidden="true"></i> '; |
|
137 | + $item_output .= '<a' . $attributes . '><i class="fa ' . esc_attr($item->attr_title) . '" aria-hidden="true"></i> '; |
|
138 | 138 | endif; |
139 | 139 | else : |
140 | 140 | $item_output .= '<a' . $attributes . '>'; |
141 | 141 | endif; |
142 | - $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after; |
|
143 | - $item_output .= ( $args->has_children && 0 === $depth ) ? ' <span class="caret"></span></a>' : '</a>'; |
|
142 | + $item_output .= $args->link_before . apply_filters('the_title', $item->title, $item->ID) . $args->link_after; |
|
143 | + $item_output .= ($args->has_children && 0 === $depth) ? ' <span class="caret"></span></a>' : '</a>'; |
|
144 | 144 | $item_output .= $args->after; |
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 | |
@@ -167,14 +167,14 @@ discard block |
||
167 | 167 | * @param mixed $output Passed by reference. Used to append additional content. |
168 | 168 | * @return null Null on failure with no changes to parameters. |
169 | 169 | */ |
170 | - public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) { |
|
171 | - if ( ! $element ) { |
|
170 | + public function display_element($element, &$children_elements, $max_depth, $depth, $args, &$output) { |
|
171 | + if ( ! $element) { |
|
172 | 172 | return; } |
173 | 173 | $id_field = $this->db_fields['id']; |
174 | 174 | // Display this element. |
175 | - if ( is_object( $args[0] ) ) { |
|
176 | - $args[0]->has_children = ! empty( $children_elements[ $element->$id_field ] ); } |
|
177 | - parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output ); |
|
175 | + if (is_object($args[0])) { |
|
176 | + $args[0]->has_children = ! empty($children_elements[$element->$id_field]); } |
|
177 | + parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | /** |
@@ -187,8 +187,8 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @param array $args passed from the wp_nav_menu function. |
189 | 189 | */ |
190 | - public static function fallback( $args ) { |
|
191 | - if ( current_user_can( 'edit_theme_options' ) ) { |
|
190 | + public static function fallback($args) { |
|
191 | + if (current_user_can('edit_theme_options')) { |
|
192 | 192 | |
193 | 193 | /* Get Arguments. */ |
194 | 194 | $container = $args['container']; |
@@ -197,25 +197,25 @@ discard block |
||
197 | 197 | $menu_class = $args['menu_class']; |
198 | 198 | $menu_id = $args['menu_id']; |
199 | 199 | |
200 | - if ( $container ) { |
|
201 | - echo '<' . esc_attr( $container ); |
|
202 | - if ( $container_id ) { |
|
203 | - echo ' id="' . esc_attr( $container_id ) . '"'; |
|
200 | + if ($container) { |
|
201 | + echo '<' . esc_attr($container); |
|
202 | + if ($container_id) { |
|
203 | + echo ' id="' . esc_attr($container_id) . '"'; |
|
204 | 204 | } |
205 | - if ( $container_class ) { |
|
206 | - echo ' class="' . sanitize_html_class( $container_class ) . '"'; } |
|
205 | + if ($container_class) { |
|
206 | + echo ' class="' . sanitize_html_class($container_class) . '"'; } |
|
207 | 207 | echo '>'; |
208 | 208 | } |
209 | 209 | echo '<ul'; |
210 | - if ( $menu_id ) { |
|
211 | - echo ' id="' . esc_attr( $menu_id ) . '"'; } |
|
212 | - if ( $menu_class ) { |
|
213 | - echo ' class="' . esc_attr( $menu_class ) . '"'; } |
|
210 | + if ($menu_id) { |
|
211 | + echo ' id="' . esc_attr($menu_id) . '"'; } |
|
212 | + if ($menu_class) { |
|
213 | + echo ' class="' . esc_attr($menu_class) . '"'; } |
|
214 | 214 | echo '>'; |
215 | - echo '<li><a href="' . esc_url( admin_url( 'nav-menus.php' ) ) . '" title="">' . esc_attr( 'Add a menu', '' ) . '</a></li>'; |
|
215 | + echo '<li><a href="' . esc_url(admin_url('nav-menus.php')) . '" title="">' . esc_attr('Add a menu', '') . '</a></li>'; |
|
216 | 216 | echo '</ul>'; |
217 | - if ( $container ) { |
|
218 | - echo '</' . esc_attr( $container ) . '>'; } |
|
217 | + if ($container) { |
|
218 | + echo '</' . esc_attr($container) . '>'; } |
|
219 | 219 | } |
220 | 220 | } |
221 | 221 | } |