Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Menu error when not assigned #1

Open
vyskoczilova opened this issue Feb 22, 2024 · 0 comments
Open

Menu error when not assigned #1

vyskoczilova opened this issue Feb 22, 2024 · 0 comments

Comments

@vyskoczilova
Copy link

$menu_3 = $this->menu_repository->get( Plugin::FOOTER_MENU_3 );

The footer menu is not assigned; it returns fatal:

Call to a member function source() on null [search►](https://www.google.com/search?sourceid=tracy&q=Error+Call+to+a+member+function+source%28%29+on+null)
File: [.../gutenberg-kemiex-landing/vendor/wpify/model/src/MenuRepository.php:72](phpstorm://open?file=%2FUsers%2Fmejta%2Fsites%2Fgutenberg-kemiex-landing%2Fvendor%2Fwpify%2Fmodel%2Fsrc%2FMenuRepository.php&line=72)

62:            if ( is_string( $source ) && in_array( $source, array_keys( $this->menu_locations ) ) ) {
63:                $wp_menu = wp_get_nav_menu_object( $this->menu_locations[ $source ] );
64:            }
65:    
66:            if ( $wp_menu ) {
67:                $menu = parent::get( $wp_menu );
68:            } else {
69:                $term = parent::get( $source );
70:                $menu = $term ? new $model_class( $this->manager() ) : null;
71:    
72:                $menu->source( $term->source() );

73:            }
74:    
75:            return $menu;
76:        }

Current solution is check has_nav_menu() before, but you might want to fix it (or I'm not using it the right way)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant