Completed
Pull Request — master (#268)
by
unknown
01:51
created
wp-bootstrap-navwalker.php 3 patches
Indentation   +180 added lines, -180 removed lines patch added patch discarded remove patch
@@ -28,204 +28,204 @@
 block discarded – undo
28 28
    */
29 29
   class WP_Bootstrap_Navwalker extends Walker_Nav_Menu {
30 30
 
31
-    /**
32
-     * Start Level.
33
-     *
34
-     * @see Walker::start_lvl()
35
-     * @since 3.0.0
36
-     *
37
-     * @access public
38
-     * @param mixed $output Passed by reference. Used to append additional content.
39
-     * @param int   $depth (default: 0) Depth of page. Used for padding.
40
-     * @param array $args (default: array()) Arguments.
41
-     * @return void
42
-     */
43
-    public function start_lvl( &$output, $depth = 0, $args = array() ) {
44
-      $indent = str_repeat( "\t", $depth );
45
-      $output .= "\n$indent<ul role=\"menu\" class=\" dropdown-menu\" >\n";
46
-    }
31
+	/**
32
+	 * Start Level.
33
+	 *
34
+	 * @see Walker::start_lvl()
35
+	 * @since 3.0.0
36
+	 *
37
+	 * @access public
38
+	 * @param mixed $output Passed by reference. Used to append additional content.
39
+	 * @param int   $depth (default: 0) Depth of page. Used for padding.
40
+	 * @param array $args (default: array()) Arguments.
41
+	 * @return void
42
+	 */
43
+	public function start_lvl( &$output, $depth = 0, $args = array() ) {
44
+	  $indent = str_repeat( "\t", $depth );
45
+	  $output .= "\n$indent<ul role=\"menu\" class=\" dropdown-menu\" >\n";
46
+	}
47 47
 
48
-    /**
49
-     * Start El.
50
-     *
51
-     * @see Walker::start_el()
52
-     * @since 3.0.0
53
-     *
54
-     * @access public
55
-     * @param mixed $output Passed by reference. Used to append additional content.
56
-     * @param mixed $item Menu item data object.
57
-     * @param int   $depth (default: 0) Depth of menu item. Used for padding.
58
-     * @param array $args (default: array()) Arguments.
59
-     * @param int   $id (default: 0) Menu item ID.
60
-     * @return void
61
-     */
62
-    public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
63
-      $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
48
+	/**
49
+	 * Start El.
50
+	 *
51
+	 * @see Walker::start_el()
52
+	 * @since 3.0.0
53
+	 *
54
+	 * @access public
55
+	 * @param mixed $output Passed by reference. Used to append additional content.
56
+	 * @param mixed $item Menu item data object.
57
+	 * @param int   $depth (default: 0) Depth of menu item. Used for padding.
58
+	 * @param array $args (default: array()) Arguments.
59
+	 * @param int   $id (default: 0) Menu item ID.
60
+	 * @return void
61
+	 */
62
+	public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
63
+	  $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
64 64
 
65
-      /**
66
-      * Dividers, Headers or Disabled
67
-      * =============================
68
-      * Determine whether the item is a Divider, Header, Disabled or regular
69
-      * menu item. To prevent errors we use the strcasecmp() function to so a
70
-      * comparison that is not case sensitive. The strcasecmp() function returns
71
-      * a 0 if the strings are equal.
72
-      */
73
-      if ( 0 === strcasecmp( $item->attr_title, 'divider' ) && 1 === $depth ) {
74
-        $output .= $indent . '<li role="presentation" class="divider">';
75
-      } elseif ( 0 === strcasecmp( $item->title, 'divider' ) && 1 === $depth ) {
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>';
81
-      } else {
82
-        $class_names = $value = '';
83
-        $classes = empty( $item->classes ) ? array() : (array) $item->classes;
84
-        $classes[] = 'menu-item-' . $item->ID;
85
-        $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );
86
-        if ( $args->has_children ) {
87
-          $class_names .= ' dropdown'; }
88
-        if ( in_array( 'current-menu-item', $classes, true ) ) {
89
-          $class_names .= ' active'; }
90
-        $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
91
-        $id = apply_filters( 'nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args );
92
-        $id = $id ? ' id="' . esc_attr( $id ) . '"' : '';
93
-        $output .= $indent . '<li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement"' . $id . $value . $class_names . '>';
94
-        $atts = array();
65
+	  /**
66
+	   * Dividers, Headers or Disabled
67
+	   * =============================
68
+	   * Determine whether the item is a Divider, Header, Disabled or regular
69
+	   * menu item. To prevent errors we use the strcasecmp() function to so a
70
+	   * comparison that is not case sensitive. The strcasecmp() function returns
71
+	   * a 0 if the strings are equal.
72
+	   */
73
+	  if ( 0 === strcasecmp( $item->attr_title, 'divider' ) && 1 === $depth ) {
74
+		$output .= $indent . '<li role="presentation" class="divider">';
75
+	  } elseif ( 0 === strcasecmp( $item->title, 'divider' ) && 1 === $depth ) {
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>';
81
+	  } else {
82
+		$class_names = $value = '';
83
+		$classes = empty( $item->classes ) ? array() : (array) $item->classes;
84
+		$classes[] = 'menu-item-' . $item->ID;
85
+		$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );
86
+		if ( $args->has_children ) {
87
+		  $class_names .= ' dropdown'; }
88
+		if ( in_array( 'current-menu-item', $classes, true ) ) {
89
+		  $class_names .= ' active'; }
90
+		$class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
91
+		$id = apply_filters( 'nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args );
92
+		$id = $id ? ' id="' . esc_attr( $id ) . '"' : '';
93
+		$output .= $indent . '<li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement"' . $id . $value . $class_names . '>';
94
+		$atts = array();
95 95
 
96
-        if ( empty( $item->attr_title ) ) {
97
-            $atts['title']  = ! empty( $item->title )   ? strip_tags( $item->title ) : '';
98
-        } else {
99
-            $atts['title'] = $item->attr_title;
100
-        }
96
+		if ( empty( $item->attr_title ) ) {
97
+			$atts['title']  = ! empty( $item->title )   ? strip_tags( $item->title ) : '';
98
+		} else {
99
+			$atts['title'] = $item->attr_title;
100
+		}
101 101
 
102
-        $atts['target'] = ! empty( $item->target )  ? $item->target : '';
103
-        $atts['rel']    = ! empty( $item->xfn )   ? $item->xfn  : '';
104
-        // If item has_children add atts to a.
105
-        if ( $args->has_children && 0 === $depth ) {
106
-          $atts['href']       = '#';
107
-          $atts['data-toggle']  = 'dropdown';
108
-          $atts['class']      = 'dropdown-toggle';
109
-          $atts['aria-haspopup']  = 'true';
110
-        } else {
111
-          $atts['href'] = ! empty( $item->url ) ? $item->url : '';
112
-        }
113
-        $atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args );
114
-        $attributes = '';
115
-        foreach ( $atts as $attr => $value ) {
116
-          if ( ! empty( $value ) ) {
117
-            $value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
118
-            $attributes .= ' ' . $attr . '="' . $value . '"';
119
-          }
120
-        }
121
-        $item_output = $args->before;
102
+		$atts['target'] = ! empty( $item->target )  ? $item->target : '';
103
+		$atts['rel']    = ! empty( $item->xfn )   ? $item->xfn  : '';
104
+		// If item has_children add atts to a.
105
+		if ( $args->has_children && 0 === $depth ) {
106
+		  $atts['href']       = '#';
107
+		  $atts['data-toggle']  = 'dropdown';
108
+		  $atts['class']      = 'dropdown-toggle';
109
+		  $atts['aria-haspopup']  = 'true';
110
+		} else {
111
+		  $atts['href'] = ! empty( $item->url ) ? $item->url : '';
112
+		}
113
+		$atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args );
114
+		$attributes = '';
115
+		foreach ( $atts as $attr => $value ) {
116
+		  if ( ! empty( $value ) ) {
117
+			$value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
118
+			$attributes .= ' ' . $attr . '="' . $value . '"';
119
+		  }
120
+		}
121
+		$item_output = $args->before;
122 122
 
123
-        /*
123
+		/*
124 124
          * Glyphicons/Font-Awesome
125 125
          * ===========
126 126
          * Since the the menu item is NOT a Divider or Header we check the see
127 127
          * if there is a value in the attr_title property. If the attr_title
128 128
          * property is NOT null we apply it as the class name for the glyphicon.
129 129
          */
130
-        if ( ! empty( $item->attr_title ) ) :
131
-                $pos = strpos( esc_attr( $item->attr_title ), 'glyphicon' );
132
-          if ( false !== $pos ) :
133
-            $item_output .= '<a' . $attributes . '><span class="glyphicon ' . esc_attr( $item->attr_title ) . '" aria-hidden="true"></span>&nbsp;';
134
-                else :
135
-                  $item_output .= '<a' . $attributes . '><i class="fa ' . esc_attr( $item->attr_title ) . '" aria-hidden="true"></i>&nbsp;';
136
-                      endif;
137
-        else :
138
-          $item_output .= '<a' . $attributes . '>';
139
-        endif;
140
-        $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
141
-        $item_output .= ( $args->has_children && 0 === $depth ) ? ' <span class="caret"></span></a>' : '</a>';
142
-        $item_output .= $args->after;
143
-        $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
144
-      }
145
-    }
130
+		if ( ! empty( $item->attr_title ) ) :
131
+				$pos = strpos( esc_attr( $item->attr_title ), 'glyphicon' );
132
+		  if ( false !== $pos ) :
133
+			$item_output .= '<a' . $attributes . '><span class="glyphicon ' . esc_attr( $item->attr_title ) . '" aria-hidden="true"></span>&nbsp;';
134
+				else :
135
+				  $item_output .= '<a' . $attributes . '><i class="fa ' . esc_attr( $item->attr_title ) . '" aria-hidden="true"></i>&nbsp;';
136
+					  endif;
137
+		else :
138
+		  $item_output .= '<a' . $attributes . '>';
139
+		endif;
140
+		$item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
141
+		$item_output .= ( $args->has_children && 0 === $depth ) ? ' <span class="caret"></span></a>' : '</a>';
142
+		$item_output .= $args->after;
143
+		$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
144
+	  }
145
+	}
146 146
 
