Block Editor: Package updates for WordPress 5.8 beta 1 (batch2).

This includes the following fixes:

 - Fix inspector opening when clicking outside the widget areas
 - Assume light theme when a transparent background is used
 - Make Post blocks non editable inside Query block
 - Rename QueryLoop to PostTemplate block

Props ntsekouras.
See #52991.

Built from https://develop.svn.wordpress.org/trunk@51101


git-svn-id: http://core.svn.wordpress.org/trunk@50710 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
youknowriad 2021-06-08 17:33:22 +00:00
parent a44c69354d
commit 1a7f28b3cd
41 changed files with 519 additions and 230 deletions

File diff suppressed because one or more lines are too long

View File

@ -11,13 +11,13 @@ return array(
'categories' => array( 'query' ),
'content' => '<!-- wp:query {"query":{"perPage":6,"pages":0,"offset":0,"postType":"post","categoryIds":[],"tagIds":[],"order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"exclude","inherit":false},"displayLayout":{"type":"flex","columns":3}} -->
<div class="wp-block-query">
<!-- wp:query-loop -->
<!-- wp:post-template -->
<!-- wp:group {"tagName":"main","style":{"spacing":{"padding":{"top":"30px","right":"30px","bottom":"30px","left":"30px"}}},"layout":{"inherit":false}} -->
<main class="wp-block-group" style="padding-top:30px;padding-right:30px;padding-bottom:30px;padding-left:30px"><!-- wp:post-title {"isLink":true} /-->
<!-- wp:post-excerpt {"wordCount":20} /-->
<!-- wp:post-date /--></div>
<!-- /wp:group -->
<!-- /wp:query-loop -->
<!-- /wp:post-template -->
</div>
<!-- /wp:query -->',
);

View File

