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
VariantPills.php
96 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 Pills element. |
| 13 | */ |
| 14 | class VariantPills extends \Bricks\Element { |
| 15 | use ConvertsBlocks; // we have to use a trait since we can't extend the surecart class. |
| 16 | |
| 17 | /** |
| 18 | * Element category. |
| 19 | * |
| 20 | * @var string |
| 21 | */ |
| 22 | public $category = 'SureCart Elements'; |
| 23 | |
| 24 | /** |
| 25 | * Element name. |
| 26 | * |
| 27 | * @var string |
| 28 | */ |
| 29 | public $name = 'surecart-product-variant-pills'; |
| 30 | |
| 31 | /** |
| 32 | * Element block name |
| 33 | * |
| 34 | * @var string |
| 35 | */ |
| 36 | public $block_name = 'surecart/product-variant-pills'; |
| 37 | |
| 38 | /** |
| 39 | * Element icon |
| 40 | * |
| 41 | * @var string |
| 42 | */ |
| 43 | public $icon = 'ion-md-options'; |
| 44 | |
| 45 | /** |
| 46 | * This is nestable. |
| 47 | * |
| 48 | * @var string |
| 49 | */ |
| 50 | public $nestable = true; |
| 51 | |
| 52 | /** |
| 53 | * Get element label |
| 54 | * |
| 55 | * @return string |
| 56 | */ |
| 57 | public function get_label() { |
| 58 | return esc_html__( 'Product Variant Pills', 'surecart' ); |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Get nestable children. |
| 63 | * |
| 64 | * @return array |
| 65 | */ |
| 66 | public function get_nestable_children() { |
| 67 | return array( |
| 68 | array( 'name' => 'surecart-product-variant-pill' ), |
| 69 | ); |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Render element. |
| 74 | * |
| 75 | * @return void |
| 76 | */ |
| 77 | public function render() { |
| 78 | if ( $this->is_admin_editor() ) { |
| 79 | $output = '<label class="sc-form-label">' . esc_html__( 'Variation', 'surecart' ) . '</label>'; |
| 80 | $output .= '<div class="sc-pill-option__wrapper">'; |
| 81 | $output .= \Bricks\Frontend::render_children( $this ); |
| 82 | $output .= '</div>'; |
| 83 | |
| 84 | echo $this->preview(// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 85 | $output, |
| 86 | 'wp-block-surecart-product-variant-pills' |
| 87 | ); |
| 88 | } |
| 89 | |
| 90 | echo $this->raw( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 91 | array(), |
| 92 | \Bricks\Frontend::render_children( $this ), |
| 93 | ); |
| 94 | } |
| 95 | } |
| 96 |