Block.php
41 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SureCartBlocks\Blocks\ProductCollectionDescription; |
| 4 | |
| 5 | use SureCartBlocks\Blocks\BaseBlock; |
| 6 | |
| 7 | /** |
| 8 | * Product Title Block |
| 9 | */ |
| 10 | class Block extends BaseBlock { |
| 11 | /** |
| 12 | * Keep track of the instance number of this block. |
| 13 | * |
| 14 | * @var integer |
| 15 | */ |
| 16 | public static $instance; |
| 17 | |
| 18 | /** |
| 19 | * Render the block |
| 20 | * |
| 21 | * @param array $attributes Block attributes. |
| 22 | * @param string $content Post content. |
| 23 | * |
| 24 | * @return string |
| 25 | */ |
| 26 | public function render( $attributes, $content ) { |
| 27 | $collection = get_query_var( 'surecart_current_collection' ); |
| 28 | if ( empty( $collection->description ) ) { |
| 29 | return ''; |
| 30 | } |
| 31 | |
| 32 | $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => 'entry-content' ) ); |
| 33 | |
| 34 | return ( |
| 35 | '<div ' . $wrapper_attributes . '>' . |
| 36 | wp_kses_post( $collection->description ) . |
| 37 | '</div>' |
| 38 | ); |
| 39 | } |
| 40 | } |
| 41 |