product-meta.php
332 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Elementor; |
| 4 | |
| 5 | use ShopEngine\Widgets\Products; |
| 6 | |
| 7 | defined('ABSPATH') || exit; |
| 8 | |
| 9 | |
| 10 | class ShopEngine_Product_Meta extends \ShopEngine\Base\Widget |
| 11 | { |
| 12 | |
| 13 | public function config() { |
| 14 | return new ShopEngine_Product_Meta_Config(); |
| 15 | } |
| 16 | |
| 17 | protected function register_controls() { |
| 18 | |
| 19 | $this->start_controls_section( |
| 20 | 'shopengine_section_meta_content', |
| 21 | [ |
| 22 | 'label' => esc_html__('Settings', 'shopengine'), |
| 23 | 'tab' => Controls_Manager::TAB_CONTENT, |
| 24 | ] |
| 25 | ); |
| 26 | |
| 27 | $this->add_control( |
| 28 | 'shopengine_meta_sku_hide', |
| 29 | [ |
| 30 | 'label' => esc_html__('SKU', 'shopengine'), |
| 31 | 'type' => Controls_Manager::SWITCHER, |
| 32 | 'label_on' => esc_html__('Show', 'shopengine'), |
| 33 | 'label_off' => esc_html__('Hide', 'shopengine'), |
| 34 | 'default' => "yes", |
| 35 | 'return_value' => "yes", |
| 36 | 'selectors' => [ |
| 37 | '{{WRAPPER}} .shopengine-product-meta .sku_wrapper' => 'display: block;', |
| 38 | '{{WRAPPER}}.shopengine-layout-inline .shopengine-product-meta .sku_wrapper' => 'display: inline-block;', |
| 39 | ], |
| 40 | ] |
| 41 | ); |
| 42 | |
| 43 | $this->add_control( |
| 44 | 'shopengine_meta_category_hide', |
| 45 | [ |
| 46 | 'label' => esc_html__('Category', 'shopengine'), |
| 47 | 'type' => Controls_Manager::SWITCHER, |
| 48 | 'label_on' => esc_html__('Show', 'shopengine'), |
| 49 | 'label_off' => esc_html__('Hide', 'shopengine'), |
| 50 | 'default' => "yes", |
| 51 | 'return_value' => "yes", |
| 52 | 'selectors' => [ |
| 53 | '{{WRAPPER}} .shopengine-product-meta .posted_in' => 'display: block;', |
| 54 | '{{WRAPPER}}.shopengine-layout-inline .shopengine-product-meta .posted_in' => 'display: inline-block;', |
| 55 | '{{WRAPPER}} .shopengine-product-meta .products-page-cats' => 'display: block;', // xstore alignment & display issue fix |
| 56 | '{{WRAPPER}}.shopengine-layout-inline .shopengine-product-meta .products-page-cats' => 'display: inline-block;', // xstore alignment & display issue fix |
| 57 | ], |
| 58 | ] |
| 59 | ); |
| 60 | |
| 61 | $this->add_control( |
| 62 | 'shopengine_meta_tag_hide', |
| 63 | [ |
| 64 | 'label' => esc_html__('Tag', 'shopengine'), |
| 65 | 'type' => Controls_Manager::SWITCHER, |
| 66 | 'label_on' => esc_html__('Show', 'shopengine'), |
| 67 | 'label_off' => esc_html__('Hide', 'shopengine'), |
| 68 | 'default' => "yes", |
| 69 | 'return_value' => "yes", |
| 70 | 'selectors' => [ |
| 71 | '{{WRAPPER}} .shopengine-product-meta .tagged_as' => 'display: block;', |
| 72 | '{{WRAPPER}}.shopengine-layout-inline .shopengine-product-meta .tagged_as' => 'display: inline-block;', |
| 73 | ], |
| 74 | ] |
| 75 | ); |
| 76 | |
| 77 | $this->end_controls_section(); |
| 78 | |
| 79 | /* |
| 80 | * Styles Tab |
| 81 | */ |
| 82 | $this->start_controls_section( |
| 83 | 'shopengine_section_meta_style', |
| 84 | [ |
| 85 | 'label' => esc_html__('Styles', 'shopengine'), |
| 86 | 'tab' => Controls_Manager::TAB_STYLE, |
| 87 | ] |
| 88 | ); |
| 89 | |
| 90 | $this->add_responsive_control( |
| 91 | 'shopengine_meta_layout', |
| 92 | [ |
| 93 | 'label' => esc_html__('Layout', 'shopengine'), |
| 94 | 'type' => Controls_Manager::CHOOSE, |
| 95 | 'default' => 'block', |
| 96 | 'options' => [ |
| 97 | 'block' => [ |
| 98 | 'title' => esc_html__('Default', 'shopengine'), |
| 99 | 'icon' => 'eicon-editor-list-ul', |
| 100 | ], |
| 101 | 'inline' => [ |
| 102 | 'title' => esc_html__('Inline', 'shopengine'), |
| 103 | 'icon' => 'eicon-ellipsis-h', |
| 104 | ], |
| 105 | ], |
| 106 | 'prefix_class' => 'shopengine-layout-', |
| 107 | ] |
| 108 | ); |
| 109 | |
| 110 | $this->add_responsive_control( |
| 111 | 'shopengine_meta_align', |
| 112 | [ |
| 113 | 'label' => esc_html__('Align', 'shopengine'), |
| 114 | 'type' => Controls_Manager::CHOOSE, |
| 115 | 'options' => [ |
| 116 | 'left' => [ |
| 117 | 'title' => esc_html__('Left', 'shopengine'), |
| 118 | 'icon' => 'eicon-text-align-left', |
| 119 | ], |
| 120 | 'center' => [ |
| 121 | 'title' => esc_html__('Center', 'shopengine'), |
| 122 | 'icon' => 'eicon-text-align-center', |
| 123 | ], |
| 124 | 'right' => [ |
| 125 | 'title' => esc_html__('Right', 'shopengine'), |
| 126 | 'icon' => 'eicon-text-align-right', |
| 127 | ], |
| 128 | ], |
| 129 | 'selectors' => [ |
| 130 | '{{WRAPPER}} .shopengine-product-meta .product_meta' => 'text-align: {{VALUE}}', |
| 131 | '.rtl {{WRAPPER}}.elementor-align-left .shopengine-product-meta .product_meta' => 'text-align:right;', |
| 132 | '.rtl {{WRAPPER}}.elementor-align-right .shopengine-product-meta .product_meta' => 'text-align:left;', |
| 133 | ], |
| 134 | 'prefix_class' => 'elementor%s-align-', |
| 135 | ] |
| 136 | ); |
| 137 | |
| 138 | $this->add_responsive_control( |
| 139 | 'shopengine_meta_padding', |
| 140 | [ |
| 141 | 'label' => esc_html__('Padding', 'shopengine'), |
| 142 | 'type' => Controls_Manager::DIMENSIONS, |
| 143 | 'size_units' => ['px'], |
| 144 | 'default' => [ |
| 145 | 'top' => '0', |
| 146 | 'right' => '0', |
| 147 | 'bottom' => '8', |
| 148 | 'left' => '0', |
| 149 | 'isLinked' => false, |
| 150 | ], |
| 151 | 'selectors' => [ |
| 152 | '{{WRAPPER}} .shopengine-product-meta .product_meta :is(.sku_wrapper, .posted_in, .tagged_as)' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 153 | '.rtl {{WRAPPER}} .shopengine-product-meta .product_meta :is(.sku_wrapper, .posted_in, .tagged_as)' => 'padding: {{TOP}}{{UNIT}} {{LEFT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{RIGHT}}{{UNIT}};', |
| 154 | ], |
| 155 | ] |
| 156 | ); |
| 157 | |
| 158 | $this->add_control( |
| 159 | 'shopengine_product_meta_label_heading', |
| 160 | [ |
| 161 | 'label' => esc_html__('Label', 'shopengine'), |
| 162 | 'type' => Controls_Manager::HEADING, |
| 163 | 'separator' => 'before', |
| 164 | ] |
| 165 | ); |
| 166 | |
| 167 | $this->add_control( |
| 168 | 'shopengine_meta_label_color', |
| 169 | [ |
| 170 | 'label' => esc_html__('Label Color', 'shopengine'), |
| 171 | 'type' => Controls_Manager::COLOR, |
| 172 | 'default' => '#101010', |
| 173 | 'alpha' => false, |
| 174 | 'selectors' => [ |
| 175 | '{{WRAPPER}} .shopengine-product-meta .product_meta :is(.sku_wrapper, .posted_in, .tagged_as)' => 'color: {{VALUE}};', |
| 176 | ], |
| 177 | ] |
| 178 | ); |
| 179 | |
| 180 | $this->add_group_control( |
| 181 | Group_Control_Typography::get_type(), |
| 182 | [ |
| 183 | 'name' => 'shopengine_product_meta_value_typography', |
| 184 | 'label' => esc_html__('Typography', 'shopengine'), |
| 185 | 'description' => esc_html__('This typography is set for this specific widget.', 'shopengine'), |
| 186 | 'selector' => '{{WRAPPER}} .shopengine-product-meta .product_meta :is(a, span, .sku_wrapper, .posted_in, .tagged_as)', |
| 187 | 'exclude' => ['text_decoration', 'font_family', 'font_style', 'letter_spacing', 'text_transform', 'text_decoration', 'word_spacing'], |
| 188 | 'fields_options' => [ |
| 189 | 'typography' => [ |
| 190 | 'default' => 'custom', |
| 191 | ], |
| 192 | 'font_size' => [ |
| 193 | 'label' => esc_html__('Font Size (px)', 'shopengine'), |
| 194 | 'size_units' => ['px'], |
| 195 | 'default' => [ |
| 196 | 'size' => '14', |
| 197 | 'unit' => 'px', |
| 198 | ], |
| 199 | ], |
| 200 | 'font_weight' => [ |
| 201 | 'default' => '500', |
| 202 | ], |
| 203 | 'text_transform' => [ |
| 204 | 'default' => 'none', |
| 205 | ], |
| 206 | 'line_height' => [ |
| 207 | 'label' => esc_html__('Line Height (px)', 'shopengine'), |
| 208 | 'default' => [ |
| 209 | 'size' => '17', |
| 210 | 'unit' => 'px', |
| 211 | ], |
| 212 | 'size_units' => ['px'], |
| 213 | 'tablet_default' => [ |
| 214 | 'unit' => 'px', |
| 215 | ], |
| 216 | 'mobile_default' => [ |
| 217 | 'unit' => 'px', |
| 218 | ], |
| 219 | ], |
| 220 | ], |
| 221 | ] |
| 222 | ); |
| 223 | |
| 224 | $this->add_control( |
| 225 | 'shopengine_product_meta_value_heading', |
| 226 | [ |
| 227 | 'label' => esc_html__('Value', 'shopengine'), |
| 228 | 'type' => Controls_Manager::HEADING, |
| 229 | 'separator' => 'before', |
| 230 | ] |
| 231 | ); |
| 232 | |
| 233 | |
| 234 | $this->add_control( |
| 235 | 'shopengine_meta_value_color', |
| 236 | [ |
| 237 | 'label' => esc_html__('Value Color', 'shopengine'), |
| 238 | 'type' => Controls_Manager::COLOR, |
| 239 | 'default' => '#a0a0a0', |
| 240 | 'alpha' => false, |
| 241 | 'selectors' => [ |
| 242 | '{{WRAPPER}} .shopengine-product-meta .product_meta :is(.sku, .posted_in a, .tagged_as a)' => 'color: {{VALUE}};', |
| 243 | ], |
| 244 | ] |
| 245 | ); |
| 246 | |
| 247 | $this->add_group_control( |
| 248 | Group_Control_Typography::get_type(), |
| 249 | [ |
| 250 | 'name' => 'shopengine_product_meta_label_typography', |
| 251 | 'label' => esc_html__('Typography', 'shopengine'), |
| 252 | 'description' => esc_html__('This typography is set for this specific widget.', 'shopengine'), |
| 253 | 'selector' => '{{WRAPPER}} .shopengine-product-meta .product_meta :is(.sku, .posted_in a, .tagged_as a)', |
| 254 | 'exclude' => ['text_decoration', 'font_family', 'font_style', 'letter_spacing', 'text_transform', 'text_decoration', 'word_spacing'], |
| 255 | 'fields_options' => [ |
| 256 | 'typography' => [ |
| 257 | 'default' => 'custom', |
| 258 | ], |
| 259 | 'font_size' => [ |
| 260 | 'label' => esc_html__('Font Size (px)', 'shopengine'), |
| 261 | 'size_units' => ['px'], |
| 262 | 'default' => [ |
| 263 | 'size' => '14', |
| 264 | 'unit' => 'px', |
| 265 | ], |
| 266 | ], |
| 267 | 'font_weight' => [ |
| 268 | 'default' => '500', |
| 269 | ], |
| 270 | 'text_transform' => [ |
| 271 | 'default' => 'none', |
| 272 | ], |
| 273 | 'line_height' => [ |
| 274 | 'label' => esc_html__('Line Height (px)', 'shopengine'), |
| 275 | 'default' => [ |
| 276 | 'size' => '17', |
| 277 | 'unit' => 'px', |
| 278 | ], |
| 279 | 'size_units' => ['px'], |
| 280 | 'tablet_default' => [ |
| 281 | 'unit' => 'px', |
| 282 | ], |
| 283 | 'mobile_default' => [ |
| 284 | 'unit' => 'px', |
| 285 | ], |
| 286 | ], |
| 287 | ], |
| 288 | ] |
| 289 | ); |
| 290 | |
| 291 | $this->add_control( |
| 292 | 'shopengine_meta_value_link_hover_color', |
| 293 | [ |
| 294 | 'label' => esc_html__('Link Hover Color', 'shopengine'), |
| 295 | 'type' => Controls_Manager::COLOR, |
| 296 | 'default' => '#101010', |
| 297 | 'alpha' => false, |
| 298 | 'selectors' => [ |
| 299 | '{{WRAPPER}} .shopengine-product-meta .product_meta :is(.posted_in a, .tagged_as a):hover' => 'color: {{VALUE}};', |
| 300 | ], |
| 301 | ] |
| 302 | ); |
| 303 | |
| 304 | $this->add_control( |
| 305 | 'shopengine_product_meta_typography_heading', |
| 306 | [ |
| 307 | 'label' => esc_html__('Global Typography', 'shopengine'), |
| 308 | 'type' => Controls_Manager::HEADING, |
| 309 | 'separator' => 'before', |
| 310 | ] |
| 311 | ); |
| 312 | |
| 313 | $this->add_group_control( |
| 314 | Group_Control_Typography::get_type(), |
| 315 | [ |
| 316 | 'name' => 'shopengine_product_global_typography', |
| 317 | 'label' => esc_html__('Typography', 'shopengine'), |
| 318 | 'exclude' => ['text_decoration', 'font_style', 'line_height', 'text_transfrom', 'font_size','font_weight'], |
| 319 | ] |
| 320 | ); |
| 321 | |
| 322 | $this->end_controls_section(); |
| 323 | } |
| 324 | |
| 325 | protected function screen() { |
| 326 | |
| 327 | $tpl = Products::instance()->get_widget_template($this->get_name()); |
| 328 | |
| 329 | include $tpl; |
| 330 | } |
| 331 | } |
| 332 |