Automattic\WooCommerce\Blocks\BlockTypes
ProductFilterClearButton::render()
Include and render the block.
Метод класса: ProductFilterClearButton{}
Хуков нет.
Возвращает
Строку
. Rendered block type output.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->render( $attributes, $content, $block );
- $attributes(массив) (обязательный)
- Block attributes.
По умолчанию: empty array - $content(строка) (обязательный)
- Block content.
По умолчанию: empty string - $block(WP_Block) (обязательный)
- Block instance.
Код ProductFilterClearButton::render() ProductFilterClearButton::render WC 9.8.5
protected function render( $attributes, $content, $block ) { // don't render if its admin, or ajax in progress. if ( is_admin() || wp_doing_ajax() || empty( $block->context['filterData'] ) || empty( $block->context['filterData']['parent'] ) ) { return ''; } $wrapper_attributes = get_block_wrapper_attributes( array( 'data-wp-bind--hidden' => '!state.hasSelectedFilters', 'data-wp-interactive' => $block->context['filterData']['parent'], ) ); $p = new \WP_HTML_Tag_Processor( $content ); if ( $p->next_tag( array( 'class_name' => 'wp-block-button__link' ) ) ) { $p->set_attribute( 'data-wp-on--click', 'actions.clearFilters' ); $style = $p->get_attribute( 'style' ); $p->set_attribute( 'style', 'outline:none;' . $style ); $content = $p->get_updated_html(); } $content = str_replace( array( '<a', '</a>' ), array( '<button', '</button>' ), $content ); return sprintf( '<div %1$s hidden>%2$s</div>', $wrapper_attributes, $content ); }