diff --git a/wp-includes/block-template-utils.php b/wp-includes/block-template-utils.php index 543cdaf629..59d76d48d3 100644 --- a/wp-includes/block-template-utils.php +++ b/wp-includes/block-template-utils.php @@ -546,13 +546,22 @@ function _build_block_template_result_from_file( $template_file, $template_type function _wp_build_title_and_description_for_single_post_type_block_template( $post_type, $slug, WP_Block_Template $template ) { $post_type_object = get_post_type_object( $post_type ); - $posts = get_posts( - array( - 'name' => $slug, - 'post_type' => $post_type, - ) + $default_args = array( + 'post_type' => $post_type, + 'post_status' => 'publish', + 'posts_per_page' => 1, + 'update_post_meta_cache' => false, + 'update_post_term_cache' => false, + 'ignore_sticky_posts' => true, + 'no_found_rows' => true, ); + $args = array( + 'name' => $slug, + ); + $args = wp_parse_args( $args, $default_args ); + $posts = new WP_Query( $args ); + if ( empty( $posts ) ) { $template->title = sprintf( /* translators: Custom template title in the Site Editor referencing a post that was not found. 1: Post type singular name, 2: Post type slug. */ @@ -579,13 +588,12 @@ function _wp_build_title_and_description_for_single_post_type_block_template( $p $post_title ); - $posts_with_same_title = get_posts( - array( - 'title' => $post_title, - 'post_type' => $post_type, - 'post_status' => 'publish', - ) + $args = array( + 'title' => $post_title, ); + $args = wp_parse_args( $args, $default_args ); + + $posts_with_same_title = new WP_Query( $args ); if ( count( $posts_with_same_title ) > 1 ) { $template->title = sprintf( @@ -615,14 +623,21 @@ function _wp_build_title_and_description_for_single_post_type_block_template( $p function _wp_build_title_and_description_for_taxonomy_block_template( $taxonomy, $slug, WP_Block_Template $template ) { $taxonomy_object = get_taxonomy( $taxonomy ); - $terms = get_terms( - array( - 'taxonomy' => $taxonomy, - 'hide_empty' => false, - 'slug' => $slug, - ) + $default_args = array( + 'taxonomy' => $taxonomy, + 'hide_empty' => false, + 'update_term_meta_cache' => false, ); + $term_query = new WP_Term_Query(); + + $args = array( + 'number' => 1, + 'slug' => $slug, + ); + $args = wp_parse_args( $args, $default_args ); + $terms = $term_query->query( $args ); + if ( empty( $terms ) ) { $template->title = sprintf( /* translators: Custom template title in the Site Editor, referencing a taxonomy term that was not found. 1: Taxonomy singular name, 2: Term slug. */ @@ -648,13 +663,15 @@ function _wp_build_title_and_description_for_taxonomy_block_template( $taxonomy, $term_title ); - $terms_with_same_title = get_terms( - array( - 'taxonomy' => $taxonomy, - 'hide_empty' => false, - 'name' => $term_title, - ) + $term_query = new WP_Term_Query(); + + $args = array( + 'number' => 2, + 'name' => $term_title, ); + $args = wp_parse_args( $args, $default_args ); + + $terms_with_same_title = $term_query->query( $args ); if ( count( $terms_with_same_title ) > 1 ) { $template->title = sprintf( diff --git a/wp-includes/version.php b/wp-includes/version.php index 22d409d3ce..0d041c8ef0 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.1-beta3-54444'; +$wp_version = '6.1-beta3-54445'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.