Block.php
41 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SureCartBlocks\Blocks\CustomerDashboardButton; |
| 4 | |
| 5 | use SureCartBlocks\Blocks\BaseBlock; |
| 6 | /** |
| 7 | * Logout Button Block. |
| 8 | */ |
| 9 | class Block extends BaseBlock { |
| 10 | /** |
| 11 | * Render the block |
| 12 | * |
| 13 | * @param array $attributes Block attributes. |
| 14 | * @param string $content Post content. |
| 15 | * |
| 16 | * @return string |
| 17 | */ |
| 18 | public function render( $attributes, $content = '' ) { |
| 19 | $href = \SureCart::pages()->url( 'dashboard' ); |
| 20 | |
| 21 | $label = $attributes['label'] ?? ''; |
| 22 | |
| 23 | if ( empty( $label ) ) { |
| 24 | $label = $content; |
| 25 | } |
| 26 | ob_start(); ?> |
| 27 | |
| 28 | <div> |
| 29 | <sc-button href="<?php echo esc_url( $href ); ?>" type="<?php echo esc_attr( $attributes['type'] ?? 'primary' ); ?>" size="<?php echo esc_attr( $attributes['size'] ?? 'medium' ); ?>" <?php echo esc_attr( ! empty( $attributes['full'] ) ? 'full' : '' ); ?>> |
| 30 | <?php if ( ! empty( $attributes['show_icon'] ) ) : ?> |
| 31 | <sc-icon name="user" style="font-size: 18px" slot="prefix"></sc-icon> |
| 32 | <?php endif; ?> |
| 33 | <?php echo esc_html( ! empty( $label ) ? $label : __( 'Dashboard', 'surecart' ) ); ?> |
| 34 | </sc-button> |
| 35 | </div> |
| 36 | |
| 37 | <?php |
| 38 | return ob_get_clean(); |
| 39 | } |
| 40 | } |
| 41 |