mirror of
git://develop.git.wordpress.org/
synced 2025-04-05 04:33:18 +02:00
Make new WordPress installations use blocks in widget areas instead of widgets
Modifies `wp_install_defaults()` so that when you install a new WordPress site you have block in your widget areas, not widgets. Fixes #53324. Props isabel_brison, hellofromtonya, andraganescu. git-svn-id: https://develop.svn.wordpress.org/trunk@51088 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
880a308485
commit
8add05ff15
@ -403,59 +403,13 @@ Commenter avatars come from <a href="https://gravatar.com">Gravatar</a>.'
|
||||
|
||||
// Set up default widgets for default theme.
|
||||
update_option(
|
||||
'widget_search',
|
||||
'widget_block',
|
||||
array(
|
||||
2 => array( 'title' => '' ),
|
||||
'_multiwidget' => 1,
|
||||
)
|
||||
);
|
||||
update_option(
|
||||
'widget_recent-posts',
|
||||
array(
|
||||
2 => array(
|
||||
'title' => '',
|
||||
'number' => 5,
|
||||
),
|
||||
'_multiwidget' => 1,
|
||||
)
|
||||
);
|
||||
update_option(
|
||||
'widget_recent-comments',
|
||||
array(
|
||||
2 => array(
|
||||
'title' => '',
|
||||
'number' => 5,
|
||||
),
|
||||
'_multiwidget' => 1,
|
||||
)
|
||||
);
|
||||
update_option(
|
||||
'widget_archives',
|
||||
array(
|
||||
2 => array(
|
||||
'title' => '',
|
||||
'count' => 0,
|
||||
'dropdown' => 0,
|
||||
),
|
||||
'_multiwidget' => 1,
|
||||
)
|
||||
);
|
||||
update_option(
|
||||
'widget_categories',
|
||||
array(
|
||||
2 => array(
|
||||
'title' => '',
|
||||
'count' => 0,
|
||||
'hierarchical' => 0,
|
||||
'dropdown' => 0,
|
||||
),
|
||||
'_multiwidget' => 1,
|
||||
)
|
||||
);
|
||||
update_option(
|
||||
'widget_meta',
|
||||
array(
|
||||
2 => array( 'title' => '' ),
|
||||
2 => array( 'content' => '<!-- wp:search /-->' ),
|
||||
3 => array( 'content' => '<!-- wp:group --><div class="wp-block-group"><!-- wp:heading --><h2>' . __( 'Recent Posts' ) . '</h2><!-- /wp:heading --><!-- wp:latest-posts /--></div><!-- /wp:group -->' ),
|
||||
4 => array( 'content' => '<!-- wp:group --><div class="wp-block-group"><!-- wp:heading --><h2>' . __( 'Recent Comments' ) . '</h2><!-- /wp:heading --><!-- wp:latest-comments {"displayAvatar":false,"displayDate":false,"displayExcerpt":false} /--></div><!-- /wp:group -->' ),
|
||||
5 => array( 'content' => '<!-- wp:group --><div class="wp-block-group"><!-- wp:heading --><h2>' . __( 'Archives' ) . '</h2><!-- /wp:heading --><!-- wp:archives /--></div><!-- /wp:group -->' ),
|
||||
6 => array( 'content' => '<!-- wp:group --><div class="wp-block-group"><!-- wp:heading --><h2>' . __( 'Categories' ) . '</h2><!-- /wp:heading --><!-- wp:categories /--></div><!-- /wp:group -->' ),
|
||||
'_multiwidget' => 1,
|
||||
)
|
||||
);
|
||||
@ -464,18 +418,18 @@ Commenter avatars come from <a href="https://gravatar.com">Gravatar</a>.'
|
||||
array(
|
||||
'wp_inactive_widgets' => array(),
|
||||
'sidebar-1' => array(
|
||||
0 => 'search-2',
|
||||
1 => 'recent-posts-2',
|
||||
2 => 'recent-comments-2',
|
||||
0 => 'block-2',
|
||||
1 => 'block-3',
|
||||
2 => 'block-4',
|
||||
),
|
||||
'sidebar-2' => array(
|
||||
0 => 'archives-2',
|
||||
1 => 'categories-2',
|
||||
2 => 'meta-2',
|
||||
0 => 'block-5',
|
||||
1 => 'block-6',
|
||||
),
|
||||
'array_version' => 3,
|
||||
)
|
||||
);
|
||||
|
||||
if ( ! is_multisite() ) {
|
||||
update_user_meta( $user_id, 'show_welcome_panel', 1 );
|
||||
} elseif ( ! is_super_admin( $user_id ) && ! metadata_exists( 'user', $user_id, 'show_welcome_panel' ) ) {
|
||||
|
@ -7360,12 +7360,60 @@ h1.page-title {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.widget-title {
|
||||
font-size: 1.125rem;
|
||||
.widget h1 {
|
||||
font-weight: 700;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.widget h2 {
|
||||
font-weight: 700;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.widget h3 {
|
||||
font-weight: 700;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.widget h4 {
|
||||
font-weight: 700;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.widget h5 {
|
||||
font-weight: 700;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.widget h6 {
|
||||
font-weight: 700;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.widget h1 {
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
|
||||
.widget h2 {
|
||||
font-size: 1.125rem;
|
||||
}
|
||||
|
||||
.widget h3 {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.widget h4 {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.widget h5 {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.widget h6 {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.search-form {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
|
File diff suppressed because one or more lines are too long
@ -75,10 +75,41 @@
|
||||
}
|
||||
}
|
||||
|
||||
.widget-title {
|
||||
font-size: var(--global--font-size-sm);
|
||||
font-weight: var(--widget--font-weight-title);
|
||||
line-height: var(--widget--line-height-title);
|
||||
.widget {
|
||||
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6 {
|
||||
font-weight: var(--widget--font-weight-title);
|
||||
line-height: var(--widget--line-height-title);
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: var(--global--font-size-md);
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: var(--global--font-size-sm);
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: var(--global--font-size-xs);
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-size: var(--global--font-size-xs);
|
||||
}
|
||||
|
||||
h5 {
|
||||
font-size: var(--global--font-size-xs);
|
||||
}
|
||||
|
||||
h6 {
|
||||
font-size: var(--global--font-size-xs);
|
||||
}
|
||||
}
|
||||
|
||||
// Search widget styles
|
||||
|
@ -5444,12 +5444,40 @@ h1.page-title {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.widget-title {
|
||||
font-size: var(--global--font-size-sm);
|
||||
.widget h1,
|
||||
.widget h2,
|
||||
.widget h3,
|
||||
.widget h4,
|
||||
.widget h5,
|
||||
.widget h6 {
|
||||
font-weight: var(--widget--font-weight-title);
|
||||
line-height: var(--widget--line-height-title);
|
||||
}
|
||||
|
||||
.widget h1 {
|
||||
font-size: var(--global--font-size-md);
|
||||
}
|
||||
|
||||
.widget h2 {
|
||||
font-size: var(--global--font-size-sm);
|
||||
}
|
||||
|
||||
.widget h3 {
|
||||
font-size: var(--global--font-size-xs);
|
||||
}
|
||||
|
||||
.widget h4 {
|
||||
font-size: var(--global--font-size-xs);
|
||||
}
|
||||
|
||||
.widget h5 {
|
||||
font-size: var(--global--font-size-xs);
|
||||
}
|
||||
|
||||
.widget h6 {
|
||||
font-size: var(--global--font-size-xs);
|
||||
}
|
||||
|
||||
.search-form {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
|
@ -5480,12 +5480,40 @@ h1.page-title {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.widget-title {
|
||||
font-size: var(--global--font-size-sm);
|
||||
.widget h1,
|
||||
.widget h2,
|
||||
.widget h3,
|
||||
.widget h4,
|
||||
.widget h5,
|
||||
.widget h6 {
|
||||
font-weight: var(--widget--font-weight-title);
|
||||
line-height: var(--widget--line-height-title);
|
||||
}
|
||||
|
||||
.widget h1 {
|
||||
font-size: var(--global--font-size-md);
|
||||
}
|
||||
|
||||
.widget h2 {
|
||||
font-size: var(--global--font-size-sm);
|
||||
}
|
||||
|
||||
.widget h3 {
|
||||
font-size: var(--global--font-size-xs);
|
||||
}
|
||||
|
||||
.widget h4 {
|
||||
font-size: var(--global--font-size-xs);
|
||||
}
|
||||
|
||||
.widget h5 {
|
||||
font-size: var(--global--font-size-xs);
|
||||
}
|
||||
|
||||
.widget h6 {
|
||||
font-size: var(--global--font-size-xs);
|
||||
}
|
||||
|
||||
.search-form {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
|
File diff suppressed because one or more lines are too long
@ -659,7 +659,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
'header_image_data',
|
||||
'background_image',
|
||||
'widget_text[2]',
|
||||
'widget_meta[3]',
|
||||
'widget_meta[2]',
|
||||
'sidebars_widgets[sidebar-1]',
|
||||
'nav_menus_created_posts',
|
||||
'nav_menu[-1]',
|
||||
@ -676,14 +676,14 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
);
|
||||
$this->assertSameSets( $expected_setting_ids, array_keys( $changeset_values ) );
|
||||
|
||||
foreach ( array( 'widget_text[2]', 'widget_meta[3]' ) as $setting_id ) {
|
||||
foreach ( array( 'widget_text[2]', 'widget_meta[2]' ) as $setting_id ) {
|
||||
$this->assertInternalType( 'array', $changeset_values[ $setting_id ] );
|
||||
$instance_data = $wp_customize->widgets->sanitize_widget_instance( $changeset_values[ $setting_id ] );
|
||||
$this->assertInternalType( 'array', $instance_data );
|
||||
$this->assertArrayHasKey( 'title', $instance_data );
|
||||
}
|
||||
|
||||
$this->assertSame( array( 'text-2', 'meta-3' ), $changeset_values['sidebars_widgets[sidebar-1]'] );
|
||||
$this->assertSame( array( 'text-2', 'meta-2' ), $changeset_values['sidebars_widgets[sidebar-1]'] );
|
||||
|
||||
$posts_by_name = array();
|
||||
$this->assertCount( 7, $changeset_values['nav_menus_created_posts'] );
|
||||
|
@ -26,8 +26,39 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
|
||||
add_theme_support( 'customize-selective-refresh-widgets' );
|
||||
add_action( 'widgets_init', array( $this, 'remove_widgets_block_editor' ) );
|
||||
|
||||
$user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
|
||||
wp_set_current_user( $user_id );
|
||||
|
||||
update_option(
|
||||
'widget_search',
|
||||
array(
|
||||
2 => array( 'title' => '' ),
|
||||
'_multiwidget' => 1,
|
||||
)
|
||||
);
|
||||
update_option(
|
||||
'widget_categories',
|
||||
array(
|
||||
2 => array(
|
||||
'title' => '',
|
||||
'count' => 0,
|
||||
'hierarchical' => 0,
|
||||
'dropdown' => 0,
|
||||
),
|
||||
'_multiwidget' => 1,
|
||||
)
|
||||
);
|
||||
update_option(
|
||||
'sidebars_widgets',
|
||||
array(
|
||||
'wp_inactive_widgets' => array(),
|
||||
'sidebar-1' => array( 'search-2' ),
|
||||
'sidebar-2' => array( 'categories-2' ),
|
||||
'array_version' => 3,
|
||||
)
|
||||
);
|
||||
|
||||
$GLOBALS['wp_customize'] = new WP_Customize_Manager();
|
||||
$this->manager = $GLOBALS['wp_customize'];
|
||||
|
||||
|
@ -655,13 +655,13 @@ class WP_Test_REST_Widgets_Controller extends WP_Test_REST_Controller_Testcase {
|
||||
);
|
||||
$response = rest_get_server()->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
$this->assertSame( 'block-2', $data['id'] );
|
||||
$this->assertSame( 'block-7', $data['id'] );
|
||||
$this->assertSame( 'sidebar-1', $data['sidebar'] );
|
||||
$this->assertEqualSets(
|
||||
array(
|
||||
'content' => '<!-- wp:paragraph --><p>Block test</p><!-- /wp:paragraph -->',
|
||||
),
|
||||
get_option( 'widget_block' )[2]
|
||||
get_option( 'widget_block' )[7]
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -574,7 +574,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
function test_wp_widget__register() {
|
||||
global $wp_registered_widgets;
|
||||
|
||||
$settings = get_option( 'widget_search' );
|
||||
$settings = get_option( 'widget_block' );
|
||||
unset( $settings['_multiwidget'] );
|
||||
$this->assertArrayHasKey( 2, $settings );
|
||||
|
||||
@ -583,7 +583,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
|
||||
// Note: We cannot use array_keys() here because $settings could be an ArrayIterator.
|
||||
foreach ( $settings as $widget_number => $instance ) {
|
||||
$widget_id = "search-$widget_number";
|
||||
$widget_id = "block-$widget_number";
|
||||
$this->assertArrayHasKey( $widget_id, $wp_registered_widgets );
|
||||
}
|
||||
}
|
||||
@ -619,13 +619,13 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
function test_wp_widget_get_settings() {
|
||||
global $wp_registered_widgets;
|
||||
|
||||
$option_value = get_option( 'widget_search' );
|
||||
$option_value = get_option( 'widget_block' );
|
||||
$this->assertArrayHasKey( '_multiwidget', $option_value );
|
||||
$this->assertSame( 1, $option_value['_multiwidget'] );
|
||||
$this->assertArrayHasKey( 2, $option_value );
|
||||
$instance = $option_value[2];
|
||||
$this->assertInternalType( 'array', $instance );
|
||||
$this->assertArrayHasKey( 'title', $instance );
|
||||
$this->assertArrayHasKey( 'content', $instance );
|
||||
unset( $option_value['_multiwidget'] );
|
||||
|
||||
// Pretend this widget is new.
|
||||
@ -634,9 +634,9 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
$this->assertSame( array(), (array) $never_used );
|
||||
|
||||
wp_widgets_init();
|
||||
$wp_widget_search = $wp_registered_widgets['search-2']['callback'][0];
|
||||
$wp_widget_block = $wp_registered_widgets['block-2']['callback'][0];
|
||||
|
||||
$settings = $wp_widget_search->get_settings();
|
||||
$settings = $wp_widget_block->get_settings();
|
||||
// @todo $this->assertArrayNotHasKey( '_multiwidget', $settings ); ?
|
||||
$this->assertArrayHasKey( 2, $settings );
|
||||
|
||||
@ -657,10 +657,10 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
global $wp_registered_widgets;
|
||||
|
||||
wp_widgets_init();
|
||||
$wp_widget_search = $wp_registered_widgets['search-2']['callback'][0];
|
||||
$wp_widget_block = $wp_registered_widgets['block-2']['callback'][0];
|
||||
|
||||
$settings = $wp_widget_search->get_settings();
|
||||
$overridden_title = 'Unit Tested';
|
||||
$settings = $wp_widget_block->get_settings();
|
||||
$overridden_content = 'Unit Tested';
|
||||
|
||||
/*
|
||||
* Note that if a plugin is filtering $settings to be an ArrayIterator,
|
||||
@ -670,15 +670,15 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
* > Indirect modification of overloaded element of X has no effect.
|
||||
* So this is why the value must be obtained.
|
||||
*/
|
||||
$instance = $settings[2];
|
||||
$instance['title'] = $overridden_title;
|
||||
$settings[2] = $instance;
|
||||
$instance = $settings[2];
|
||||
$instance['content'] = $overridden_content;
|
||||
$settings[2] = $instance;
|
||||
|
||||
$wp_widget_search->save_settings( $settings );
|
||||
$wp_widget_block->save_settings( $settings );
|
||||
|
||||
$option_value = get_option( $wp_widget_search->option_name );
|
||||
$option_value = get_option( $wp_widget_block->option_name );
|
||||
$this->assertArrayHasKey( '_multiwidget', $option_value );
|
||||
$this->assertSame( $overridden_title, $option_value[2]['title'] );
|
||||
$this->assertSame( $overridden_content, $option_value[2]['content'] );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -688,13 +688,13 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
global $wp_registered_widgets;
|
||||
|
||||
wp_widgets_init();
|
||||
$wp_widget_search = $wp_registered_widgets['search-2']['callback'][0];
|
||||
$wp_widget_block = $wp_registered_widgets['block-2']['callback'][0];
|
||||
|
||||
$settings = $wp_widget_search->get_settings();
|
||||
$settings = $wp_widget_block->get_settings();
|
||||
$this->assertArrayHasKey( 2, $settings );
|
||||
unset( $settings[2] );
|
||||
$wp_widget_search->save_settings( $settings );
|
||||
$option_value = get_option( $wp_widget_search->option_name );
|
||||
$wp_widget_block->save_settings( $settings );
|
||||
$option_value = get_option( $wp_widget_block->option_name );
|
||||
$this->assertArrayNotHasKey( 2, $option_value );
|
||||
}
|
||||
|
||||
@ -704,6 +704,23 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
function test_wp_widget_control() {
|
||||
global $wp_registered_widgets;
|
||||
|
||||
update_option(
|
||||
'widget_search',
|
||||
array(
|
||||
2 => array( 'title' => '' ),
|
||||
'_multiwidget' => 1,
|
||||
)
|
||||
);
|
||||
update_option(
|
||||
'sidebars_widgets',
|
||||
array(
|
||||
'wp_inactive_widgets' => array(),
|
||||
'sidebar-1' => array( 'search-2' ),
|
||||
'sidebar-2' => array(),
|
||||
'array_version' => 3,
|
||||
)
|
||||
);
|
||||
|
||||
wp_widgets_init();
|
||||
require_once ABSPATH . '/wp-admin/includes/widgets.php';
|
||||
$widget_id = 'search-2';
|
||||
@ -873,15 +890,14 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
// Unregistered widget should be filtered out.
|
||||
$this->assertNotContains( 'unregistered_widget-1', $sidebars_widgets['sidebar-3'] );
|
||||
|
||||
// 6 default widgets - 1 active text widget + 1 orphaned widget = 6.
|
||||
$this->assertCount( 6, $sidebars_widgets['wp_inactive_widgets'] );
|
||||
// 5 default widgets - 1 active text widget + 1 orphaned widget = 5.
|
||||
$this->assertCount( 5, $sidebars_widgets['wp_inactive_widgets'] );
|
||||
|
||||
$this->assertContains( 'meta-2', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'search-2', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'archives-2', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'categories-2', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'recent-posts-2', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'recent-comments-2', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'block-2', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'block-3', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'block-4', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'block-5', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'block-6', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
|
||||
// Sidebar_widgets option was updated.
|
||||
$this->assertSame( $sidebars_widgets, wp_get_sidebars_widgets() );
|
||||
@ -965,15 +981,14 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
// We should not have orphaned widgets, because widget was not registered.
|
||||
$this->assertArrayNotHasKey( 'orphaned_widgets_1', $sidebars_widgets );
|
||||
|
||||
// 6 default widgets.
|
||||
$this->assertCount( 6, $sidebars_widgets['wp_inactive_widgets'] );
|
||||
// 5 default widgets.
|
||||
$this->assertCount( 5, $sidebars_widgets['wp_inactive_widgets'] );
|
||||
|
||||
$this->assertContains( 'archives-2', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'meta-2', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'search-2', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'categories-2', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'recent-posts-2', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'recent-comments-2', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'block-2', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'block-3', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'block-4', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'block-5', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'block-6', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
|
||||
// Sidebar_widgets option was updated.
|
||||
$this->assertSame( $sidebars_widgets, wp_get_sidebars_widgets() );
|
||||
@ -982,7 +997,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
$sidebars_widgets = array(
|
||||
'sidebar-1' => array( 'tag_cloud-1' ),
|
||||
'sidebar-2' => array( 'text-1' ),
|
||||
'fantasy' => array( 'archives-2' ),
|
||||
'fantasy' => array( 'block-4' ),
|
||||
'wp_inactive_widgets' => array(),
|
||||
);
|
||||
|
||||
@ -1004,16 +1019,15 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
$this->assertContains( 'tag_cloud-1', $sidebars_widgets['sidebar-1'] );
|
||||
$this->assertContains( 'text-1', $sidebars_widgets['sidebar-2'] );
|
||||
|
||||
// 6 default widgets - 1 active text widget = 5.
|
||||
$this->assertCount( 6, $sidebars_widgets['wp_inactive_widgets'] );
|
||||
// 5 default widgets - 1 active text widget = 5.
|
||||
$this->assertCount( 5, $sidebars_widgets['wp_inactive_widgets'] );
|
||||
|
||||
$this->assertContains( 'meta-2', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'search-2', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
// archives-2 ends up as inactive because fantasy sidebar doesn't exist.
|
||||
$this->assertContains( 'archives-2', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'categories-2', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'recent-posts-2', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'recent-comments-2', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'block-2', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'block-3', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
// block-4 ends up as inactive because fantasy sidebar doesn't exist.
|
||||
$this->assertContains( 'block-4', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'block-5', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'block-6', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
|
||||
// Sidebar_widgets option was updated.
|
||||
$this->assertSame( $sidebars_widgets, wp_get_sidebars_widgets() );
|
||||
@ -1053,14 +1067,13 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
$this->assertContains( 'text-1', $sidebars_widgets['sidebar-2'] );
|
||||
$this->assertArrayHasKey( 'sidebar-3', $sidebars_widgets );
|
||||
$this->assertEmpty( $sidebars_widgets['sidebar-3'] );
|
||||
$this->assertCount( 6, $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertCount( 5, $sidebars_widgets['wp_inactive_widgets'] );
|
||||
|
||||
$this->assertContains( 'meta-2', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'search-2', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'archives-2', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'categories-2', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'recent-posts-2', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'recent-comments-2', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'block-2', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'block-3', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'block-4', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'block-5', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'block-6', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
|
||||
// Theme mod with previous widgets was not removed.
|
||||
$this->assertSameSets( $old_sidebars_widgets, get_theme_mod( 'sidebars_widgets' ) );
|
||||
@ -1117,8 +1130,8 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
$this->assertInternalType( 'array', $widgets );
|
||||
}
|
||||
|
||||
// 6 default widgets + 1 orphaned calendar widget = 7.
|
||||
$this->assertCount( 7, $sidebars_widgets['wp_inactive_widgets'] );
|
||||
// 5 default widgets + 1 orphaned calendar widget = 6.
|
||||
$this->assertCount( 6, $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertContains( 'calendar-1', $sidebars_widgets['wp_inactive_widgets'] );
|
||||
$this->assertArrayNotHasKey( 'orphaned_widgets_1', $sidebars_widgets );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user