run:R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
2.35 KB
2026-03-11 16:18:52
R W Run
1.12 KB
2026-03-11 16:18:52
R W Run
4.31 KB
2026-03-11 16:18:52
R W Run
5.61 KB
2026-03-11 16:18:51
R W Run
4.09 KB
2026-03-11 16:18:52
R W Run
213.43 KB
2026-03-11 16:18:51
R W Run
1.71 KB
2026-03-11 16:18:51
R W Run
5.93 KB
2026-03-11 16:18:51
R W Run
4.54 KB
2026-03-11 16:18:52
R W Run
2.08 KB
2026-03-11 16:18:52
R W Run
2.4 KB
2026-03-11 16:18:52
R W Run
1.82 KB
2026-03-11 16:18:52
R W Run
1.67 KB
2026-03-11 16:18:52
R W Run
2.03 KB
2026-03-11 16:18:51
R W Run
4.39 KB
2026-03-11 16:18:52
R W Run
1.88 KB
2026-03-11 16:18:51
R W Run
1.59 KB
2026-03-11 16:18:51
R W Run
1.75 KB
2026-03-11 16:18:51
R W Run
1.23 KB
2026-03-11 16:18:52
R W Run
2.71 KB
2026-03-11 16:18:51
R W Run
6.63 KB
2026-03-11 16:18:52
R W Run
3.1 KB
2026-03-11 16:18:52
R W Run
1.83 KB
2026-03-11 16:18:52
R W Run
3.68 KB
2026-03-11 16:18:51
R W Run
6.29 KB
2026-03-11 16:18:52
R W Run
1.27 KB
2026-03-11 16:18:52
R W Run
5.31 KB
2026-03-11 16:18:52
R W Run
13.5 KB
2026-03-11 16:18:52
R W Run
4.99 KB
2026-03-11 16:18:52
R W Run
4.91 KB
2026-03-11 16:18:52
R W Run
8.53 KB
2026-03-11 16:18:51
R W Run
3.92 KB
2026-03-11 16:18:51
R W Run
1.24 KB
2026-03-11 16:18:51
R W Run
1.63 KB
2026-03-11 16:18:51
R W Run
4.28 KB
2026-03-11 16:18:51
R W Run
13.63 KB
2026-03-11 16:18:51
R W Run
9.74 KB
2026-03-11 16:18:52
R W Run
48.39 KB
2026-03-11 16:18:52
R W Run
361 By
2026-03-11 16:18:52
R W Run
13.29 KB
2026-03-11 16:18:51
R W Run
1.75 KB
2026-03-11 16:18:52
R W Run
1.49 KB
2026-03-11 16:18:51
R W Run
1.91 KB
2026-03-11 16:18:52
R W Run
2.67 KB
2026-03-11 16:18:51
R W Run
1.25 KB
2026-03-11 16:18:52
R W Run
2.74 KB
2026-03-11 16:18:52
R W Run
2.18 KB
2026-03-11 16:18:52
R W Run
2.29 KB
2026-03-11 16:18:52
R W Run
3.55 KB
2026-03-11 16:18:51
R W Run
3.53 KB
2026-03-11 16:18:51
R W Run
9.14 KB
2026-03-11 16:18:52
R W Run
4.72 KB
2026-03-11 16:18:51
R W Run
5.61 KB
2026-03-11 16:18:52
R W Run
3.55 KB
2026-03-11 16:18:51
R W Run
6.34 KB
2026-03-11 16:18:52
R W Run
2.09 KB
2026-03-11 16:18:51
R W Run
1.8 KB
2026-03-11 16:18:52
R W Run
3.69 KB
2026-03-11 16:18:52
R W Run
4.66 KB
2026-03-11 16:18:52
R W Run
3.49 KB
2026-03-11 16:18:52
R W Run
1.15 KB
2026-03-11 16:18:51
R W Run
2.87 KB
2026-03-11 16:18:51
R W Run
2.48 KB
2026-03-11 16:18:52
R W Run
5.56 KB
2026-03-11 16:18:51
R W Run
1.79 KB
2026-03-11 16:18:52
R W Run
4.59 KB
2026-03-11 16:18:51
R W Run
558 By
2026-03-11 16:18:52
R W Run
4.5 KB
2026-03-11 16:18:52
R W Run
23.26 KB
2026-03-11 16:18:52
R W Run
735 By
2026-03-11 16:18:52
R W Run
6.19 KB
2026-03-11 16:18:51
R W Run
1.17 KB
2026-03-11 16:18:51
R W Run
1.82 KB
2026-03-11 16:18:52
R W Run
66.15 KB
2026-03-11 16:18:52
R W Run
1.55 KB
2026-03-11 16:18:51
R W Run
9.92 KB
2026-03-11 16:18:52
R W Run
1.8 KB
2026-03-11 16:18:52
R W Run
1.73 KB
2026-03-11 16:18:52
R W Run
2.02 KB
2026-03-11 16:18:52
R W Run
4.41 KB
2026-03-11 16:18:52
R W Run
2.67 KB
2026-03-11 16:18:51
R W Run
2.38 KB
2026-03-11 16:18:52
R W Run
error_log
📄template-part.php
1<?php
2/**
3 * Server-side rendering of the `core/template-part` block.
4 *
5 * @package WordPress
6 */
7
8/**
9 * Renders the `core/template-part` block on the server.
10 *
11 * @since 5.9.0
12 *
13 * @global WP_Embed $wp_embed WordPress Embed object.
14 *
15 * @param array $attributes The block attributes.
16 *
17 * @return string The render.
18 */
19function render_block_core_template_part( $attributes ) {
20 static $seen_ids = array();
21
22 $template_part_id = null;
23 $content = null;
24 $area = WP_TEMPLATE_PART_AREA_UNCATEGORIZED;
25 $theme = isset( $attributes['theme'] ) ? $attributes['theme'] : get_stylesheet();
26
27 if ( isset( $attributes['slug'] ) && get_stylesheet() === $theme ) {
28 $template_part_id = $theme . '//' . $attributes['slug'];
29 $template_part_query = new WP_Query(
30 array(
31 'post_type' => 'wp_template_part',
32 'post_status' => 'publish',
33 'post_name__in' => array( $attributes['slug'] ),
34 'tax_query' => array(
35 array(
36 'taxonomy' => 'wp_theme',
37 'field' => 'name',
38 'terms' => $theme,
39 ),
40 ),
41 'posts_per_page' => 1,
42 'no_found_rows' => true,
43 'lazy_load_term_meta' => false, // Do not lazy load term meta, as template parts only have one term.
44 )
45 );
46 $template_part_post = $template_part_query->have_posts() ? $template_part_query->next_post() : null;
47 if ( $template_part_post ) {
48 // A published post might already exist if this template part was customized elsewhere
49 // or if it's part of a customized template.
50 $block_template = _build_block_template_result_from_post( $template_part_post );
51 $content = $block_template->content;
52 if ( isset( $block_template->area ) ) {
53 $area = $block_template->area;
54 }
55 /**
56 * Fires when a block template part is loaded from a template post stored in the database.
57 *
58 * @since 5.9.0
59 *
60 * @param string $template_part_id The requested template part namespaced to the theme.
61 * @param array $attributes The block attributes.
62 * @param WP_Post $template_part_post The template part post object.
63 * @param string $content The template part content.
64 */
65 do_action( 'render_block_core_template_part_post', $template_part_id, $attributes, $template_part_post, $content );
66 } else {
67 $template_part_file_path = '';
68 // Else, if the template part was provided by the active theme,
69 // render the corresponding file content.
70 if ( 0 === validate_file( $attributes['slug'] ) ) {
71 $block_template = get_block_file_template( $template_part_id, 'wp_template_part' );
72
73 if ( isset( $block_template->content ) ) {
74 $content = $block_template->content;
75 }
76 if ( isset( $block_template->area ) ) {
77 $area = $block_template->area;
78 }
79
80 // Needed for the `render_block_core_template_part_file` and `render_block_core_template_part_none` actions below.
81 $block_template_file = _get_block_template_file( 'wp_template_part', $attributes['slug'] );
82 if ( $block_template_file ) {
83 $template_part_file_path = $block_template_file['path'];
84 }
85 }
86
87 if ( '' !== $content && null !== $content ) {
88 /**
89 * Fires when a block template part is loaded from a template part in the theme.
90 *
91 * @since 5.9.0
92 *
93 * @param string $template_part_id The requested template part namespaced to the theme.
94 * @param array $attributes The block attributes.
95 * @param string $template_part_file_path Absolute path to the template path.
96 * @param string $content The template part content.
97 */
98 do_action( 'render_block_core_template_part_file', $template_part_id, $attributes, $template_part_file_path, $content );
99 } else {
100 /**
101 * Fires when a requested block template part does not exist in the database nor in the theme.
102 *
103 * @since 5.9.0
104 *
105 * @param string $template_part_id The requested template part namespaced to the theme.
106 * @param array $attributes The block attributes.
107 * @param string $template_part_file_path Absolute path to the not found template path.
108 */
109 do_action( 'render_block_core_template_part_none', $template_part_id, $attributes, $template_part_file_path );
110 }
111 }
112 }
113
114 // WP_DEBUG_DISPLAY must only be honored when WP_DEBUG. This precedent
115 // is set in `wp_debug_mode()`.
116 $is_debug = WP_DEBUG && WP_DEBUG_DISPLAY;
117
118 if ( is_null( $content ) ) {
119 if ( $is_debug && isset( $attributes['slug'] ) ) {
120 return sprintf(
121 /* translators: %s: Template part slug. */
122 __( 'Template part has been deleted or is unavailable: %s' ),
123 $attributes['slug']
124 );
125 }
126
127 return '';
128 }
129
130 if ( isset( $seen_ids[ $template_part_id ] ) ) {
131 return $is_debug ?
132 // translators: Visible only in the front end, this warning takes the place of a faulty block.
133 __( '[block rendering halted]' ) :
134 '';
135 }
136
137 // Look up area definition.
138 $area_definition = null;
139 $defined_areas = get_allowed_block_template_part_areas();
140 foreach ( $defined_areas as $defined_area ) {
141 if ( $defined_area['area'] === $area ) {
142 $area_definition = $defined_area;
143 break;
144 }
145 }
146
147 // If $area is not allowed, set it back to the uncategorized default.
148 if ( ! $area_definition ) {
149 $area = WP_TEMPLATE_PART_AREA_UNCATEGORIZED;
150 }
151
152 // Run through the actions that are typically taken on the_content.
153 $content = shortcode_unautop( $content );
154 $content = do_shortcode( $content );
155 $seen_ids[ $template_part_id ] = true;
156 $content = do_blocks( $content );
157 unset( $seen_ids[ $template_part_id ] );
158 $content = wptexturize( $content );
159 $content = convert_smilies( $content );
160 $content = wp_filter_content_tags( $content, "template_part_{$area}" );
161
162 // Handle embeds for block template parts.
163 global $wp_embed;
164 $content = $wp_embed->autoembed( $content );
165
166 if ( empty( $attributes['tagName'] ) || tag_escape( $attributes['tagName'] ) !== $attributes['tagName'] ) {
167 $area_tag = 'div';
168 if ( $area_definition && isset( $area_definition['area_tag'] ) ) {
169 $area_tag = $area_definition['area_tag'];
170 }
171 $html_tag = $area_tag;
172 } else {
173 $html_tag = esc_attr( $attributes['tagName'] );
174 }
175 $wrapper_attributes = get_block_wrapper_attributes();
176
177 return "<$html_tag $wrapper_attributes>" . str_replace( ']]>', ']]&gt;', $content ) . "</$html_tag>";
178}
179
180/**
181 * Returns an array of area variation objects for the template part block.
182 *
183 * @since 6.1.0
184 *
185 * @param array $instance_variations The variations for instances.
186 *
187 * @return array Array containing the block variation objects.
188 */
189function build_template_part_block_area_variations( $instance_variations ) {
190 $variations = array();
191 $defined_areas = get_allowed_block_template_part_areas();
192
193 foreach ( $defined_areas as $area ) {
194 if ( 'uncategorized' !== $area['area'] ) {
195 $has_instance_for_area = false;
196 foreach ( $instance_variations as $variation ) {
197 if ( $variation['attributes']['area'] === $area['area'] ) {
198 $has_instance_for_area = true;
199 break;
200 }
201 }
202
203 $scope = $has_instance_for_area ? array() : array( 'inserter' );
204
205 $variations[] = array(
206 'name' => 'area_' . $area['area'],
207 'title' => $area['label'],
208 'description' => $area['description'],
209 'attributes' => array(
210 'area' => $area['area'],
211 ),
212 'scope' => $scope,
213 'icon' => $area['icon'],
214 );
215 }
216 }
217 return $variations;
218}
219
220/**
221 * Returns an array of instance variation objects for the template part block
222 *
223 * @since 6.1.0
224 *
225 * @return array Array containing the block variation objects.
226 */
227function build_template_part_block_instance_variations() {
228 // Block themes are unavailable during installation.
229 if ( wp_installing() ) {
230 return array();
231 }
232
233 if ( ! current_theme_supports( 'block-templates' ) && ! current_theme_supports( 'block-template-parts' ) ) {
234 return array();
235 }
236
237 $variations = array();
238 $template_parts = get_block_templates(
239 array(
240 'post_type' => 'wp_template_part',
241 ),
242 'wp_template_part'
243 );
244
245 $defined_areas = get_allowed_block_template_part_areas();
246 $icon_by_area = array_combine( array_column( $defined_areas, 'area' ), array_column( $defined_areas, 'icon' ) );
247
248 foreach ( $template_parts as $template_part ) {
249 $variations[] = array(
250 'name' => 'instance_' . sanitize_title( $template_part->slug ),
251 'title' => $template_part->title,
252 // If there's no description for the template part don't show the
253 // block description. This is a bit hacky, but prevent the fallback
254 // by using a non-breaking space so that the value of description
255 // isn't falsey.
256 'description' => $template_part->description || '&nbsp;',
257 'attributes' => array(
258 'slug' => $template_part->slug,
259 'theme' => $template_part->theme,
260 'area' => $template_part->area,
261 ),
262 'scope' => array( 'inserter' ),
263 'icon' => isset( $icon_by_area[ $template_part->area ] ) ? $icon_by_area[ $template_part->area ] : null,
264 'example' => array(
265 'attributes' => array(
266 'slug' => $template_part->slug,
267 'theme' => $template_part->theme,
268 'area' => $template_part->area,
269 ),
270 ),
271 );
272 }
273 return $variations;
274}
275
276/**
277 * Returns an array of all template part block variations.
278 *
279 * @since 5.9.0
280 *
281 * @return array Array containing the block variation objects.
282 */
283function build_template_part_block_variations() {
284 $instance_variations = build_template_part_block_instance_variations();
285 $area_variations = build_template_part_block_area_variations( $instance_variations );
286 return array_merge( $area_variations, $instance_variations );
287}
288
289/**
290 * Registers the `core/template-part` block on the server.
291 *
292 * @since 5.9.0
293 */
294function register_block_core_template_part() {
295 register_block_type_from_metadata(
296 __DIR__ . '/template-part',
297 array(
298 'render_callback' => 'render_block_core_template_part',
299 'variation_callback' => 'build_template_part_block_variations',
300 )
301 );
302}
303add_action( 'init', 'register_block_core_template_part' );
304