Saving widget gets an undefined variable-Collection of common programming errors
I am developing a widget for cached feeds. The widget itself works exactly as I want but I noticed that if I were to delete the widget and then add a new one (or simply just add a new one) on the first save I get an undefined variable error. This is in the admin Appearence->widgets section.
Notice: Undefined index: cached_feed1450-3 in D:\Sites\test.dev\wordpress\wp-admin\includes\ajax-actions.php on line 1578
It looks to me that this may be a WordPress issue since that line is:
if ( $form = $wp_registered_widget_controls[$widget_id] )
I guess they need to check isset
I am pasting my widget here to make sure that this isn’t an issue with my widget but confirmation that this is a WordPress bug. I really hope its the latter…
Thanks for you help is identifying this issue.
EDIT:
This error only happens on when saving a new widget. It only seems to happen with my widget. When editing it’s not an issue.
I have a bootstrap for loading the plugin. I use this add_action( 'widgets_init', array('BootStrap1450', 'addWidgets') );
in the
/**
* Initialize the BootStrap
*/
public static function init() {
require_once(A1450COM_LIBRARY_PATH.'Functions1450.php');
// Initialize proper components (do not put into a hook!)
if (is_admin()) {
require_once(A1450COM_LIBRARY_PATH.'BackEnd1450.php');
} else {
require_once(A1450COM_LIBRARY_PATH.'FrontEnd1450.php');
FrontEnd1450::init(); // Call manually
}
// Initiation of WP hook
add_action( 'init', array('BootStrap1450', 'initWP') );
add_action( 'widgets_init', array('BootStrap1450', 'addWidgets') );
}
addWidgets is:
/**
* Adds widgets
*/
public static function addWidgets() {
include_once(A1450COM_WIDGETS_PATH.'CachedFeed1450.php');
}
The widget file then follows: