{"id":72586,"date":"2018-03-28T12:31:27","date_gmt":"2018-03-28T12:31:27","guid":{"rendered":"https:\/\/es.wordpress.org\/support\/topic\/error-en-el-function-walker_nav_menu-wordpress\/"},"modified":"2018-03-28T12:31:27","modified_gmt":"2018-03-28T12:31:27","slug":"error-en-el-function-walker_nav_menu-wordpress","status":"publish","type":"topic","link":"https:\/\/es.wordpress.org\/support\/topic\/error-en-el-function-walker_nav_menu-wordpress\/","title":{"rendered":"Error en el function Walker_Nav_Menu wordpress"},"content":{"rendered":"<p>Estoy intentando poner un men\u00fa personalizado con wordpress y estoy usando el Walker_Nav_Menu pero cuando pongo la funci\u00f3n me salta un cartel de<\/p>\n<p>Warning: Declaration of BootstrapNavMenuWalker::start_lvl(&amp;$output, $depth) should be compatible with Walker_Nav_Menu::start_lvl(&amp;$output, $depth = 0, $args = Array) in \/www\/qkstudiodemo.com\/htdocs\/camconnection\/web\/wp-content\/themes\/camconnection\/functions.php on line 212<\/p>\n<p>Por el momento se puede ver bien porque lo desahabilite pero cuando intento ponerlo se ve todo bien pero por encima me salta esa leyenda.<\/p>\n<p>class BootstrapNavMenuWalker extends Walker_Nav_Menu {<br \/>\n\tfunction start_lvl( &amp;$output, $depth ) {<br \/>\n\t\t$indent = str_repeat( \u00ab\\t\u00bb, $depth );<br \/>\n\t\t$submenu = ($depth &gt; 0) ? &#8216; sub-menu&#8217; : \u00bb;<br \/>\n\t\t$output\t   .= \u00ab\\n$indent&lt;ul class=\\\u00bbdropdown-menu$submenu depth_$depth\\\u00bb&gt;\\n\u00bb;<br \/>\n\t}<br \/>\n\tfunction start_el( &amp;$output, $item, $depth = 0, $args = array(), $id = 0 ) {<br \/>\n\t\t$indent = ( $depth ) ? str_repeat( \u00ab\\t\u00bb, $depth ) : \u00bb;<br \/>\n\t\t$li_attributes = \u00bb;<br \/>\n\t\t$class_names = $value = \u00bb;<br \/>\n\t\t$classes = empty( $item-&gt;classes ) ? array() : (array) $item-&gt;classes;<\/p>\n<p>\t\t\/\/ managing divider: add divider class to an element to get a divider before it.<br \/>\n\t\t$divider_class_position = array_search(&#8216;divider&#8217;, $classes);<br \/>\n\t\tif($divider_class_position !== false){<br \/>\n\t\t\t$output .= \u00ab&lt;li class=\\\u00bbdivider\\\u00bb&gt;<\/li>\n<p>\\n\u00bb;<br \/>\n\t\t\tunset($classes[$divider_class_position]);<br \/>\n\t\t}<\/p>\n<p>\t\t$classes[] = ($args-&gt;has_children) ? &#8216;dropdown&#8217; : \u00bb;<br \/>\n\t\t$classes[] = ($item-&gt;current || $item-&gt;current_item_ancestor) ? &#8216;active&#8217; : \u00bb;<br \/>\n\t\t$classes[] = &#8216;menu-item-&#8216; . $item-&gt;ID;<br \/>\n\t\tif($depth &amp;&amp; $args-&gt;has_children){<br \/>\n\t\t\t$classes[] = &#8216;dropdown-submenu&#8217;;<br \/>\n\t\t}<br \/>\n\t\t$class_names = join( &#8216; &#8216;, apply_filters( &#8216;nav_menu_css_class&#8217;, array_filter( $classes ), $item, $args ) );<br \/>\n\t\t$class_names = &#8216; class=\u00bb&#8216; . esc_attr( $class_names ) . &#8216;\u00bb&#8216;;<br \/>\n\t\t$id = apply_filters( &#8216;nav_menu_item_id&#8217;, &#8216;menu-item-&#8216;. $item-&gt;ID, $item, $args );<br \/>\n\t\t$id = strlen( $id ) ? &#8216; id=\u00bb&#8216; . esc_attr( $id ) . &#8216;\u00bb&#8216; : \u00bb;<br \/>\n\t\t$output .= $indent . &#8216;&lt;li&#8217; . $id . $value . $class_names . $li_attributes . &#8216;&gt;&#8217;;<br \/>\n\t\t$attributes  = ! empty( $item-&gt;attr_title ) ? &#8216; title=\u00bb&#8216;  . esc_attr( $item-&gt;attr_title ) .'\u00bb&#8216; : \u00bb;<br \/>\n\t\t$attributes .= ! empty( $item-&gt;target )     ? &#8216; target=\u00bb&#8216; . esc_attr( $item-&gt;target     ) .'\u00bb&#8216; : \u00bb;<br \/>\n\t\t$attributes .= ! empty( $item-&gt;xfn )        ? &#8216; rel=\u00bb&#8216;    . esc_attr( $item-&gt;xfn        ) .'\u00bb&#8216; : \u00bb;<br \/>\n\t\t$attributes .= ! empty( $item-&gt;url )        ? &#8216; href=\u00bb&#8216;   . esc_attr( $item-&gt;url        ) .'\u00bb&#8216; : \u00bb;<br \/>\n\t\t$attributes .= ($args-&gt;has_children) \t    ? &#8216; class=\u00bbdropdown-toggle\u00bb data-toggle=\u00bbdropdown\u00bb&#8216; : \u00bb;<br \/>\n\t\t$item_output = $args-&gt;before;<br \/>\n\t\t$item_output .= &#8216;&lt;a&#8217;. $attributes .&#8217;&gt;&#8217;;<br \/>\n\t\t$item_output .= $args-&gt;link_before . apply_filters( &#8216;the_title&#8217;, $item-&gt;title, $item-&gt;ID ) . $args-&gt;link_after;<br \/>\n\t\t$item_output .= ($depth == 0 &amp;&amp; $args-&gt;has_children) ? &#8216; &lt;b class=\u00bbcaret\u00bb&gt;&lt;\/b&gt;<\/a>&#8216; : &#8216;<\/a>&#8216;;<br \/>\n\t\t$item_output .= $args-&gt;after;<br \/>\n\t\t$output .= apply_filters( &#8216;walker_nav_menu_start_el&#8217;, $item_output, $item, $depth, $args );<br \/>\n\t}<\/p>\n<p>\tfunction display_element( $element, &amp;$children_elements, $max_depth, $depth=0, $args, &amp;$output ) {<br \/>\n\t\t\/\/v($element);<br \/>\n\t\tif ( !$element )<br \/>\n\t\t\treturn;<br \/>\n\t\t$id_field = $this-&gt;db_fields[&#8216;id&#8217;];<br \/>\n\t\t\/\/display this element<br \/>\n\t\tif ( is_array( $args[0] ) )<br \/>\n\t\t\t$args[0][&#8216;has_children&#8217;] = ! empty( $children_elements[$element-&gt;$id_field] );<br \/>\n\t\telse if ( is_object( $args[0] ) )<br \/>\n\t\t\t$args[0]-&gt;has_children = ! empty( $children_elements[$element-&gt;$id_field] );<br \/>\n\t\t$cb_args = array_merge( array(&amp;$output, $element, $depth), $args);<br \/>\n\t\tcall_user_func_array(array(&amp;$this, &#8216;start_el&#8217;), $cb_args);<br \/>\n\t\t$id = $element-&gt;$id_field;<br \/>\n\t\t\/\/ descend only when the depth is right and there are childrens for this element<br \/>\n\t\tif ( ($max_depth == 0 || $max_depth &gt; $depth+1 ) &amp;&amp; isset( $children_elements[$id]) ) {<br \/>\n\t\t\tforeach( $children_elements[ $id ] as $child ){<br \/>\n\t\t\t\tif ( !isset($newlevel) ) {<br \/>\n\t\t\t\t\t$newlevel = true;<br \/>\n\t\t\t\t\t\/\/start the child delimiter<br \/>\n\t\t\t\t\t$cb_args = array_merge( array(&amp;$output, $depth), $args);<br \/>\n\t\t\t\t\tcall_user_func_array(array(&amp;$this, &#8216;start_lvl&#8217;), $cb_args);<br \/>\n\t\t\t\t}<br \/>\n\t\t\t\t$this-&gt;display_element( $child, $children_elements, $max_depth, $depth + 1, $args, $output );<br \/>\n\t\t\t}<br \/>\n\t\t\tunset( $children_elements[ $id ] );<br \/>\n\t\t}<br \/>\n\t\tif ( isset($newlevel) &amp;&amp; $newlevel ){<br \/>\n\t\t\t\/\/end the child delimiter<br \/>\n\t\t\t$cb_args = array_merge( array(&amp;$output, $depth), $args);<br \/>\n\t\t\tcall_user_func_array(array(&amp;$this, &#8216;end_lvl&#8217;), $cb_args);<br \/>\n\t\t}<br \/>\n\t\t\/\/end this element<br \/>\n\t\t$cb_args = array_merge( array(&amp;$output, $element, $depth), $args);<br \/>\n\t\tcall_user_func_array(array(&amp;$this, &#8216;end_el&#8217;), $cb_args);<br \/>\n\t}<br \/>\n}<\/p>\n<p>\t &lt;?php<br \/>\n                 $args = array(<br \/>\n                   &#8216;theme_location&#8217; =&gt; &#8216;principal-menu&#8217;,<br \/>\n                   &#8216;container&#8217; =&gt; \u00bb,<br \/>\n                   &#8216;menu_class&#8217; =&gt; &#8216;nav navbar-nav pull-right&#8217;,<br \/>\n                   &#8216;menu_id&#8217; =&gt; &#8216;nav&#8217;,<br \/>\n                   &#8216;walker&#8217;\t =&gt; new BootstrapNavMenuWalker()<br \/>\n                   );<br \/>\n                   wp_nav_menu( $args );<\/p>\n<p>            ?&gt;<br \/>\nEste es el c\u00f3digo que implemente para usarlo.<\/p>\n","protected":false},"template":"","class_list":["post-72586","topic","type-topic","status-publish","hentry","topic-tag-php"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/es.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/72586","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/es.wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/es.wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/es.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/72586\/revisions"}],"wp:attachment":[{"href":"https:\/\/es.wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=72586"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}