[wp-hackers] global $wp_registered_widgets of the main blog

Rocio Valdivia rocio at mecus.es
Fri Jun 10 07:42:47 UTC 2011


Hi Hackers,

I'm creating a plugin for WP multisite and I need to access to the value of
the global variable $wp_registered_widgets of the blog_id = 1, that is,
wherever I am, for example, in the index of blog_id = 2 or 3, etc. I need
the value of that variable of the main blog.

I have tried the following code to do this:

global $switched;
switch_to_blog(1);
global $wp_registered_widgets;
restore_current_blog();

but it doesn't work because the function switch_to_blog only works if you
call to another functions, not for global variables.

Any ideas?, because I have not found a function in /wp-includes/widgets.php
that retrieves that value. So I prefer to ask you before to query the info
of each register widget and to merge it into an array.

Thanks :)

Rocío Valdivia --- Web: http://mecus.es --- Twitter: @_DorsVenabili


More information about the wp-hackers mailing list