product-excerpt.php
119 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Elementor; |
| 4 | |
| 5 | defined('ABSPATH') || exit; |
| 6 | |
| 7 | use ShopEngine\Widgets\Products; |
| 8 | |
| 9 | |
| 10 | class ShopEngine_Product_Excerpt extends \ShopEngine\Base\Widget |
| 11 | { |
| 12 | |
| 13 | public function config() { |
| 14 | return new ShopEngine_Product_Excerpt_Config(); |
| 15 | } |
| 16 | |
| 17 | |
| 18 | protected function register_controls() { |
| 19 | |
| 20 | /* |
| 21 | * Content Tab - Product Excerpt |
| 22 | */ |
| 23 | $this->start_controls_section( |
| 24 | 'shopengine_section_excerpt', |
| 25 | [ |
| 26 | 'label' => esc_html__('Styles', 'shopengine'), |
| 27 | 'tab' => Controls_Manager::TAB_STYLE, |
| 28 | ] |
| 29 | ); |
| 30 | |
| 31 | $this->add_control( |
| 32 | 'shopengine_excerpt_color', |
| 33 | [ |
| 34 | 'label' => esc_html__('Color', 'shopengine'), |
| 35 | 'type' => Controls_Manager::COLOR, |
| 36 | 'default' => '#444444', |
| 37 | 'alpha' => false, |
| 38 | 'selectors' => [ |
| 39 | '{{WRAPPER}} .shopengine-product-excerpt, {{WRAPPER}} .shopengine-product-excerpt p' => 'color: {{VALUE}};', |
| 40 | ], |
| 41 | ] |
| 42 | ); |
| 43 | |
| 44 | $this->add_group_control( |
| 45 | Group_Control_Typography::get_type(), |
| 46 | array( |
| 47 | 'name' => 'shopengine_excerpt_typography', |
| 48 | 'label' => esc_html__('Typography', 'shopengine'), |
| 49 | 'selector' => '{{WRAPPER}} .shopengine-product-excerpt, {{WRAPPER}} .shopengine-product-excerpt p', |
| 50 | 'exclude' => ['text_decoration'], |
| 51 | 'fields_options' => [ |
| 52 | 'typography' => [ |
| 53 | 'default' => 'custom', |
| 54 | ], |
| 55 | 'font_weight' => [ |
| 56 | 'default' => '400', |
| 57 | ], |
| 58 | 'font_size' => [ |
| 59 | 'default' => [ |
| 60 | 'size' => '17', |
| 61 | 'unit' => 'px' |
| 62 | ], |
| 63 | 'label' => 'Font size (px)', |
| 64 | 'size_units' => ['px'], |
| 65 | ], |
| 66 | 'line_height' => [ |
| 67 | 'default' => [ |
| 68 | 'size' => '22', |
| 69 | 'unit' => 'px' |
| 70 | ], |
| 71 | 'label' => 'Line-height (px)', |
| 72 | 'size_units' => ['px'] |
| 73 | ], |
| 74 | 'letter_spacing' => [ |
| 75 | 'responsive' => false, |
| 76 | ] |
| 77 | ], |
| 78 | ) |
| 79 | ); |
| 80 | |
| 81 | $this->add_control( |
| 82 | 'shopengine_excerpt_align', |
| 83 | [ |
| 84 | 'label' => esc_html__('Align', 'shopengine'), |
| 85 | 'type' => Controls_Manager::CHOOSE, |
| 86 | 'options' => [ |
| 87 | 'left' => [ |
| 88 | 'title' => esc_html__('Left', 'shopengine'), |
| 89 | 'icon' => 'eicon-text-align-left', |
| 90 | ], |
| 91 | 'center' => [ |
| 92 | 'title' => esc_html__('Center', 'shopengine'), |
| 93 | 'icon' => 'eicon-text-align-center', |
| 94 | ], |
| 95 | 'right' => [ |
| 96 | 'title' => esc_html__('Right', 'shopengine'), |
| 97 | 'icon' => 'eicon-text-align-right', |
| 98 | ] |
| 99 | ], |
| 100 | 'selectors' => [ |
| 101 | '{{WRAPPER}} .shopengine-product-excerpt' => 'text-align: {{VALUE}}', |
| 102 | '.rtl {{WRAPPER}}.elementor-align-left .shopengine-product-excerpt' => 'text-align:right;', |
| 103 | '.rtl {{WRAPPER}}.elementor-align-right .shopengine-product-excerpt' => 'text-align:left;', |
| 104 | ], |
| 105 | 'prefix_class' => 'elementor-align-', |
| 106 | ] |
| 107 | ); |
| 108 | |
| 109 | $this->end_controls_section(); |
| 110 | } |
| 111 | |
| 112 | protected function screen() { |
| 113 | |
| 114 | $tpl = Products::instance()->get_widget_template($this->get_name()); |
| 115 | |
| 116 | include $tpl; |
| 117 | } |
| 118 | } |
| 119 |