Skip to content

Commit f19aeee

Browse files
committed
Merge pull request #41 from claudiosmweb/master
Fix WordPress Coding Standards and Strict Standards message for non-static method
2 parents 5de602e + 33abc81 commit f19aeee

File tree

1 file changed

+37
-48
lines changed

1 file changed

+37
-48
lines changed

wp_bootstrap_navwalker.php

Lines changed: 37 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ class wp_bootstrap_navwalker extends Walker_Nav_Menu {
1919
* @param string $output Passed by reference. Used to append additional content.
2020
* @param int $depth Depth of page. Used for padding.
2121
*/
22-
function start_lvl( &$output, $depth = 0, $args = array() ) {
23-
$indent = str_repeat("\t", $depth);
22+
public function start_lvl( &$output, $depth = 0, $args = array() ) {
23+
$indent = str_repeat( "\t", $depth );
2424
$output .= "\n$indent<ul role=\"menu\" class=\" dropdown-menu\">\n";
2525
}
2626

@@ -34,8 +34,7 @@ function start_lvl( &$output, $depth = 0, $args = array() ) {
3434
* @param int $current_page Menu item ID.
3535
* @param object $args
3636
*/
37-
38-
function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
37+
public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
3938
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
4039

4140
/**
@@ -46,13 +45,13 @@ function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
4645
* comparison that is not case sensitive. The strcasecmp() function returns
4746
* a 0 if the strings are equal.
4847
*/
49-
if (strcasecmp($item->attr_title, 'divider') == 0 && $depth === 1) {
48+
if ( strcasecmp( $item->attr_title, 'divider' ) == 0 && $depth === 1 ) {
5049
$output .= $indent . '<li role="presentation" class="divider">';
51-
} else if (strcasecmp($item->title, 'divider') == 0 && $depth === 1) {
50+
} else if ( strcasecmp( $item->title, 'divider') == 0 && $depth === 1 ) {
5251
$output .= $indent . '<li role="presentation" class="divider">';
53-
} else if (strcasecmp($item->attr_title, 'dropdown-header') == 0 && $depth === 1) {
52+
} else if ( strcasecmp( $item->attr_title, 'dropdown-header') == 0 && $depth === 1 ) {
5453
$output .= $indent . '<li role="presentation" class="dropdown-header">' . esc_attr( $item->title );
55-
} else if (strcasecmp($item->attr_title, 'disabled') == 0) {
54+
} else if ( strcasecmp($item->attr_title, 'disabled' ) == 0 ) {
5655
$output .= $indent . '<li role="presentation" class="disabled"><a href="#">' . esc_attr( $item->title ) . '</a>';
5756
} else {
5857

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

6463
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );
65-
66-
if($args->has_children) { $class_names .= ' dropdown'; }
67-
if(in_array('current-menu-item', $classes)) { $class_names .= ' active'; }
64+
65+
if ( $args->has_children )
66+
$class_names .= ' dropdown';
67+
68+
if ( in_array( 'current-menu-item', $classes ) )
69+
$class_names .= ' active';
6870

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

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

7678
$atts = array();
77-
$atts['title'] = ! empty( $item->title ) ? $item->title : '';
78-
$atts['target'] = ! empty( $item->target ) ? $item->target : '';
79-
$atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : '';
79+
$atts['title'] = ! empty( $item->title ) ? $item->title : '';
80+
$atts['target'] = ! empty( $item->target ) ? $item->target : '';
81+
$atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : '';
8082

81-
//If item has_children add atts to a
82-
if($args->has_children && $depth === 0) {
83+
// If item has_children add atts to a.
84+
if ( $args->has_children && $depth === 0 ) {
8385
$atts['href'] = '#';
8486
$atts['data-toggle'] = 'dropdown';
8587
$atts['class'] = 'dropdown-toggle';
@@ -106,15 +108,13 @@ function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
106108
* if there is a value in the attr_title property. If the attr_title
107109
* property is NOT null we apply it as the class name for the glyphicon.
108110
*/
109-
110-
if(! empty( $item->attr_title )){
111+
if ( ! empty( $item->attr_title ) )
111112
$item_output .= '<a'. $attributes .'><span class="glyphicon ' . esc_attr( $item->attr_title ) . '"></span>&nbsp;';
112-
} else {
113+
else
113114
$item_output .= '<a'. $attributes .'>';
114-
}
115-
115+
116116
$item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
117-
$item_output .= ($args->has_children && $depth === 0) ? ' <span class="caret"></span></a>' : '</a>';
117+
$item_output .= ( $args->has_children && 0 === $depth ) ? ' <span class="caret"></span></a>' : '</a>';
118118
$item_output .= $args->after;
119119

120120
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
@@ -126,7 +126,7 @@ function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
126126
*
127127
* Display one element if the element doesn't have any children otherwise,
128128
* display the element and its children. Will only traverse up to the max
129-
* depth and no ignore elements under that depth.
129+
* depth and no ignore elements under that depth.
130130
*
131131
* This method shouldn't be called directly, use the walk() method instead.
132132
*
@@ -141,20 +141,17 @@ function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
141141
* @param string $output Passed by reference. Used to append additional content.
142142
* @return null Null on failure with no changes to parameters.
143143
*/
144-
145-
function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
146-
if ( !$element ) {
144+
public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
145+
if ( ! $element )
147146
return;
148-
}
149147

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

152-
//display this element
153-
if ( is_object( $args[0] ) ) {
154-
$args[0]->has_children = ! empty( $children_elements[$element->$id_field] );
155-
}
150+
// Display this element.
151+
if ( is_object( $args[0] ) )
152+
$args[0]->has_children = ! empty( $children_elements[ $element->$id_field ] );
156153

157-
parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output);
154+
parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
158155
}
159156

160157
/**
@@ -165,11 +162,10 @@ function display_element( $element, &$children_elements, $max_depth, $depth, $ar
165162
* menu manager the function with display nothing to a non-logged in user,
166163
* and will add a link to the WordPress menu manager if logged in as an admin.
167164
*
168-
* @param array $args passed from the wp_nav_menu function
165+
* @param array $args passed from the wp_nav_menu function.
169166
*
170167
*/
171-
172-
function fallback( $args ) {
168+
public static function fallback( $args ) {
173169
if ( current_user_can( 'manage_options' ) ) {
174170

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

182-
if ( $container_id ) {
178+
if ( $container_id )
183179
$fb_output .= ' id="' . $container_id . '"';
184-
}
185180

186-
if ( $container_class ) {
181+
if ( $container_class )
187182
$fb_output .= ' class="' . $container_class . '"';
188-
}
189183

190184
$fb_output .= '>';
191185
}
192-
186+
193187
$fb_output .= '<ul';
194188

195-
if ( $menu_id ) {
189+
if ( $menu_id )
196190
$fb_output .= ' id="' . $menu_id . '"';
197-
}
198191

199-
if ( $menu_class ) {
192+
if ( $menu_class )
200193
$fb_output .= ' class="' . $menu_class . '"';
201-
}
202194

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

207-
if ( $container ) {
199+
if ( $container )
208200
$fb_output .= '</' . $container . '>';
209-
}
210201

211202
echo $fb_output;
212203
}
213204
}
214205
}
215-
216-
?>

0 commit comments

Comments
 (0)