Support » Plugin: If Menu - Visibility control for Menu Items » Incorrectly calling a filter

  • Resolved joelworsham

    (@joelworsham)


    On line 36 of the main plugin file, you have the following line of code:

    
    self::$has_custom_walker = 'Walker_Nav_Menu_Edit' !== apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit' );
    

    I’m not certain calling apply_filters() in this way is best, but if you are going to do it, you need to send a 2nd parameter through, as that is what other plugins expect. The second parameter should be a menu ID. You can see that in the documentation for the filter within WordPress core:

    
    /**
     * Filters the Walker class used when adding nav menu items.
     *
     * @since 3.0.0
     *
     * @param string $class   The walker class to use. Default 'Walker_Nav_Menu_Edit'.
     * @param int    $menu_id ID of the menu being rendered.
     */
    

    So, again, if you’re not calling this filter for a specific menu ID, you’re probably not doing it right. But, if this is going to be done, please send a second parameter, even if it is null.

    Thanks!

    • This topic was modified 2 years ago by  joelworsham.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Any reply from the developer?

    I need this functionality but afford any conflicts.

    Plugin Author Andrei Igna

    (@andreiigna)

    Hi Joel,

    Thanks for letting me know about this.

    This code was used to detect if the Walker has been modified, but I saw it’s not so good and even cause problems. This has been removed in the latest version of the plugin, and the conflict notice is done differently now.

    Cheers

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Incorrectly calling a filter’ is closed to new replies.