[wp-trac] [WordPress Trac] #40177: sidebars_widgets option is not updated after activating a theme on Live Preview (on some themes)

WordPress Trac noreply at wordpress.org
Sun Mar 19 06:19:49 UTC 2017


#40177: sidebars_widgets option is not updated after activating a theme on Live
Preview (on some themes)
--------------------------+------------------------------
 Reporter:  alexvorn2     |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Customize     |     Version:  trunk
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by alexvorn2):

 Replying to [comment:1 westonruter]:
 > I'm assuming this is going to be closely related to #39693.
 >
 > The steps in this ticket will be great to codify in a test case.

 Yes, I can share a code I created that can simulate that Twenty Fourteen
 theme had a Calendar widget in the sidebar-1 Sidebar before...

 {{{#!php

 $template_my = 'twentyfourteen';

 $theme_installed = get_option( $template_my . '_theme_installed', false );

 if ( ! (bool) $theme_installed ) {

         $sidebars_widgets = array(
                 'wp_inactive_widgets' => array(),
                 'sidebar-1' => array(
                         'calendar-2'
                 ),
                 'sidebar-2' => array(),
                 'sidebar-3' => array(),
         );

         set_theme_mod( 'sidebars_widgets', array( 'time' => time(), 'data'
 => $sidebars_widgets ) );

         $calendar_widget = array(
                 '2' => array(
                         'title' => ''
                 ),
                 '_multiwidget' => 1
         );

         update_option( 'widget_calendar', $calendar_widget );

         update_option( $template_my . '_theme_installed', true );
 }
 }}}


 So you can add this code to functions.php file of the Twenty Fourteen
 theme.
 To test this you need to:
 1. Go to themes page
 2. Click Live Preview for Twenty Fourteen theme (You will see the Calendar
 widget there in the sidebar)
 3. Click Save & Publish
 4. When you go after that to the widgets.php page the Calendar widget is
 not in the Sidebar anymore.

 Expected to see it there :(

 Hope this helps.

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


More information about the wp-trac mailing list