Automattic\WooCommerce\Blocks\BlockTypes
ProductFilterClearButton::render()
Include and render the block.
Method of the class: ProductFilterClearButton{}
No Hooks.
Return
String
. Rendered block type output.
Usage
// protected - for code of main (parent) or child class $result = $this->render( $attributes, $content, $block );
- $attributes(array) (required)
- Block attributes.
Default: empty array - $content(string) (required)
- Block content.
Default: empty string - $block(WP_Block) (required)
- Block instance.
ProductFilterClearButton::render() ProductFilterClearButton::render code WC 9.4.2
protected function render( $attributes, $content, $block ) { // don't render if its admin, or ajax in progress. if ( is_admin() || wp_doing_ajax() ) { return ''; } $wrapper_attributes = get_block_wrapper_attributes( array( 'data-wc-bind--hidden' => '!context.hasSelectedFilters', ) ); $p = new \WP_HTML_Tag_Processor( $content ); if ( $p->next_tag( array( 'class_name' => 'wp-block-button__link' ) ) ) { $p->set_attribute( 'data-wc-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 ); }