Errore Strict Standards nel Bootstrap Navwalker
Sto avendo problemi a capire questo errore che non ho mai incontrato prima, qualcuno potrebbe aiutarmi?
Strict Standards: Declaration of wp_bootstrap_navwalker::start_lvl() should be compatible with Walker_Nav_Menu::start_lvl(&$output, $depth = 0, $args = Array) in .../wp-content/themes/flat-portfolio/wp_bootstrap_navwalker.php on line 143
Il codice di wp_bootstrap_navwalker.php è il seguente:
<?php
/**
* Nome Classe: wp_bootstrap_navwalker
* GitHub URI: https://github.com/twittem/wp-bootstrap-navwalker
* Descrizione: Una classe personalizzata di WordPress nav walker per implementare lo stile di navigazione Twitter Bootstrap 2.3.2 in un tema personalizzato usando il gestore menu integrato di WordPress.
* Versione: 1.4.3
* Autore: Edward McIntyre - @twittem
* Licenza: GPL-2.0+
* Licenza URI: http://www.gnu.org/licenses/gpl-2.0.txt
*/
class wp_bootstrap_navwalker extends Walker_Nav_Menu {
/**
* @see Walker::start_lvl()
* @since 3.0.0
*
* @param string $output Passato per riferimento. Usato per aggiungere contenuto aggiuntivo.
* @param int $depth Profondità della pagina. Usato per il padding.
*/
function start_lvl( &$output, $depth ) {
$indent = str_repeat( "\t", $depth );
$output .= "\n$indent<ul class=\"dropdown-menu\">\n";
}
/**
* @see Walker::start_el()
* @since 3.0.0
*
* @param string $output Passato per riferimento. Usato per aggiungere contenuto aggiuntivo.
* @param object $item Oggetto dati del menu item.
* @param int $depth Profondità del menu item. Usato per il padding.
* @param int $current_page ID del menu item.
* @param object $args
*/
function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
global $wp_query;
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
/**
* Divisori & Intestazioni
* ==================
* Determina se l'item è un Divisore, Intestazione o un normale menu item.
* Per prevenire errori usiamo la funzione strcasecmp() per un confronto
* che non sia case sensitive. La funzione strcasecmp() restituisce 0 se
* le stringhe sono uguali.
*/
if (strcasecmp($item->title, 'divider') == 0) {
// Item è un Divisore
$output .= $indent . '<li class="divider">';
} else if (strcasecmp($item->title, 'divider-vertical') == 0) {
// Item è un Divisore Verticale
$output .= $indent . '<li class="divider-vertical">';
} else if (strcasecmp($item->title, 'nav-header') == 0) {
// Item è un'Intestazione
$output .= $indent . '<li class="nav-header">' . esc_attr( $item->attr_title );
} else {
$class_names = $value = '';
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
$classes[] = ($item->current) ? 'active' : '';
$classes[] = 'menu-item-' . $item->ID;
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );
if ($args->has_children && $depth > 0) {
$class_names .= ' dropdown-submenu';
} else if($args->has_children && $depth === 0) {
$class_names .= ' dropdown';
}
$class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
$id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args );
$id = $id ? ' id="' . esc_attr( $id ) . '"' : '';
$output .= $indent . '<li' . $id . $value . $class_names .'>';
$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) ? ' data-toggle="dropdown" data-target="#" class="dropdown-toggle"' : '';
$item_output = $args->before;
/**
* Glyphicons
* ===========
* Poiché l'item del menu NON è un Divisore o Intestazione controlliamo
* se c'è un valore nella proprietà attr_title. Se la proprietà attr_title
* NON è null la applichiamo come nome classe per il glyphicon.
*/
if(! empty( $item->attr_title )){
$item_output .= '<a'. $attributes .'><i class="' . esc_attr( $item->attr_title ) . '"></i> ';
} 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->after;
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
}
}
/**
* Attraversa gli elementi per creare una lista dagli elementi.
*
* Mostra un elemento se l'elemento non ha figli, altrimenti,
* mostra l'elemento e i suoi figli. Attraverserà solo fino alla massima
* profondità e ignorerà elementi sotto quella profondità.
*
* Questo metodo non dovrebbe essere chiamato direttamente, usa invece il metodo walk().
*
* @see Walker::start_el()
* @since 2.5.0
*
* @param object $element Oggetto dati
* @param array $children_elements Lista di elementi da continuare ad attraversare.
* @param int $max_depth Profondità massima da attraversare.
* @param int $depth Profondità dell'elemento corrente.
* @param array $args
* @param string $output Passato per riferimento. Usato per aggiungere contenuto aggiuntivo.
* @return null Null in caso di fallimento senza cambiamenti ai parametri.
*/
function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
if ( !$element ) {
return;
}
$id_field = $this->db_fields['id'];
// Mostra questo elemento
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);
}
}
?>
Sto chiamando il walker inserendo questo codice nel mio header.php
<?php
wp_nav_menu( array(
'menu' => 'top_menu',
'depth' => 2,
'container' => false,
'menu_class' => 'nav',
'fallback_cb' => 'wp_page_menu',
//Processa il menu nav usando il nostro custom nav walker
'walker' => new wp_bootstrap_navwalker())
);
?>
e registrando la funzione in functions.php:
// Registra il Custom Navigation Walker
require_once('wp_bootstrap_navwalker.php');

Significa che la dichiarazione del metodo start_lvl
in wp_bootstrap_navwalker
dovrebbe corrispondere alla dichiarazione del metodo in Walker_Nav_Menu
. Ma non corrisponde.
function start_lvl( &$output, $depth ) {
VS.
function start_lvl( &$output, $depth = 0, $args = array() ) {
Fai in modo che gli argomenti corrispondano esattamente e dovresti risolvere il problema.
Inoltre, probabilmente non dovresti usare il prefisso wp_
dato che il tuo codice non fa parte del Core.

La riga di definizione della tua classe che è:
class description_walker extends Walker_Nav_Menu { function start_el(&$output, $item, $depth, $args)
Dovrebbe essere modificata per includere il nuovo campo $id (e assegnare valori predefiniti agli altri parametri del metodo):
class description_walker extends Walker_Nav_Menu { function start_el(&$output, $item, $depth, $args, $id = 0)
Devi anche aggiornare la riga del filtro apply per includere il nuovo campo $id:
apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args, $id);

Non so se hai già trovato una soluzione a questo problema, ma anche io ho avuto un errore simile e quello che ho fatto è stato completamente diverso da questo. La soluzione che ho adottato è stata piuttosto semplice (anche se non sono sicuro che sia convenzionale).
Passo #1
Vai alla riga 172 del file "wp_bootstrap_navwalker.php" (che dovrebbe apparire così)
function fallback( $args ) {
if ( current_user_can( 'manage_options' ) ) {
Passo #2
Modifica quella riga con il codice qui sotto e dovresti avere un menu di navigazione funzionante
public static function fallback( $args ) {
if ( current_user_can( 'manage_options' ) ) {
Questo è tutto... Spero che funzioni anche per te!