147
-    /**
148
-     * Traverse elements to create list from elements.
149
-     *
150
-     * Display one element if the element doesn't have any children otherwise,
151
-     * display the element and its children. Will only traverse up to the max
152
-     * depth and no ignore elements under that depth.
153
-     *
154
-     * This method shouldn't be called directly, use the walk() method instead.
155
-     *
156
-     * @see Walker::start_el()
157
-     * @since 2.5.0
158
-     *
159
-     * @access public
160
-     * @param mixed $element Data object.
161
-     * @param mixed $children_elements List of elements to continue traversing.
162
-     * @param mixed $max_depth Max depth to traverse.
163
-     * @param mixed $depth Depth of current element.
164
-     * @param mixed $args Arguments.
165
-     * @param mixed $output Passed by reference. Used to append additional content.
166
-     * @return null Null on failure with no changes to parameters.
167
-     */
168
-    public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
169
-      if ( ! $element ) {
170
-        return; }
171
-      $id_field = $this->db_fields['id'];
172
-      // Display this element.
173
-      if ( is_object( $args[0] ) ) {
174
-        $args[0]->has_children = ! empty( $children_elements[ $element->$id_field ] ); }
175
-      parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
176
-    }
147
+	/**
148
+	 * Traverse elements to create list from elements.
149
+	 *
150
+	 * Display one element if the element doesn't have any children otherwise,
151
+	 * display the element and its children. Will only traverse up to the max
152
+	 * depth and no ignore elements under that depth.
153
+	 *
154
+	 * This method shouldn't be called directly, use the walk() method instead.
155
+	 *
156
+	 * @see Walker::start_el()
157
+	 * @since 2.5.0
158
+	 *
159
+	 * @access public
160
+	 * @param mixed $element Data object.
161
+	 * @param mixed $children_elements List of elements to continue traversing.
162
+	 * @param mixed $max_depth Max depth to traverse.
163
+	 * @param mixed $depth Depth of current element.
164
+	 * @param mixed $args Arguments.
165
+	 * @param mixed $output Passed by reference. Used to append additional content.
166
+	 * @return null Null on failure with no changes to parameters.
167
+	 */
168
+	public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
169
+	  if ( ! $element ) {
170
+		return; }
171
+	  $id_field = $this->db_fields['id'];
172
+	  // Display this element.
173
+	  if ( is_object( $args[0] ) ) {
174
+		$args[0]->has_children = ! empty( $children_elements[ $element->$id_field ] ); }
175
+	  parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
176
+	}
177 177
 
