BuyButton.php
3 months ago
CartMenuIcon.php
5 months ago
CollectionTag.php
1 year ago
CollectionTags.php
1 year ago
Media.php
1 year ago
PriceChoiceTemplate.php
1 year ago
PriceChooser.php
4 months ago
PriceData.php
1 year ago
Product.php
4 months ago
ProductCard.php
10 months ago
ProductContent.php
10 months ago
ProductData.php
1 year ago
ProductLineItemNote.php
10 months ago
ProductQuickAddButton.php
10 months ago
ProductReviewAverageRatingStars.php
4 months ago
ProductReviewAverageRatingValue.php
4 months ago
ProductReviewBreakdown.php
4 months ago
ProductReviewContent.php
4 months ago
ProductReviewList.php
2 months ago
ProductReviewRating.php
4 months ago
ProductReviewTotalRating.php
4 months ago
ProductReviews.php
4 months ago
Quantity.php
10 months ago
SaleBadge.php
1 year ago
SelectedPriceAdHocAmount.php
1 year ago
VariantPill.php
6 months ago
VariantPills.php
1 year ago
VariantPill.php
114 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 | 'css' => [ |
| 57 | [ |
| 58 | 'property' => 'color', |
| 59 | 'selector' => '&.sc-pill-option__button--selected', |
| 60 | 'important' => true, |
| 61 | ], |
| 62 | ], |
| 63 | ); |
| 64 | |
| 65 | $this->controls['highlight_background'] = array( |
| 66 | 'label' => esc_html__( 'Highlight Background Color', 'surecart' ), |
| 67 | 'type' => 'color', |
| 68 | 'css' => [ |
| 69 | [ |
| 70 | 'property' => 'background-color', |
| 71 | 'selector' => '&.sc-pill-option__button--selected', |
| 72 | 'important' => true, |
| 73 | ], |
| 74 | ], |
| 75 | ); |
| 76 | |
| 77 | $this->controls['highlight_border'] = array( |
| 78 | 'label' => esc_html__( 'Highlight Border Color', 'surecart' ), |
| 79 | 'type' => 'color', |
| 80 | 'css' => [ |
| 81 | [ |
| 82 | 'property' => 'border-color', |
| 83 | 'selector' => '&.sc-pill-option__button--selected', |
| 84 | 'important' => true, |
| 85 | ], |
| 86 | ], |
| 87 | ); |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * Render element. |
| 92 | * |
| 93 | * @return void |
| 94 | */ |
| 95 | public function render() { |
| 96 | if ( $this->is_admin_editor() ) { |
| 97 | echo $this->preview( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 98 | esc_html__( 'Option Value', 'surecart' ), |
| 99 | 'sc-pill-option__button wp-block-surecart-product-variant-pill', |
| 100 | 'span' |
| 101 | ); |
| 102 | return; |
| 103 | } |
| 104 | |
| 105 | echo $this->raw( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 106 | array( |
| 107 | 'highlight_text' => esc_attr( $this->get_raw_color( 'highlight_text' ) ), |
| 108 | 'highlight_background' => esc_attr( $this->get_raw_color( 'highlight_background' ) ), |
| 109 | 'highlight_border' => esc_attr( $this->get_raw_color( 'highlight_border' ) ), |
| 110 | ) |
| 111 | ); |
| 112 | } |
| 113 | } |
| 114 |