Skip to content

Commit

Permalink
Merge pull request #1624 from INN/1623-has_dhildren-notice
Browse files Browse the repository at this point in the history
In Bootstrap_Walker_Nav_Menu::start_el(), stop referring to array keys as object properties, and set visibility of methods.
  • Loading branch information
benlk authored Jan 31, 2019
2 parents 17caa1e + 3491d70 commit 00d11d8
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions inc/nav-menus.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function largo_add_footer_menu_label( $items, $args ) {
*/
class Bootstrap_Walker_Nav_Menu extends Walker_Nav_Menu {

function start_lvl( &$output, $depth = 0, $args = array() ) {
public function start_lvl( &$output, $depth = 0, $args = array() ) {

$indent = str_repeat( "\t", $depth );
if ($depth == 1) {
Expand All @@ -76,15 +76,15 @@ function start_lvl( &$output, $depth = 0, $args = array() ) {
}
}

function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {

$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';

$li_attributes = '';
$class_names = $value = '';

$classes = empty( $item->classes ) ? array() : (array) $item->classes;
$classes[] = ($args->has_children) ? 'dropdown' : '';
$classes[] = ( isset( $args['has_children'] ) && $args['has_children'] ) ? 'dropdown' : '';
$classes[] = ($item->current || $item->current_item_ancestor) ? 'active' : '';
$classes[] = 'menu-item-' . $item->ID;

Expand All @@ -100,29 +100,30 @@ function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
$attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
$attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
$attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
$attributes .= (($args->has_children) && ($depth == 0)) ? ' class="dropdown-toggle"' : '';
$attributes .= (( $args['has_children'] ) && ($depth == 0)) ? ' class="dropdown-toggle"' : '';

$item_output = $args->before;
$item_output = $args['before'];
$item_output .= '<a'. $attributes .'>';
$item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
$item_output .= (($args->has_children) && ($depth == 0)) ? ' <b class="caret"></b></a>' : '';
$item_output .= (($args->has_children) && ($depth != 0)) ? ' <i class="icon-arrow-right"></i></a>' : '</a>';
$item_output .= $args->after;
$item_output .= $args['link_before'] . apply_filters( 'the_title', $item->title, $item->ID ) . $args['link_after'];
$item_output .= ( ( $args['has_children'] ) && ($depth == 0)) ? ' <b class="caret"></b></a>' : '';
$item_output .= ( ( $args['has_children'] ) && ($depth != 0)) ? ' <i class="icon-arrow-right"></i></a>' : '</a>';
$item_output .= $args['after'];

$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
}

function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ) {
public function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ) {
if ( !$element )
return;

$id_field = $this->db_fields['id'];

//display this element
if ( is_array( $args[0] ) )
if ( is_array( $args[0] ) ) {
$args[0]['has_children'] = ! empty( $children_elements[$element->$id_field] );
else if ( is_object( $args[0] ) )
} else if ( is_object( $args[0] ) ) {
$args[0]->has_children = ! empty( $children_elements[$element->$id_field] );
}
$cb_args = array_merge( array(&$output, $element, $depth), $args);
call_user_func_array(array(&$this, 'start_el'), $cb_args);

Expand Down

0 comments on commit 00d11d8

Please sign in to comment.