Skip to content

Commit

Permalink
Merge pull request #41 from claudiosmweb/master
Browse files Browse the repository at this point in the history
Fix WordPress Coding Standards and Strict Standards message for non-static method
  • Loading branch information
PlanBrewski committed Oct 10, 2013
2 parents 5de602e + 33abc81 commit f19aeee
Showing 1 changed file with 37 additions and 48 deletions.
85 changes: 37 additions & 48 deletions wp_bootstrap_navwalker.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class wp_bootstrap_navwalker extends Walker_Nav_Menu {
* @param string $output Passed by reference. Used to append additional content.
* @param int $depth Depth of page. Used for padding.
*/
function start_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat("\t", $depth);
public function start_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat( "\t", $depth );
$output .= "\n$indent<ul role=\"menu\" class=\" dropdown-menu\">\n";
}

Expand All @@ -34,8 +34,7 @@ function start_lvl( &$output, $depth = 0, $args = array() ) {
* @param int $current_page Menu item ID.
* @param object $args
*/

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 ) : '';

/**
Expand All @@ -46,13 +45,13 @@ function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
* comparison that is not case sensitive. The strcasecmp() function returns
* a 0 if the strings are equal.
*/
if (strcasecmp($item->attr_title, 'divider') == 0 && $depth === 1) {
if ( strcasecmp( $item->attr_title, 'divider' ) == 0 && $depth === 1 ) {
$output .= $indent . '<li role="presentation" class="divider">';
} else if (strcasecmp($item->title, 'divider') == 0 && $depth === 1) {
} else if ( strcasecmp( $item->title, 'divider') == 0 && $depth === 1 ) {
$output .= $indent . '<li role="presentation" class="divider">';
} else if (strcasecmp($item->attr_title, 'dropdown-header') == 0 && $depth === 1) {
} else if ( strcasecmp( $item->attr_title, 'dropdown-header') == 0 && $depth === 1 ) {
$output .= $indent . '<li role="presentation" class="dropdown-header">' . esc_attr( $item->title );
} else if (strcasecmp($item->attr_title, 'disabled') == 0) {
} else if ( strcasecmp($item->attr_title, 'disabled' ) == 0 ) {
$output .= $indent . '<li role="presentation" class="disabled"><a href="#">' . esc_attr( $item->title ) . '</a>';
} else {

Expand All @@ -62,9 +61,12 @@ function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
$classes[] = 'menu-item-' . $item->ID;

$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );

if($args->has_children) { $class_names .= ' dropdown'; }
if(in_array('current-menu-item', $classes)) { $class_names .= ' active'; }

if ( $args->has_children )
$class_names .= ' dropdown';

if ( in_array( 'current-menu-item', $classes ) )
$class_names .= ' active';

$class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';

Expand All @@ -74,12 +76,12 @@ function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
$output .= $indent . '<li' . $id . $value . $class_names .'>';

$atts = array();
$atts['title'] = ! empty( $item->title ) ? $item->title : '';
$atts['target'] = ! empty( $item->target ) ? $item->target : '';
$atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : '';
$atts['title'] = ! empty( $item->title ) ? $item->title : '';
$atts['target'] = ! empty( $item->target ) ? $item->target : '';
$atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : '';

//If item has_children add atts to a
if($args->has_children && $depth === 0) {
// If item has_children add atts to a.
if ( $args->has_children && $depth === 0 ) {
$atts['href'] = '#';
$atts['data-toggle'] = 'dropdown';
$atts['class'] = 'dropdown-toggle';
Expand All @@ -106,15 +108,13 @@ function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
* if there is a value in the attr_title property. If the attr_title
* property is NOT null we apply it as the class name for the glyphicon.
*/

if(! empty( $item->attr_title )){
if ( ! empty( $item->attr_title ) )
$item_output .= '<a'. $attributes .'><span class="glyphicon ' . esc_attr( $item->attr_title ) . '"></span>&nbsp;';
} else {
else
$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) ? ' <span class="caret"></span></a>' : '</a>';
$item_output .= ( $args->has_children && 0 === $depth ) ? ' <span class="caret"></span></a>' : '</a>';
$item_output .= $args->after;

$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
Expand All @@ -126,7 +126,7 @@ function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
*
* Display one element if the element doesn't have any children otherwise,
* display the element and its children. Will only traverse up to the max
* depth and no ignore elements under that depth.
* depth and no ignore elements under that depth.
*
* This method shouldn't be called directly, use the walk() method instead.
*
Expand All @@ -141,20 +141,17 @@ function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
* @param string $output Passed by reference. Used to append additional content.
* @return null Null on failure with no changes to parameters.
*/

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

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

//display this element
if ( is_object( $args[0] ) ) {
$args[0]->has_children = ! empty( $children_elements[$element->$id_field] );
}
// Display this element.
if ( is_object( $args[0] ) )
$args[0]->has_children = ! empty( $children_elements[ $element->$id_field ] );

parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output);
parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
}

/**
Expand All @@ -165,11 +162,10 @@ function display_element( $element, &$children_elements, $max_depth, $depth, $ar
* menu manager the function with display nothing to a non-logged in user,
* and will add a link to the WordPress menu manager if logged in as an admin.
*
* @param array $args passed from the wp_nav_menu function
* @param array $args passed from the wp_nav_menu function.
*
*/

function fallback( $args ) {
public static function fallback( $args ) {
if ( current_user_can( 'manage_options' ) ) {

extract( $args );
Expand All @@ -179,38 +175,31 @@ function fallback( $args ) {
if ( $container ) {
$fb_output = '<' . $container;

if ( $container_id ) {
if ( $container_id )
$fb_output .= ' id="' . $container_id . '"';
}

if ( $container_class ) {
if ( $container_class )
$fb_output .= ' class="' . $container_class . '"';
}

$fb_output .= '>';
}

$fb_output .= '<ul';

if ( $menu_id ) {
if ( $menu_id )
$fb_output .= ' id="' . $menu_id . '"';
}

if ( $menu_class ) {
if ( $menu_class )
$fb_output .= ' class="' . $menu_class . '"';
}

$fb_output .= '>';
$fb_output .= '<li><a href="' . admin_url( 'nav-menus.php' ) . '">Add a menu</a></li>';
$fb_output .= '</ul>';

if ( $container ) {
if ( $container )
$fb_output .= '</' . $container . '>';
}

echo $fb_output;
}
}
}

?>

0 comments on commit f19aeee

Please sign in to comment.