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 https://github.com/WordPress/twentytwenty/issues/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
This commit is contained in:
Sergey Biryukov 2019-09-23 23:16:59 +00:00
parent bb41a65acd
commit 197d99a589
6 changed files with 22 additions and 22 deletions

View File

@ -446,12 +446,12 @@ Commenter avatars come from <a href="https://gravatar.com">Gravatar</a>.'
'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',

View File

@ -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 } ?>

View File

@ -334,7 +334,7 @@ if ( ! function_exists( '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 @@ if ( ! function_exists( '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' ),
)
)

View File

@ -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',
),
),

View File

@ -1777,8 +1777,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
$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 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
'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 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
// 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'] );
}
/**

View File

@ -32,9 +32,9 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
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 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
* @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 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
'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 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
$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"' ) );