WP SITES

3086 Coded Tutorials & 291 Plugins

Bug Fix – Genesis Featured Content Widget – Fatal error: Call to undefined function genesis_get_option()

The Genesis sandbox featured content widget ( plugin ) by Travis Smith can only be activated when Genesis is active. However, if you have already successfully activated the plugin, after activating Genesis, you can cause a fatal error if you change to a different parent theme like Twenty Sixteen.

To fix this, the plugin needs an additional check added on line 87 of genesis-featured-content-widget/gs-featured-content-widget.php

/** require Genesis */
if ( ! function_exists( 'genesis_get_option' ) ) {
    return;
}

Now the entire function will look like this:

add_action( 'widgets_init', 'gsfc_widgets_init', 50 );
/**
 * Register GSFC for use in the Genesis theme.
 *
 * @since 1.1.0
 */
function gsfc_widgets_init() {
    if ( class_exists( 'Premise_Base' ) && !is_admin() ) {
        return;
    }
    
    /** require Genesis */
	if ( ! function_exists( 'genesis_get_option' ) ) {
		return;
	}
		
    $gfwa = genesis_get_option( 'gsfc_gfwa' );
    if ( class_exists( 'Genesis_Featured_Widget_Amplified' ) && $gfwa ) {
        unregister_widget( 'Genesis_Featured_Widget_Amplified' );
    }
    register_widget( 'GS_Featured_Content' );
}

Otherwise, you’ll get the following fatal error message:

Fatal error: Call to undefined function genesis_get_option() in genesis-featured-content-widget/gs-featured-content-widget.php on line 92

fatal-error

This bug fix relates to resolving this question on the StudioPress community forums.

You can download the latest version of the Genesis Sandbox Featured Content Widget from WordPress.org

Leave a Reply

New Plugins