mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
Administration: For block themes, link to Site Editor interface instead of Customizer in Dashboard's welcome panel and Themes interface.
For block themes (like Twenty Twenty-Two), Customizer menu item is removed and replaced with the Site Editor menu item. However, other links exist in the Dashboard's welcome panel "Customize Your Site" button and the "Customize" button in each theme listed in the Appearance > Themes interface. This commit changes each of those remaining links to link to the Site Editor interface instead of the Customizer. To help identify block vs non-block themes, two method methods are introduced in `WP_Theme`: * `WP_Theme:: is_block_based()` which identifies if the theme is a block theme or not. * `WP_Theme::get_file_path()` which is similar to `get_theme_file_path()` but uses the directories within the theme object. Both of these new methods include test coverage including the addition of a parent and child block theme in test data. Follow-up to [18749], [35483], [42013], [42169]. Props antonvlasenko, jameskoster, hellofromTonya, matveb, noisysocks, poena, sergeybiryukov. Fixes #54460. git-svn-id: https://develop.svn.wordpress.org/trunk@52279 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
echo 'PHP template for page with slug "home"';
|
||||
@@ -0,0 +1,4 @@
|
||||
/*
|
||||
Theme Name: Test Block Child Theme
|
||||
Template: test-block-theme
|
||||
*/
|
||||
@@ -0,0 +1,3 @@
|
||||
<!-- wp:paragraph -->
|
||||
<p>Page (ID 1) Template</p>
|
||||
<!-- /wp:paragraph -->
|
||||
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
// This file is for test purposes only.
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
echo 'PHP template for page with ID 1';
|
||||
@@ -0,0 +1,3 @@
|
||||
/*
|
||||
Theme Name: Test Block Theme
|
||||
*/
|
||||
@@ -0,0 +1,3 @@
|
||||
<!-- wp:paragraph -->
|
||||
<p>Index Template</p>
|
||||
<!-- /wp:paragraph -->
|
||||
@@ -0,0 +1,3 @@
|
||||
<!-- wp:paragraph -->
|
||||
<p>Page (Home) Template</p>
|
||||
<!-- /wp:paragraph -->
|
||||
@@ -0,0 +1,3 @@
|
||||
<!-- wp:paragraph -->
|
||||
<p>Page Template</p>
|
||||
<!-- /wp:paragraph -->
|
||||
@@ -163,6 +163,8 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase {
|
||||
'REST Theme',
|
||||
'Block Theme',
|
||||
'Block Theme Child Theme',
|
||||
'Test Block Theme',
|
||||
'Test Block Child Theme',
|
||||
);
|
||||
|
||||
sort( $theme_names );
|
||||
|
||||
@@ -246,4 +246,117 @@ class Tests_Theme_wpTheme extends WP_UnitTestCase {
|
||||
|
||||
$this->assertSameSetsWithIndex( $allowed_themes, $new_allowed_themes );
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider data_is_block_based
|
||||
* @ticket 54460
|
||||
*
|
||||
* @covers WP_Theme::is_block_based
|
||||
*
|
||||
* @param string $theme_dir Directory of the theme to test.
|
||||
* @param bool $expected Expected result.
|
||||
*/
|
||||
public function test_is_block_based( $theme_dir, $expected ) {
|
||||
$theme = new WP_Theme( $theme_dir, $this->theme_root );
|
||||
$actual = $theme->is_block_based();
|
||||
|
||||
if ( $expected ) {
|
||||
$this->assertTrue( $actual );
|
||||
} else {
|
||||
$this->assertFalse( $actual );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function data_is_block_based() {
|
||||
return array(
|
||||
'default - non-block theme' => array(
|
||||
'theme_dir' => 'default',
|
||||
'expected' => false,
|
||||
),
|
||||
'parent block theme' => array(
|
||||
'theme_dir' => 'test-block-theme',
|
||||
'expected' => true,
|
||||
),
|
||||
'child block theme' => array(
|
||||
'theme_dir' => 'test-block-child-theme',
|
||||
'expected' => true,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider data_get_file_path
|
||||
* @ticket 54460
|
||||
*
|
||||
* @covers WP_Theme::get_file_path
|
||||
*
|
||||
* @param string $theme_dir Directory of the theme to test.
|
||||
* @param string $file Given file name to test.
|
||||
* @param string $expected Expected file path.
|
||||
*/
|
||||
public function test_get_file_path( $theme_dir, $file, $expected ) {
|
||||
$theme = new WP_Theme( $theme_dir, $this->theme_root );
|
||||
|
||||
$this->assertStringEndsWith( $expected, $theme->get_file_path( $file ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function data_get_file_path() {
|
||||
return array(
|
||||
'no theme: no file given' => array(
|
||||
'theme_dir' => 'nonexistent',
|
||||
'file' => '',
|
||||
'expected' => '/nonexistent',
|
||||
),
|
||||
'parent theme: no file given' => array(
|
||||
'theme_dir' => 'test-block-theme',
|
||||
'file' => '',
|
||||
'expected' => '/test-block-theme',
|
||||
),
|
||||
'child theme: no file given' => array(
|
||||
'theme_dir' => 'test-block-child-theme',
|
||||
'file' => '',
|
||||
'expected' => '/test-block-child-theme',
|
||||
),
|
||||
'nonexistent theme: file given' => array(
|
||||
'theme_dir' => 'nonexistent',
|
||||
'file' => '/templates/page.html',
|
||||
'expected' => '/nonexistent/templates/page.html',
|
||||
),
|
||||
'parent theme: file exists' => array(
|
||||
'theme_dir' => 'test-block-theme',
|
||||
'file' => '/templates/page-home.html',
|
||||
'expected' => '/test-block-theme/templates/page-home.html',
|
||||
),
|
||||
'parent theme: file does not exist' => array(
|
||||
'theme_dir' => 'test-block-theme',
|
||||
'file' => '/templates/nonexistent.html',
|
||||
'expected' => '/test-block-theme/templates/nonexistent.html',
|
||||
),
|
||||
'child theme: file exists' => array(
|
||||
'theme_dir' => 'test-block-child-theme',
|
||||
'file' => '/templates/page-1.html',
|
||||
'expected' => '/test-block-child-theme/templates/page-1.html',
|
||||
),
|
||||
'child theme: file does not exist' => array(
|
||||
'theme_dir' => 'test-block-child-theme',
|
||||
'file' => '/templates/nonexistent.html',
|
||||
'expected' => '/test-block-theme/templates/nonexistent.html',
|
||||
),
|
||||
'child theme: file exists in parent, not in child' => array(
|
||||
'theme_dir' => 'test-block-child-theme',
|
||||
'file' => '/templates/page.html',
|
||||
'expected' => '/test-block-theme/templates/page.html',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user