• Resolved teeboy4real

    (@teeboy4real)


    Hello,

    I found this error in my debug.log file I don’t know what it really means kindly fix

    Fatal error: Uncaught Error: Call to a member function get() on bool in /home/—/public_html/wp-content/plugins/menu-icons/includes/settings.php:694 Stack trace: #0 /home/—/public_html/wp-includes/class-wp-hook.php(286): Menu_Icons_Settings::_enqueue_assets(‘nav-menus.php’) #1 /home/—/public_html/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array) #2 /home/—/public_html/wp-includes/plugin.php(465): WP_Hook->do_action(Array) #3 /home/—/public_html/wp-admin/admin-header.php(99): do_action(‘admin_enqueue_s…’, ‘nav-menus.php’) #4 /home/—/public_html/wp-admin/nav-menus.php(600): require_once(‘/home/—/…’) #5 {main} thrown in /home/—/public_html/wp-content/plugins/menu-icons/includes/settings.php on line 694

    Thanks

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support Poonam Namdev

    (@poonam9)

    Hello @teeboy4real

    Sorry for the delay in response.

    Please make sure you are using the latest version of the plugin and WordPress.

    I have the latest version of Menu Icons and WordPress and I get the “The site is experiencing technical difficulties. Please check your site admin email inbox for instructions.” error when trying to view the /wp-admin/nav-menus.php page of my site. Btw, this is actually a fatal error so I cannot use the Menu editor with the plugin enabled with the current state of things.

    Enabling WP_DEBUG has the very same/similar notice that @teeboy4real has included here.

    What was the solution for this, or is there a fix still in the works for this?

    I found that it could be caused by a misconfigured parent/child theme setup.

    The code that can have trouble is in includes/settings.php:

    
    $menu_current_theme = '';
    $theme              = wp_get_theme();
    if ( ! empty( $theme ) ) {
    	if ( is_child_theme() ) {
    		$menu_current_theme = $theme->parent()->get( 'Name' );
    	} else {
    		$menu_current_theme = $theme->get( 'Name' );
    	}
    }
    

    As https://codex.www.ads-software.com/Class_Reference/WP_Theme#Methods mentions, the parent() method on wp_get_theme() returns false if no parent is available. Somehow, is_child_theme() is returning true while wp_get_theme()->parent() is returning false. Therefore, trying to run ->get( ‘Name’ ); on a false return isn’t possible & results in this error.

    I know the theme setup should be revisited to prevent this issue, but sometimes that isn’t possible (someone without code experience is using a theme where this is a problem and the theme isn’t being udpated, etc.) As such, it seems like this could/should be implemented to simply prevent this issue even when it’s mostly on the theme setup’s end.

    
    $menu_current_theme = '';
    $theme              = wp_get_theme();
    if ( ! empty( $theme ) ) {
    	if ( is_child_theme() && $theme->parent() ) {
    		$menu_current_theme = $theme->parent()->get( 'Name' );
    	} else {
    		$menu_current_theme = $theme->get( 'Name' );
    	}
    }
    

    I can confirm that adding && $theme->parent() to the existing is_child_theme() fixes this potential error.

    I’ve submitted this as a PR on GitHub at: https://github.com/Codeinwp/wp-menu-icons/pull/154

    So, besides editing the plugin, will the author provide an update?

    @mbzo2006 I’m unaware of a workaround other than making this code update to accommodate the condition of this issue.

    I might also recommend reaching out via https://github.com/Codeinwp/wp-menu-icons/pull/154 (the official GitHub repo for this plugin) and stating your interest in having this solution officially implemented in a future version update for this plugin.

    That being said, I am wondering what would be causing is_child_theme() to return true while wp_get_theme()->parent() returns false (causing this error). Please send what you find if you happen to come across a reason for this and/or a fix for this condition.

    @poonam9 Any update on your end of things? It seems like a pretty straightforward issue and proposed fix with a PR having been submitted while it’s been a few months without a follow-up response on the matter.

    • This reply was modified 5 years, 1 month ago by KZeni. Reason: Added message for @poonam9 regarding the status of things
    Thread Starter teeboy4real

    (@teeboy4real)

    This problem is still not fixed with the latest update

    @teeboy4real I see the patch has been merged into the plugin on GitHub so I’d expect it to be resolved in the next version update.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Debug error’ is closed to new replies.