1111 * Plugin URI: https://github.com/wp-bootstrap/wp-bootstrap-navwalker
1212 * Description: A custom WordPress nav walker class to implement the Bootstrap 4 navigation style in a custom theme using the WordPress built in menu manager.
1313 * Author: Edward McIntyre - @twittem, WP Bootstrap, William Patton - @pattonwebz
14- * Version: 4.0.3
14+ * Version: 4.1.0
1515 * Author URI: https://github.com/wp-bootstrap
1616 * GitHub Plugin URI: https://github.com/wp-bootstrap/wp-bootstrap-navwalker
1717 * GitHub Branch: master
@@ -133,7 +133,7 @@ public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0
133133 $ args = apply_filters ( 'nav_menu_item_args ' , $ args , $ item , $ depth );
134134
135135 // Add .dropdown or .active classes where they are needed.
136- if ( $ args ->has_children ) {
136+ if ( isset ( $ args -> has_children ) && $ args ->has_children ) {
137137 $ classes [] = 'dropdown ' ;
138138 }
139139 if ( in_array ( 'current-menu-item ' , $ classes , true ) || in_array ( 'current-menu-parent ' , $ classes , true ) ) {
@@ -181,7 +181,7 @@ public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0
181181 $ atts ['target ' ] = ! empty ( $ item ->target ) ? $ item ->target : '' ;
182182 $ atts ['rel ' ] = ! empty ( $ item ->xfn ) ? $ item ->xfn : '' ;
183183 // If item has_children add atts to <a>.
184- if ( $ args ->has_children && 0 === $ depth && $ args ->depth > 1 ) {
184+ if ( isset ( $ args -> has_children ) && $ args ->has_children && 0 === $ depth && $ args ->depth > 1 ) {
185185 $ atts ['href ' ] = '# ' ;
186186 $ atts ['data-toggle ' ] = 'dropdown ' ;
187187 $ atts ['aria-haspopup ' ] = 'true ' ;
@@ -201,7 +201,7 @@ public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0
201201 // update atts of this item based on any custom linkmod classes.
202202 $ atts = self ::update_atts_for_linkmod_type ( $ atts , $ linkmod_classes );
203203 // 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, $ depth );
205205
206206 // Build a string of html containing all the atts for the item.
207207 $ attributes = '' ;
@@ -220,8 +220,7 @@ public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0
220220 /**
221221 * START appending the internal item contents to the output.
222222 */
223- $ item_output = $ args ->before ;
224-
223+ $ item_output = isset ( $ args ->before ) ? $ args ->before : '' ;
225224 /**
226225 * This is the start of the internal nav item. Depending on what
227226 * kind of linkmod we have we may need different wrapper elements.
@@ -272,8 +271,7 @@ public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0
272271 }
273272
274273 // Put the item contents into $output.
275- $ item_output .= $ args ->link_before . $ icon_html . $ title . $ args ->link_after ;
276-
274+ $ item_output .= isset ( $ args ->link_before ) ? $ args ->link_before . $ icon_html . $ title . $ args ->link_after : '' ;
277275 /**
278276 * This is the end of the internal nav item. We need to close the
279277 * correct element depending on the type of link or link mod.
@@ -286,11 +284,11 @@ public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0
286284 $ item_output .= '</a> ' ;
287285 }
288286
289- $ item_output .= $ args ->after ;
287+ $ item_output .= isset ( $ args ->after ) ? $ args ->after : '' ;
288+
290289 /**
291290 * END appending the internal item contents to the output.
292291 */
293-
294292 $ output .= apply_filters ( 'walker_nav_menu_start_el ' , $ item_output , $ item , $ depth , $ args );
295293
296294 }
@@ -407,7 +405,7 @@ private function seporate_linkmods_and_icons_from_classes( $classes, &$linkmod_c
407405 // Test for .disabled or .sr-only classes.
408406 $ linkmod_classes [] = $ class ;
409407 unset( $ classes [ $ key ] );
410- } elseif ( preg_match ( '/^dropdown-header|^dropdown-divider/i ' , $ class ) && $ depth > 0 ) {
408+ } elseif ( preg_match ( '/^dropdown-header|^dropdown-divider|^dropdown-item-text /i ' , $ class ) && $ depth > 0 ) {
411409 // Test for .dropdown-header or .dropdown-divider and a
412410 // depth greater than 0 - IE inside a dropdown.
413411 $ linkmod_classes [] = $ class ;
@@ -448,6 +446,8 @@ private function get_linkmod_type( $linkmod_classes = array() ) {
448446 $ linkmod_type = 'dropdown-header ' ;
449447 } elseif ( 'dropdown-divider ' === $ link_class ) {
450448 $ linkmod_type = 'dropdown-divider ' ;
449+ } elseif ( 'dropdown-item-text ' === $ link_class ) {
450+ $ linkmod_type = 'dropdown-item-text ' ;
451451 }
452452 }
453453 }
@@ -479,7 +479,7 @@ private function update_atts_for_linkmod_type( $atts = array(), $linkmod_classes
479479 // Convert link to '#' and unset open targets.
480480 $ atts ['href ' ] = '# ' ;
481481 unset( $ atts ['target ' ] );
482- } elseif ( 'dropdown-header ' === $ link_class || 'dropdown-divider ' === $ link_class ) {
482+ } elseif ( 'dropdown-header ' === $ link_class || 'dropdown-divider ' === $ link_class || ' dropdown-item-text ' === $ link_class ) {
483483 // Store a type flag and unset href and target.
484484 unset( $ atts ['href ' ] );
485485 unset( $ atts ['target ' ] );
@@ -517,7 +517,9 @@ private function wrap_for_screen_reader( $text = '' ) {
517517 */
518518 private function linkmod_element_open ( $ linkmod_type , $ attributes = '' ) {
519519 $ output = '' ;
520- if ( 'dropdown-header ' === $ linkmod_type ) {
520+ if ( 'dropdown-item-text ' === $ linkmod_type ) {
521+ $ output .= '<span class="dropdown-item-text" ' . $ attributes . '> ' ;
522+ } elseif ( 'dropdown-header ' === $ linkmod_type ) {
521523 // For a header use a span with the .h6 class instead of a real
522524 // header tag so that it doesn't confuse screen readers.
523525 $ output .= '<span class="dropdown-header h6" ' . $ attributes . '> ' ;
@@ -539,7 +541,7 @@ private function linkmod_element_open( $linkmod_type, $attributes = '' ) {
539541 */
540542 private function linkmod_element_close ( $ linkmod_type ) {
541543 $ output = '' ;
542- if ( 'dropdown-header ' === $ linkmod_type ) {
544+ if ( 'dropdown-header ' === $ linkmod_type || ' dropdown-item-text ' === $ linkmod_type ) {
543545 // For a header use a span with the .h6 class instead of a real
544546 // header tag so that it doesn't confuse screen readers.
545547 $ output .= '</span> ' ;
0 commit comments