wp/wp-includes/blocks/query-no-results.php
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
--- a/wp/wp-includes/blocks/query-no-results.php	Thu Sep 29 08:06:27 2022 +0200
+++ b/wp/wp-includes/blocks/query-no-results.php	Fri Sep 05 18:40:08 2025 +0200
@@ -8,6 +8,10 @@
 /**
  * Renders the `core/query-no-results` block on the server.
  *
+ * @since 6.0.0
+ *
+ * @global WP_Query $wp_query WordPress Query object.
+ *
  * @param array    $attributes Block attributes.
  * @param string   $content    Block default content.
  * @param WP_Block $block      Block instance.
@@ -32,23 +36,23 @@
 		$query      = new WP_Query( $query_args );
 	}
 
-	if ( $query->have_posts() ) {
+	if ( $query->post_count > 0 ) {
 		return '';
 	}
 
-	if ( ! $use_global_query ) {
-		wp_reset_postdata();
-	}
-
+	$classes            = ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) ? 'has-link-color' : '';
+	$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
 	return sprintf(
 		'<div %1$s>%2$s</div>',
-		get_block_wrapper_attributes(),
+		$wrapper_attributes,
 		$content
 	);
 }
 
 /**
  * Registers the `core/query-no-results` block on the server.
+ *
+ * @since 6.0.0
  */
 function register_block_core_query_no_results() {
 	register_block_type_from_metadata(