• When I copy the pb-embedFlash folder to my plugins directory, I get this fatal error:

    Fatal error: Call to undefined function: wp_register_sidebar_widget() in /*database-stuff*/wp-content/plugins/pb-embedflash/inc/inc.widgets.php on line 202

    This happens to me while I’m in WordPress 2.3.3. I realize that this is not yet officially compatible with 2.3.2, just giving a heads up. Good luck!

    http://wordpress.org/extend/plugins/pb-embedflash/

Viewing 12 replies - 1 through 12 (of 12 total)
  • I’ll check it.

    wp_register_sidebar_widget() is a core function since widgets are introduced in Version 2.2. As of …/plugins/pb-embedflash/inc/inc.widgets.php is required in …/plugins/pb-embedflash/pb-embedFlash.php and pb_embedFlash_widget_register is called after all plugins are loaded, I couldn’t reproduce the error.

    Please check if you updated to WordPress 2.3.3 properly. (I’m using 2.3.3., too, with no problems).

    I’m having the same problem as above. I’ve tested and for some reason the wp_register_sidebar_widget() function is not available from within the loaded plugin, despite working perfectly well for the inbuilt widgets.

    I’ve run a test and it appears that the widgets code is being loaded after plugins load. This means that plugins cannot access the functions in it.

    That’s going to cause problems on a lot of plugins surely?

    (tested on WP 2.3.3 / php5)

    I’ve run a test and it appears that the widgets code is being loaded after plugins load. This means that plugins cannot access the functions in it.

    My widgets are called in an add_action(‘plugins_loaded’,…), so widget-functions should already exist.

    Do both of you use the latest version of pb-embedFlash (rc 5.0.1)?

    pasber: Apologies, I jumped on this thread but am not using your plugin: I’m just experiencing the same problem as the person above while writing my own on my local install. Like you I have a plugins_loaded action but Widgets are no longer a plugin and the code is being loaded after the final load of plugins.

    I can’t quite identify when they are being loaded at all though: If I attach my plugin startup to the loading of the footer in the page it still fires before the Widget initialisation code. Very, very, odd.

    I’ve found the cause of this problem: for some reason calling classes without instantiating a variable causes problems. I was using adsensem::etc to refer to functions in the class – but doing this prevents access to the widget functions from within that.

    If I create a variable $adsensem=new adsensem(); and call from within it works absolutely fine.

    Anybody know a technical reason for this? Seems odd.

    I think it’s a bug: see here.

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    My widgets are called in an add_action(‘plugins_loaded’,…), so widget-functions should already exist.

    You should not be hooking to “plugins_loaded”, you should be hooking to “widgets_init”. The widgets_init action is (and always has been) the actual correct place to call your register widget functions.

    Hooking to plugins_loaded was an error. It worked when the widgets was a plugin, but only because of circumstances. Even the widgets plugin included the widget_init action hook.

    Thx Otto42, I’ll change the call then! As said before, it worked somehow for me (as of plugins_loaded is used by others plugins I’ve installed, too, like Simple Tags).

    Otto42: Thanks for that I wasn’t aware of the change, but in the plugin I’m working on it strangely doesn’t make any difference:

    function adsensem_init_widgets(){
    if (function_exists('wp_register_sidebar_widget') ){echo "WAAAAAAAAAAAAAAAAAAH";}	
    
    }
    add_action('widgets_init', adsensem_init_widgets(), 1);

    Putting the above in a file by itself rightfully outputs “WAAAAAAAAAAAAAAAAH” when the plugin is activated. Putting at the bottom of the plugin I’m developing has no effect. I’m a bit lost here… everything else about the plugin is functioning correctly, all other function calls work correctly, but for some reason widgets refuse to work.

    If you want to try, it’s the development version of AdSense Manager: put a die(); in after the function_exists(‘wp_register_sidebar_widget’) check and notice it doesn’t get activated.

    I’m stumped.

    Thanks.

    Just a note: the bug was caused by the way the init function was being called above:

    add_action('widgets_init', adsensem_init_widgets(), 1);

    Should be…

    add_action('widgets_init', 'adsensem_init_widgets', 1);

    The first method is evaluated the plugin at the point where the action is added & attaching the result (i.e. nothing) to the action. This means it’s called before the widgets_init is set: thats the reason the functions weren’t available.

    Weird one to track down that.

    For function usage/reference, I propose to use the WordPress Codex.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Register to WordPress 2.3.3 gives undefined function’ is closed to new replies.