@ -11,7 +11,7 @@ return array(
'categories' => array( 'query' ),
'content' => '<!-- wp:group {"align":"full","style":{"spacing":{"padding":{"top":"100px","right":"100px","bottom":"100px","left":"100px"}},"color":{"text":"#ffffff","background":"#000000"}}} -->
<div class="wp-block-group alignfull has-text-color has-background" style="background-color:#000000;color:#ffffff;padding-top:100px;padding-right:100px;padding-bottom:100px;padding-left:100px"><!-- wp:query {"query":{"perPage":3,"pages":0,"offset":0,"postType":"post","categoryIds":[],"tagIds":[],"order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false}} -->
<div class="wp-block-query"><!-- wp:query-loop -->
<div class="wp-block-query"><!-- wp:post-template -->
<!-- wp:separator {"customColor":"#ffffff","align":"wide","className":"is-style-wide"} -->
<hr class="wp-block-separator alignwide has-text-color has-background is-style-wide" style="background-color:#ffffff;color:#ffffff"/>
<!-- /wp:separator -->
@ -25,7 +25,7 @@ return array(
<div class="wp-block-column is-vertically-aligned-center" style="flex-basis:80%"><!-- wp:post-title {"isLink":true,"style":{"typography":{"fontSize":"72px","lineHeight":"1.1"},"color":{"text":"#ffffff","link":"#ffffff"}}} /--></div>
<!-- /wp:column --></div>
<!-- /wp:columns -->
<!-- /wp:query-loop --></div>
<!-- /wp:post-template --></div>
<!-- /wp:query --></div>
<!-- /wp:group -->',
);

View File

@ -11,7 +11,7 @@ return array(
'categories' => array( 'query' ),
'content' => '<!-- wp:query {"query":{"perPage":1,"pages":0,"offset":0,"postType":"post","categoryIds":[],"tagIds":[],"order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false}} -->
<div class="wp-block-query">
<!-- wp:query-loop -->
<!-- wp:post-template -->
<!-- wp:columns {"align":"wide"} -->
<div class="wp-block-columns alignwide"><!-- wp:column {"width":"66.66%"} -->
<div class="wp-block-column" style="flex-basis:66.66%"><!-- wp:post-featured-image {"isLink":true} /--></div>
@ -21,7 +21,7 @@ return array(
<!-- wp:post-excerpt /--></div>
<!-- /wp:column --></div>
<!-- /wp:columns -->
<!-- /wp:query-loop -->
<!-- /wp:post-template -->
</div>
<!-- /wp:query -->',
);

View File

@ -13,26 +13,26 @@ return array(
<main class="wp-block-group" style="padding-top:30px;padding-right:30px;padding-bottom:30px;padding-left:30px"><!-- wp:columns -->
<div class="wp-block-columns"><!-- wp:column {"width":"50%"} -->
<div class="wp-block-column" style="flex-basis:50%"><!-- wp:query {"query":{"perPage":2,"pages":0,"offset":0,"postType":"post","categoryIds":[],"tagIds":[],"order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"exclude","inherit":false},"displayLayout":{"type":"list"}} -->
<div class="wp-block-query"><!-- wp:query-loop -->
<div class="wp-block-query"><!-- wp:post-template -->
<!-- wp:post-featured-image /-->
<!-- wp:post-title /-->
<!-- wp:post-date /-->
<!-- wp:spacer {"height":200} -->
<div style="height:200px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->
<!-- /wp:query-loop --></div>
<!-- /wp:post-template --></div>
<!-- /wp:query --></div>
<!-- /wp:column -->
<!-- wp:column {"width":"50%"} -->
<div class="wp-block-column" style="flex-basis:50%"><!-- wp:query {"query":{"perPage":2,"pages":0,"offset":2,"postType":"post","categoryIds":[],"tagIds":[],"order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"exclude","inherit":false},"displayLayout":{"type":"list"}} -->
<div class="wp-block-query"><!-- wp:query-loop -->
<div class="wp-block-query"><!-- wp:post-template -->
<!-- wp:spacer {"height":200} -->
<div style="height:200px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->
<!-- wp:post-featured-image /-->
<!-- wp:post-title /-->
<!-- wp:post-date /-->
<!-- /wp:query-loop --></div>
<!-- /wp:post-template --></div>
<!-- /wp:query --></div>
<!-- /wp:column --></div>
<!-- /wp:columns --></main>

View File

@ -11,7 +11,7 @@ return array(
'categories' => array( 'query' ),
'content' => '<!-- wp:query {"query":{"perPage":1,"pages":0,"offset":0,"postType":"post","categoryIds":[],"tagIds":[],"order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false}} -->
<div class="wp-block-query">
<!-- wp:query-loop -->
<!-- wp:post-template -->
<!-- wp:columns {"verticalAlignment":"center"} -->
<div class="wp-block-columns are-vertically-aligned-center"><!-- wp:column {"verticalAlignment":"center","width":"25%"} -->
<div class="wp-block-column is-vertically-aligned-center" style="flex-basis:25%"><!-- wp:post-featured-image {"isLink":true} /--></div>
@ -20,7 +20,7 @@ return array(
<div class="wp-block-column is-vertically-aligned-center" style="flex-basis:75%"><!-- wp:post-title {"isLink":true} /--></div>
<!-- /wp:column --></div>
<!-- /wp:columns -->
<!-- /wp:query-loop -->
<!-- /wp:post-template -->
</div>
<!-- /wp:query -->',
);

View File

@ -11,7 +11,7 @@ return array(
'categories' => array( 'query' ),
'content' => '<!-- wp:query {"query":{"perPage":1,"pages":0,"offset":0,"postType":"post","categoryIds":[],"tagIds":[],"order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false}} -->
<div class="wp-block-query">
<!-- wp:query-loop -->
<!-- wp:post-template -->
<!-- wp:post-title {"isLink":true} /-->
<!-- wp:post-featured-image {"isLink":true,"align":"wide"} /-->
<!-- wp:post-excerpt /-->
@ -19,7 +19,7 @@ return array(
<hr class="wp-block-separator"/>
<!-- /wp:separator -->
<!-- wp:post-date /-->
<!-- /wp:query-loop -->
<!-- /wp:post-template -->
</div>
<!-- /wp:query -->',
);

View File

@ -21,8 +21,8 @@ require ABSPATH . WPINC . '/blocks/post-excerpt.php';
require ABSPATH . WPINC . '/blocks/post-featured-image.php';
require ABSPATH . WPINC . '/blocks/post-terms.php';
require ABSPATH . WPINC . '/blocks/post-title.php';
require ABSPATH . WPINC . '/blocks/post-template.php';
require ABSPATH . WPINC . '/blocks/query.php';
require ABSPATH . WPINC . '/blocks/query-loop.php';
require ABSPATH . WPINC . '/blocks/query-pagination.php';
require ABSPATH . WPINC . '/blocks/query-pagination-next.php';
require ABSPATH . WPINC . '/blocks/query-pagination-numbers.php';

View File

@ -0,0 +1,148 @@
<?php
/**
* Server-side rendering of the `core/post-template` block.
*
* @package WordPress
*/
/**
* Renders the `core/post-template` block on the server.
*
* @param array $attributes Block attributes.
* @param string $content Block default content.
* @param WP_Block $block Block instance.
*
* @return string Returns the output of the query, structured using the layout defined by the block's inner blocks.
*/
function render_block_core_post_template( $attributes, $content, $block ) {
$page_key = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page';
$page = empty( $_GET[ $page_key ] ) ? 1 : (int) $_GET[ $page_key ];
$query_args = build_query_vars_from_query_block( $block, $page );
// Override the custom query with the global query if needed.
$use_global_query = ( isset( $block->context['query']['inherit'] ) && $block->context['query']['inherit'] );
if ( $use_global_query ) {
global $wp_query;
if ( $wp_query && isset( $wp_query->query_vars ) && is_array( $wp_query->query_vars ) ) {
// Unset `offset` because if is set, $wp_query overrides/ignores the paged parameter and breaks pagination.
unset( $query_args['offset'] );
$query_args = wp_parse_args( $wp_query->query_vars, $query_args );
if ( empty( $query_args['post_type'] ) && is_singular() ) {
$query_args['post_type'] = get_post_type( get_the_ID() );
}
}
}
$query = new WP_Query( $query_args );
if ( ! $query->have_posts() ) {
return '';
}
$classnames = '';
if ( isset( $block->context['displayLayout'] ) && isset( $block->context['query'] ) ) {
if ( isset( $block->context['displayLayout']['type'] ) && 'flex' === $block->context['displayLayout']['type'] ) {
$classnames = "is-flex-container columns-{$block->context['displayLayout']['columns']}";
}
}
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classnames ) );
$content = '';
while ( $query->have_posts() ) {
$query->the_post();
$block_content = (
new WP_Block(
$block->parsed_block,
array(
'postType' => get_post_type(),
'postId' => get_the_ID(),
)
)
)->render( array( 'dynamic' => false ) );
$content .= "<li>{$block_content}</li>";
}
wp_reset_postdata();
return sprintf(
'<ul %1$s>%2$s</ul>',
$wrapper_attributes,
$content
);
}
/**
* Registers the `core/post-template` block on the server.
*/
function register_block_core_post_template() {
register_block_type_from_metadata(
__DIR__ . '/post-template',
array(
'render_callback' => 'render_block_core_post_template',
'skip_inner_blocks' => true,
)
);
}
add_action( 'init', 'register_block_core_post_template' );
/**
* Renders the legacy `core/query-loop` block on the server.
* It triggers a developer warning and then calls the renamed
* block's `render_callback` function output.
*
* This can be removed when WordPress 5.9 is released.
*
* @param array $attributes Block attributes.
* @param string $content Block default content.
* @param WP_Block $block Block instance.
*
* @return string Returns the output of the query, structured using the layout defined by the block's inner blocks.
*/
function render_legacy_query_loop_block( $attributes, $content, $block ) {
trigger_error(
/* translators: %1$s: Block type */
sprintf( __( 'Block %1$s has been renamed to Post Template. %1$s will be supported until WordPress version 5.9.', 'gutenberg' ), $block->name ),
headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE
);
return render_block_core_post_template( $attributes, $content, $block );
}
/**
* Complements the renaming of `Query Loop` to `Post Template`.
* This ensures backwards compatibility for any users running the Gutenberg
* plugin who have used Query Loop prior to its renaming.
*
* This can be removed when WordPress 5.9 is released.
*
* @see https://github.com/WordPress/gutenberg/pull/32514
*/
function gutenberg_register_legacy_query_loop_block() {
$registry = WP_Block_Type_Registry::get_instance();
if ( $registry->is_registered( 'core/query-loop' ) ) {
unregister_block_type( 'core/query-loop' );
}
register_block_type(
'core/query-loop',
array(
'category' => 'design',
'uses_context' => array(
'queryId',
'query',
'queryContext',
'displayLayout',
'templateSlug',
),
'supports' => array(
'reusable' => false,
'html' => false,
'align' => true,
),
'style' => 'wp-block-post-template',
'render_callback' => 'render_legacy_query_loop_block',
'skip_inner_blocks' => true,
)
);
}
add_action( 'init', 'gutenberg_register_legacy_query_loop_block' );

View File

@ -1,10 +1,10 @@
{
"apiVersion": 2,
"name": "core/query-loop",
"title": "Query Loop",
"name": "core/post-template",
"title": "Post Template",
"category": "design",
"parent": [ "core/query" ],
"description": "Query loop.",
"description": "Post Template.",
"textdomain": "default",
"usesContext": [
"queryId",
@ -18,6 +18,6 @@
"html": false,
"align": true
},
"style": "wp-block-query-loop",
"editorStyle": "wp-block-query-loop-editor"
"style": "wp-block-post-template",
"editorStyle": "wp-block-post-template-editor"
}

View File

@ -68,7 +68,7 @@
/**
* Reset the WP Admin page styles for Gutenberg-like pages.
*/
.editor-styles-wrapper ul.wp-block-query-loop {
.editor-styles-wrapper ul.wp-block-post-template {
padding-right: 0;
margin-right: 0;
list-style: none;

View File

@ -0,0 +1 @@
.editor-styles-wrapper ul.wp-block-post-template{padding-right:0;margin-right:0;list-style:none}

View File

@ -68,7 +68,7 @@
/**
* Reset the WP Admin page styles for Gutenberg-like pages.
*/
.editor-styles-wrapper ul.wp-block-query-loop {
.editor-styles-wrapper ul.wp-block-post-template {
padding-left: 0;
margin-left: 0;
list-style: none;

View File

@ -0,0 +1 @@
.editor-styles-wrapper ul.wp-block-post-template{padding-left:0;margin-left:0;list-style:none}

View File

@ -68,55 +68,70 @@
/**
* Reset the WP Admin page styles for Gutenberg-like pages.
*/
.wp-block-post-template,
.wp-block-query-loop {
max-width: 100%;
list-style: none;
padding: 0;
}
.wp-block-post-template li,
.wp-block-query-loop li {
clear: both;
}
.wp-block-post-template.is-flex-container,
.wp-block-query-loop.is-flex-container {
flex-direction: row;
display: flex;
flex-wrap: wrap;
}
.wp-block-post-template.is-flex-container li,
.wp-block-query-loop.is-flex-container li {
margin: 0 0 1.25em 0;
width: 100%;
}
@media (min-width: 600px) {
.wp-block-query-loop.is-flex-container li {
.wp-block-post-template.is-flex-container li,
.wp-block-query-loop.is-flex-container li {
margin-left: 1.25em;
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-2 > li {
.wp-block-post-template.is-flex-container.is-flex-container.columns-2 > li,
.wp-block-query-loop.is-flex-container.is-flex-container.columns-2 > li {
width: calc((100% / 2) - 1.25em + (1.25em / 2));
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-2 > li:nth-child(2n) {
.wp-block-post-template.is-flex-container.is-flex-container.columns-2 > li:nth-child(2n),
.wp-block-query-loop.is-flex-container.is-flex-container.columns-2 > li:nth-child(2n) {
margin-left: 0;
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-3 > li {
.wp-block-post-template.is-flex-container.is-flex-container.columns-3 > li,
.wp-block-query-loop.is-flex-container.is-flex-container.columns-3 > li {
width: calc((100% / 3) - 1.25em + (1.25em / 3));
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-3 > li:nth-child(3n) {
.wp-block-post-template.is-flex-container.is-flex-container.columns-3 > li:nth-child(3n),
.wp-block-query-loop.is-flex-container.is-flex-container.columns-3 > li:nth-child(3n) {
margin-left: 0;
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-4 > li {
.wp-block-post-template.is-flex-container.is-flex-container.columns-4 > li,
.wp-block-query-loop.is-flex-container.is-flex-container.columns-4 > li {
width: calc((100% / 4) - 1.25em + (1.25em / 4));
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-4 > li:nth-child(4n) {
.wp-block-post-template.is-flex-container.is-flex-container.columns-4 > li:nth-child(4n),
.wp-block-query-loop.is-flex-container.is-flex-container.columns-4 > li:nth-child(4n) {
margin-left: 0;
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-5 > li {
.wp-block-post-template.is-flex-container.is-flex-container.columns-5 > li,
.wp-block-query-loop.is-flex-container.is-flex-container.columns-5 > li {
width: calc((100% / 5) - 1.25em + (1.25em / 5));
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-5 > li:nth-child(5n) {
.wp-block-post-template.is-flex-container.is-flex-container.columns-5 > li:nth-child(5n),
.wp-block-query-loop.is-flex-container.is-flex-container.columns-5 > li:nth-child(5n) {
margin-left: 0;
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-6 > li {
.wp-block-post-template.is-flex-container.is-flex-container.columns-6 > li,
.wp-block-query-loop.is-flex-container.is-flex-container.columns-6 > li {
width: calc((100% / 6) - 1.25em + (1.25em / 6));
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-6 > li:nth-child(6n) {
.wp-block-post-template.is-flex-container.is-flex-container.columns-6 > li:nth-child(6n),
.wp-block-query-loop.is-flex-container.is-flex-container.columns-6 > li:nth-child(6n) {
margin-left: 0;
}
}

View File

@ -0,0 +1 @@
.wp-block-post-template,.wp-block-query-loop{max-width:100%;list-style:none;padding:0}.wp-block-post-template li,.wp-block-query-loop li{clear:both}.wp-block-post-template.is-flex-container,.wp-block-query-loop.is-flex-container{flex-direction:row;display:flex;flex-wrap:wrap}.wp-block-post-template.is-flex-container li,.wp-block-query-loop.is-flex-container li{margin:0 0 1.25em;width:100%}@media (min-width:600px){.wp-block-post-template.is-flex-container li,.wp-block-query-loop.is-flex-container li{margin-left:1.25em}.wp-block-post-template.is-flex-container.is-flex-container.columns-2>li,.wp-block-query-loop.is-flex-container.is-flex-container.columns-2>li{width:calc(50% - .625em)}.wp-block-post-template.is-flex-container.is-flex-container.columns-2>li:nth-child(2n),.wp-block-query-loop.is-flex-container.is-flex-container.columns-2>li:nth-child(2n){margin-left:0}.wp-block-post-template.is-flex-container.is-flex-container.columns-3>li,.wp-block-query-loop.is-flex-container.is-flex-container.columns-3>li{width:calc(33.33333% - .83333em)}.wp-block-post-template.is-flex-container.is-flex-container.columns-3>li:nth-child(3n),.wp-block-query-loop.is-flex-container.is-flex-container.columns-3>li:nth-child(3n){margin-left:0}.wp-block-post-template.is-flex-container.is-flex-container.columns-4>li,.wp-block-query-loop.is-flex-container.is-flex-container.columns-4>li{width:calc(25% - .9375em)}.wp-block-post-template.is-flex-container.is-flex-container.columns-4>li:nth-child(4n),.wp-block-query-loop.is-flex-container.is-flex-container.columns-4>li:nth-child(4n){margin-left:0}.wp-block-post-template.is-flex-container.is-flex-container.columns-5>li,.wp-block-query-loop.is-flex-container.is-flex-container.columns-5>li{width:calc(20% - 1em)}.wp-block-post-template.is-flex-container.is-flex-container.columns-5>li:nth-child(5n),.wp-block-query-loop.is-flex-container.is-flex-container.columns-5>li:nth-child(5n){margin-left:0}.wp-block-post-template.is-flex-container.is-flex-container.columns-6>li,.wp-block-query-loop.is-flex-container.is-flex-container.columns-6>li{width:calc(16.66667% - 1.04167em)}.wp-block-post-template.is-flex-container.is-flex-container.columns-6>li:nth-child(6n),.wp-block-query-loop.is-flex-container.is-flex-container.columns-6>li:nth-child(6n){margin-left:0}}

View File

@ -68,55 +68,70 @@
/**
* Reset the WP Admin page styles for Gutenberg-like pages.
*/
.wp-block-post-template,
.wp-block-query-loop {
max-width: 100%;
list-style: none;
padding: 0;
}
.wp-block-post-template li,
.wp-block-query-loop li {
clear: both;
}
.wp-block-post-template.is-flex-container,
.wp-block-query-loop.is-flex-container {
flex-direction: row;
display: flex;
flex-wrap: wrap;
}
.wp-block-post-template.is-flex-container li,
.wp-block-query-loop.is-flex-container li {
margin: 0 0 1.25em 0;
width: 100%;
}
@media (min-width: 600px) {
.wp-block-query-loop.is-flex-container li {
.wp-block-post-template.is-flex-container li,
.wp-block-query-loop.is-flex-container li {
margin-right: 1.25em;
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-2 > li {
.wp-block-post-template.is-flex-container.is-flex-container.columns-2 > li,
.wp-block-query-loop.is-flex-container.is-flex-container.columns-2 > li {
width: calc((100% / 2) - 1.25em + (1.25em / 2));
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-2 > li:nth-child(2n) {
.wp-block-post-template.is-flex-container.is-flex-container.columns-2 > li:nth-child(2n),
.wp-block-query-loop.is-flex-container.is-flex-container.columns-2 > li:nth-child(2n) {
margin-right: 0;
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-3 > li {
.wp-block-post-template.is-flex-container.is-flex-container.columns-3 > li,
.wp-block-query-loop.is-flex-container.is-flex-container.columns-3 > li {
width: calc((100% / 3) - 1.25em + (1.25em / 3));
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-3 > li:nth-child(3n) {
.wp-block-post-template.is-flex-container.is-flex-container.columns-3 > li:nth-child(3n),
.wp-block-query-loop.is-flex-container.is-flex-container.columns-3 > li:nth-child(3n) {
margin-right: 0;
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-4 > li {
.wp-block-post-template.is-flex-container.is-flex-container.columns-4 > li,
.wp-block-query-loop.is-flex-container.is-flex-container.columns-4 > li {
width: calc((100% / 4) - 1.25em + (1.25em / 4));
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-4 > li:nth-child(4n) {
.wp-block-post-template.is-flex-container.is-flex-container.columns-4 > li:nth-child(4n),
.wp-block-query-loop.is-flex-container.is-flex-container.columns-4 > li:nth-child(4n) {
margin-right: 0;
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-5 > li {
.wp-block-post-template.is-flex-container.is-flex-container.columns-5 > li,
.wp-block-query-loop.is-flex-container.is-flex-container.columns-5 > li {
width: calc((100% / 5) - 1.25em + (1.25em / 5));
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-5 > li:nth-child(5n) {
.wp-block-post-template.is-flex-container.is-flex-container.columns-5 > li:nth-child(5n),
.wp-block-query-loop.is-flex-container.is-flex-container.columns-5 > li:nth-child(5n) {
margin-right: 0;
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-6 > li {
.wp-block-post-template.is-flex-container.is-flex-container.columns-6 > li,
.wp-block-query-loop.is-flex-container.is-flex-container.columns-6 > li {
width: calc((100% / 6) - 1.25em + (1.25em / 6));
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-6 > li:nth-child(6n) {
.wp-block-post-template.is-flex-container.is-flex-container.columns-6 > li:nth-child(6n),
.wp-block-query-loop.is-flex-container.is-flex-container.columns-6 > li:nth-child(6n) {
margin-right: 0;
}
}

View File

@ -0,0 +1 @@
.wp-block-post-template,.wp-block-query-loop{max-width:100%;list-style:none;padding:0}.wp-block-post-template li,.wp-block-query-loop li{clear:both}.wp-block-post-template.is-flex-container,.wp-block-query-loop.is-flex-container{flex-direction:row;display:flex;flex-wrap:wrap}.wp-block-post-template.is-flex-container li,.wp-block-query-loop.is-flex-container li{margin:0 0 1.25em;width:100%}@media (min-width:600px){.wp-block-post-template.is-flex-container li,.wp-block-query-loop.is-flex-container li{margin-right:1.25em}.wp-block-post-template.is-flex-container.is-flex-container.columns-2>li,.wp-block-query-loop.is-flex-container.is-flex-container.columns-2>li{width:calc(50% - .625em)}.wp-block-post-template.is-flex-container.is-flex-container.columns-2>li:nth-child(2n),.wp-block-query-loop.is-flex-container.is-flex-container.columns-2>li:nth-child(2n){margin-right:0}.wp-block-post-template.is-flex-container.is-flex-container.columns-3>li,.wp-block-query-loop.is-flex-container.is-flex-container.columns-3>li{width:calc(33.33333% - .83333em)}.wp-block-post-template.is-flex-container.is-flex-container.columns-3>li:nth-child(3n),.wp-block-query-loop.is-flex-container.is-flex-container.columns-3>li:nth-child(3n){margin-right:0}.wp-block-post-template.is-flex-container.is-flex-container.columns-4>li,.wp-block-query-loop.is-flex-container.is-flex-container.columns-4>li{width:calc(25% - .9375em)}.wp-block-post-template.is-flex-container.is-flex-container.columns-4>li:nth-child(4n),.wp-block-query-loop.is-flex-container.is-flex-container.columns-4>li:nth-child(4n){margin-right:0}.wp-block-post-template.is-flex-container.is-flex-container.columns-5>li,.wp-block-query-loop.is-flex-container.is-flex-container.columns-5>li{width:calc(20% - 1em)}.wp-block-post-template.is-flex-container.is-flex-container.columns-5>li:nth-child(5n),.wp-block-query-loop.is-flex-container.is-flex-container.columns-5>li:nth-child(5n){margin-right:0}.wp-block-post-template.is-flex-container.is-flex-container.columns-6>li,.wp-block-query-loop.is-flex-container.is-flex-container.columns-6>li{width:calc(16.66667% - 1.04167em)}.wp-block-post-template.is-flex-container.is-flex-container.columns-6>li:nth-child(6n),.wp-block-query-loop.is-flex-container.is-flex-container.columns-6>li:nth-child(6n){margin-right:0}}

View File

@ -1,88 +0,0 @@
<?php
/**
* Server-side rendering of the `core/query-loop` block.
*
* @package WordPress
*/
/**
* Renders the `core/query-loop` block on the server.
*
* @param array $attributes Block attributes.
* @param string $content Block default content.
* @param WP_Block $block Block instance.
*
* @return string Returns the output of the query, structured using the layout defined by the block's inner blocks.
*/
function render_block_core_query_loop( $attributes, $content, $block ) {
$page_key = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page';
$page = empty( $_GET[ $page_key ] ) ? 1 : (int) $_GET[ $page_key ];
$query_args = build_query_vars_from_query_block( $block, $page );
// Override the custom query with the global query if needed.
$use_global_query = ( isset( $block->context['query']['inherit'] ) && $block->context['query']['inherit'] );
if ( $use_global_query ) {
global $wp_query;
if ( $wp_query && isset( $wp_query->query_vars ) && is_array( $wp_query->query_vars ) ) {
// Unset `offset` because if is set, $wp_query overrides/ignores the paged parameter and breaks pagination.
unset( $query_args['offset'] );
$query_args = wp_parse_args( $wp_query->query_vars, $query_args );
if ( empty( $query_args['post_type'] ) && is_singular() ) {
$query_args['post_type'] = get_post_type( get_the_ID() );
}
}
}
$query = new WP_Query( $query_args );
if ( ! $query->have_posts() ) {
return '';
}
$classnames = '';
if ( isset( $block->context['displayLayout'] ) && isset( $block->context['query'] ) ) {
if ( isset( $block->context['displayLayout']['type'] ) && 'flex' === $block->context['displayLayout']['type'] ) {
$classnames = "is-flex-container columns-{$block->context['displayLayout']['columns']}";
}
}
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classnames ) );
$content = '';
while ( $query->have_posts() ) {
$query->the_post();
$block_content = (
new WP_Block(
$block->parsed_block,
array(
'postType' => get_post_type(),
'postId' => get_the_ID(),
)
)
)->render( array( 'dynamic' => false ) );
$content .= "<li>{$block_content}</li>";
}
wp_reset_postdata();
return sprintf(
'<ul %1$s>%2$s</ul>',
$wrapper_attributes,
$content
);
}
/**
* Registers the `core/query-loop` block on the server.
*/
function register_block_core_query_loop() {
register_block_type_from_metadata(
__DIR__ . '/query-loop',
array(
'render_callback' => 'render_block_core_query_loop',
'skip_inner_blocks' => true,
)
);
}
add_action( 'init', 'register_block_core_query_loop' );

View File

@ -1 +0,0 @@
.editor-styles-wrapper ul.wp-block-query-loop{padding-right:0;margin-right:0;list-style:none}

View File

@ -1 +0,0 @@
.editor-styles-wrapper ul.wp-block-query-loop{padding-left:0;margin-left:0;list-style:none}

View File

@ -1 +0,0 @@
.wp-block-query-loop{max-width:100%;list-style:none;padding:0}.wp-block-query-loop li{clear:both}.wp-block-query-loop.is-flex-container{flex-direction:row;display:flex;flex-wrap:wrap}.wp-block-query-loop.is-flex-container li{margin:0 0 1.25em;width:100%}@media (min-width:600px){.wp-block-query-loop.is-flex-container li{margin-left:1.25em}.wp-block-query-loop.is-flex-container.is-flex-container.columns-2>li{width:calc(50% - .625em)}.wp-block-query-loop.is-flex-container.is-flex-container.columns-2>li:nth-child(2n){margin-left:0}.wp-block-query-loop.is-flex-container.is-flex-container.columns-3>li{width:calc(33.33333% - .83333em)}.wp-block-query-loop.is-flex-container.is-flex-container.columns-3>li:nth-child(3n){margin-left:0}.wp-block-query-loop.is-flex-container.is-flex-container.columns-4>li{width:calc(25% - .9375em)}.wp-block-query-loop.is-flex-container.is-flex-container.columns-4>li:nth-child(4n){margin-left:0}.wp-block-query-loop.is-flex-container.is-flex-container.columns-5>li{width:calc(20% - 1em)}.wp-block-query-loop.is-flex-container.is-flex-container.columns-5>li:nth-child(5n){margin-left:0}.wp-block-query-loop.is-flex-container.is-flex-container.columns-6>li{width:calc(16.66667% - 1.04167em)}.wp-block-query-loop.is-flex-container.is-flex-container.columns-6>li:nth-child(6n){margin-left:0}}

View File

@ -1 +0,0 @@
.wp-block-query-loop{max-width:100%;list-style:none;padding:0}.wp-block-query-loop li{clear:both}.wp-block-query-loop.is-flex-container{flex-direction:row;display:flex;flex-wrap:wrap}.wp-block-query-loop.is-flex-container li{margin:0 0 1.25em;width:100%}@media (min-width:600px){.wp-block-query-loop.is-flex-container li{margin-right:1.25em}.wp-block-query-loop.is-flex-container.is-flex-container.columns-2>li{width:calc(50% - .625em)}.wp-block-query-loop.is-flex-container.is-flex-container.columns-2>li:nth-child(2n){margin-right:0}.wp-block-query-loop.is-flex-container.is-flex-container.columns-3>li{width:calc(33.33333% - .83333em)}.wp-block-query-loop.is-flex-container.is-flex-container.columns-3>li:nth-child(3n){margin-right:0}.wp-block-query-loop.is-flex-container.is-flex-container.columns-4>li{width:calc(25% - .9375em)}.wp-block-query-loop.is-flex-container.is-flex-container.columns-4>li:nth-child(4n){margin-right:0}.wp-block-query-loop.is-flex-container.is-flex-container.columns-5>li{width:calc(20% - 1em)}.wp-block-query-loop.is-flex-container.is-flex-container.columns-5>li:nth-child(5n){margin-right:0}.wp-block-query-loop.is-flex-container.is-flex-container.columns-6>li{width:calc(16.66667% - 1.04167em)}.wp-block-query-loop.is-flex-container.is-flex-container.columns-6>li:nth-child(6n){margin-right:0}}

View File

@ -1,7 +1,7 @@
{
"apiVersion": 2,
"name": "core/query",
"title": "Query",
"title": "Query Loop",
"category": "design",
"description": "Displays a list of posts as a result of a query.",
"textdomain": "default",

View File

@ -2311,7 +2311,7 @@ body.admin-bar .wp-block-navigation__responsive-container.is-menu-open {
border: 1px dashed;
}
.editor-styles-wrapper ul.wp-block-query-loop {
.editor-styles-wrapper ul.wp-block-post-template {
padding-right: 0;
margin-right: 0;
list-style: none;

File diff suppressed because one or more lines are too long

View File

@ -2316,7 +2316,7 @@ body.admin-bar .wp-block-navigation__responsive-container.is-menu-open {
border: 1px dashed;
}
.editor-styles-wrapper ul.wp-block-query-loop {
.editor-styles-wrapper ul.wp-block-post-template {
padding-left: 0;
margin-left: 0;
list-style: none;

File diff suppressed because one or more lines are too long

View File

@ -2028,55 +2028,70 @@ p.has-text-color a {
color: inherit;
}
.wp-block-post-template,
.wp-block-query-loop {
max-width: 100%;
list-style: none;
padding: 0;
}
.wp-block-post-template li,
.wp-block-query-loop li {
clear: both;
}
.wp-block-post-template.is-flex-container,
.wp-block-query-loop.is-flex-container {
flex-direction: row;
display: flex;
flex-wrap: wrap;
}
.wp-block-post-template.is-flex-container li,
.wp-block-query-loop.is-flex-container li {
margin: 0 0 1.25em 0;
width: 100%;
}
@media (min-width: 600px) {
.wp-block-query-loop.is-flex-container li {
.wp-block-post-template.is-flex-container li,
.wp-block-query-loop.is-flex-container li {
margin-left: 1.25em;
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-2 > li {
.wp-block-post-template.is-flex-container.is-flex-container.columns-2 > li,
.wp-block-query-loop.is-flex-container.is-flex-container.columns-2 > li {
width: calc((100% / 2) - 1.25em + (1.25em / 2));
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-2 > li:nth-child(2n) {
.wp-block-post-template.is-flex-container.is-flex-container.columns-2 > li:nth-child(2n),
.wp-block-query-loop.is-flex-container.is-flex-container.columns-2 > li:nth-child(2n) {
margin-left: 0;
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-3 > li {
.wp-block-post-template.is-flex-container.is-flex-container.columns-3 > li,
.wp-block-query-loop.is-flex-container.is-flex-container.columns-3 > li {
width: calc((100% / 3) - 1.25em + (1.25em / 3));
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-3 > li:nth-child(3n) {
.wp-block-post-template.is-flex-container.is-flex-container.columns-3 > li:nth-child(3n),
.wp-block-query-loop.is-flex-container.is-flex-container.columns-3 > li:nth-child(3n) {
margin-left: 0;
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-4 > li {
.wp-block-post-template.is-flex-container.is-flex-container.columns-4 > li,
.wp-block-query-loop.is-flex-container.is-flex-container.columns-4 > li {
width: calc((100% / 4) - 1.25em + (1.25em / 4));
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-4 > li:nth-child(4n) {
.wp-block-post-template.is-flex-container.is-flex-container.columns-4 > li:nth-child(4n),
.wp-block-query-loop.is-flex-container.is-flex-container.columns-4 > li:nth-child(4n) {
margin-left: 0;
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-5 > li {
.wp-block-post-template.is-flex-container.is-flex-container.columns-5 > li,
.wp-block-query-loop.is-flex-container.is-flex-container.columns-5 > li {
width: calc((100% / 5) - 1.25em + (1.25em / 5));
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-5 > li:nth-child(5n) {
.wp-block-post-template.is-flex-container.is-flex-container.columns-5 > li:nth-child(5n),
.wp-block-query-loop.is-flex-container.is-flex-container.columns-5 > li:nth-child(5n) {
margin-left: 0;
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-6 > li {
.wp-block-post-template.is-flex-container.is-flex-container.columns-6 > li,
.wp-block-query-loop.is-flex-container.is-flex-container.columns-6 > li {
width: calc((100% / 6) - 1.25em + (1.25em / 6));
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-6 > li:nth-child(6n) {
.wp-block-post-template.is-flex-container.is-flex-container.columns-6 > li:nth-child(6n),
.wp-block-query-loop.is-flex-container.is-flex-container.columns-6 > li:nth-child(6n) {
margin-left: 0;
}
}

File diff suppressed because one or more lines are too long

View File

@ -2063,55 +2063,70 @@ p.has-text-color a {
color: inherit;
}
.wp-block-post-template,
.wp-block-query-loop {
max-width: 100%;
list-style: none;
padding: 0;
}
.wp-block-post-template li,
.wp-block-query-loop li {
clear: both;
}
.wp-block-post-template.is-flex-container,
.wp-block-query-loop.is-flex-container {
flex-direction: row;
display: flex;
flex-wrap: wrap;
}
.wp-block-post-template.is-flex-container li,
.wp-block-query-loop.is-flex-container li {
margin: 0 0 1.25em 0;
width: 100%;
}
@media (min-width: 600px) {
.wp-block-query-loop.is-flex-container li {
.wp-block-post-template.is-flex-container li,
.wp-block-query-loop.is-flex-container li {
margin-right: 1.25em;
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-2 > li {
.wp-block-post-template.is-flex-container.is-flex-container.columns-2 > li,
.wp-block-query-loop.is-flex-container.is-flex-container.columns-2 > li {
width: calc((100% / 2) - 1.25em + (1.25em / 2));
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-2 > li:nth-child(2n) {
.wp-block-post-template.is-flex-container.is-flex-container.columns-2 > li:nth-child(2n),
.wp-block-query-loop.is-flex-container.is-flex-container.columns-2 > li:nth-child(2n) {
margin-right: 0;
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-3 > li {
.wp-block-post-template.is-flex-container.is-flex-container.columns-3 > li,
.wp-block-query-loop.is-flex-container.is-flex-container.columns-3 > li {
width: calc((100% / 3) - 1.25em + (1.25em / 3));
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-3 > li:nth-child(3n) {
.wp-block-post-template.is-flex-container.is-flex-container.columns-3 > li:nth-child(3n),
.wp-block-query-loop.is-flex-container.is-flex-container.columns-3 > li:nth-child(3n) {
margin-right: 0;
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-4 > li {
.wp-block-post-template.is-flex-container.is-flex-container.columns-4 > li,
.wp-block-query-loop.is-flex-container.is-flex-container.columns-4 > li {
width: calc((100% / 4) - 1.25em + (1.25em / 4));
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-4 > li:nth-child(4n) {
.wp-block-post-template.is-flex-container.is-flex-container.columns-4 > li:nth-child(4n),
.wp-block-query-loop.is-flex-container.is-flex-container.columns-4 > li:nth-child(4n) {
margin-right: 0;
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-5 > li {
.wp-block-post-template.is-flex-container.is-flex-container.columns-5 > li,
.wp-block-query-loop.is-flex-container.is-flex-container.columns-5 > li {
width: calc((100% / 5) - 1.25em + (1.25em / 5));
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-5 > li:nth-child(5n) {
.wp-block-post-template.is-flex-container.is-flex-container.columns-5 > li:nth-child(5n),
.wp-block-query-loop.is-flex-container.is-flex-container.columns-5 > li:nth-child(5n) {
margin-right: 0;
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-6 > li {
.wp-block-post-template.is-flex-container.is-flex-container.columns-6 > li,
.wp-block-query-loop.is-flex-container.is-flex-container.columns-6 > li {
width: calc((100% / 6) - 1.25em + (1.25em / 6));
}
.wp-block-query-loop.is-flex-container.is-flex-container.columns-6 > li:nth-child(6n) {
.wp-block-post-template.is-flex-container.is-flex-container.columns-6 > li:nth-child(6n),
.wp-block-query-loop.is-flex-container.is-flex-container.columns-6 > li:nth-child(6n) {
margin-right: 0;
}
}

File diff suppressed because one or more lines are too long

View File

@ -37670,9 +37670,9 @@ function useDarkThemeBodyClassName(styles) {
body
} = ownerDocument;
const canvas = ownerDocument.querySelector(EDITOR_STYLES_SELECTOR);
const backgroundColor = defaultView.getComputedStyle(canvas, null).getPropertyValue('background-color');
const backgroundColor = defaultView.getComputedStyle(canvas, null).getPropertyValue('background-color'); // If background is transparent, it should be treated as light color.
if (tinycolor_default()(backgroundColor).getLuminance() > 0.5) {
if (tinycolor_default()(backgroundColor).getLuminance() > 0.5 || tinycolor_default()(backgroundColor).getAlpha() === 0) {
body.classList.remove('is-dark-theme');
} else {
body.classList.add('is-dark-theme');

File diff suppressed because one or more lines are too long

View File

@ -1545,12 +1545,12 @@ __webpack_require__.d(query_namespaceObject, "metadata", function() { return que
__webpack_require__.d(query_namespaceObject, "name", function() { return query_name; });
__webpack_require__.d(query_namespaceObject, "settings", function() { return query_settings; });
// NAMESPACE OBJECT: ./node_modules/@wordpress/block-library/build-module/query-loop/index.js
var query_loop_namespaceObject = {};
__webpack_require__.r(query_loop_namespaceObject);
__webpack_require__.d(query_loop_namespaceObject, "metadata", function() { return query_loop_metadata; });
__webpack_require__.d(query_loop_namespaceObject, "name", function() { return query_loop_name; });
__webpack_require__.d(query_loop_namespaceObject, "settings", function() { return query_loop_settings; });
// NAMESPACE OBJECT: ./node_modules/@wordpress/block-library/build-module/post-template/index.js
var post_template_namespaceObject = {};
__webpack_require__.r(post_template_namespaceObject);
__webpack_require__.d(post_template_namespaceObject, "metadata", function() { return post_template_metadata; });
__webpack_require__.d(post_template_namespaceObject, "name", function() { return post_template_name; });
__webpack_require__.d(post_template_namespaceObject, "settings", function() { return post_template_settings; });
// NAMESPACE OBJECT: ./node_modules/@wordpress/block-library/build-module/query-title/index.js
var query_title_namespaceObject = {};
@ -30358,7 +30358,7 @@ const QueryPlaceholder = ({
const edit_TEMPLATE = [['core/query-loop']];
const edit_TEMPLATE = [['core/post-template']];
function QueryContent({
attributes,
setAttributes
@ -30597,7 +30597,8 @@ const query_variations_variations = [{
orderBy: 'date',
author: '',
search: '',
sticky: 'exclude'
sticky: 'exclude',
inherit: false
}
},
scope: ['inserter']
@ -30605,25 +30606,25 @@ const query_variations_variations = [{
name: 'title-date',
title: Object(external_wp_i18n_["__"])('Title & Date'),
icon: titleDate,
innerBlocks: [['core/query-loop', {}, [['core/post-title'], ['core/post-date']]]],
innerBlocks: [['core/post-template', {}, [['core/post-title'], ['core/post-date']]]],
scope: ['block']
}, {
name: 'title-excerpt',
title: Object(external_wp_i18n_["__"])('Title & Excerpt'),
icon: titleExcerpt,
innerBlocks: [['core/query-loop', {}, [['core/post-title'], ['core/post-excerpt']]]],
innerBlocks: [['core/post-template', {}, [['core/post-title'], ['core/post-excerpt']]]],
scope: ['block']
}, {
name: 'title-date-excerpt',
title: Object(external_wp_i18n_["__"])('Title, Date, & Excerpt'),
icon: titleDateExcerpt,
innerBlocks: [['core/query-loop', {}, [['core/post-title'], ['core/post-date'], ['core/post-excerpt']]]],
innerBlocks: [['core/post-template', {}, [['core/post-title'], ['core/post-date'], ['core/post-excerpt']]]],
scope: ['block']
}, {
name: 'image-date-title',
title: Object(external_wp_i18n_["__"])('Image, Date, & Title'),
icon: imageDateTitle,
innerBlocks: [['core/query-loop', {}, [['core/post-featured-image'], ['core/post-date'], ['core/post-title']]]],
innerBlocks: [['core/post-template', {}, [['core/post-featured-image'], ['core/post-date'], ['core/post-title']]]],
scope: ['block']
}];
/* harmony default export */ var query_variations = (query_variations_variations);
@ -30749,7 +30750,7 @@ const queryTopInspectorControls = Object(external_wp_compose_["createHigherOrder
const query_metadata = {
apiVersion: 2,
name: "core/query",
title: "Query",
title: "Query Loop",
category: "design",
description: "Displays a list of posts as a result of a query.",
textdomain: "default",
@ -30822,7 +30823,7 @@ const query_settings = {
Object(external_wp_hooks_["addFilter"])('editor.BlockEdit', 'core/query', hooks);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-library/build-module/query-loop/edit.js
// CONCATENATED MODULE: ./node_modules/@wordpress/block-library/build-module/post-template/edit.js
/**
@ -30839,8 +30840,8 @@ Object(external_wp_hooks_["addFilter"])('editor.BlockEdit', 'core/query', hooks)
const query_loop_edit_TEMPLATE = [['core/post-title'], ['core/post-date'], ['core/post-excerpt']];
function QueryLoopEdit({
const post_template_edit_TEMPLATE = [['core/post-title'], ['core/post-date'], ['core/post-excerpt']];
function PostTemplateEdit({
clientId,
context: {
query: {
@ -30938,7 +30939,7 @@ function QueryLoopEdit({
})
});
const innerBlocksProps = Object(external_wp_blockEditor_["__experimentalUseInnerBlocksProps"])({}, {
template: query_loop_edit_TEMPLATE
template: post_template_edit_TEMPLATE
});
if (!posts) {
@ -30959,18 +30960,18 @@ function QueryLoopEdit({
})))));
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-library/build-module/query-loop/save.js
// CONCATENATED MODULE: ./node_modules/@wordpress/block-library/build-module/post-template/save.js
/**
* WordPress dependencies
*/
function QueryLoopSave() {
function PostTemplateSave() {
return Object(external_wp_element_["createElement"])(external_wp_blockEditor_["InnerBlocks"].Content, null);
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-library/build-module/query-loop/index.js
// CONCATENATED MODULE: ./node_modules/@wordpress/block-library/build-module/post-template/index.js
/**
* WordPress dependencies
*/
@ -30979,13 +30980,13 @@ function QueryLoopSave() {
* Internal dependencies
*/
const query_loop_metadata = {
const post_template_metadata = {
apiVersion: 2,
name: "core/query-loop",
title: "Query Loop",
name: "core/post-template",
title: "Post Template",
category: "design",
parent: ["core/query"],
description: "Query loop.",
description: "Post Template.",
textdomain: "default",
usesContext: ["queryId", "query", "queryContext", "displayLayout", "templateSlug"],
supports: {
@ -30993,19 +30994,19 @@ const query_loop_metadata = {
html: false,
align: true
},
style: "wp-block-query-loop",
editorStyle: "wp-block-query-loop-editor"
style: "wp-block-post-template",
editorStyle: "wp-block-post-template-editor"
};
const {
name: query_loop_name
} = query_loop_metadata;
name: post_template_name
} = post_template_metadata;
const query_loop_settings = {
const post_template_settings = {
icon: library_loop,
edit: QueryLoopEdit,
save: QueryLoopSave
edit: PostTemplateEdit,
save: PostTemplateSave
};
// CONCATENATED MODULE: ./node_modules/@wordpress/block-library/build-module/query-title/edit.js
@ -31585,6 +31586,102 @@ const postTitle = Object(external_wp_element_["createElement"])(external_wp_prim
}));
/* harmony default export */ var post_title = (postTitle);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-library/build-module/utils/hooks.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
const queryMetaData = {
apiVersion: 2,
name: "core/query",
title: "Query Loop",
category: "design",
description: "Displays a list of posts as a result of a query.",
textdomain: "default",
attributes: {
queryId: {
type: "number"
},
query: {
type: "object",
"default": {
perPage: null,
pages: 0,
offset: 0,
postType: "post",
categoryIds: [],
tagIds: [],
order: "desc",
orderBy: "date",
author: "",
search: "",
exclude: [],
sticky: "",
inherit: true
}
},
tagName: {
type: "string",
"default": "div"
},
displayLayout: {
type: "object",
"default": {
type: "list"
}
}
},
providesContext: {
queryId: "queryId",
query: "query",
displayLayout: "displayLayout"
},
supports: {
align: ["wide", "full"],
html: false,
color: {
gradients: true,
link: true
},
__experimentalLayout: true
},
editorStyle: "wp-block-query-editor"
};
const {
name: queryBlockName
} = queryMetaData;
/**
* Hook that determines if a Post block is editable or not.
* The returned value is used to determine if the specific
* Post block will be rendered in `readonly` mode or not.
*
* For now this is checking if a Post block is nested in
* a Query block. If it is, the block should not be editable.
*
* @param {string} clientId The ID of the block to be checked.
* @return {boolean} Whether the block can be edited or not.
*/
function useIsEditablePostBlock(clientId) {
return Object(external_wp_data_["useSelect"])(select => {
const {
getBlockParents,
getBlockName
} = select(external_wp_blockEditor_["store"]);
const blockParents = getBlockParents(clientId);
const hasQueryParent = blockParents.some(parentClientId => getBlockName(parentClientId) === queryBlockName);
return !hasQueryParent;
}, [clientId]);
}
/* harmony default export */ var utils_hooks = ({
useIsEditablePostBlock
});
// CONCATENATED MODULE: ./node_modules/@wordpress/block-library/build-module/post-title/edit.js
@ -31607,7 +31704,9 @@ const postTitle = Object(external_wp_element_["createElement"])(external_wp_prim
*/
function PostTitleEdit({
clientId,
attributes: {
level,
textAlign,
@ -31622,6 +31721,7 @@ function PostTitleEdit({
}
}) {
const TagName = 0 === level ? 'p' : 'h' + level;
const isEditable = useIsEditablePostBlock(clientId);
const post = Object(external_wp_data_["useSelect"])(select => select(external_wp_coreData_["store"]).getEditedEntityRecord('postType', postType, postId), [postType, postId]);
const {
editEntityRecord
@ -31643,7 +31743,7 @@ function PostTitleEdit({
let titleElement = Object(external_wp_element_["createElement"])(TagName, isLink ? {} : blockProps, Object(external_wp_i18n_["__"])('An example title'));
if (postType && postId) {
titleElement = Object(external_wp_element_["createElement"])(external_wp_blockEditor_["PlainText"], Object(esm_extends["a" /* default */])({
titleElement = isEditable ? Object(external_wp_element_["createElement"])(external_wp_blockEditor_["PlainText"], Object(esm_extends["a" /* default */])({
tagName: TagName,
placeholder: Object(external_wp_i18n_["__"])('No Title'),
value: title,
@ -31651,11 +31751,11 @@ function PostTitleEdit({
title: value
}),
__experimentalVersion: 2
}, isLink ? {} : blockProps));
}, isLink ? {} : blockProps)) : Object(external_wp_element_["createElement"])(TagName, isLink ? {} : blockProps, title);
}
if (isLink) {
titleElement = Object(external_wp_element_["createElement"])(TagName, blockProps, Object(external_wp_element_["createElement"])(external_wp_blockEditor_["PlainText"], {
titleElement = isEditable ? Object(external_wp_element_["createElement"])(TagName, blockProps, Object(external_wp_element_["createElement"])(external_wp_blockEditor_["PlainText"], {
tagName: "a",
href: link,
target: linkTarget,
@ -31666,7 +31766,12 @@ function PostTitleEdit({
title: value
}),
__experimentalVersion: 2
}));
})) : Object(external_wp_element_["createElement"])(TagName, blockProps, Object(external_wp_element_["createElement"])("a", {
href: link,
target: linkTarget,
rel: rel,
onClick: event => event.preventDefault()
}, title));
}
return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(external_wp_blockEditor_["BlockControls"], {
@ -31796,8 +31901,24 @@ const postContent = Object(external_wp_element_["createElement"])(external_wp_pr
/**
* Internal dependencies
*/
function Content({
function ReadOnlyContent({
postType,
postId
}) {
const [,, content] = Object(external_wp_coreData_["useEntityProp"])('postType', postType, 'content', postId);
const blockProps = Object(external_wp_blockEditor_["useBlockProps"])();
return Object(external_wp_element_["createElement"])("div", blockProps, Object(external_wp_element_["createElement"])(external_wp_element_["RawHTML"], {
key: "html"
}, content === null || content === void 0 ? void 0 : content.rendered));
}
function EditableContent({
layout,
postType,
postId
@ -31844,6 +31965,19 @@ function Content({
return Object(external_wp_element_["createElement"])("div", props);
}
function Content(props) {
const {
clientId,
postType,
postId
} = props;
const isEditable = useIsEditablePostBlock(clientId);
return isEditable ? Object(external_wp_element_["createElement"])(EditableContent, props) : Object(external_wp_element_["createElement"])(ReadOnlyContent, {
postType: postType,
postId: postId
});
}
function edit_Placeholder() {
const blockProps = Object(external_wp_blockEditor_["useBlockProps"])();
return Object(external_wp_element_["createElement"])("div", blockProps, Object(external_wp_element_["createElement"])("div", {
@ -31857,6 +31991,7 @@ function RecursionError() {
}
function PostContentEdit({
clientId,
context: {
postId: contextPostId,
postType: contextPostType
@ -31875,7 +32010,8 @@ function PostContentEdit({
return Object(external_wp_element_["createElement"])(RecursionProvider, null, contextPostId && contextPostType ? Object(external_wp_element_["createElement"])(Content, {
postType: contextPostType,
postId: contextPostId,
layout: layout
layout: layout,
clientId: clientId
}) : Object(external_wp_element_["createElement"])(edit_Placeholder, null));
}
@ -31948,7 +32084,13 @@ const post_date_postDate = Object(external_wp_element_["createElement"])(externa
/**
* Internal dependencies
*/
function PostDateEdit({
clientId,
attributes,
context,
setAttributes
@ -31962,6 +32104,7 @@ function PostDateEdit({
postId,
postType
} = context;
const isEditable = useIsEditablePostBlock(clientId);
const [siteFormat] = Object(external_wp_coreData_["useEntityProp"])('root', 'site', 'date_format');
const [date, setDate] = Object(external_wp_coreData_["useEntityProp"])('postType', postType, 'date', postId);
const [isPickerOpen, setIsPickerOpen] = Object(external_wp_element_["useState"])(false);
@ -32010,7 +32153,7 @@ function PostDateEdit({
textAlign: nextAlign
});
}
}), date && Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarButton"], {
}), date && isEditable && Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarButton"], {
icon: library_edit["a" /* default */],
title: Object(external_wp_i18n_["__"])('Change Date'),
onClick: () => setIsPickerOpen(_isPickerOpen => !_isPickerOpen)
@ -32120,6 +32263,11 @@ const post_excerpt_postExcerpt = Object(external_wp_element_["createElement"])(e
/**
* Internal dependencies
*/
function usePostContentExcerpt(wordCount, postId, postType) {
// Don't destrcuture items from content here, it can be undefined.
@ -32138,6 +32286,7 @@ function usePostContentExcerpt(wordCount, postId, postType) {
}
function PostExcerptEditor({
clientId,
attributes: {
textAlign,
wordCount,
@ -32151,6 +32300,7 @@ function PostExcerptEditor({
postType
}
}) {
const isEditable = useIsEditablePostBlock(clientId);
const [excerpt, setExcerpt] = Object(external_wp_coreData_["useEntityProp"])('postType', postType, 'excerpt', postId);
const postContentExcerpt = usePostContentExcerpt(wordCount, postId, postType);
const blockProps = Object(external_wp_blockEditor_["useBlockProps"])({
@ -32173,6 +32323,12 @@ function PostExcerptEditor({
moreText: newMoreText
})
});
const excerptContent = isEditable ? Object(external_wp_element_["createElement"])(external_wp_blockEditor_["RichText"], {
className: !showMoreOnNewLine && 'wp-block-post-excerpt__excerpt is-inline',
"aria-label": Object(external_wp_i18n_["__"])('Post excerpt text'),
value: excerpt || postContentExcerpt || (isSelected ? '' : Object(external_wp_i18n_["__"])('No post excerpt found')),
onChange: setExcerpt
}) : excerpt || postContentExcerpt || Object(external_wp_i18n_["__"])('No post excerpt found');
return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(external_wp_blockEditor_["BlockControls"], null, Object(external_wp_element_["createElement"])(external_wp_blockEditor_["AlignmentToolbar"], {
value: textAlign,
onChange: newAlign => setAttributes({
@ -32194,12 +32350,7 @@ function PostExcerptEditor({
onChange: newShowMoreOnNewLine => setAttributes({
showMoreOnNewLine: newShowMoreOnNewLine
})
}))), Object(external_wp_element_["createElement"])("div", blockProps, Object(external_wp_element_["createElement"])(external_wp_blockEditor_["RichText"], {
className: !showMoreOnNewLine && 'wp-block-post-excerpt__excerpt is-inline',
"aria-label": Object(external_wp_i18n_["__"])('Post excerpt text'),
value: excerpt || postContentExcerpt || (isSelected ? '' : Object(external_wp_i18n_["__"])('No post excerpt found')),
onChange: setExcerpt
}), !showMoreOnNewLine && ' ', showMoreOnNewLine ? Object(external_wp_element_["createElement"])("p", {
}))), Object(external_wp_element_["createElement"])("div", blockProps, excerptContent, !showMoreOnNewLine && ' ', showMoreOnNewLine ? Object(external_wp_element_["createElement"])("p", {
className: "wp-block-post-excerpt__more-text"
}, readMoreLink) : readMoreLink));
}
@ -32288,6 +32439,11 @@ const postFeaturedImage = Object(external_wp_element_["createElement"])(external
/**
* Internal dependencies
*/
const post_featured_image_edit_ALLOWED_MEDIA_TYPES = ['image'];
const placeholderChip = Object(external_wp_element_["createElement"])("div", {
className: "post-featured-image_placeholder"
@ -32296,6 +32452,7 @@ const placeholderChip = Object(external_wp_element_["createElement"])("div", {
}), Object(external_wp_element_["createElement"])("p", null, " ", Object(external_wp_i18n_["__"])('Featured Image')));
function PostFeaturedImageDisplay({
clientId,
attributes: {
isLink
},
@ -32307,8 +32464,10 @@ function PostFeaturedImageDisplay({
noticeUI,
noticeOperations
}) {
const isEditable = useIsEditablePostBlock(clientId);
const [featuredImage, setFeaturedImage] = Object(external_wp_coreData_["useEntityProp"])('postType', postType, 'featured_media', postId);
const media = Object(external_wp_data_["useSelect"])(select => featuredImage && select(external_wp_coreData_["store"]).getMedia(featuredImage), [featuredImage]);
const blockProps = Object(external_wp_blockEditor_["useBlockProps"])();
const onSelectImage = value => {
if (value !== null && value !== void 0 && value.id) {
@ -32323,6 +32482,10 @@ function PostFeaturedImageDisplay({
let image;
if (!featuredImage && !isEditable) {
return Object(external_wp_element_["createElement"])("div", blockProps, placeholderChip);
}
if (!featuredImage) {
image = Object(external_wp_element_["createElement"])(external_wp_blockEditor_["MediaPlaceholder"], {
icon: Object(external_wp_element_["createElement"])(external_wp_blockEditor_["BlockIcon"], {
@ -32355,16 +32518,16 @@ function PostFeaturedImageDisplay({
isLink: !isLink
}),
checked: isLink
}))), Object(external_wp_element_["createElement"])(external_wp_blockEditor_["BlockControls"], {
}))), !!media && isEditable && Object(external_wp_element_["createElement"])(external_wp_blockEditor_["BlockControls"], {
group: "other"
}, !!media && Object(external_wp_element_["createElement"])(external_wp_blockEditor_["MediaReplaceFlow"], {
}, Object(external_wp_element_["createElement"])(external_wp_blockEditor_["MediaReplaceFlow"], {
mediaId: featuredImage,
mediaURL: media.source_url,
allowedTypes: post_featured_image_edit_ALLOWED_MEDIA_TYPES,
accept: "image/*",
onSelect: onSelectImage,
onError: onUploadError
})), Object(external_wp_element_["createElement"])("figure", Object(external_wp_blockEditor_["useBlockProps"])(), image));
})), Object(external_wp_element_["createElement"])("figure", blockProps, image));
}
const PostFeaturedImageWithNotices = Object(external_wp_components_["withNotices"])(PostFeaturedImageDisplay);
@ -32771,7 +32934,7 @@ build_module_paragraph_namespaceObject, build_module_image_namespaceObject, buil
build_module_shortcode_namespaceObject, archives_namespaceObject, build_module_audio_namespaceObject, button_namespaceObject, build_module_buttons_namespaceObject, build_module_calendar_namespaceObject, categories_namespaceObject, code_namespaceObject, build_module_columns_namespaceObject, build_module_column_namespaceObject, build_module_cover_namespaceObject, embed_namespaceObject, build_module_file_namespaceObject, build_module_group_namespaceObject, window.wp && window.wp.oldEditor ? freeform_namespaceObject : null, // Only add the classic block in WP Context
build_module_html_namespaceObject, media_text_namespaceObject, latest_comments_namespaceObject, latest_posts_namespaceObject, legacy_widget_namespaceObject, missing_namespaceObject, build_module_more_namespaceObject, nextpage_namespaceObject, page_list_namespaceObject, build_module_preformatted_namespaceObject, build_module_pullquote_namespaceObject, build_module_rss_namespaceObject, search_namespaceObject, build_module_separator_namespaceObject, block_namespaceObject, social_links_namespaceObject, social_link_namespaceObject, spacer_namespaceObject, build_module_table_namespaceObject, // tableOfContents,
tag_cloud_namespaceObject, text_columns_namespaceObject, build_module_verse_namespaceObject, build_module_video_namespaceObject, // Theme blocks
build_module_site_logo_namespaceObject, site_tagline_namespaceObject, site_title_namespaceObject, query_namespaceObject, query_loop_namespaceObject, query_title_namespaceObject, build_module_query_pagination_namespaceObject, build_module_query_pagination_next_namespaceObject, build_module_query_pagination_numbers_namespaceObject, build_module_query_pagination_previous_namespaceObject, build_module_post_title_namespaceObject, build_module_post_content_namespaceObject, build_module_post_date_namespaceObject, build_module_post_excerpt_namespaceObject, build_module_post_featured_image_namespaceObject, post_terms_namespaceObject, loginout_namespaceObject];
build_module_site_logo_namespaceObject, site_tagline_namespaceObject, site_title_namespaceObject, query_namespaceObject, post_template_namespaceObject, query_title_namespaceObject, build_module_query_pagination_namespaceObject, build_module_query_pagination_next_namespaceObject, build_module_query_pagination_numbers_namespaceObject, build_module_query_pagination_previous_namespaceObject, build_module_post_title_namespaceObject, build_module_post_content_namespaceObject, build_module_post_date_namespaceObject, build_module_post_excerpt_namespaceObject, build_module_post_featured_image_namespaceObject, post_terms_namespaceObject, loginout_namespaceObject];
/**
* Function to register core blocks provided by the block editor.
*

File diff suppressed because one or more lines are too long

View File

@ -5400,6 +5400,12 @@ function convertLegacyBlocks(name, attributes) {
}
name = 'core/embed';
} // Convert 'core/query-loop' blocks in existing content to 'core/post-template'.
// TODO: Remove this check when WordPress 5.9 is released.
if (name === 'core/query-loop') {
name = 'core/post-template';
}
return {

File diff suppressed because one or more lines are too long

View File

@ -1977,17 +1977,17 @@ function Sidebar() {
getActiveComplementaryArea
} = select(build_module["g" /* store */]);
const selectedBlock = getSelectedBlock();
let activeArea = getActiveComplementaryArea(store.name);
const activeArea = getActiveComplementaryArea(store.name);
let currentSelection = activeArea;
if (!activeArea) {
if (!currentSelection) {
if (selectedBlock) {
activeArea = BLOCK_INSPECTOR_IDENTIFIER;
currentSelection = BLOCK_INSPECTOR_IDENTIFIER;
} else {
activeArea = WIDGET_AREAS_IDENTIFIER;
currentSelection = WIDGET_AREAS_IDENTIFIER;
}
}
const isSidebarOpen = !!activeArea;
let widgetAreaBlock;
if (selectedBlock) {
@ -1999,9 +1999,9 @@ function Sidebar() {
}
return {
currentArea: activeArea,
currentArea: currentSelection,
hasSelectedNonAreaBlock: !!(selectedBlock && selectedBlock.name !== 'core/widget-area'),
isGeneralSidebarOpen: isSidebarOpen,
isGeneralSidebarOpen: !!activeArea,
selectedWidgetAreaBlock: widgetAreaBlock
};
}, []); // currentArea, and isGeneralSidebarOpen are intentionally left out from the dependencies,

File diff suppressed because one or more lines are too long

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.8-alpha-51100';
$wp_version = '5.8-alpha-51101';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.