Changeset 59951 for trunk/src/wp-includes/block-template-utils.php
- Timestamp:
- 03/07/2025 05:53:37 PM (12 months ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/block-template-utils.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/block-template-utils.php
r59819 r59951 1186 1186 */ 1187 1187 $query['slug__not_in'] = wp_list_pluck( $query_result, 'slug' ); 1188 $template_files = _get_block_templates_files( $template_type, $query ); 1188 /* 1189 * We need to unset the post_type query param because some templates 1190 * would be excluded otherwise, like `page.html` when looking for 1191 * `page` templates. We need all templates so we can exclude duplicates 1192 * from plugin-registered templates. 1193 * See: https://github.com/WordPress/gutenberg/issues/65584 1194 */ 1195 $template_files_query = $query; 1196 unset( $template_files_query['post_type'] ); 1197 $template_files = _get_block_templates_files( $template_type, $template_files_query ); 1189 1198 foreach ( $template_files as $template_file ) { 1190 $query_result[] = _build_block_template_result_from_file( $template_file, $template_type ); 1199 // If the query doesn't specify a post type, or it does and the template matches the post type, add it. 1200 if ( 1201 ! isset( $query['post_type'] ) || 1202 ( 1203 isset( $template_file['postTypes'] ) && 1204 in_array( $query['post_type'], $template_file['postTypes'], true ) 1205 ) 1206 ) { 1207 $query_result[] = _build_block_template_result_from_file( $template_file, $template_type ); 1208 } elseif ( ! isset( $template_file['postTypes'] ) ) { 1209 // The custom templates with no associated post types are available for all post types as long 1210 // as they are not default templates. 1211 $candidate = _build_block_template_result_from_file( $template_file, $template_type ); 1212 $default_template_types = get_default_block_template_types(); 1213 if ( ! isset( $default_template_types[ $candidate->slug ] ) ) { 1214 $query_result[] = $candidate; 1215 } 1216 } 1191 1217 } 1192 1218
Note: See TracChangeset
for help on using the changeset viewer.