Deprecation in Smart Nav Walker with PHP 8.1

I see a few deprecation warnings on the wp_smart_navwalker.php in PHP 8.1. PHP 8.0 seems to be fine.

  • explode(): Passing null to parameter #2 ($string) of type string is deprecated
  • strrpos(): Passing null to parameter #1 ($haystack) of type string is deprecated
  • str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

@adamslowe this appears to be connected with some kind of issue with smart menu figuring out the template for the menu. Does this menu work? (I would not expect it to) I can take a look if you send me the source HTML with the Smart menu action and relevant generated PHP file.

@matjaz Yes, the menu appears to work correctly. I’ll make a simplified example and email the project/LocalWP site to support.

I just sent the email with a project and LocalWP site to support.

I also did a bit more digging, and the symptom occurs when I assign a multi-level menu in WordPress to a Pinegrow menu that doesn’t have the “Menu Item with Dropdown” set. On the front end, it looks fine and shows all the menu items on a single level, but it causes warnings in PHP 8.1+. It works as expected when I only assign a single-level menu.

Thanks Adam, this was helpful. I found and fixed that cause.

All the best, Matjaz

1 Like