Multiple PHP Warning: Undefined property on inc/walker/menu-walker.php
-
Hi, I get infinite PHP warnings on the file inc/walker/menu-walker.php
Lines 98, 103, 211, 219 and 391
the lines check for undefined properties, I fixed them this way, line 98:[27-Oct-2023 20:52:29 UTC] PHP Warning: Undefined property: stdClass::$category_post in /home2/public_html/wp-content/themes/oceanwp/inc/walker/menu-walker.php on line 391 [27-Oct-2023 20:52:29 UTC] PHP Warning: Undefined property: stdClass::$category_post in /home2/public_html/wp-content/themes/oceanwp/inc/walker/menu-walker.php on line 98 [27-Oct-2023 20:52:29 UTC] PHP Warning: Undefined property: stdClass::$nolink in /home2/public_html/wp-content/themes/oceanwp/inc/walker/menu-walker.php on line 103 [27-Oct-2023 20:52:29 UTC] PHP Warning: Undefined property: stdClass::$template in /home2/public_html/wp-content/themes/oceanwp/inc/walker/menu-walker.php on line 211 [27-Oct-2023 20:52:29 UTC] PHP Warning: Undefined property: stdClass::$mega_template in /home2/public_html/wp-content/themes/oceanwp/inc/walker/menu-walker.php on line 211 [27-Oct-2023 20:52:29 UTC] PHP Warning: Undefined property: stdClass::$megamenu_widgetarea in /home2/public_html/wp-content/themes/oceanwp/inc/walker/menu-walker.php on line 219
if ( $item->category_post != '' && $item->object == 'category' && 'vertical' != oceanwp_header_style() ) {
changed into (first I check if it is a category, LATER if it is empty…
if ( $item->object == 'category' && $item->category_post != '' && 'vertical' != oceanwp_header_style() ) {
so on for the other lines, adding some isset() too, line 211, from:
if ( ( $item->template || $item->mega_template ) && $this->megamenu != '' && 'vertical' != oceanwp_header_style() ) {
to:
if ( ( (isset($item->template) && $item->template) || (isset($item->mega_template) && $item->mega_template) ) && $this->megamenu != '' && 'vertical' != oceanwp_header_style() ) {
and so on for the other lines…
I tried to add the modified menu-walker.php fine in my child theme under inc/walker, but it seems that works only if I override it in the parent theme. So please fix it to avoid the problem on future updates.
Thanks
Nadia
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Multiple PHP Warning: Undefined property on inc/walker/menu-walker.php’ is closed to new replies.