Automattic\WooCommerce\Blocks\BlockTypes
ProductFilterActive::render()
Render the block.
Метод класса: ProductFilterActive{}
Хуки из метода
Возвращает
Строку
. Rendered block type output.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->render( $attributes, $content, $block );
- $attributes(массив) (обязательный)
- Block attributes.
- $content(строка) (обязательный)
- Block content.
- $block(WP_Block) (обязательный)
- Block instance.
Код ProductFilterActive::render() ProductFilterActive::render WC 9.4.2
<?php protected function render( $attributes, $content, $block ) { $query_id = $block->context['queryId'] ?? 0; /** * Filters the active filter data provided by filter blocks. * * $data = array( * <id> => array( * 'type' => string, * 'items' => array( * array( * 'title' => string, * 'attributes' => array( * <key> => string * ) * ) * ) * ), * ); * * @since 11.7.0 * * @param array $data The active filters data * @param array $params The query param parsed from the URL. * @return array Active filters data. */ $active_filters = apply_filters( 'collection_active_filters_data', array(), $this->get_filter_query_params( $query_id ) ); $wrapper_attributes = get_block_wrapper_attributes( array( 'data-wc-interactive' => wp_json_encode( array( 'namespace' => $this->get_full_block_name() ), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP ), ) ); $list_classes = 'filter-list'; if ( 'chips' === $attributes['displayStyle'] ) { $list_classes .= ' list-chips'; } ob_start(); ?> <div <?php echo $wrapper_attributes; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>> <?php if ( ! empty( $active_filters ) ) : ?> <ul class="<?php echo esc_attr( $list_classes ); ?>"> <?php foreach ( $active_filters as $filter ) : ?> <li> <span class="list-item-type"><?php echo esc_html( $filter['type'] ); ?>: </span> <ul> <?php $this->render_items( $filter['items'], $attributes['displayStyle'] ); ?> </ul> </li> <?php endforeach; ?> </ul> <button class="clear-all" data-wc-on--click="actions.clearAll"> <span aria-hidden="true"><?php echo esc_html__( 'Clear All', 'woocommerce' ); ?></span> <span class="screen-reader-text"><?php echo esc_html__( 'Clear All Filters', 'woocommerce' ); ?></span> </button> <?php endif; ?> </div> <?php return ob_get_clean(); }