{"id":3485,"date":"2014-03-25T21:56:22","date_gmt":"2014-03-25T21:56:22","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/25\/saving-widget-gets-an-undefined-variable-collection-of-common-programming-errors\/"},"modified":"2014-03-25T21:56:22","modified_gmt":"2014-03-25T21:56:22","slug":"saving-widget-gets-an-undefined-variable-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/25\/saving-widget-gets-an-undefined-variable-collection-of-common-programming-errors\/","title":{"rendered":"Saving widget gets an undefined variable-Collection of common programming errors"},"content":{"rendered":"<p>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-&gt;widgets section.<\/p>\n<p><code>Notice: Undefined index: cached_feed1450-3 in D:\\Sites\\test.dev\\wordpress\\wp-admin\\includes\\ajax-actions.php on line 1578<\/code><\/p>\n<p>It looks to me that this may be a WordPress issue since that line is:<\/p>\n<pre><code>if ( $form = $wp_registered_widget_controls[$widget_id] )\n<\/code><\/pre>\n<p>I guess they need to check <code>isset<\/code><\/p>\n<p>I am pasting my widget here to make sure that this isn&#8217;t an issue with my widget but confirmation that this is a WordPress bug. I really hope its the latter&#8230;<\/p>\n<p>Thanks for you help is identifying this issue.<\/p>\n<p><strong>EDIT:<\/strong><\/p>\n<p>This error only happens on when saving a new widget. It only seems to happen with my widget. When editing it&#8217;s not an issue.<\/p>\n<p>I have a bootstrap for loading the plugin. I use this <code>add_action( 'widgets_init', array('BootStrap1450', 'addWidgets') );<\/code> in the<\/p>\n<pre><code>\/**\n * Initialize the BootStrap\n *\/\npublic static function init() {\n    require_once(A1450COM_LIBRARY_PATH.'Functions1450.php');\n\n    \/\/ Initialize proper components (do not put into a hook!)\n    if (is_admin()) {\n        require_once(A1450COM_LIBRARY_PATH.'BackEnd1450.php');\n    } else {\n        require_once(A1450COM_LIBRARY_PATH.'FrontEnd1450.php');\n        FrontEnd1450::init(); \/\/ Call manually\n    }\n\n    \/\/ Initiation of WP hook\n    add_action( 'init', array('BootStrap1450', 'initWP') );\n    add_action( 'widgets_init', array('BootStrap1450', 'addWidgets') );\n} \n<\/code><\/pre>\n<p>addWidgets is:<\/p>\n<pre><code>\/**\n * Adds widgets\n *\/\npublic static function addWidgets() {\n    include_once(A1450COM_WIDGETS_PATH.'CachedFeed1450.php');\n}\n<\/code><\/pre>\n<p>The widget file then follows:<\/p>\n<pre><code>\n        <br \/><\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3485","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3485","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=3485"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3485\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3485"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3485"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3485"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}