mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Tests: Cover Block Hooks integration with a custom block theme
Adds a simplified version of Twenty Twenty-Three theme that helps testing Block Hooks integration. The theme contains: - The required index.html template. - The optional single.html template used with tests. - 3 template parts where two of them reference patterns. - 3 patterns referenced in the templates and the template parts. New tests automatically register 4 custom blocks with the test theme where each of them hooks into another block using all four target relative positions: `before`, `after`, `firstChild`, `lastChild`. The tests verify that the block gets hooked into the correct positions when targeting: - template - template part - pattern Props ockham, costdev. See #59313, #59383. Follow-up [56610]. git-svn-id: https://develop.svn.wordpress.org/trunk@56759 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "tests/hooked-after",
|
||||
"blockHooks": {
|
||||
"core/post-content": "after"
|
||||
},
|
||||
"render": "file:render.php"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<p>Block hooked after.<p>
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "tests/hooked-before",
|
||||
"blockHooks": {
|
||||
"core/navigation": "before"
|
||||
},
|
||||
"render": "file:render.php"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<p>Block hooked before.<p>
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "tests/hooked-first-child",
|
||||
"blockHooks": {
|
||||
"core/comments": "firstChild"
|
||||
},
|
||||
"render": "file:render.php"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<p>Block hooked as the first child.<p>
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "tests/hooked-last-child",
|
||||
"blockHooks": {
|
||||
"core/comment-template": "lastChild"
|
||||
},
|
||||
"render": "file:render.php"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<p>Block hooked as the last child.<p>
|
||||
@@ -0,0 +1 @@
|
||||
<!-- wp:pattern {"slug":"block-theme-with-hooked-blocks/hidden-comments"} /-->
|
||||
@@ -0,0 +1 @@
|
||||
<!-- wp:pattern {"slug":"block-theme-with-hooked-blocks/footer-default"} /-->
|
||||
@@ -0,0 +1,10 @@
|
||||
<!-- wp:group {"layout":{"type":"constrained"}} -->
|
||||
<div class="wp-block-group">
|
||||
<!-- wp:group {"align":"wide","layout":{"type":"flex","justifyContent":"space-between"}} -->
|
||||
<div class="wp-block-group alignwide">
|
||||
<!-- wp:site-title {"level":0} /-->
|
||||
<!-- wp:navigation {"layout":{"type":"flex","setCascadingProperties":true,"justifyContent":"right"}} /-->
|
||||
</div>
|
||||
<!-- /wp:group -->
|
||||
</div>
|
||||
<!-- /wp:group -->
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Title: Default Footer
|
||||
* Slug: block-theme-with-hooked-blocks/footer-default
|
||||
* Categories: footer
|
||||
* Block Types: core/template-part/footer
|
||||
*/
|
||||
?>
|
||||
<!-- wp:group {"layout":{"type":"constrained"}} -->
|
||||
<div class="wp-block-group">
|
||||
<!-- wp:group {"align":"wide","layout":{"type":"flex","justifyContent":"space-between"}} -->
|
||||
<div class="wp-block-group alignwide">
|
||||
<!-- wp:site-title {"level":0} /-->
|
||||
<!-- wp:paragraph {"align":"right"} -->
|
||||
<p class="has-text-align-right">
|
||||
<?php
|
||||
printf(
|
||||
/* Translators: WordPress link. */
|
||||
esc_html__( 'Proudly powered by %s', 'block-theme-with-hooked-blocks' ),
|
||||
'<a href="' . esc_url( __( 'https://wordpress.org', 'block-theme-with-hooked-blocks' ) ) . '" rel="nofollow">WordPress</a>'
|
||||
)
|
||||
?>
|
||||
</p>
|
||||
<!-- /wp:paragraph -->
|
||||
</div>
|
||||
<!-- /wp:group -->
|
||||
</div>
|
||||
<!-- /wp:group -->
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* Title: Hidden Comments
|
||||
* Slug: block-theme-with-hooked-blocks/hidden-comments
|
||||
* Inserter: no
|
||||
*/
|
||||
?>
|
||||
<!-- wp:group {"layout":{"type":"constrained"}} -->
|
||||
<div class="wp-block-group" >
|
||||
<!-- wp:comments -->
|
||||
<div class="wp-block-comments">
|
||||
<!-- wp:heading {"level":2} -->
|
||||
<h2><?php echo esc_html_x( 'Comments', 'Title of comments section', 'block-theme-with-hooked-blocks' ); ?></h2>
|
||||
<!-- /wp:heading -->
|
||||
|
||||
<!-- wp:comments-title {"level":3} /-->
|
||||
|
||||
<!-- wp:comment-template -->
|
||||
<!-- wp:columns -->
|
||||
<div class="wp-block-columns">
|
||||
<!-- wp:column -->
|
||||
<div class="wp-block-column">
|
||||
<!-- wp:avatar /-->
|
||||
</div>
|
||||
<!-- /wp:column -->
|
||||
|
||||
<!-- wp:column -->
|
||||
<div class="wp-block-column">
|
||||
<!-- wp:comment-author-name /-->
|
||||
|
||||
<!-- wp:group -->
|
||||
<div class="wp-block-group">
|
||||
<!-- wp:comment-date /-->
|
||||
<!-- wp:comment-edit-link /-->
|
||||
</div>
|
||||
<!-- /wp:group -->
|
||||
|
||||
<!-- wp:comment-content /-->
|
||||
|
||||
<!-- wp:comment-reply-link /-->
|
||||
</div>
|
||||
<!-- /wp:column -->
|
||||
</div>
|
||||
<!-- /wp:columns -->
|
||||
<!-- /wp:comment-template -->
|
||||
|
||||
<!-- wp:comments-pagination {"paginationArrow":"arrow","layout":{"type":"flex","justifyContent":"space-between"}} -->
|
||||
<!-- wp:comments-pagination-previous /-->
|
||||
<!-- wp:comments-pagination-numbers /-->
|
||||
<!-- wp:comments-pagination-next /-->
|
||||
<!-- /wp:comments-pagination -->
|
||||
|
||||
<!-- wp:post-comments-form /-->
|
||||
</div>
|
||||
<!-- /wp:comments -->
|
||||
</div>
|
||||
<!-- /wp:group -->
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* Title: Post Meta
|
||||
* Slug: block-theme-with-hooked-blocks/post-meta
|
||||
* Categories: query
|
||||
* Keywords: post meta
|
||||
* Block Types: core/template-part/post-meta
|
||||
*/
|
||||
?>
|
||||
<!-- wp:spacer {"height":"0"} -->
|
||||
<div style="height:0" aria-hidden="true" class="wp-block-spacer"></div>
|
||||
<!-- /wp:spacer -->
|
||||
|
||||
<!-- wp:group {"layout":{"type":"constrained"}} -->
|
||||
<div class="wp-block-group">
|
||||
<!-- wp:separator {"opacity":"css","align":"wide","className":"is-style-wide"} -->
|
||||
<hr class="wp-block-separator alignwide has-css-opacity is-style-wide"/>
|
||||
<!-- /wp:separator -->
|
||||
|
||||
<!-- wp:columns -->
|
||||
<div class="wp-block-columns">
|
||||
<!-- wp:column -->
|
||||
<div class="wp-block-column">
|
||||
<!-- wp:group {"layout":{"type":"flex"}} -->
|
||||
<div class="wp-block-group">
|
||||
<!-- wp:paragraph -->
|
||||
<p>
|
||||
<?php echo esc_html_x( 'Posted', 'Verb to explain the publication status of a post', 'block-theme-with-hooked-blocks' ); ?>
|
||||
</p>
|
||||
<!-- /wp:paragraph -->
|
||||
|
||||
<!-- wp:post-date /-->
|
||||
|
||||
<!-- wp:paragraph -->
|
||||
<p>
|
||||
<?php echo esc_html_x( 'in', 'Preposition to show the relationship between the post and its categories', 'block-theme-with-hooked-blocks' ); ?>
|
||||
</p>
|
||||
<!-- /wp:paragraph -->
|
||||
|
||||
<!-- wp:post-terms {"term":"category"} /-->
|
||||
</div>
|
||||
<!-- /wp:group -->
|
||||
|
||||
<!-- wp:group {"layout":{"type":"flex"}} -->
|
||||
<div class="wp-block-group">
|
||||
<!-- wp:paragraph -->
|
||||
<p>
|
||||
<?php echo esc_html_x( 'by', 'Preposition to show the relationship between the post and its author', 'block-theme-with-hooked-blocks' ); ?>
|
||||
</p>
|
||||
<!-- /wp:paragraph -->
|
||||
|
||||
<!-- wp:post-author {"showAvatar":false} /-->
|
||||
</div>
|
||||
<!-- /wp:group -->
|
||||
</div>
|
||||
<!-- /wp:column -->
|
||||
|
||||
<!-- wp:column -->
|
||||
<div class="wp-block-column">
|
||||
<!-- wp:group {"layout":{"type":"flex","orientation":"vertical"}} -->
|
||||
<div class="wp-block-group">
|
||||
<!-- wp:paragraph -->
|
||||
<p>
|
||||
<?php echo esc_html_x( 'Tags:', 'Label for a list of post tags', 'block-theme-with-hooked-blocks' ); ?>
|
||||
</p>
|
||||
<!-- /wp:paragraph -->
|
||||
|
||||
<!-- wp:post-terms {"term":"post_tag"} /-->
|
||||
</div>
|
||||
<!-- /wp:group -->
|
||||
</div>
|
||||
<!-- /wp:column -->
|
||||
</div>
|
||||
<!-- /wp:columns -->
|
||||
</div>
|
||||
<!-- /wp:group -->
|
||||
@@ -0,0 +1,7 @@
|
||||
/*
|
||||
Theme Name: Block Theme with Hooked Blocks
|
||||
Theme URI: https://wordpress.org/
|
||||
Description: For testing purposes only.
|
||||
Version: 1.0.0
|
||||
Text Domain: block-theme-with-hooked-blocks
|
||||
*/
|
||||
@@ -0,0 +1,23 @@
|
||||
<!-- wp:template-part {"slug":"header","tagName":"header"} /-->
|
||||
|
||||
<!-- wp:group {"tagName":"main","layout":{"type":"constrained"}} -->
|
||||
<main class="wp-block-group">
|
||||
<!-- wp:query {"query":{"pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":true,"taxQuery":null,"parents":[]},"displayLayout":{"type":"flex","columns":3},"align":"wide","layout":{"type":"default"}} -->
|
||||
<div class="wp-block-query alignwide">
|
||||
<!-- wp:post-template {"align":"wide"} -->
|
||||
<!-- wp:post-featured-image {"isLink":true,"width":"100%","height":"clamp(15vw, 30vh, 400px)","align":"wide"} /-->
|
||||
<!-- wp:post-title {"isLink":true,"align":"wide"} /-->
|
||||
<!-- wp:post-excerpt /-->
|
||||
<!-- wp:post-date {"isLink":true} /-->
|
||||
<!-- /wp:post-template -->
|
||||
|
||||
<!-- wp:query-pagination {"paginationArrow":"arrow","align":"wide","layout":{"type":"flex","justifyContent":"space-between"}} -->
|
||||
<!-- wp:query-pagination-previous /-->
|
||||
<!-- wp:query-pagination-next /-->
|
||||
<!-- /wp:query-pagination -->
|
||||
</div>
|
||||
<!-- /wp:query -->
|
||||
</main>
|
||||
<!-- /wp:group -->
|
||||
|
||||
<!-- wp:template-part {"slug":"footer","tagName":"footer"} /-->
|
||||
@@ -0,0 +1,18 @@
|
||||
<!-- wp:template-part {"slug":"header","tagName":"header"} /-->
|
||||
|
||||
<!-- wp:group {"tagName":"main"} -->
|
||||
<main class="wp-block-group">
|
||||
<!-- wp:group {"layout":{"type":"constrained"}} -->
|
||||
<div class="wp-block-group">
|
||||
<!-- wp:post-featured-image /-->
|
||||
<!-- wp:post-title /-->
|
||||
</div>
|
||||
<!-- /wp:group -->
|
||||
|
||||
<!-- wp:post-content {"layout":{"type":"constrained"}} /-->
|
||||
<!-- wp:pattern {"slug":"block-theme-with-hooked-blocks/post-meta"} /-->
|
||||
<!-- wp:template-part {"slug":"comments","tagName":"section"} /-->
|
||||
</main>
|
||||
<!-- /wp:group -->
|
||||
|
||||
<!-- wp:template-part {"slug":"footer","tagName":"footer"} /-->
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"$schema": "https://schemas.wp.org/trunk/theme.json",
|
||||
"version": 2,
|
||||
"templateParts": [
|
||||
{
|
||||
"area": "header",
|
||||
"name": "header",
|
||||
"title": "Header"
|
||||
},
|
||||
{
|
||||
"area": "footer",
|
||||
"name": "footer",
|
||||
"title": "Footer"
|
||||
},
|
||||
{
|
||||
"area": "uncategorized",
|
||||
"name": "comments",
|
||||
"title": "Comments"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user