Block.php
48 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SureCartBlocks\Blocks\Password; |
| 4 | |
| 5 | use SureCartBlocks\Blocks\BaseBlock; |
| 6 | |
| 7 | /** |
| 8 | * Password block |
| 9 | */ |
| 10 | class Block extends BaseBlock { |
| 11 | /** |
| 12 | * Render the block |
| 13 | * |
| 14 | * @param array $attributes Block attributes. |
| 15 | * @param string $content Post content. |
| 16 | * |
| 17 | * @return string |
| 18 | */ |
| 19 | public function render( $attributes, $content ) { |
| 20 | ob_start(); ?> |
| 21 | |
| 22 | <sc-order-password |
| 23 | type="password" |
| 24 | name="password" |
| 25 | class="<?php echo esc_attr( $attributes['className'] ?? '' ); ?>" |
| 26 | label="<?php echo esc_attr( $attributes['label'] ?? '' ); ?>" |
| 27 | help="<?php echo esc_attr( $attributes['help'] ?? '' ); ?>" |
| 28 | autofocus="<?php echo esc_attr( $attributes['autofocus'] ?? false ); ?>" |
| 29 | maxlength="<?php echo esc_attr( $attributes['maxlength'] ?? '' ); ?>" |
| 30 | minlength="<?php echo esc_attr( $attributes['minlength'] ?? '' ); ?>" |
| 31 | placeholder="<?php echo esc_attr( $attributes['placeholder'] ?? '' ); ?>" |
| 32 | showLabel="<?php echo esc_attr( $attributes['showLabel'] ?? true ); ?>" |
| 33 | size="<?php echo esc_attr( $attributes['size'] ?? 'medium' ); ?>" |
| 34 | value="<?php echo esc_attr( $attributes['value'] ?? '' ); ?>" |
| 35 | required="<?php echo esc_attr( ! empty( $attributes['required'] ) ? 'true' : 'false' ); ?>" |
| 36 | confirmation="<?php echo esc_attr( $attributes['confirmation'] ? 'true' : 'false' ); ?>" |
| 37 | confirmation-label="<?php echo esc_attr( $attributes['confirmation_label'] ?? '' ); ?>" |
| 38 | confirmation-placeholder="<?php echo esc_attr( $attributes['confirmation_placeholder'] ?? '' ); ?>" |
| 39 | confirmation-help="<?php echo esc_attr( $attributes['confirmation_help'] ?? '' ); ?>" |
| 40 | enable-validation="<?php echo get_option( 'surecart_password_validation_enabled', true ) ? 'true' : 'false'; ?>" |
| 41 | > |
| 42 | </sc-order-password> |
| 43 | |
| 44 | <?php |
| 45 | return ob_get_clean(); |
| 46 | } |
| 47 | } |
| 48 |