mirrored from git://develop.git.wordpress.org/
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Editor: Adds template types,
is_wp_suggestion
, and fallback templat…
…e content. This commit improves site editor templates by: * Adds a post meta `is_wp_suggestion` to templates created from the site editor. Why? To differentiate the templates created from the post editor in the Template panel in inspector controls and the templates suggested in site editor. See [WordPress/gutenberg#41387 Gutenberg PR 41387] for more details. * Expands the template types that can be added to the site editor to include single custom post type and specific posts templates. See [WordPress/gutenberg#41189 Gutenberg PR 41189] for more details. * Adds fallback template content on creation in site editor: * Introduces `get_template_hierarchy()` to get the template hierarchy for a given template slug to be created. * Adds a `lookup` route to `WP_REST_Templates_Controller` to get the fallback template content. See [WordPress/gutenberg#42520 Gutenberg PR 42520] for more details. * Fixes a typo in default category template's description within `get_default_block_template_types()`. See [WordPress/gutenberg#42586 Gutenberg PR 42586] for more details. * Changes field checks from `in_array()` to `rest_is_field_included()` in `WP_REST_Post_Types_Controller`. * Adds an `icon` field to `WP_REST_Post_Types_Controller` Follow-up to [53129], [52331], [52275], [52062], [51962], [43087]. Props ntsekouras, spacedmonkey, mamaduka, mburridge, jameskoster, bernhard-reiter, mcsf, hellofromTonya. See #56467. git-svn-id: https://develop.svn.wordpress.org/trunk@54269 602fd350-edb4-49c9-b593-d223f7449a82
- Loading branch information
1 parent
072d9da
commit b343603
Showing
10 changed files
with
583 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
|
||
/** | ||
* @group block-templates | ||
* @covers ::get_template_hierarchy | ||
*/ | ||
abstract class WP_Block_Templates_UnitTestCase extends WP_UnitTestCase { | ||
const TEST_THEME = 'block-theme'; | ||
|
||
protected static $template_post; | ||
protected static $template_part_post; | ||
|
||
public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { | ||
/* | ||
* Set up a template post corresponding to a different theme. | ||
* Do this to ensure resolution and slug creation works as expected, | ||
* even with another post of that same name present for another theme. | ||
*/ | ||
self::$template_post = $factory->post->create_and_get( | ||
array( | ||
'post_type' => 'wp_template', | ||
'post_name' => 'my_template', | ||
'post_title' => 'My Template', | ||
'post_content' => 'Content', | ||
'post_excerpt' => 'Description of my template', | ||
'tax_input' => array( | ||
'wp_theme' => array( | ||
'this-theme-should-not-resolve', | ||
), | ||
), | ||
) | ||
); | ||
|
||
wp_set_post_terms( self::$template_post->ID, 'this-theme-should-not-resolve', 'wp_theme' ); | ||
|
||
// Set up template post. | ||
self::$template_post = $factory->post->create_and_get( | ||
array( | ||
'post_type' => 'wp_template', | ||
'post_name' => 'my_template', | ||
'post_title' => 'My Template', | ||
'post_content' => 'Content', | ||
'post_excerpt' => 'Description of my template', | ||
'tax_input' => array( | ||
'wp_theme' => array( | ||
self::TEST_THEME, | ||
), | ||
), | ||
) | ||
); | ||
|
||
wp_set_post_terms( self::$template_post->ID, self::TEST_THEME, 'wp_theme' ); | ||
|
||
// Set up template part post. | ||
self::$template_part_post = $factory->post->create_and_get( | ||
array( | ||
'post_type' => 'wp_template_part', | ||
'post_name' => 'my_template_part', | ||
'post_title' => 'My Template Part', | ||
'post_content' => 'Content', | ||
'post_excerpt' => 'Description of my template part', | ||
'tax_input' => array( | ||
'wp_theme' => array( | ||
self::TEST_THEME, | ||
), | ||
'wp_template_part_area' => array( | ||
WP_TEMPLATE_PART_AREA_HEADER, | ||
), | ||
), | ||
) | ||
); | ||
|
||
wp_set_post_terms( self::$template_part_post->ID, WP_TEMPLATE_PART_AREA_HEADER, 'wp_template_part_area' ); | ||
wp_set_post_terms( self::$template_part_post->ID, self::TEST_THEME, 'wp_theme' ); | ||
} | ||
|
||
public static function wpTearDownAfterClass() { | ||
wp_delete_post( self::$template_post->ID ); | ||
wp_delete_post( self::$template_part_post->ID ); | ||
} | ||
|
||
public function set_up() { | ||
parent::set_up(); | ||
switch_theme( self::TEST_THEME ); | ||
} | ||
} |
Oops, something went wrong.