WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Strict Standards: Declaration of ... should be compatible with ... (12 posts)

  1. Regis-rf
    Member
    Posted 10 months ago #

    Hello guys,

    Someone could help me with this problem?
    The problem is, I have this theme, link here. and I'm getting this error:

    Strict Standards: Declaration of description_walker::start_el() should be compatible with Walker_Nav_Menu::start_el(&$output, $item, $depth = 0, $args = Array, $id = 0) in C:\xampp\htdocs\wordpress\wp-content\themes\bismuth\functions.php on line 278

    about the part of functions.php

    function register_menus() {
    register_nav_menus( array( 'top-menu' => 'Top primary menu')
                        );
    
    } add_action('init', 'register_menus');
    
    class description_walker extends Walker_Nav_Menu { function start_el(&$output, $item, $depth, $args) { global $wp_query; $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
    
           $class_names = $value = '';
    
           $classes = empty( $item->classes ) ? array() : (array) $item->classes;
    
           $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
           $class_names = ' class="'. esc_attr( $class_names ) . '"';
    
           $output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';
    
           $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';
           $attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';
           $attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';
           if($item->object == 'page')
           {
                $varpost = get_post($item->object_id);
                $attributes .= ' href="' . get_site_url() . '#' . $varpost->post_name . '"';
           }
           else
                $attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';
            $item_output = $args->before;
            $item_output .= '<a'. $attributes .'>';
            $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID );
            $item_output .= $args->link_after;
            $item_output .= '</a>';
            $item_output .= $args->after;
    
            $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
            }
    
    }

    Thanks a lot!

  2. WPyogi
    Volunteer Moderator
    Posted 10 months ago #

    Have you asked the developer of the theme about this issue?

    http://themeforest.net/item/bismuth-all-in-one-responsive-template/4259375

    Commercial themes aren't supported on these forums - partly because we don't have access to them, so the developer would be your best place for theme questions or problems.

  3. Regis-rf
    Member
    Posted 10 months ago #

    Hi WPyogi,
    Thanks for the help.

    I'm the author of this theme :D

    The link you sent is the html version I developed a version of WordPress, the theme works perfectly, but with the WP_Debug on, I got this error, and I need to solve it.

    Anyone else could help me? :(

  4. nopuck4you
    Member
    Posted 9 months ago #

    The issue is easily fixed. The error actually tells you how to match your function to the underlying WordPress one.

    Your class definition line which is:

    class description_walker extends Walker_Nav_Menu { function start_el(&$output, $item, $depth, $args)

    Should be modified to include the new $id field (and assign defaults to your other method parameters:

    class description_walker extends Walker_Nav_Menu { function start_el(&$output, $item, $depth, $args, $id = 0)

    You also need to update the apply filter line to include the new $id field:

    apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args, $id);

  5. emregan
    Member
    Posted 8 months ago #

    nopuck4you - thank you for the tip - this fixed our issue.

    In case this helps anybody, one of my colleagues is using the Themeforest "Origami" theme. The menu suddenly stopped working. I had to make the above change to this file: origami/function_includes/theme-common-elements.php

    I changed line 136
    from function start_el($output, $item, $depth, $args) {
    to function start_el(&$output, $item, $depth, $args, $id = 0) {

    and line 155
    from $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
    to $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args, $id);

    and Voila! Menus have returned.

  6. sethtipton
    Member
    Posted 6 months ago #

    I am having a similar problem with a little different piece of code. I am getting this error:

    Strict Standards: Declaration of primary::start_el() should be compatible with Walker_Nav_Menu::start_el(&$output, $item, $depth = 0, $args = Array, $id = 0) in /home6/boondoc7/public_html/bw/wp-content/themes/twentythirteen/functions.php on line 771

    class primary extends Walker_Nav_Menu {
    	function start_el (&$output, $item, $depth, $args, $id = 0) {
    	    global $wp_query;
    
    	    $indent = ( $depth ) ? str_repeat( "", $depth ) : '';
    
    	    $class_names = $value = '';
    
    	    $classes = empty( $item->classes ) ? array() : (array) $item->classes;
    
    	    $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
    	    $class_names = ' class="' . esc_attr( $class_names ) . '"';
    
    	    $output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';
    
    	    $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';
    	    $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        ) .'"' : '';
    
    	    // get user defined attributes for thumbnail images
    	    $attr_defaults = array( 'class' => 'nav_thumb' , 'alt' => esc_attr( $item->attr_title ) , 'title' => esc_attr( $item->attr_title ) );
    	    $attr = isset( $args->thumbnail_attr ) ? $args->thumbnail_attr : '';
    	    $attr = wp_parse_args( $attr , $attr_defaults );
    
    	    $item_output = $args->before;
    	     $item_output .= '<a'. $attributes .'>';
    	    if($depth == 1){
    	    // thumbnail image output
    	    $item_output .= ( isset( $args->thumbnail_link ) && $args->thumbnail_link ) ? '<a' . $attributes . '>' : '';
    	    $item_output .= apply_filters( 'menu_item_thumbnail' , ( isset( $args->thumbnail ) && $args->thumbnail ) ? get_the_post_thumbnail( $item->object_id , ( isset( $args->thumbnail_size ) ) ? $args->thumbnail_size : 'thumbnail' , $attr ) : '' , $item , $args , $depth );
    	    $item_output .= ( isset( $args->thumbnail_link ) && $args->thumbnail_link ) ? '</a>' : '';
    	    }
    	    // menu link output
    
    	    $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
    
    	    // menu description output based on depth
    	    //$item_output .= ( $args->desc_depth >= $depth ) ? '<br /><span class="sub">' . $item->description . '</span>' : '';
    
    	    // close menu link anchor
    	    $item_output .= '</a>';
    	    $item_output .= $args->after;
    
    	    $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args, $id );
    	}
    }
    add_filter( 'wp_nav_menu_args' , 'my_add_menu_descriptions' );
    function my_add_menu_descriptions( $args ) {
        $args['walker'] = new primary;
        $args['desc_depth'] = 1;
        $args['thumbnail'] = true;
        $args['thumbnail_link'] = false;
        $args['thumbnail_size'] = 'nav-thumb';
        $args['thumbnail_attr'] = array( 'class' => 'nav_thumb my_thumb' , 'alt' => 'test' , 'title' => 'test' );
    
        return $args;
    }
  7. ptiswitz
    Member
    Posted 6 months ago #

    You've got this kind of error because you run PHP in a strict mode.

    Strict mode imply to class inheritance that a child function must have the same declaration that his parent.

    The following example will throw a strict error :

    class A {
       function foo($bar = 0) {}
    }
    
    class B extends A {
       function foo($bar) {}
    }

    The foo function of class B must be like that :

    class B extends A {
       function foo($bar = 0) {}
    }

    For your case, you've to copy the exact declaration written in the Walker class file to fix that.

  8. leslied
    Member
    Posted 2 months ago #

    I can not log in to my account with the wp-admin. When I do, I get this message. PLEASE HELP!!!

    Strict Standards: Declaration of EM_Booking::can_manage() should be compatible with EM_Object::can_manage($owner_capability = false, $admin_capability = false, $user_to_check = false) in /home3/leslied/public_html/strutthemovement.com/wp-content/plugins/events-manager/classes/em-booking.php on line 1085

    Strict Standards: Declaration of EM_Bookings::get_default_search() should be compatible with EM_Object::get_default_search($defaults = Array, $array = Array) in /home3/leslied/public_html/strutthemovement.com/wp-content/plugins/events-manager/classes/em-bookings.php on line 7

    Strict Standards: Declaration of EM_Calendar::get_default_search() should be compatible with EM_Object::get_default_search($defaults = Array, $array = Array) in /home3/leslied/public_html/strutthemovement.com/wp-content/plugins/events-manager/classes/em-calendar.php on line 413

    Strict Standards: Declaration of EM_Category::can_manage() should be compatible with EM_Object::can_manage($owner_capability = false, $admin_capability = false, $user_to_check = false) in /home3/leslied/public_html/strutthemovement.com/wp-content/plugins/events-manager/classes/em-category.php on line 282

    Strict Standards: Declaration of EM_Category::get_image_url() should be compatible with EM_Object::get_image_url($size = 'full') in /home3/leslied/public_html/strutthemovement.com/wp-content/plugins/events-manager/classes/em-category.php on line 282

    Strict Standards: Declaration of EM_Walker_Category::start_el() should be compatible with Walker::start_el(&$output, $object, $depth = 0, $args = Array, $current_object_id = 0) in /home3/leslied/public_html/strutthemovement.com/wp-content/plugins/events-manager/classes/em-category-taxonomy.php on line 152

    Strict Standards: Non-static method EM_Category_Taxonomy::init() should not be called statically in /home3/leslied/public_html/strutthemovement.com/wp-content/plugins/events-manager/classes/em-category-taxonomy.php on line 103

    Strict Standards: Declaration of EM_Categories::get_default_search() should be compatible with EM_Object::get_default_search($defaults = Array, $array = Array) in /home3/leslied/public_html/strutthemovement.com/wp-content/plugins/events-manager/classes/em-categories.php on line 2

    Strict Standards: Non-static method EM_Event_Post::init() should not be called statically in /home3/leslied/public_html/strutthemovement.com/wp-content/plugins/events-manager/classes/em-event-post.php on line 337

    Strict Standards: Declaration of EM_Events::get_default_search() should be compatible with EM_Object::get_default_search($defaults = Array, $array = Array) in /home3/leslied/public_html/strutthemovement.com/wp-content/plugins/events-manager/classes/em-events.php on line 440

    Strict Standards: Declaration of EM_Events::get_post_search() should be compatible with EM_Object::get_post_search($args = Array, $filter = false, $request = Array) in /home3/leslied/public_html/strutthemovement.com/wp-content/plugins/events-manager/classes/em-events.php on line 440

    Strict Standards: Declaration of EM_Events::can_manage() should be compatible with EM_Object::can_manage($owner_capability = false, $admin_capability = false, $user_to_check = false) in /home3/leslied/public_html/strutthemovement.com/wp-content/plugins/events-manager/classes/em-events.php on line 440

    Strict Standards: Non-static method EM_Location_Post::init() should not be called statically in /home3/leslied/public_html/strutthemovement.com/wp-content/plugins/events-manager/classes/em-location-post.php on line 104

    Strict Standards: Declaration of EM_Locations::get_default_search() should be compatible with EM_Object::get_default_search($defaults = Array, $array = Array) in /home3/leslied/public_html/strutthemovement.com/wp-content/plugins/events-manager/classes/em-locations.php on line 314

    Strict Standards: Non-static method EM_Permalinks::init() should not be called statically in /home3/leslied/public_html/strutthemovement.com/wp-content/plugins/events-manager/classes/em-permalinks.php on line 262

    Strict Standards: Non-static method EM_Tag_Taxonomy::init() should not be called statically in /home3/leslied/public_html/strutthemovement.com/wp-content/plugins/events-manager/classes/em-tag-taxonomy.php on line 103

    Strict Standards: Declaration of EM_Tags::get_default_search() should be compatible with EM_Object::get_default_search($defaults = Array, $array = Array) in /home3/leslied/public_html/strutthemovement.com/wp-content/plugins/events-manager/classes/em-tags.php on line 2

    Strict Standards: Declaration of EM_Ticket_Booking::can_manage() should be compatible with EM_Object::can_manage($owner_capability = false, $admin_capability = false, $user_to_check = false) in /home3/leslied/public_html/strutthemovement.com/wp-content/plugins/events-manager/classes/em-ticket-booking.php on line 245

    Strict Standards: Declaration of EM_Ticket::can_manage() should be compatible with EM_Object::can_manage($owner_capability = false, $admin_capability = false, $user_to_check = false) in /home3/leslied/public_html/strutthemovement.com/wp-content/plugins/events-manager/classes/em-ticket.php on line 489

    Strict Standards: Declaration of EM_Tickets_Bookings::get_default_search() should be compatible with EM_Object::get_default_search($defaults = Array, $array = Array) in /home3/leslied/public_html/strutthemovement.com/wp-content/plugins/events-manager/classes/em-tickets-bookings.php on line 7

    Strict Standards: Non-static method EM_Scripts_and_Styles::init() should not be called statically in /home3/leslied/public_html/strutthemovement.com/wp-content/plugins/events-manager/events-manager.php on line 418

  9. Ignacio Atencia
    Member
    Posted 1 month ago #

    Child function must have the same declaration.
    This is de current parent declaration:

    start_el( &$output, $object, $depth = 0, $args = array(), $current_object_id = 0 )

  10. niren
    Member
    Posted 3 weeks ago #

    Hi this is the code from the theme that is giving me similar problems and error message i changed it to match the code above but that work for me any suggestions?

    ERROR:
    Strict standards: Declaration of DCC_WPMenuCustomWalker::start_el() should be compatible with Walker::start_el(&$output, $object, $depth = 0, $args = Array, $current_object_id = 0) in C:\wamp\www\DavisLife\wp-content\themes\dl\cms\php\cp_classes.php

    CODE:
    class DCC_WPMenuCustomWalker extends Walker_Nav_Menu
    {
    function start_el(&$output, $item, $depth, $args, $id = 0)
    {
    global $wp_query;
    $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
    $class_names = $value = '';
    $classes = empty( $item->classes ) ? array() : (array) $item->classes;
    // $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
    $class_names = '';
    $output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';
    $attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
    $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 ) .'"' : '';
    $item_output = $args->before;

    $a_classes = '';
    if($depth == 0) { $a_classes = ' class="top" '; }
    $item_output .= '';
    $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
    $item_output .= '
    ';
    $item_output .= $args->after;
    $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args, $id);
    }
    }

  11. niren
    Member
    Posted 3 weeks ago #

    Never mind I fixed it thank you though!

  12. Ferdows
    Member
    Posted 2 days ago #

    Hello #niren How to fixed it you. Do you share it with us?

Reply

You must log in to post.

About this Topic