0, returns * empty (the items rendered, no fallback needed). When totalItems === 0, * returns the saved content unchanged so authors see their message. * * @package airo-wp * @since 2.1.0 * * @param array $attributes Block attributes. * @param string $content Serialized innerBlocks HTML (authored content). * @param WP_Block $block Block instance. */ defined( 'ABSPATH' ) || exit; if ( ! function_exists( 'airowp_render_query_no_results' ) ) { /** * Render the Query No-Results block. * * @param array $attributes Block attributes. * @param string $content Inner block content. * @param WP_Block $block Block instance. * @return void */ function airowp_render_query_no_results( $attributes, $content, $block ) { $query_id = isset( $block->context['airo-wp/queryId'] ) ? sanitize_key( (string) $block->context['airo-wp/queryId'] ) : ''; if ( '' === $query_id ) { return; } $helpers = AIRO_WP_PLUGIN_DIR . 'build/blocks/query/render-helpers.php'; if ( ! file_exists( $helpers ) ) { return; } require_once $helpers; // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingVariable -- build artifact; path resolved from plugin directory $state = airowp_query_get_last_state( $query_id ); // Only render when the parent query had zero items. if ( ! $state || (int) $state['totalItems'] > 0 ) { return; } // $content already contains the authored innerBlocks HTML from save(). // Wrap with block-wrapper attrs so native supports apply. $wrapper = get_block_wrapper_attributes( array( 'class' => 'airo-wp-query-no-results' ) ); printf( '