@@ -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 | /** |
66 | 66 | * Dividers, Headers or Disabled |
@@ -70,59 +70,59 @@ discard block |
||
70 | 70 | * comparison that is not case sensitive. The strcasecmp() function returns |
71 | 71 | * a 0 if the strings are equal. |
72 | 72 | */ |
73 | - if ( 0 === strcasecmp( $item->attr_title, 'divider' ) && 1 === $depth ) { |
|
73 | + if (0 === strcasecmp($item->attr_title, 'divider') && 1 === $depth) { |
|
74 | 74 | $output .= $indent . '<li role="presentation" class="divider">'; |
75 | - } elseif ( 0 === strcasecmp( $item->title, 'divider' ) && 1 === $depth ) { |
|
75 | + } elseif (0 === strcasecmp($item->title, 'divider') && 1 === $depth) { |
|
76 | 76 | $output .= $indent . '<li role="presentation" class="divider">'; |
77 | - } elseif ( 0 === strcasecmp( $item->attr_title, 'dropdown-header' ) && 1 === $depth ) { |
|
78 | - $output .= $indent . '<li role="presentation" class="dropdown-header">' . esc_attr( $item->title ); |
|
79 | - } elseif ( 0 === strcasecmp( $item->attr_title, 'disabled' ) ) { |
|
80 | - $output .= $indent . '<li role="presentation" class="disabled"><a href="#">' . esc_attr( $item->title ) . '</a>'; |
|
77 | + } elseif (0 === strcasecmp($item->attr_title, 'dropdown-header') && 1 === $depth) { |
|
78 | + $output .= $indent . '<li role="presentation" class="dropdown-header">' . esc_attr($item->title); |
|
79 | + } elseif (0 === strcasecmp($item->attr_title, 'disabled')) { |
|
80 | + $output .= $indent . '<li role="presentation" class="disabled"><a href="#">' . esc_attr($item->title) . '</a>'; |
|
81 | 81 | } else { |
82 | 82 | $value = ''; |
83 | 83 | $class_names = $value; |
84 | - $classes = empty( $item->classes ) ? array() : (array) $item->classes; |
|
84 | + $classes = empty($item->classes) ? array() : (array) $item->classes; |
|
85 | 85 | $classes[] = 'menu-item-' . $item->ID; |
86 | - $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args, $depth ) ); |
|
87 | - if ( $args->has_children ) { |
|
86 | + $class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item, $args, $depth)); |
|
87 | + if ($args->has_children) { |
|
88 | 88 | $class_names .= ' dropdown'; |
89 | 89 | } |
90 | - if ( in_array( 'current-menu-item', $classes, true ) ) { |
|
90 | + if (in_array('current-menu-item', $classes, true)) { |
|
91 | 91 | $class_names .= ' active'; |
92 | 92 | } |
93 | - $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : ''; |
|
94 | - $id = apply_filters( 'nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args ); |
|
95 | - $id = $id ? ' id="' . esc_attr( $id ) . '"' : ''; |
|
93 | + $class_names = $class_names ? ' class="' . esc_attr($class_names) . '"' : ''; |
|
94 | + $id = apply_filters('nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args); |
|
95 | + $id = $id ? ' id="' . esc_attr($id) . '"' : ''; |
|
96 | 96 | $output .= $indent . '<li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement"' . $id . $value . $class_names . '>'; |
97 | 97 | $atts = array(); |
98 | 98 | |
99 | - if ( empty( $item->attr_title ) ) { |
|
100 | - $atts['title'] = ! empty( $item->title ) ? strip_tags( $item->title ) : ''; |
|
99 | + if (empty($item->attr_title)) { |
|
100 | + $atts['title'] = ! empty($item->title) ? strip_tags($item->title) : ''; |
|
101 | 101 | } else { |
102 | 102 | $atts['title'] = $item->attr_title; |
103 | 103 | } |
104 | 104 | |
105 | - $atts['target'] = ! empty( $item->target ) ? $item->target : ''; |
|
106 | - $atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : ''; |
|
105 | + $atts['target'] = ! empty($item->target) ? $item->target : ''; |
|
106 | + $atts['rel'] = ! empty($item->xfn) ? $item->xfn : ''; |
|
107 | 107 | // If item has_children add atts to a. |
108 | - if ( $args->has_children && 0 === $depth ) { |
|
108 | + if ($args->has_children && 0 === $depth) { |
|
109 | 109 | $atts['href'] = '#'; |
110 | 110 | $atts['data-toggle'] = 'dropdown'; |
111 | 111 | $atts['class'] = 'dropdown-toggle'; |
112 | 112 | $atts['aria-haspopup'] = 'true'; |
113 | 113 | } else { |
114 | - $atts['href'] = ! empty( $item->url ) ? $item->url : ''; |
|
114 | + $atts['href'] = ! empty($item->url) ? $item->url : ''; |
|
115 | 115 | } |
116 | - $atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args ); |
|
116 | + $atts = apply_filters('nav_menu_link_attributes', $atts, $item, $args); |
|
117 | 117 | $icon_attributes = ''; |
118 | 118 | $attributes = ''; |
119 | - foreach ( $atts as $attr => $value ) { |
|
120 | - if ( ! empty( $value ) ) { |
|
121 | - $value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value ); |
|
119 | + foreach ($atts as $attr => $value) { |
|
120 | + if ( ! empty($value)) { |
|
121 | + $value = ('href' === $attr) ? esc_url($value) : esc_attr($value); |
|
122 | 122 | $attributes .= ' ' . $attr . '="' . $value . '"'; |
123 | 123 | // if item has icon, we want all except title attributes because we |
124 | 124 | // want to avoid link title to be icon class |
125 | - if ( 'title' != $attr ) { |
|
125 | + if ('title' != $attr) { |
|
126 | 126 | $icon_attributes .= ' ' . $attr . '="' . $value . '"'; |
127 | 127 | } |
128 | 128 | } |
@@ -136,20 +136,20 @@ discard block |
||
136 | 136 | * if there is a value in the attr_title property. If the attr_title |
137 | 137 | * property is NOT null we apply it as the class name for the glyphicon. |
138 | 138 | */ |
139 | - if ( ! empty( $item->attr_title ) ) { |
|
140 | - $pos = strpos( esc_attr( $item->attr_title ), 'glyphicon' ); |
|
141 | - if ( false !== $pos ) { |
|
142 | - $item_output .= '<a' . $icon_attributes . ' title="' . esc_attr( $item->title ) . '"><span class="glyphicon ' . esc_attr( $item->attr_title ) . '" aria-hidden="true"></span> '; |
|
139 | + if ( ! empty($item->attr_title)) { |
|
140 | + $pos = strpos(esc_attr($item->attr_title), 'glyphicon'); |
|
141 | + if (false !== $pos) { |
|
142 | + $item_output .= '<a' . $icon_attributes . ' title="' . esc_attr($item->title) . '"><span class="glyphicon ' . esc_attr($item->attr_title) . '" aria-hidden="true"></span> '; |
|
143 | 143 | } else { |
144 | - $item_output .= '<a' . $icon_attributes . ' title="' . esc_attr( $item->title ) . '"><i class="fa ' . esc_attr( $item->attr_title ) . '" aria-hidden="true"></i> '; |
|
144 | + $item_output .= '<a' . $icon_attributes . ' title="' . esc_attr($item->title) . '"><i class="fa ' . esc_attr($item->attr_title) . '" aria-hidden="true"></i> '; |
|
145 | 145 | } |
146 | 146 | } else { |
147 | 147 | $item_output .= '<a' . $attributes . '>'; |
148 | 148 | } |
149 | - $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after; |
|
150 | - $item_output .= ( $args->has_children && 0 === $depth ) ? ' <span class="caret"></span></a>' : '</a>'; |
|
149 | + $item_output .= $args->link_before . apply_filters('the_title', $item->title, $item->ID) . $args->link_after; |
|
150 | + $item_output .= ($args->has_children && 0 === $depth) ? ' <span class="caret"></span></a>' : '</a>'; |
|
151 | 151 | $item_output .= $args->after; |
152 | - $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args ); |
|
152 | + $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args); |
|
153 | 153 | } // End if(). |
154 | 154 | } |
155 | 155 | |
@@ -174,14 +174,14 @@ discard block |
||
174 | 174 | * @param mixed $output Passed by reference. Used to append additional content. |
175 | 175 | * @return null Null on failure with no changes to parameters. |
176 | 176 | */ |
177 | - public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) { |
|
178 | - if ( ! $element ) { |
|
177 | + public function display_element($element, &$children_elements, $max_depth, $depth, $args, &$output) { |
|
178 | + if ( ! $element) { |
|
179 | 179 | return; } |
180 | 180 | $id_field = $this->db_fields['id']; |
181 | 181 | // Display this element. |
182 | - if ( is_object( $args[0] ) ) { |
|
183 | - $args[0]->has_children = ! empty( $children_elements[ $element->$id_field ] ); } |
|
184 | - parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output ); |
|
182 | + if (is_object($args[0])) { |
|
183 | + $args[0]->has_children = ! empty($children_elements[$element->$id_field]); } |
|
184 | + parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | /** |
@@ -194,8 +194,8 @@ discard block |
||
194 | 194 | * |
195 | 195 | * @param array $args passed from the wp_nav_menu function. |
196 | 196 | */ |
197 | - public static function fallback( $args ) { |
|
198 | - if ( current_user_can( 'edit_theme_options' ) ) { |
|
197 | + public static function fallback($args) { |
|
198 | + if (current_user_can('edit_theme_options')) { |
|
199 | 199 | |
200 | 200 | /* Get Arguments. */ |
201 | 201 | $container = $args['container']; |
@@ -204,25 +204,25 @@ discard block |
||
204 | 204 | $menu_class = $args['menu_class']; |
205 | 205 | $menu_id = $args['menu_id']; |
206 | 206 | |
207 | - if ( $container ) { |
|
208 | - echo '<' . esc_attr( $container ); |
|
209 | - if ( $container_id ) { |
|
210 | - echo ' id="' . esc_attr( $container_id ) . '"'; |
|
207 | + if ($container) { |
|
208 | + echo '<' . esc_attr($container); |
|
209 | + if ($container_id) { |
|
210 | + echo ' id="' . esc_attr($container_id) . '"'; |
|
211 | 211 | } |
212 | - if ( $container_class ) { |
|
213 | - echo ' class="' . esc_attr( $container_class ) . '"'; } |
|
212 | + if ($container_class) { |
|
213 | + echo ' class="' . esc_attr($container_class) . '"'; } |
|
214 | 214 | echo '>'; |
215 | 215 | } |
216 | 216 | echo '<ul'; |
217 | - if ( $menu_id ) { |
|
218 | - echo ' id="' . esc_attr( $menu_id ) . '"'; } |
|
219 | - if ( $menu_class ) { |
|
220 | - echo ' class="' . esc_attr( $menu_class ) . '"'; } |
|
217 | + if ($menu_id) { |
|
218 | + echo ' id="' . esc_attr($menu_id) . '"'; } |
|
219 | + if ($menu_class) { |
|
220 | + echo ' class="' . esc_attr($menu_class) . '"'; } |
|
221 | 221 | echo '>'; |
222 | - echo '<li><a href="' . esc_url( admin_url( 'nav-menus.php' ) ) . '" title="">' . esc_attr( 'Add a menu', '' ) . '</a></li>'; |
|
222 | + echo '<li><a href="' . esc_url(admin_url('nav-menus.php')) . '" title="">' . esc_attr('Add a menu', '') . '</a></li>'; |
|
223 | 223 | echo '</ul>'; |
224 | - if ( $container ) { |
|
225 | - echo '</' . esc_attr( $container ) . '>'; } |
|
224 | + if ($container) { |
|
225 | + echo '</' . esc_attr($container) . '>'; } |
|
226 | 226 | } |
227 | 227 | } |
228 | 228 | } |