wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
render_block_core_query › WordPress Function
Seit6.4.0
Veraltetn/v
› render_block_core_query ( $attributes, $content, $block )
Parameter: (3) |
|
Gibt zurück: |
|
Definiert in: |
|
Codex: |
Modifies the static `core/query` block on the server.
Quellcode
function render_block_core_query( $attributes, $content, $block ) { $is_interactive = isset( $attributes['enhancedPagination'] ) && true === $attributes['enhancedPagination'] && isset( $attributes['queryId'] ); // Enqueue the script module and add the necessary directives if the block is // interactive. if ( $is_interactive ) { wp_enqueue_script_module( '@wordpress/block-library/query/view' ); $p = new WP_HTML_Tag_Processor( $content ); if ( $p->next_tag() ) { // Add the necessary directives. $p->set_attribute( 'data-wp-interactive', 'core/query' ); $p->set_attribute( 'data-wp-router-region', 'query-' . $attributes['queryId'] ); $p->set_attribute( 'data-wp-context', '{}' ); $p->set_attribute( 'data-wp-key', $attributes['queryId'] ); $content = $p->get_updated_html(); } } // Add the styles to the block type if the block is interactive and remove // them if it's not. $style_asset = 'wp-block-query'; if ( ! wp_style_is( $style_asset ) ) { $style_handles = $block->block_type->style_handles; // If the styles are not needed, and they are still in the `style_handles`, remove them. if ( ! $is_interactive && in_array( $style_asset, $style_handles, true ) ) { $block->block_type->style_handles = array_diff( $style_handles, array( $style_asset ) ); } // If the styles are needed, but they were previously removed, add them again. if ( $is_interactive && ! in_array( $style_asset, $style_handles, true ) ) { $block->block_type->style_handles = array_merge( $style_handles, array( $style_asset ) ); } } return $content; }