WordPress.org

Make WordPress Core

Opened 10 months ago

Closed 5 months ago

Last modified 5 months ago

#40177 closed defect (bug) (duplicate)

sidebars_widgets option is not updated after activating a theme on Live Preview (on some themes)

Reported by: alexvorn2 Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Customize Keywords:
Focuses: Cc:

Description

Widgets are lost after theme activation on Live Preview, a very strange bug, it seems the sidebars_widgets option is not saved after you press Save & Activate button on Live Preview...

This bug can be replicated only doing the same steps as I did:

  1. Fresh Install
  2. Activate Twenty Fourteen theme
  3. Go to widgets.php
  4. Remove all widgets in the Primary Sidebar
  5. Add custom widget to Primary Sidebar (Calendar for example)
  6. Active Twenty Seventeen theme
  7. Now Live Preview our theme Twenty Fourteen

(you can see that we have the Calendar widget in the live preview)

  1. Click Save & Activate
  2. Go to widgets.php page and you can see that the Primary Sidebar is empty and our Calendar widget is as inactive widget

Expected to see the Calendar widget in Primary Sidebar

I hope you can replicate this...

Change History (5)

#1 follow-up: @westonruter
10 months ago

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.

#2 in reply to: ↑ 1 @alexvorn2
10 months ago

Replying to 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...


$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.

#3 @swissspidy
9 months ago

  • Version trunk deleted

#4 @alexvorn2
5 months ago

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #39693.

I am closing this ticket because it seems that the fix from other ticket can fix this issue.

#5 @SergeyBiryukov
5 months ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.