• Resolved Joy

    (@joyously)


    I’m having trouble with the changed theme getting the old theme’s theme_mods (sidebar setup).
    It appears that all the widgets are supplied by plugins, which load first, and then the theme switch filters are added. The filters are before the theme loads, but the sidebar names are based on the old theme?

    I wondered if I merged my code with this plugin’s code, I could have it active before the end of the plugins_loaded time. My theme switch is done based on REQUEST variables, so I can check those really early.
    Do you see another way to make sure the right theme_mods are used?

    https://www.ads-software.com/plugins/wp-conditional-themes/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter Joy

    (@joyously)

    It turns out that it wasn’t a matter of when the filters were run.
    The problem was that the actual current theme’s sidebar widgets are stored in the option called ‘sidebars_widgets’, and inactive theme’s widgets are stored in theme_mod_$themename under ‘sidebars_widgets’ data.

    So this code makes it work correctly:

    add_filter( 'pre_option_sidebars_widgets', 'my_pre_option_sidebars_widgets_filter' );
    function my_pre_option_sidebars_widgets_filter( $w ) {
      $mod = get_theme_mod( 'sidebars_widgets' );
      if ( is_array( $mod ) )   //not the true active theme
    	$w = $mod['data'];
      return $w;
    }

    Plugin Author Nashwan D

    (@alex-ye)

    Thanks a lot for your feedback! .. I will check it again and make the required changes for the plugin.. Thank you again! ??

    Thread Starter Joy

    (@joyously)

    No update yet?

    Joy, would you please email me at jason at hendriks dot ca.

    Thread Starter Joy

    (@joyously)

    I was just looking at the code changes for 0.3, and this fix is not in there.

    Plugin Author Nashwan D

    (@alex-ye)

    Sorry I forget it!.
    Check the new update (Conditional Themes 0.4).

    I had write your name in the Changelog.
    Thank you.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘getting new theme with old (or no) sidebars’ is closed to new replies.