Skip to content
Permalink
Browse files

Twenty Twenty: Rename widget areas to `sidebar-1` and `sidebar-2`.

This ensures that widgets are mapped correctly and is consistent with the previous default themes.

See WordPress/twentytwenty#481.

Reverts [46282].

Props ocean90, garrett-eclipse, desrosj, SergeyBiryukov.
See #48110.

git-svn-id: https://develop.svn.wordpress.org/trunk@46283 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information...
SergeyBiryukov committed Sep 23, 2019
1 parent bb41a65 commit 197d99a589f23c735be0543a7476759764fea076
@@ -446,12 +446,12 @@ function wp_install_defaults( $user_id ) {
'sidebars_widgets',
array(
'wp_inactive_widgets' => array(),
'footer-one' => array(
'sidebar-1' => array(
0 => 'search-2',
1 => 'recent-posts-2',
2 => 'recent-comments-2',
),
'footer-two' => array(
'sidebar-2' => array(
0 => 'archives-2',
1 => 'categories-2',
2 => 'meta-2',
@@ -89,24 +89,24 @@
<?php } ?>


<?php if ( is_active_sidebar( 'footer-one' ) || is_active_sidebar( 'footer-two' ) ) { ?>
<?php if ( is_active_sidebar( 'sidebar-1' ) || is_active_sidebar( 'sidebar-2' ) ) { ?>

<div class="footer-widgets-outer-wrapper">

<div class="footer-widgets-wrapper">

<?php if ( is_active_sidebar( 'footer-one' ) ) { ?>
<?php if ( is_active_sidebar( 'sidebar-1' ) ) { ?>

<div class="footer-widgets column-one grid-item">
<?php dynamic_sidebar( 'footer-one' ); ?>
<?php dynamic_sidebar( 'sidebar-1' ); ?>
</div>

<?php } ?>

<?php if ( is_active_sidebar( 'footer-two' ) ) { ?>
<?php if ( is_active_sidebar( 'sidebar-2' ) ) { ?>

<div class="footer-widgets column-two grid-item">
<?php dynamic_sidebar( 'footer-two' ); ?>
<?php dynamic_sidebar( 'sidebar-2' ); ?>
</div>

<?php } ?>
@@ -334,7 +334,7 @@ function twentytwenty_sidebar_registration() {
$shared_args,
array(
'name' => __( 'Footer #1', 'twentytwenty' ),
'id' => 'footer-one',
'id' => 'sidebar-1',
'description' => __( 'Widgets in this area will be displayed in the first column in the footer.', 'twentytwenty' ),
)
)
@@ -346,7 +346,7 @@ function twentytwenty_sidebar_registration() {
$shared_args,
array(
'name' => __( 'Footer #2', 'twentytwenty' ),
'id' => 'footer-two',
'id' => 'sidebar-2',
'description' => __( 'Widgets in this area will be displayed in the second column in the footer.', 'twentytwenty' ),
)
)
@@ -23,11 +23,11 @@ function twentytwenty_get_starter_content() {
$starter_content = array(
'widgets' => array(
// Place one core-defined widgets in the first tooter widget area.
'footer-one' => array(
'sidebar-1' => array(
'text_about',
),
// Place one core-defined widgets in the second tooter widget area.
'footer-two' => array(
'sidebar-2' => array(
'text_business_info',
),
),
@@ -1777,8 +1777,8 @@ function test_wp_customize_publish_changeset() {
$old_sidebars_widgets = get_option( 'sidebars_widgets' );
$new_sidebars_widgets = $old_sidebars_widgets;
$this->assertGreaterThan( 2, count( $new_sidebars_widgets['footer-one'] ) );
$new_sidebar_1 = array_reverse( $new_sidebars_widgets['footer-one'] );
$this->assertGreaterThan( 2, count( $new_sidebars_widgets['sidebar-1'] ) );
$new_sidebar_1 = array_reverse( $new_sidebars_widgets['sidebar-1'] );
$post_id = $this->factory()->post->create(
array(
@@ -1787,7 +1787,7 @@ function test_wp_customize_publish_changeset() {
'post_name' => wp_generate_uuid4(),
'post_content' => wp_json_encode(
array(
'sidebars_widgets[footer-one]' => array(
'sidebars_widgets[sidebar-1]' => array(
'value' => $new_sidebar_1,
),
)
@@ -1804,7 +1804,7 @@ function test_wp_customize_publish_changeset() {
// Ensure that the value has actually been written to the DB.
$updated_sidebars_widgets = get_option( 'sidebars_widgets' );
$this->assertEquals( $new_sidebar_1, $updated_sidebars_widgets['footer-one'] );
$this->assertEquals( $new_sidebar_1, $updated_sidebars_widgets['sidebar-1'] );
}
/**
@@ -32,9 +32,9 @@ function setUp() {
unset( $GLOBALS['_wp_sidebars_widgets'] ); // clear out cache set by wp_get_sidebars_widgets()
$sidebars_widgets = wp_get_sidebars_widgets();
$this->assertEqualSets( array( 'wp_inactive_widgets', 'footer-one', 'footer-two' ), array_keys( wp_get_sidebars_widgets() ) );
$this->assertContains( 'search-2', $sidebars_widgets['footer-one'] );
$this->assertContains( 'categories-2', $sidebars_widgets['footer-two'] );
$this->assertEqualSets( array( 'wp_inactive_widgets', 'sidebar-1', 'sidebar-2' ), array_keys( wp_get_sidebars_widgets() ) );
$this->assertContains( 'search-2', $sidebars_widgets['sidebar-1'] );
$this->assertContains( 'categories-2', $sidebars_widgets['sidebar-2'] );
$this->assertArrayHasKey( 2, get_option( 'widget_search' ) );
$widget_categories = get_option( 'widget_categories' );
$this->assertArrayHasKey( 2, $widget_categories );
@@ -101,7 +101,7 @@ function test_construct() {
* @ticket 36660
*/
function test_customize_register_with_deleted_sidebars() {
$sidebar_id = 'footer-one';
$sidebar_id = 'sidebar-1';
delete_option( 'sidebars_widgets' );
register_sidebar( array( 'id' => $sidebar_id ) );
$this->manager->widgets->customize_register();
@@ -311,11 +311,11 @@ function test_get_setting_args() {
'sanitize_callback' => array( $this->manager->widgets, 'sanitize_sidebar_widgets' ),
'sanitize_js_callback' => array( $this->manager->widgets, 'sanitize_sidebar_widgets_js_instance' ),
);
$args = $this->manager->widgets->get_setting_args( 'sidebars_widgets[footer-one]' );
$args = $this->manager->widgets->get_setting_args( 'sidebars_widgets[sidebar-1]' );
foreach ( $default_args as $key => $default_value ) {
$this->assertEquals( $default_value, $args[ $key ] );
}
$this->assertEquals( 'SIDEBARS_WIDGETS[FOOTER-ONE]', $args['uppercase_id_set_by_filter'] );
$this->assertEquals( 'SIDEBARS_WIDGETS[SIDEBAR-1]', $args['uppercase_id_set_by_filter'] );
$override_args = array(
'type' => 'theme_mod',
@@ -653,7 +653,7 @@ function test_render_widget_partial() {
$this->assertFalse( $this->manager->widgets->render_widget_partial( $partial, array() ) );
$this->assertFalse( $this->manager->widgets->render_widget_partial( $partial, array( 'sidebar_id' => 'non-existing' ) ) );
$output = $this->manager->widgets->render_widget_partial( $partial, array( 'sidebar_id' => 'footer-one' ) );
$output = $this->manager->widgets->render_widget_partial( $partial, array( 'sidebar_id' => 'sidebar-1' ) );
$this->assertEquals( 1, substr_count( $output, 'data-customize-partial-id' ) );
$this->assertEquals( 1, substr_count( $output, 'data-customize-partial-type="widget"' ) );

0 comments on commit 197d99a

Please sign in to comment.
You can’t perform that action at this time.