178
-    /**
179
-     * Menu Fallback
180
-     * =============
181
-     * If this function is assigned to the wp_nav_menu's fallback_cb variable
182
-     * and a menu has not been assigned to the theme location in the WordPress
183
-     * menu manager the function with display nothing to a non-logged in user,
184
-     * and will add a link to the WordPress menu manager if logged in as an admin.
185
-     *
186
-     * @param array $args passed from the wp_nav_menu function.
187
-     */
188
-    public static function fallback( $args ) {
189
-      if ( current_user_can( 'edit_theme_options' ) ) {
178
+	/**
179
+	 * Menu Fallback
180
+	 * =============
181
+	 * If this function is assigned to the wp_nav_menu's fallback_cb variable
182
+	 * and a menu has not been assigned to the theme location in the WordPress
183
+	 * menu manager the function with display nothing to a non-logged in user,
184
+	 * and will add a link to the WordPress menu manager if logged in as an admin.
185
+	 *
186
+	 * @param array $args passed from the wp_nav_menu function.
187
+	 */
188
+	public static function fallback( $args ) {
189
+	  if ( current_user_can( 'edit_theme_options' ) ) {
190 190
 
191
-        /* Get Arguments. */
192
-        $container = $args['container'];
193
-        $container_id = $args['container_id'];
194
-        $container_class = $args['container_class'];
195
-        $menu_class = $args['menu_class'];
196
-        $menu_id = $args['menu_id'];
191
+		/* Get Arguments. */
192
+		$container = $args['container'];
193
+		$container_id = $args['container_id'];
194
+		$container_class = $args['container_class'];
195
+		$menu_class = $args['menu_class'];
196
+		$menu_id = $args['menu_id'];
197 197
 
198
-        $fb_output_safe = '';
198
+		$fb_output_safe = '';
199 199
         
200
-        if ( $container ) {
201
-          $fb_output_safe .= '<' . esc_attr( $container );
202
-          if ( $container_id ) {
203
-            $fb_output_safe .= ' id="' . esc_attr( $container_id ) . '"';
204
-          }
205
-          if ( $container_class ) {
206
-            $fb_output_safe .= ' class="' . sanitize_html_class( $container_class ) . '"'; }
207
-          $fb_output_safe .= '>';
208
-        }
209
-        $fb_output_safe .= '<ul';
210
-        if ( $menu_id ) {
211
-          $fb_output_safe .= ' id="' . esc_attr( $menu_id ) . '"'; }
212
-        if ( $menu_class ) {
213
-          $fb_output_safe .= ' class="' . esc_attr( $menu_class ) . '"'; }
214
-        $fb_output_safe .= '>';
215
-        $fb_output_safe .= '<li><a href="' . esc_url( admin_url( 'nav-menus.php' ) ) . '" title="">' . esc_attr( 'Add a menu', '' ) . '</a></li>';
216
-        $fb_output_safe .= '</ul>';
217
-        if ( $container ) {
218
-          $fb_output_safe .= '</' . esc_attr( $container ) . '>'; }
219
-      }
200
+		if ( $container ) {
201
+		  $fb_output_safe .= '<' . esc_attr( $container );
202
+		  if ( $container_id ) {
203
+			$fb_output_safe .= ' id="' . esc_attr( $container_id ) . '"';
204
+		  }
205
+		  if ( $container_class ) {
206
+			$fb_output_safe .= ' class="' . sanitize_html_class( $container_class ) . '"'; }
207
+		  $fb_output_safe .= '>';
208
+		}
209
+		$fb_output_safe .= '<ul';
210
+		if ( $menu_id ) {
211
+		  $fb_output_safe .= ' id="' . esc_attr( $menu_id ) . '"'; }
212
+		if ( $menu_class ) {
213
+		  $fb_output_safe .= ' class="' . esc_attr( $menu_class ) . '"'; }
214
+		$fb_output_safe .= '>';
215
+		$fb_output_safe .= '<li><a href="' . esc_url( admin_url( 'nav-menus.php' ) ) . '" title="">' . esc_attr( 'Add a menu', '' ) . '</a></li>';
216
+		$fb_output_safe .= '</ul>';
217
+		if ( $container ) {
218
+		  $fb_output_safe .= '</' . esc_attr( $container ) . '>'; }
219
+	  }
220 220
       
221
-      // if echo, echo, otherwise return
222
-      if ( $args['echo'] ):
223
-        echo $fb_output_safe;
224
-      else:
225
-        return $fb_output_safe;
226
-      endif;   
221
+	  // if echo, echo, otherwise return
222
+	  if ( $args['echo'] ):
223
+		echo $fb_output_safe;
224
+	  else:
225
+		return $fb_output_safe;
226
+	  endif;   
227 227
 
228 228
 
229
-    }
229
+	}
230 230
   }
