BuyButton.php
1 year ago
CollectionTag.php
1 year ago
CollectionTags.php
1 year ago
Media.php
1 year ago
PriceChoiceTemplate.php
1 year ago
PriceChooser.php
1 year ago
PriceData.php
1 year ago
Product.php
1 year ago
ProductCard.php
1 year ago
ProductData.php
1 year ago
Quantity.php
1 year ago
SaleBadge.php
1 year ago
SelectedPriceAdHocAmount.php
1 year ago
VariantPill.php
1 year ago
VariantPills.php
1 year ago
VariantPill.php
93 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SureCart\Integrations\Bricks\Elements; |
| 4 | |
| 5 | use SureCart\Integrations\Bricks\Concerns\ConvertsBlocks; |
| 6 | |
| 7 | if ( ! defined( 'ABSPATH' ) ) { |
| 8 | exit; // Exit if accessed directly. |
| 9 | } |
| 10 | |
| 11 | /** |
| 12 | * Variant Pill element. |
| 13 | */ |
| 14 | class VariantPill extends \Bricks\Element { |
| 15 | use ConvertsBlocks; // we have to use a trait since we can't extend the surecart class. |
| 16 | |
| 17 | /** |
| 18 | * Element name. |
| 19 | * |
| 20 | * @var string |
| 21 | */ |
| 22 | public $name = 'surecart-product-variant-pill'; |
| 23 | |
| 24 | /** |
| 25 | * Element block name. |
| 26 | * |
| 27 | * @var string |
| 28 | */ |
| 29 | public $block_name = 'surecart/product-variant-pill'; |
| 30 | |
| 31 | /** |
| 32 | * Element icon |
| 33 | * |
| 34 | * @var string |
| 35 | */ |
| 36 | public $icon = 'ion-md-radio-button-on'; |
| 37 | |
| 38 | /** |
| 39 | * Get element label |
| 40 | * |
| 41 | * @return string |
| 42 | */ |
| 43 | public function get_label() { |
| 44 | return esc_html__( 'Product Variant Pill', 'surecart' ); |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Set controls. |
| 49 | * |
| 50 | * @return void |
| 51 | */ |
| 52 | public function set_controls() { |
| 53 | $this->controls['highlight_text'] = array( |
| 54 | 'label' => esc_html__( 'Highlight Text Color', 'surecart' ), |
| 55 | 'type' => 'color', |
| 56 | ); |
| 57 | |
| 58 | $this->controls['highlight_background'] = array( |
| 59 | 'label' => esc_html__( 'Highlight Background Color', 'surecart' ), |
| 60 | 'type' => 'color', |
| 61 | ); |
| 62 | |
| 63 | $this->controls['highlight_border'] = array( |
| 64 | 'label' => esc_html__( 'Highlight Border Color', 'surecart' ), |
| 65 | 'type' => 'color', |
| 66 | ); |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Render element. |
| 71 | * |
| 72 | * @return void |
| 73 | */ |
| 74 | public function render() { |
| 75 | if ( $this->is_admin_editor() ) { |
| 76 | echo $this->preview( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 77 | esc_html__( 'Option Value', 'surecart' ), |
| 78 | 'sc-pill-option__button wp-block-surecart-product-variant-pill', |
| 79 | 'span' |
| 80 | ); |
| 81 | return; |
| 82 | } |
| 83 | |
| 84 | echo $this->raw( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 85 | array( |
| 86 | 'highlight_text' => esc_attr( $this->get_raw_color( 'highlight_text' ) ), |
| 87 | 'highlight_background' => esc_attr( $this->get_raw_color( 'highlight_background' ) ), |
| 88 | 'highlight_border' => esc_attr( $this->get_raw_color( 'highlight_border' ) ), |
| 89 | ) |
| 90 | ); |
| 91 | } |
| 92 | } |
| 93 |