Make WordPress Core

Changeset 46283


Ignore:
Timestamp:
09/23/2019 11:16:59 PM (5 years ago)
Author:
SergeyBiryukov
Message:

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.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/upgrade.php

    r46278 r46283  
    447447            array(
    448448                'wp_inactive_widgets' => array(),
    449                 'footer-one'          => array(
     449                'sidebar-1'          => array(
    450450                    0 => 'search-2',
    451451                    1 => 'recent-posts-2',
    452452                    2 => 'recent-comments-2',
    453453                ),
    454                 'footer-two'          => array(
     454                'sidebar-2'          => array(
    455455                    0 => 'archives-2',
    456456                    1 => 'categories-2',
  • trunk/src/wp-content/themes/twentytwenty/footer.php

    r46271 r46283  
    9090
    9191
    92                 <?php if ( is_active_sidebar( 'footer-one' ) || is_active_sidebar( 'footer-two' ) ) { ?>
     92                <?php if ( is_active_sidebar( 'sidebar-1' ) || is_active_sidebar( 'sidebar-2' ) ) { ?>
    9393
    9494                    <div class="footer-widgets-outer-wrapper">
     
    9696                        <div class="footer-widgets-wrapper">
    9797
    98                             <?php if ( is_active_sidebar( 'footer-one' ) ) { ?>
     98                            <?php if ( is_active_sidebar( 'sidebar-1' ) ) { ?>
    9999
    100100                                <div class="footer-widgets column-one grid-item">
    101                                     <?php dynamic_sidebar( 'footer-one' ); ?>
     101                                    <?php dynamic_sidebar( 'sidebar-1' ); ?>
    102102                                </div>
    103103
    104104                            <?php } ?>
    105105
    106                             <?php if ( is_active_sidebar( 'footer-two' ) ) { ?>
     106                            <?php if ( is_active_sidebar( 'sidebar-2' ) ) { ?>
    107107
    108108                                <div class="footer-widgets column-two grid-item">
    109                                     <?php dynamic_sidebar( 'footer-two' ); ?>
     109                                    <?php dynamic_sidebar( 'sidebar-2' ); ?>
    110110                                </div>
    111111
  • trunk/src/wp-content/themes/twentytwenty/functions.php

    r46271 r46283  
    335335                array(
    336336                    'name'        => __( 'Footer #1', 'twentytwenty' ),
    337                     'id'          => 'footer-one',
     337                    'id'          => 'sidebar-1',
    338338                    'description' => __( 'Widgets in this area will be displayed in the first column in the footer.', 'twentytwenty' ),
    339339                )
     
    347347                array(
    348348                    'name'        => __( 'Footer #2', 'twentytwenty' ),
    349                     'id'          => 'footer-two',
     349                    'id'          => 'sidebar-2',
    350350                    'description' => __( 'Widgets in this area will be displayed in the second column in the footer.', 'twentytwenty' ),
    351351                )
  • trunk/src/wp-content/themes/twentytwenty/inc/starter-content.php

    r46271 r46283  
    2424        'widgets'   => array(
    2525            // Place one core-defined widgets in the first tooter widget area.
    26             'footer-one' => array(
     26            'sidebar-1' => array(
    2727                'text_about',
    2828            ),
    2929            // Place one core-defined widgets in the second tooter widget area.
    30             'footer-two' => array(
     30            'sidebar-2' => array(
    3131                'text_business_info',
    3232            ),
  • trunk/tests/phpunit/tests/customize/manager.php

    r46282 r46283  
    17781778        $old_sidebars_widgets = get_option( 'sidebars_widgets' );
    17791779        $new_sidebars_widgets = $old_sidebars_widgets;
    1780         $this->assertGreaterThan( 2, count( $new_sidebars_widgets['footer-one'] ) );
    1781         $new_sidebar_1 = array_reverse( $new_sidebars_widgets['footer-one'] );
     1780        $this->assertGreaterThan( 2, count( $new_sidebars_widgets['sidebar-1'] ) );
     1781        $new_sidebar_1 = array_reverse( $new_sidebars_widgets['sidebar-1'] );
    17821782
    17831783        $post_id = $this->factory()->post->create(
     
    17881788                'post_content' => wp_json_encode(
    17891789                    array(
    1790                         'sidebars_widgets[footer-one]' => array(
     1790                        'sidebars_widgets[sidebar-1]' => array(
    17911791                            'value' => $new_sidebar_1,
    17921792                        ),
     
    18051805        // Ensure that the value has actually been written to the DB.
    18061806        $updated_sidebars_widgets = get_option( 'sidebars_widgets' );
    1807         $this->assertEquals( $new_sidebar_1, $updated_sidebars_widgets['footer-one'] );
     1807        $this->assertEquals( $new_sidebar_1, $updated_sidebars_widgets['sidebar-1'] );
    18081808    }
    18091809
  • trunk/tests/phpunit/tests/customize/widgets.php

    r46282 r46283  
    3333        unset( $GLOBALS['_wp_sidebars_widgets'] ); // clear out cache set by wp_get_sidebars_widgets()
    3434        $sidebars_widgets = wp_get_sidebars_widgets();
    35         $this->assertEqualSets( array( 'wp_inactive_widgets', 'footer-one', 'footer-two' ), array_keys( wp_get_sidebars_widgets() ) );
    36         $this->assertContains( 'search-2', $sidebars_widgets['footer-one'] );
    37         $this->assertContains( 'categories-2', $sidebars_widgets['footer-two'] );
     35        $this->assertEqualSets( array( 'wp_inactive_widgets', 'sidebar-1', 'sidebar-2' ), array_keys( wp_get_sidebars_widgets() ) );
     36        $this->assertContains( 'search-2', $sidebars_widgets['sidebar-1'] );
     37        $this->assertContains( 'categories-2', $sidebars_widgets['sidebar-2'] );
    3838        $this->assertArrayHasKey( 2, get_option( 'widget_search' ) );
    3939        $widget_categories = get_option( 'widget_categories' );
     
    102102     */
    103103    function test_customize_register_with_deleted_sidebars() {
    104         $sidebar_id = 'footer-one';
     104        $sidebar_id = 'sidebar-1';
    105105        delete_option( 'sidebars_widgets' );
    106106        register_sidebar( array( 'id' => $sidebar_id ) );
     
    312312            'sanitize_js_callback' => array( $this->manager->widgets, 'sanitize_sidebar_widgets_js_instance' ),
    313313        );
    314         $args         = $this->manager->widgets->get_setting_args( 'sidebars_widgets[footer-one]' );
     314        $args         = $this->manager->widgets->get_setting_args( 'sidebars_widgets[sidebar-1]' );
    315315        foreach ( $default_args as $key => $default_value ) {
    316316            $this->assertEquals( $default_value, $args[ $key ] );
    317317        }
    318         $this->assertEquals( 'SIDEBARS_WIDGETS[FOOTER-ONE]', $args['uppercase_id_set_by_filter'] );
     318        $this->assertEquals( 'SIDEBARS_WIDGETS[SIDEBAR-1]', $args['uppercase_id_set_by_filter'] );
    319319
    320320        $override_args = array(
     
    654654        $this->assertFalse( $this->manager->widgets->render_widget_partial( $partial, array( 'sidebar_id' => 'non-existing' ) ) );
    655655
    656         $output = $this->manager->widgets->render_widget_partial( $partial, array( 'sidebar_id' => 'footer-one' ) );
     656        $output = $this->manager->widgets->render_widget_partial( $partial, array( 'sidebar_id' => 'sidebar-1' ) );
    657657
    658658        $this->assertEquals( 1, substr_count( $output, 'data-customize-partial-id' ) );
Note: See TracChangeset for help on using the changeset viewer.