231 231
 }
Please login to merge, or discard this patch.
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,51 +70,51 @@  discard block
 block discarded – undo
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
         $class_names = $value = '';
83
-        $classes = empty( $item->classes ) ? array() : (array) $item->classes;
83
+        $classes = empty($item->classes) ? array() : (array) $item->classes;
84 84
         $classes[] = 'menu-item-' . $item->ID;
85
-        $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );
86
-        if ( $args->has_children ) {
85
+        $class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item, $args));
86
+        if ($args->has_children) {
87 87
           $class_names .= ' dropdown'; }
88
-        if ( in_array( 'current-menu-item', $classes, true ) ) {
88
+        if (in_array('current-menu-item', $classes, true)) {
89 89
           $class_names .= ' active'; }
90
-        $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
91
-        $id = apply_filters( 'nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args );
92
-        $id = $id ? ' id="' . esc_attr( $id ) . '"' : '';
90
+        $class_names = $class_names ? ' class="' . esc_attr($class_names) . '"' : '';
91
+        $id = apply_filters('nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args);
92
+        $id = $id ? ' id="' . esc_attr($id) . '"' : '';
93 93
         $output .= $indent . '<li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement"' . $id . $value . $class_names . '>';
94 94
         $atts = array();
95 95
 
96
-        if ( empty( $item->attr_title ) ) {
97
-            $atts['title']  = ! empty( $item->title )   ? strip_tags( $item->title ) : '';
96
+        if (empty($item->attr_title)) {
97
+            $atts['title'] = ! empty($item->title) ? strip_tags($item->title) : '';
98 98
         } else {
99 99
             $atts['title'] = $item->attr_title;
100 100
         }
101 101
 
102
-        $atts['target'] = ! empty( $item->target )  ? $item->target : '';
103
-        $atts['rel']    = ! empty( $item->xfn )   ? $item->xfn  : '';
102
+        $atts['target'] = ! empty($item->target) ? $item->target : '';
103
+        $atts['rel']    = ! empty($item->xfn) ? $item->xfn : '';
104 104
         // If item has_children add atts to a.
105
-        if ( $args->has_children && 0 === $depth ) {
105
+        if ($args->has_children && 0 === $depth) {
106 106
           $atts['href']       = '#';
107
-          $atts['data-toggle']  = 'dropdown';
107
+          $atts['data-toggle'] = 'dropdown';
108 108
           $atts['class']      = 'dropdown-toggle';
109
-          $atts['aria-haspopup']  = 'true';
109
+          $atts['aria-haspopup'] = 'true';
110 110
         } else {
111
-          $atts['href'] = ! empty( $item->url ) ? $item->url : '';
111
+          $atts['href'] = ! empty($item->url) ? $item->url : '';
112 112
         }
113
-        $atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args );
113
+        $atts = apply_filters('nav_menu_link_attributes', $atts, $item, $args);
114 114
         $attributes = '';
115
-        foreach ( $atts as $attr => $value ) {
116
-          if ( ! empty( $value ) ) {
117
-            $value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
115
+        foreach ($atts as $attr => $value) {
116
+          if ( ! empty($value)) {
117
+            $value = ('href' === $attr) ? esc_url($value) : esc_attr($value);
118 118
             $attributes .= ' ' . $attr . '="' . $value . '"';
119 119
           }
120 120
         }
@@ -127,20 +127,20 @@  discard block
 block discarded – undo
127 127
          * if there is a value in the attr_title property. If the attr_title
128 128
          * property is NOT null we apply it as the class name for the glyphicon.
129 129
          */
130
-        if ( ! empty( $item->attr_title ) ) :
131
-                $pos = strpos( esc_attr( $item->attr_title ), 'glyphicon' );
132
-          if ( false !== $pos ) :
133
-            $item_output .= '<a' . $attributes . '><span class="glyphicon ' . esc_attr( $item->attr_title ) . '" aria-hidden="true"></span>&nbsp;';
130
+        if ( ! empty($item->attr_title)) :
131
+                $pos = strpos(esc_attr($item->attr_title), 'glyphicon');
132
+          if (false !== $pos) :
133
+            $item_output .= '<a' . $attributes . '><span class="glyphicon ' . esc_attr($item->attr_title) . '" aria-hidden="true"></span>&nbsp;';
134 134
                 else :
135
-                  $item_output .= '<a' . $attributes . '><i class="fa ' . esc_attr( $item->attr_title ) . '" aria-hidden="true"></i>&nbsp;';
135
+                  $item_output .= '<a' . $attributes . '><i class="fa ' . esc_attr($item->attr_title) . '" aria-hidden="true"></i>&nbsp;';
136 136
                       endif;
137 137
         else :
138 138
           $item_output .= '<a' . $attributes . '>';
139 139
         endif;
140
-        $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
141
-        $item_output .= ( $args->has_children && 0 === $depth ) ? ' <span class="caret"></span></a>' : '</a>';
140
+        $item_output .= $args->link_before . apply_filters('the_title', $item->title, $item->ID) . $args->link_after;
141
+        $item_output .= ($args->has_children && 0 === $depth) ? ' <span class="caret"></span></a>' : '</a>';
142 142
         $item_output .= $args->after;
143
-        $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
143
+        $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
144 144
       }
145 145
     }
146 146
 
@@ -165,14 +165,14 @@  discard block
 block discarded – undo
165 165
      * @param mixed $output Passed by reference. Used to append additional content.
166 166
      * @return null Null on failure with no changes to parameters.
167 167
      */
168
-    public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
169
-      if ( ! $element ) {
168
+    public function display_element($element, &$children_elements, $max_depth, $depth, $args, &$output) {
169
+      if ( ! $element) {
170 170
         return; }
171 171
       $id_field = $this->db_fields['id'];
172 172
       // Display this element.
173
-      if ( is_object( $args[0] ) ) {
174
-        $args[0]->has_children = ! empty( $children_elements[ $element->$id_field ] ); }
175
-      parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
173
+      if (is_object($args[0])) {
174
+        $args[0]->has_children = ! empty($children_elements[$element->$id_field]); }
175
+      parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output);
176 176
     }
177 177
 
178 178
     /**
@@ -185,8 +185,8 @@  discard block
 block discarded – undo
185 185
      *
186 186
      * @param array $args passed from the wp_nav_menu function.
187 187
      */
188
-    public static function fallback( $args ) {
189
-      if ( current_user_can( 'edit_theme_options' ) ) {
188
+    public static function fallback($args) {
189
+      if (current_user_can('edit_theme_options')) {
190 190
 
191 191
         /* Get Arguments. */
192 192
         $container = $args['container'];
@@ -197,29 +197,29 @@  discard block
 block discarded – undo
197 197
 
198 198
         $fb_output_safe = '';
199 199
         
200
-        if ( $container ) {
201
-          $fb_output_safe .= '<' . esc_attr( $container );
202
-          if ( $container_id ) {
203
-            $fb_output_safe .= ' id="' . esc_attr( $container_id ) . '"';
200
+        if ($container) {
201
+          $fb_output_safe .= '<' . esc_attr($container);
202
+          if ($container_id) {
203
+            $fb_output_safe .= ' id="' . esc_attr($container_id) . '"';
204 204
           }
205
-          if ( $container_class ) {
206
-            $fb_output_safe .= ' class="' . sanitize_html_class( $container_class ) . '"'; }
205
+          if ($container_class) {
206
+            $fb_output_safe .= ' class="' . sanitize_html_class($container_class) . '"'; }
207 207
           $fb_output_safe .= '>';
208 208
         }
209 209
         $fb_output_safe .= '<ul';
210
-        if ( $menu_id ) {
211
-          $fb_output_safe .= ' id="' . esc_attr( $menu_id ) . '"'; }
212
-        if ( $menu_class ) {
213
-          $fb_output_safe .= ' class="' . esc_attr( $menu_class ) . '"'; }
210
+        if ($menu_id) {
211
+          $fb_output_safe .= ' id="' . esc_attr($menu_id) . '"'; }
212
+        if ($menu_class) {
213
+          $fb_output_safe .= ' class="' . esc_attr($menu_class) . '"'; }
214 214
         $fb_output_safe .= '>';
215
-        $fb_output_safe .= '<li><a href="' . esc_url( admin_url( 'nav-menus.php' ) ) . '" title="">' . esc_attr( 'Add a menu', '' ) . '</a></li>';
215
+        $fb_output_safe .= '<li><a href="' . esc_url(admin_url('nav-menus.php')) . '" title="">' . esc_attr('Add a menu', '') . '</a></li>';
216 216
         $fb_output_safe .= '</ul>';
217
-        if ( $container ) {
218
-          $fb_output_safe .= '</' . esc_attr( $container ) . '>'; }
217
+        if ($container) {
218
+          $fb_output_safe .= '</' . esc_attr($container) . '>'; }
219 219
       }
220 220
       
221 221
       // if echo, echo, otherwise return
222
-      if ( $args['echo'] ):
222
+      if ($args['echo']):
223 223
         echo $fb_output_safe;
224 224
       else:
225 225
         return $fb_output_safe;
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -131,11 +131,15 @@  discard block
 block discarded – undo
131 131
                 $pos = strpos( esc_attr( $item->attr_title ), 'glyphicon' );
132 132
           if ( false !== $pos ) :
133 133
             $item_output .= '<a' . $attributes . '><span class="glyphicon ' . esc_attr( $item->attr_title ) . '" aria-hidden="true"></span>&nbsp;';
134
-                else :
134
+                else {
135
+                	:
135 136
                   $item_output .= '<a' . $attributes . '><i class="fa ' . esc_attr( $item->attr_title ) . '" aria-hidden="true"></i>&nbsp;';
137
+                }
136 138
                       endif;
137
-        else :
139
+        else {
140
+        	:
138 141
           $item_output .= '<a' . $attributes . '>';
142
+        }
139 143
         endif;
140 144
         $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
141 145
         $item_output .= ( $args->has_children && 0 === $depth ) ? ' <span class="caret"></span></a>' : '</a>';
@@ -221,8 +225,10 @@  discard block
 block discarded – undo
221 225
       // if echo, echo, otherwise return
222 226
       if ( $args['echo'] ):
223 227
         echo $fb_output_safe;
224
-      else:
228
+      else {
229
+      	:
225 230
         return $fb_output_safe;
231
+      }
226 232
       endif;   
227 233
 
228 234
 
Please login to merge, or discard this patch.