nash-ye / wp-conditional-themes

A simple API to switch the themes on certain conditions.

Home Page:https://wordpress.org/plugins/wp-conditional-themes/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Widgets in sidebars get messed up through switching

lmoffereins opened this issue · comments

When switching between themes, the registered widgets in sidebars are removed and tossed around. WP apparently does a bad job remembering which widgets belong with which theme's sidebars. I haven't looked into it yet, but is there any chance the widgets can be brought back in their right position when toggling through themes?

It would be great if this plugin would allow for per-theme widget positions (and settings!), so one could setup a switched theme's details in the admin, while the other theme's compositions remain intact.

I found that the issue is with updating widgets when using the switched theme. Since the registered widgets are theme-dependent, both getting and updating widgets has to be filtered. In your plugin, only the getting part is covered.

I have fixed this with filtering the pre_update_option_sidebars_widgets filter. You can view my implementation in my Theme Switcher plugin.

Thank you!. I had never got an enough time to look into this, I will include your solution with your name in the next update.