summaryrefslogtreecommitdiffstats
path: root/wp-includes/blocks/template-part
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 07:57:30 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 07:57:30 +0000
commitfa9a33d818470a5796f0ff8797f98b510ed8de18 (patch)
treebde6a1eede376f9b5df5898ce812330152984d8e /wp-includes/blocks/template-part
parentReleasing progress-linux version 6.4.3+dfsg1-1~progress7.99u1. (diff)
downloadwordpress-fa9a33d818470a5796f0ff8797f98b510ed8de18.tar.xz
wordpress-fa9a33d818470a5796f0ff8797f98b510ed8de18.zip
Merging upstream version 6.5+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--wp-includes/blocks/template-part.php36
-rw-r--r--wp-includes/blocks/template-part/block.json6
2 files changed, 26 insertions, 16 deletions
diff --git a/wp-includes/blocks/template-part.php b/wp-includes/blocks/template-part.php
index 3ad4009..8c01c5a 100644
--- a/wp-includes/blocks/template-part.php
+++ b/wp-includes/blocks/template-part.php
@@ -43,10 +43,10 @@ function render_block_core_template_part( $attributes ) {
if ( $template_part_post ) {
// A published post might already exist if this template part was customized elsewhere
// or if it's part of a customized template.
- $content = $template_part_post->post_content;
- $area_terms = get_the_terms( $template_part_post, 'wp_template_part_area' );
- if ( ! is_wp_error( $area_terms ) && false !== $area_terms ) {
- $area = $area_terms[0]->name;
+ $block_template = _build_block_template_result_from_post( $template_part_post );
+ $content = $block_template->content;
+ if ( isset( $block_template->area ) ) {
+ $area = $block_template->area;
}
/**
* Fires when a block template part is loaded from a template post stored in the database.
@@ -70,6 +70,12 @@ function render_block_core_template_part( $attributes ) {
if ( isset( $block_template->area ) ) {
$area = $block_template->area;
}
+
+ // Needed for the `render_block_core_template_part_file` and `render_block_core_template_part_none` actions below.
+ $block_template_file = _get_block_template_file( 'wp_template_part', $attributes['slug'] );
+ if ( $block_template_file ) {
+ $template_part_file_path = $block_template_file['path'];
+ }
}
if ( '' !== $content && null !== $content ) {
@@ -103,16 +109,16 @@ function render_block_core_template_part( $attributes ) {
// is set in `wp_debug_mode()`.
$is_debug = WP_DEBUG && WP_DEBUG_DISPLAY;
- if ( is_null( $content ) && $is_debug ) {
- if ( ! isset( $attributes['slug'] ) ) {
- // If there is no slug this is a placeholder and we dont want to return any message.
- return;
+ if ( is_null( $content ) ) {
+ if ( $is_debug && isset( $attributes['slug'] ) ) {
+ return sprintf(
+ /* translators: %s: Template part slug. */
+ __( 'Template part has been deleted or is unavailable: %s' ),
+ $attributes['slug']
+ );
}
- return sprintf(
- /* translators: %s: Template part slug. */
- __( 'Template part has been deleted or is unavailable: %s' ),
- $attributes['slug']
- );
+
+ return '';
}
if ( isset( $seen_ids[ $template_part_id ] ) ) {
@@ -275,8 +281,8 @@ function register_block_core_template_part() {
register_block_type_from_metadata(
__DIR__ . '/template-part',
array(
- 'render_callback' => 'render_block_core_template_part',
- 'variations' => build_template_part_block_variations(),
+ 'render_callback' => 'render_block_core_template_part',
+ 'variation_callback' => 'build_template_part_block_variations',
)
);
}
diff --git a/wp-includes/blocks/template-part/block.json b/wp-includes/blocks/template-part/block.json
index 9fe4311..9710bde 100644
--- a/wp-includes/blocks/template-part/block.json
+++ b/wp-includes/blocks/template-part/block.json
@@ -23,7 +23,11 @@
"supports": {
"align": true,
"html": false,
- "reusable": false
+ "reusable": false,
+ "renaming": false,
+ "interactivity": {
+ "clientNavigation": true
+ }
},
"editorStyle": "wp-block-template-part-editor"
}