WordPress.org

Make WordPress Core

Changeset 37352


Ignore:
Timestamp:
05/02/2016 11:41:18 PM (4 years ago)
Author:
westonruter
Message:

Customize: Handle filtering sidebars_widgets when the underlying option is non-existent.

Fixes warning related to a non-array argument for array_merge() in WP_Customize_Widgets::customize_register().

See [37166].
See #36389.
Fixes #36660.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-customize-widgets.php

    r37279 r37352  
    10651065     */
    10661066    public function preview_sidebars_widgets( $sidebars_widgets ) {
    1067         $sidebars_widgets = get_option( 'sidebars_widgets' );
     1067        $sidebars_widgets = get_option( 'sidebars_widgets', array() );
    10681068
    10691069        unset( $sidebars_widgets['array_version'] );
  • trunk/tests/phpunit/tests/customize/widgets.php

    r37166 r37352  
    9797        $this->assertInstanceOf( 'WP_Customize_Widgets', $this->manager->widgets );
    9898        $this->assertEquals( $this->manager, $this->manager->widgets->manager );
     99    }
     100
     101    /**
     102     * Test registering sidebars without an extant sidebars_widgets option.
     103     *
     104     * @see WP_Customize_Widgets::customize_register()
     105     * @see WP_Customize_Widgets::preview_sidebars_widgets()
     106     * @ticket 36660
     107     */
     108    function test_customize_register_with_deleted_sidebars() {
     109        $sidebar_id = 'sidebar-1';
     110        delete_option( 'sidebars_widgets' );
     111        register_sidebar( array( 'id' => $sidebar_id ) );
     112        $this->manager->widgets->customize_register();
     113        $this->assertEquals( array_fill_keys( array( 'wp_inactive_widgets', $sidebar_id ), array() ), wp_get_sidebars_widgets() );
    99114    }
    100115
Note: See TracChangeset for help on using the changeset viewer.