WordPress.org

Make WordPress Core

Changeset 37453


Ignore:
Timestamp:
05/17/2016 08:33:26 PM (4 years ago)
Author:
ocean90
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().

Merge of [37352] to the 4.5 branch.

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

Location:
branches/4.5
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/4.5

  • branches/4.5/src/wp-includes/class-wp-customize-widgets.php

    r37166 r37453  
    10621062     */
    10631063    public function preview_sidebars_widgets( $sidebars_widgets ) {
    1064         $sidebars_widgets = get_option( 'sidebars_widgets' );
     1064        $sidebars_widgets = get_option( 'sidebars_widgets', array() );
    10651065
    10661066        unset( $sidebars_widgets['array_version'] );
  • branches/4.5/tests/phpunit/tests/customize/widgets.php

    r37166 r37453  
    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.