screens
3 years ago
additional-information-config.php
4 years ago
additional-information.php
3 years ago
additional-information.php
225 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Elementor; |
| 4 | |
| 5 | use ShopEngine\Widgets\Products; |
| 6 | |
| 7 | defined('ABSPATH') || exit; |
| 8 | |
| 9 | |
| 10 | class ShopEngine_Additional_Information extends \ShopEngine\Base\Widget |
| 11 | { |
| 12 | |
| 13 | public function config() { |
| 14 | return new ShopEngine_Additional_Information_Config(); |
| 15 | } |
| 16 | |
| 17 | protected function register_controls() { |
| 18 | |
| 19 | $this->start_controls_section( |
| 20 | 'shopengine_section_product_additional_information_common', |
| 21 | array( |
| 22 | 'label' => esc_html__('Common', 'shopengine'), |
| 23 | 'tab' => Controls_Manager::TAB_STYLE, |
| 24 | ) |
| 25 | ); |
| 26 | |
| 27 | |
| 28 | $this->add_responsive_control( |
| 29 | 'shopengine_product_additional_information_table_cell_padding', |
| 30 | [ |
| 31 | 'label' => esc_html__('Table Cell Padding', 'shopengine'), |
| 32 | 'type' => Controls_Manager::DIMENSIONS, |
| 33 | 'default' => [ |
| 34 | 'top' => '15', |
| 35 | 'right' => '35', |
| 36 | 'bottom' => '15', |
| 37 | 'left' => '35', |
| 38 | 'unit' => 'px', |
| 39 | 'isLinked' => false, |
| 40 | ], |
| 41 | 'size_units' => ['px'], |
| 42 | 'selectors' => [ |
| 43 | '{{WRAPPER}} .shopengine-additional-information tr td' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 44 | '.rtl {{WRAPPER}} .shopengine-additional-information tr td' => 'padding: {{TOP}}{{UNIT}} {{LEFT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{RIGHT}}{{UNIT}}; text-align:right;', |
| 45 | '{{WRAPPER}} .shopengine-additional-information tr th' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 46 | '.rtl {{WRAPPER}} .shopengine-additional-information tr th' => 'padding: {{TOP}}{{UNIT}} {{LEFT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{RIGHT}}{{UNIT}};text-align:right;', |
| 47 | ], |
| 48 | ] |
| 49 | ); |
| 50 | $this->add_group_control( |
| 51 | Group_Control_Typography::get_type(), |
| 52 | array( |
| 53 | 'name' => 'shopengine_product_additional_information_label_typography', |
| 54 | 'label' => esc_html__('Typography', 'shopengine'), |
| 55 | 'selector' => '{{WRAPPER}} .shopengine-additional-information tr :is(td, th, p) ', |
| 56 | 'exclude' => ['text_transform', 'text_decoration', 'line_height', 'text_style', 'letter_spacing'], |
| 57 | 'fields_options' => [ |
| 58 | 'typography' => [ |
| 59 | 'default' => 'custom', |
| 60 | ], |
| 61 | 'font_size' => [ |
| 62 | 'label' => esc_html__('Font Size (px)', 'shopengine'), |
| 63 | 'size_units' => ['px'], |
| 64 | 'default' => [ |
| 65 | 'size' => '16', |
| 66 | 'unit' => 'px', |
| 67 | ], |
| 68 | ], |
| 69 | 'font_weight' => [ |
| 70 | 'default' => '400', |
| 71 | ], |
| 72 | 'text_transform' => [ |
| 73 | 'default' => 'capitalize', |
| 74 | ], |
| 75 | 'font_style' => [ |
| 76 | 'default' => 'normal', |
| 77 | ], |
| 78 | 'line_height' => [ |
| 79 | 'default' => [ |
| 80 | 'size' => '19', |
| 81 | 'unit' => 'px', |
| 82 | ], |
| 83 | ], |
| 84 | 'letter_spacing' => [ |
| 85 | 'default' => [ |
| 86 | 'size' => '0', |
| 87 | ], |
| 88 | ], |
| 89 | ], |
| 90 | ) |
| 91 | ); |
| 92 | |
| 93 | $this->add_control( |
| 94 | 'shopengine_product_additional_information_separator_color', |
| 95 | [ |
| 96 | 'label' => esc_html__('Separator Color', 'shopengine'), |
| 97 | 'type' => Controls_Manager::COLOR, |
| 98 | 'alpha' => false, |
| 99 | 'selectors' => [ |
| 100 | '{{WRAPPER}} .shopengine-additional-information .shop_attributes tr:not(:last-child), |
| 101 | {{WRAPPER}} .shopengine-additional-information table.shop_attributes tr td, |
| 102 | {{WRAPPER}} .shopengine-additional-information table.shop_attributes tr th' => 'border-color: {{VALUE}};', |
| 103 | ], |
| 104 | ] |
| 105 | ); |
| 106 | |
| 107 | $this->end_controls_section(); |
| 108 | |
| 109 | |
| 110 | $this->start_controls_section( |
| 111 | 'shopengine_section_product_additional_information_label', |
| 112 | array( |
| 113 | 'label' => esc_html__('Label', 'shopengine'), |
| 114 | 'tab' => Controls_Manager::TAB_STYLE, |
| 115 | ) |
| 116 | ); |
| 117 | |
| 118 | $this->add_control( |
| 119 | 'shopengine_product_additional_information_label_color', |
| 120 | [ |
| 121 | 'label' => esc_html__('Color', 'shopengine'), |
| 122 | 'type' => Controls_Manager::COLOR, |
| 123 | 'default' => '#888888', |
| 124 | 'alpha' => false, |
| 125 | 'selectors' => [ |
| 126 | '{{WRAPPER}} .shopengine-additional-information tr th' => 'color: {{VALUE}};', |
| 127 | ], |
| 128 | ] |
| 129 | ); |
| 130 | |
| 131 | $this->add_control( |
| 132 | 'shopengine_product_additional_information_label_bg_color', |
| 133 | [ |
| 134 | 'label' => esc_html__('Background', 'shopengine'), |
| 135 | 'type' => Controls_Manager::COLOR, |
| 136 | 'default' => '#f8f8f8', |
| 137 | 'alpha' => false, |
| 138 | 'selectors' => [ |
| 139 | '{{WRAPPER}} .shopengine-additional-information tr th' => 'background: {{VALUE}};', |
| 140 | ], |
| 141 | ] |
| 142 | ); |
| 143 | |
| 144 | |
| 145 | |
| 146 | $this->add_responsive_control( |
| 147 | 'shopengine_product_additional_information_label_width', |
| 148 | [ |
| 149 | 'label' => esc_html__('Width', 'shopengine'), |
| 150 | 'type' => Controls_Manager::SLIDER, |
| 151 | 'size_units' => ['px', '%'], |
| 152 | 'range' => [ |
| 153 | 'px' => [ |
| 154 | 'min' => 0, |
| 155 | 'max' => 1000, |
| 156 | 'step' => 5, |
| 157 | ], |
| 158 | '%' => [ |
| 159 | 'min' => 0, |
| 160 | 'max' => 100, |
| 161 | ], |
| 162 | ], |
| 163 | 'default' => [ |
| 164 | 'unit' => '%', |
| 165 | 'size' => 25, |
| 166 | ], |
| 167 | 'selectors' => [ |
| 168 | '{{WRAPPER}} .shopengine-additional-information tr th' => 'width: {{SIZE}}{{UNIT}};', |
| 169 | ], |
| 170 | ] |
| 171 | ); |
| 172 | |
| 173 | $this->end_controls_section(); |
| 174 | |
| 175 | $this->start_controls_section( |
| 176 | 'shopengine_section_product_additional_information_value', |
| 177 | array( |
| 178 | 'label' => esc_html__('Value', 'shopengine'), |
| 179 | 'tab' => Controls_Manager::TAB_STYLE, |
| 180 | ) |
| 181 | ); |
| 182 | |
| 183 | $this->add_control( |
| 184 | 'shopengine_product_additional_information_value_color', |
| 185 | [ |
| 186 | 'label' => esc_html__('Color', 'shopengine'), |
| 187 | 'type' => Controls_Manager::COLOR, |
| 188 | 'default' => '#101010', |
| 189 | 'alpha' => false, |
| 190 | 'selectors' => [ |
| 191 | '{{WRAPPER}} .shopengine-additional-information tr td p' => 'color: {{VALUE}};', |
| 192 | ], |
| 193 | ] |
| 194 | ); |
| 195 | |
| 196 | $this->add_control( |
| 197 | 'shopengine_product_additional_information_value_bg_color', |
| 198 | [ |
| 199 | 'label' => esc_html__('Background', 'shopengine'), |
| 200 | 'type' => Controls_Manager::COLOR, |
| 201 | 'default' => '#fdfdfd', |
| 202 | 'alpha' => false, |
| 203 | 'selectors' => [ |
| 204 | '{{WRAPPER}} .shopengine-additional-information tr td' => 'background: {{VALUE}};', |
| 205 | ], |
| 206 | ] |
| 207 | ); |
| 208 | |
| 209 | $this->end_controls_section(); |
| 210 | } |
| 211 | |
| 212 | protected function screen() { |
| 213 | |
| 214 | $settings = $this->get_settings_for_display(); |
| 215 | |
| 216 | $post_type = get_post_type(); |
| 217 | |
| 218 | $product = Products::instance()->get_product($post_type); |
| 219 | |
| 220 | $tpl = Products::instance()->get_widget_template($this->get_name()); |
| 221 | |
| 222 | include $tpl; |
| 223 | } |
| 224 | } |
| 225 |