[wp-trac] [WordPress Trac] #22370: dynamic_sidebar does not consider switch_to_blog

WordPress Trac noreply at wordpress.org
Sat Oct 11 22:05:45 UTC 2014


#22370: dynamic_sidebar does not consider switch_to_blog
--------------------------+----------------------------------
 Reporter:  tarasm        |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Widgets       |     Version:  3.4.2
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:  template, multisite
--------------------------+----------------------------------

Comment (by westonruter):

 Yeah, the problem is that all widgets instances are registered during
 `widgets_init` up front when WordPress is initializing, so doing
 `switch_to_blog` is going to indeed switch the `sidebars_widgets` but then
 it is going to be referring to widget IDs that are not registered. I
 suppose you could try re-running `do_action( 'widgets_init' )` after you
 do your `switch_to_blog()` call, but no guarantees. There's also the
 problem of needing to re-initialize `$wp_reigstered_sidebars`; see
 http://wordpress.stackexchange.com/a/48227/8521

 An alternative solution was written up by WebDevStudios, which involves
 using Ajax to fetch the widgets from other blogs, though the widgets could
 be fetched server-side via `wp_remote_get()` too of course:
 http://webdevstudios.com/2013/12/17/sharing-sidebars-across-a-multisite-
 network/

--
Ticket URL: <https://core.trac.wordpress.org/ticket/22370#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list