| 1 |
<?php |
| 2 |
|
| 3 |
namespace UltimateStoreKit\Modules\ProductList\Widgets; |
| 4 |
|
| 5 |
|
| 6 |
use Elementor\Controls_Manager; |
| 7 |
use UltimateStoreKit\Base\Module_Base; |
| 8 |
use Elementor\Group_Control_Border; |
| 9 |
use Elementor\Group_Control_Background; |
| 10 |
use Elementor\Group_Control_Box_Shadow; |
| 11 |
use Elementor\Group_Control_Image_Size; |
| 12 |
use Elementor\Group_Control_Typography; |
| 13 |
use UltimateStoreKit\traits\Global_Widget_Controls; |
| 14 |
use UltimateStoreKit\traits\Global_Widget_Template; |
| 15 |
// use UltimateStoreKit\traits\Global_Swiper_Template; |
| 16 |
use UltimateStoreKit\Includes\Controls\GroupQuery\Group_Control_Query; |
| 17 |
use WP_Query; |
| 18 |
|
| 19 |
if (!defined('ABSPATH')) { |
| 20 |
exit; |
| 21 |
} |
| 22 |
|
| 23 |
// Exit if accessed directly |
| 24 |
|
| 25 |
class Product_List extends Module_Base { |
| 26 |
use Global_Widget_Controls; |
| 27 |
use Global_Widget_Template; |
| 28 |
// use Global_Swiper_Template; |
| 29 |
use Group_Control_Query; |
| 30 |
|
| 31 |
/** |
| 32 |
* @var \WP_Query |
| 33 |
*/ |
| 34 |
private $_query = null; |
| 35 |
public function get_name() { |
| 36 |
return 'usk-product-list'; |
| 37 |
} |
| 38 |
|
| 39 |
public function get_title() { |
| 40 |
return esc_html__('Product List', 'ultimate-store-kit'); |
| 41 |
} |
| 42 |
|
| 43 |
public function get_icon() { |
| 44 |
return 'usk-widget-icon usk-icon-product-list'; |
| 45 |
} |
| 46 |
|
| 47 |
public function get_categories() { |
| 48 |
return ['ultimate-store-kit']; |
| 49 |
} |
| 50 |
|
| 51 |
public function get_keywords() { |
| 52 |
return ['product', 'product-grid', 'table', 'wc']; |
| 53 |
} |
| 54 |
|
| 55 |
public function get_script_depends() { |
| 56 |
return ['micromodal']; |
| 57 |
} |
| 58 |
|
| 59 |
public function get_style_depends() { |
| 60 |
if ($this->usk_is_edit_mode()) { |
| 61 |
return ['usk-all-styles']; |
| 62 |
} else { |
| 63 |
return ['ultimate-store-kit-font', 'usk-product-list']; |
| 64 |
} |
| 65 |
} |
| 66 |
|
| 67 |
public function get_custom_help_url() { |
| 68 |
return 'https://youtu.be/qJQ9wfdoMKg'; |
| 69 |
} |
| 70 |
|
| 71 |
public function get_query() { |
| 72 |
return $this->_query; |
| 73 |
} |
| 74 |
protected function register_controls() { |
| 75 |
|
| 76 |
$this->start_controls_section( |
| 77 |
'section_woocommerce_layout', |
| 78 |
[ |
| 79 |
'label' => esc_html__('Layout', 'ultimate-store-kit'), |
| 80 |
] |
| 81 |
); |
| 82 |
$this->add_responsive_control( |
| 83 |
'items_gap', |
| 84 |
[ |
| 85 |
'label' => esc_html__('Items Gap', 'ultimate-wook'), |
| 86 |
'type' => Controls_Manager::SLIDER, |
| 87 |
'default' => [ |
| 88 |
'size' => 20, |
| 89 |
], |
| 90 |
'selectors' => [ |
| 91 |
'{{WRAPPER}} .ultimate-store-kit .usk-list-wrap' => 'grid-gap: {{SIZE}}px;', |
| 92 |
], |
| 93 |
] |
| 94 |
); |
| 95 |
$this->add_control( |
| 96 |
'title_tags', |
| 97 |
[ |
| 98 |
'label' => esc_html__('Title HTML Tag', 'ultimate-store-kit'), |
| 99 |
'type' => Controls_Manager::SELECT, |
| 100 |
'default' => 'h3', |
| 101 |
'options' => ultimate_store_kit_title_tags(), |
| 102 |
] |
| 103 |
); |
| 104 |
$this->add_group_control( |
| 105 |
Group_Control_Image_Size::get_type(), |
| 106 |
[ |
| 107 |
'name' => 'image', |
| 108 |
'label' => esc_html__('Image Size', 'ultimate-store-kit'), |
| 109 |
'exclude' => ['custom'], |
| 110 |
'default' => 'full', |
| 111 |
] |
| 112 |
); |
| 113 |
|
| 114 |
$this->end_controls_section(); |
| 115 |
$this->start_controls_section( |
| 116 |
'section_post_query_builder', |
| 117 |
[ |
| 118 |
'label' => __('Query', 'ultimate-store-kit'), |
| 119 |
'tab' => Controls_Manager::TAB_CONTENT, |
| 120 |
] |
| 121 |
); |
| 122 |
$this->register_query_builder_controls(); |
| 123 |
$this->register_controls_wc_additional(); |
| 124 |
$this->end_controls_section(); |
| 125 |
|
| 126 |
$this->start_controls_section( |
| 127 |
'section_woocommerce_additional', |
| 128 |
[ |
| 129 |
'label' => esc_html__('Additional', 'ultimate-store-kit'), |
| 130 |
] |
| 131 |
); |
| 132 |
$this->start_controls_tabs( |
| 133 |
'tabs_show_hide_content' |
| 134 |
); |
| 135 |
$this->start_controls_tab( |
| 136 |
'show_content_tab', |
| 137 |
[ |
| 138 |
'label' => esc_html__('Content', 'ultimate-store-kit'), |
| 139 |
] |
| 140 |
); |
| 141 |
$this->add_control( |
| 142 |
'show_image', |
| 143 |
[ |
| 144 |
'label' => esc_html__('Image', 'ultimate-store-kit'), |
| 145 |
'type' => Controls_Manager::SWITCHER, |
| 146 |
'return_value' => 'yes', |
| 147 |
'default' => 'yes', |
| 148 |
] |
| 149 |
); |
| 150 |
$this->add_control( |
| 151 |
'show_title', |
| 152 |
[ |
| 153 |
'label' => esc_html__('Title', 'ultimate-store-kit'), |
| 154 |
'type' => Controls_Manager::SWITCHER, |
| 155 |
'return_value' => 'yes', |
| 156 |
'default' => 'yes', |
| 157 |
] |
| 158 |
); |
| 159 |
$this->add_control( |
| 160 |
'show_price', |
| 161 |
[ |
| 162 |
'label' => esc_html__('Price', 'ultimate-store-kit'), |
| 163 |
'type' => Controls_Manager::SWITCHER, |
| 164 |
'default' => 'yes', |
| 165 |
] |
| 166 |
); |
| 167 |
$this->add_control( |
| 168 |
'show_rating', |
| 169 |
[ |
| 170 |
'label' => esc_html__('Rating', 'ultimate-store-kit'), |
| 171 |
'type' => Controls_Manager::SWITCHER, |
| 172 |
'default' => 'yes', |
| 173 |
] |
| 174 |
); |
| 175 |
$this->add_control( |
| 176 |
'hide_customer_review', |
| 177 |
[ |
| 178 |
'label' => esc_html__('Hide Review Text', 'ultimate-store-kit'), |
| 179 |
'type' => Controls_Manager::SWITCHER, |
| 180 |
'label_on' => esc_html__('Yes', 'product-grid'), |
| 181 |
'label_off' => esc_html__('No', 'product-grid'), |
| 182 |
// 'return_value' => 'yes', |
| 183 |
'default' => 'yes', |
| 184 |
'condition' => [ |
| 185 |
'show_rating' => 'yes', |
| 186 |
], |
| 187 |
'selectors' => [ |
| 188 |
'{{WRAPPER}} .usk-recently-view-products .usk-rating .woocommerce-product-rating .woocommerce-review-link' => 'display:none', |
| 189 |
], |
| 190 |
] |
| 191 |
); |
| 192 |
|
| 193 |
$this->end_controls_tab(); |
| 194 |
$this->start_controls_tab( |
| 195 |
'show_badge_tab', |
| 196 |
[ |
| 197 |
'label' => esc_html__('Badge', 'ultimate-store-kit'), |
| 198 |
] |
| 199 |
); |
| 200 |
$this->add_control( |
| 201 |
'show_sale_badge', |
| 202 |
[ |
| 203 |
'label' => esc_html__('Sale', 'ultimate-store-kit'), |
| 204 |
'type' => Controls_Manager::SWITCHER, |
| 205 |
'default' => 'yes', |
| 206 |
] |
| 207 |
); |
| 208 |
$this->add_control( |
| 209 |
'show_discount_badge', |
| 210 |
[ |
| 211 |
'label' => esc_html__('Percentage', 'ultimate-store-kit'), |
| 212 |
'type' => Controls_Manager::SWITCHER, |
| 213 |
'default' => 'yes', |
| 214 |
] |
| 215 |
); |
| 216 |
$this->add_control( |
| 217 |
'show_stock_status', |
| 218 |
[ |
| 219 |
'label' => esc_html__('Stock Status', 'ultimate-store-kit'), |
| 220 |
'type' => Controls_Manager::SWITCHER, |
| 221 |
'default' => 'yes', |
| 222 |
] |
| 223 |
); |
| 224 |
$this->add_control( |
| 225 |
'show_trending_badge', |
| 226 |
[ |
| 227 |
'label' => esc_html__('Trending', 'ultimate-store-kit'), |
| 228 |
'type' => Controls_Manager::SWITCHER, |
| 229 |
'default' => 'yes', |
| 230 |
] |
| 231 |
); |
| 232 |
$this->add_control( |
| 233 |
'show_new_badge', |
| 234 |
[ |
| 235 |
'label' => esc_html__('New', 'ultimate-store-kit'), |
| 236 |
'type' => Controls_Manager::SWITCHER, |
| 237 |
'default' => 'yes', |
| 238 |
] |
| 239 |
); |
| 240 |
$this->add_control( |
| 241 |
'newness_days', |
| 242 |
[ |
| 243 |
'label' => esc_html__('Newness Days', 'ultimate-store-kit'), |
| 244 |
'type' => Controls_Manager::NUMBER, |
| 245 |
'default' => 90, |
| 246 |
'description' => esc_html__('Define newness day from product created date; default newness day is 30', 'ultimate-store-kit'), |
| 247 |
'condition' => [ |
| 248 |
'show_new_badge' => 'yes', |
| 249 |
], |
| 250 |
] |
| 251 |
); |
| 252 |
$this->end_controls_tab(); |
| 253 |
$this->end_controls_tabs(); |
| 254 |
|
| 255 |
// $this-> add_control( |
| 256 |
// 'heading_show_hide_badge', |
| 257 |
// [ |
| 258 |
// 'label' => esc_html__( 'Badge', 'ultimate-store-kit' ), |
| 259 |
// 'type' => Controls_Manager::HEADING, |
| 260 |
// 'separator' => 'before', |
| 261 |
// ] |
| 262 |
// ); |
| 263 |
|
| 264 |
$this->end_controls_section(); |
| 265 |
$this->start_controls_section( |
| 266 |
'section_style_item', |
| 267 |
[ |
| 268 |
'label' => esc_html__('Items', 'ultimate-store-kit'), |
| 269 |
'tab' => Controls_Manager::TAB_STYLE, |
| 270 |
] |
| 271 |
); |
| 272 |
$this->add_group_control( |
| 273 |
Group_Control_Background::get_type(), |
| 274 |
[ |
| 275 |
'name' => 'item_background', |
| 276 |
'label' => esc_html__('Background', 'ultimate-store-kit'), |
| 277 |
'types' => ['classic', 'gradient'], |
| 278 |
'selector' => '{{WRAPPER}} .ultimate-store-kit .usk-list-wrap .usk-item', |
| 279 |
] |
| 280 |
); |
| 281 |
$this->add_group_control( |
| 282 |
Group_Control_Border::get_type(), |
| 283 |
[ |
| 284 |
'name' => 'item_border', |
| 285 |
'label' => esc_html__('Border', 'ultimate-store-kit'), |
| 286 |
'selector' => '{{WRAPPER}} .ultimate-store-kit .usk-list-wrap .usk-item', |
| 287 |
'separator' => 'before', |
| 288 |
] |
| 289 |
); |
| 290 |
$this->add_control( |
| 291 |
'item_border_radius', |
| 292 |
[ |
| 293 |
'label' => esc_html__('Border Radius', 'ultimate-store-kit'), |
| 294 |
'type' => Controls_Manager::DIMENSIONS, |
| 295 |
'size_units' => ['px', '%', 'em'], |
| 296 |
'selectors' => [ |
| 297 |
'{{WRAPPER}} .ultimate-store-kit .usk-list-wrap .usk-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 298 |
], |
| 299 |
] |
| 300 |
); |
| 301 |
$this->add_control( |
| 302 |
'item_padding', |
| 303 |
[ |
| 304 |
'label' => esc_html__('Padding', 'ultimate-store-kit'), |
| 305 |
'type' => Controls_Manager::DIMENSIONS, |
| 306 |
'size_units' => ['px', '%', 'em'], |
| 307 |
'selectors' => [ |
| 308 |
'{{WRAPPER}} .ultimate-store-kit .usk-list-wrap .usk-item' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 309 |
], |
| 310 |
] |
| 311 |
); |
| 312 |
|
| 313 |
$this->add_group_control( |
| 314 |
Group_Control_Box_Shadow::get_type(), |
| 315 |
[ |
| 316 |
'name' => 'item_shadow', |
| 317 |
'selector' => '{{WRAPPER}} .ultimate-store-kit .usk-list-wrap .usk-item', |
| 318 |
] |
| 319 |
); |
| 320 |
$this->end_controls_section(); |
| 321 |
|
| 322 |
$this->start_controls_section( |
| 323 |
'section_style_image', |
| 324 |
[ |
| 325 |
'label' => esc_html__('Image', 'ultimate-store-kit'), |
| 326 |
'tab' => Controls_Manager::TAB_STYLE, |
| 327 |
] |
| 328 |
); |
| 329 |
|
| 330 |
$this->add_group_control( |
| 331 |
Group_Control_Border::get_type(), |
| 332 |
[ |
| 333 |
'name' => 'image_border', |
| 334 |
'label' => esc_html__('Image Border', 'ultimate-store-kit'), |
| 335 |
'selector' => '{{WRAPPER}} .ultimate-store-kit .usk-list-wrap .usk-item .usk-item-box .usk-image-wrap', |
| 336 |
] |
| 337 |
); |
| 338 |
|
| 339 |
$this->add_responsive_control( |
| 340 |
'image_border_radius', |
| 341 |
[ |
| 342 |
'label' => esc_html__('Border Radius', 'ultimate-store-kit'), |
| 343 |
'type' => Controls_Manager::DIMENSIONS, |
| 344 |
'size_units' => ['px', '%'], |
| 345 |
'selectors' => [ |
| 346 |
'{{WRAPPER}} .ultimate-store-kit .usk-list-wrap .usk-item .usk-item-box .usk-image-wrap' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 347 |
], |
| 348 |
] |
| 349 |
); |
| 350 |
|
| 351 |
$this->add_group_control( |
| 352 |
Group_Control_Box_Shadow::get_type(), |
| 353 |
[ |
| 354 |
'name' => 'image_shadow', |
| 355 |
'exclude' => [ |
| 356 |
'shadow_position', |
| 357 |
], |
| 358 |
'selector' => '{{WRAPPER}} .ultimate-store-kit .usk-list-wrap .usk-item .usk-item-box .usk-image-wrap', |
| 359 |
] |
| 360 |
); |
| 361 |
|
| 362 |
$this->add_responsive_control( |
| 363 |
'item_image_size', |
| 364 |
[ |
| 365 |
'label' => esc_html__('Image Size', 'ultimate-store-kit'), |
| 366 |
'type' => Controls_Manager::SLIDER, |
| 367 |
'size_units' => ['px', '%'], |
| 368 |
'range' => [ |
| 369 |
'px' => [ |
| 370 |
'min' => 50, |
| 371 |
'max' => 500, |
| 372 |
], |
| 373 |
'%' => [ |
| 374 |
'min' => 0, |
| 375 |
'max' => 100, |
| 376 |
], |
| 377 |
], |
| 378 |
'selectors' => [ |
| 379 |
'{{WRAPPER}} .ultimate-store-kit .usk-list-wrap .usk-item .usk-item-box .usk-image-wrap' => 'width: {{SIZE}}{{UNIT}};', |
| 380 |
], |
| 381 |
] |
| 382 |
); |
| 383 |
|
| 384 |
$this->end_controls_section(); |
| 385 |
$this->register_global_controls_title(); |
| 386 |
$this->register_global_controls_price(); |
| 387 |
$this->register_global_controls_rating(); |
| 388 |
$this->start_controls_section( |
| 389 |
'badge', |
| 390 |
[ |
| 391 |
'label' => esc_html__('Badge', 'ultimate-store-kit'), |
| 392 |
'tab' => Controls_Manager::TAB_STYLE, |
| 393 |
] |
| 394 |
); |
| 395 |
$this->start_controls_tabs( |
| 396 |
'label_badge_tabs' |
| 397 |
); |
| 398 |
$this->start_controls_tab( |
| 399 |
'sale_badge_tab', |
| 400 |
[ |
| 401 |
'label' => esc_html__('Sale', 'ultimate-store-kit'), |
| 402 |
'condition' => [ |
| 403 |
'show_sale_badge' => 'yes', |
| 404 |
] |
| 405 |
] |
| 406 |
); |
| 407 |
$this->add_control( |
| 408 |
'sale_badge_color', |
| 409 |
[ |
| 410 |
'label' => esc_html__('Color', 'ultimate-store-kit'), |
| 411 |
'type' => Controls_Manager::COLOR, |
| 412 |
'selectors' => [ |
| 413 |
'{{WRAPPER}} .usk-product-list .usk-item .usk-badge-label-wrapper .usk-sale-badge .usk-badge' => 'color: {{VALUE}}', |
| 414 |
], |
| 415 |
] |
| 416 |
); |
| 417 |
$this->add_control( |
| 418 |
'sale_badge_bg', |
| 419 |
[ |
| 420 |
'label' => esc_html__('Background', 'ultimae-woo-kit'), |
| 421 |
'type' => Controls_Manager::COLOR, |
| 422 |
'selectors' => [ |
| 423 |
'{{WRAPPER}} .usk-product-list .usk-item .usk-badge-label-wrapper .usk-sale-badge .usk-badge' => 'background: {{VALUE}}', |
| 424 |
], |
| 425 |
] |
| 426 |
); |
| 427 |
$this->end_controls_tab(); |
| 428 |
$this->start_controls_tab( |
| 429 |
'discount_badge_tab', |
| 430 |
[ |
| 431 |
'label' => esc_html__('Discount', 'ultimate-store-kit'), |
| 432 |
'condition' => [ |
| 433 |
'show_discount_badge' => 'yes', |
| 434 |
], |
| 435 |
] |
| 436 |
); |
| 437 |
$this->add_control( |
| 438 |
'discount_badge_color', |
| 439 |
[ |
| 440 |
'label' => esc_html__('Color', 'ultimate-store-kit'), |
| 441 |
'type' => Controls_Manager::COLOR, |
| 442 |
'selectors' => [ |
| 443 |
'{{WRAPPER}} .usk-product-list .usk-item .usk-badge-label-wrapper .usk-percantage-badge .usk-badge' => 'color: {{VALUE}}', |
| 444 |
], |
| 445 |
] |
| 446 |
); |
| 447 |
$this->add_control( |
| 448 |
'discount_badge_bg', |
| 449 |
[ |
| 450 |
'label' => esc_html__('Background', 'ultimae-woo-kit'), |
| 451 |
'type' => Controls_Manager::COLOR, |
| 452 |
'selectors' => [ |
| 453 |
'{{WRAPPER}} .usk-product-list .usk-item .usk-badge-label-wrapper .usk-percantage-badge .usk-badge' => 'background: {{VALUE}}', |
| 454 |
], |
| 455 |
] |
| 456 |
); |
| 457 |
$this->end_controls_tab(); |
| 458 |
$this->start_controls_tab( |
| 459 |
'stock_badge_tab', |
| 460 |
[ |
| 461 |
'label' => esc_html__('Stock', 'ultimate-store-kit'), |
| 462 |
'condition' => [ |
| 463 |
'show_stock_status' => 'yes', |
| 464 |
], |
| 465 |
] |
| 466 |
); |
| 467 |
$this->add_control( |
| 468 |
'stock_badge_color', |
| 469 |
[ |
| 470 |
'label' => esc_html__('Color', 'ultimate-store-kit'), |
| 471 |
'type' => Controls_Manager::COLOR, |
| 472 |
'selectors' => [ |
| 473 |
'{{WRAPPER}} .usk-product-list .usk-item .usk-badge-label-wrapper .usk-stock-status-badge .usk-badge' => 'color: {{VALUE}}', |
| 474 |
], |
| 475 |
] |
| 476 |
); |
| 477 |
$this->add_control( |
| 478 |
'stock_badge_bg', |
| 479 |
[ |
| 480 |
'label' => esc_html__('Background', 'ultimae-woo-kit'), |
| 481 |
'type' => Controls_Manager::COLOR, |
| 482 |
'selectors' => [ |
| 483 |
'{{WRAPPER}} .usk-product-list .usk-item .usk-badge-label-wrapper .usk-stock-status-badge .usk-badge' => 'background: {{VALUE}}', |
| 484 |
], |
| 485 |
] |
| 486 |
); |
| 487 |
$this->end_controls_tab(); |
| 488 |
$this->start_controls_tab( |
| 489 |
'trending_badge_tab', |
| 490 |
[ |
| 491 |
'label' => esc_html__('Trending', 'ultimate-store-kit'), |
| 492 |
'condition' => [ |
| 493 |
'show_trending_badge' => 'yes', |
| 494 |
], |
| 495 |
] |
| 496 |
); |
| 497 |
$this->add_control( |
| 498 |
'trending_badge_color', |
| 499 |
[ |
| 500 |
'label' => esc_html__('Color', 'ultimate-store-kit'), |
| 501 |
'type' => Controls_Manager::COLOR, |
| 502 |
'selectors' => [ |
| 503 |
'{{WRAPPER}} .usk-product-list .usk-item .usk-badge-label-wrapper .usk-trending-badge .usk-badge' => 'color: {{VALUE}}', |
| 504 |
], |
| 505 |
] |
| 506 |
); |
| 507 |
$this->add_control( |
| 508 |
'trending_badge_bg', |
| 509 |
[ |
| 510 |
'label' => esc_html__('Background', 'ultimae-woo-kit'), |
| 511 |
'type' => Controls_Manager::COLOR, |
| 512 |
'selectors' => [ |
| 513 |
'{{WRAPPER}} .usk-product-list .usk-item .usk-badge-label-wrapper .usk-trending-badge .usk-badge' => 'background: {{VALUE}}', |
| 514 |
], |
| 515 |
] |
| 516 |
); |
| 517 |
$this->end_controls_tab(); |
| 518 |
$this->start_controls_tab( |
| 519 |
'new_badge_tab', |
| 520 |
[ |
| 521 |
'label' => esc_html__('new', 'ultimate-store-kit'), |
| 522 |
'condition' => [ |
| 523 |
'show_new_badge' => 'yes', |
| 524 |
], |
| 525 |
] |
| 526 |
); |
| 527 |
$this->add_control( |
| 528 |
'new_badge_color', |
| 529 |
[ |
| 530 |
'label' => esc_html__('Color', 'ultimate-store-kit'), |
| 531 |
'type' => Controls_Manager::COLOR, |
| 532 |
'selectors' => [ |
| 533 |
'{{WRAPPER}} .usk-product-list .usk-item .usk-badge-label-wrapper .usk-new-badge .usk-badge' => 'color: {{VALUE}}', |
| 534 |
], |
| 535 |
] |
| 536 |
); |
| 537 |
$this->add_control( |
| 538 |
'new_badge_bg', |
| 539 |
[ |
| 540 |
'label' => esc_html__('Background', 'ultimae-woo-kit'), |
| 541 |
'type' => Controls_Manager::COLOR, |
| 542 |
'selectors' => [ |
| 543 |
'{{WRAPPER}} .usk-product-list .usk-item .usk-badge-label-wrapper .usk-new-badge .usk-badge' => 'background: {{VALUE}}', |
| 544 |
], |
| 545 |
] |
| 546 |
); |
| 547 |
$this->end_controls_tab(); |
| 548 |
$this->end_controls_tabs(); |
| 549 |
$this->add_responsive_control( |
| 550 |
'badge_padding', |
| 551 |
[ |
| 552 |
'label' => esc_html__('Padding', 'ultimate-store-kit'), |
| 553 |
'type' => Controls_Manager::DIMENSIONS, |
| 554 |
'size_units' => ['px', '%', 'em'], |
| 555 |
'selectors' => [ |
| 556 |
'{{WRAPPER}} .usk-product-list .usk-item .usk-badge-label-wrapper div .usk-badge' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 557 |
], |
| 558 |
'separator' => 'before', |
| 559 |
] |
| 560 |
); |
| 561 |
$this->add_responsive_control( |
| 562 |
'badge_margin', |
| 563 |
[ |
| 564 |
'label' => esc_html__('Margin', 'ultimate-store-kit'), |
| 565 |
'type' => Controls_Manager::DIMENSIONS, |
| 566 |
'size_units' => ['px', '%', 'em'], |
| 567 |
'selectors' => [ |
| 568 |
'{{WRAPPER}} .usk-product-list .usk-item .usk-badge-label-wrapper div .usk-badge' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 569 |
], |
| 570 |
] |
| 571 |
); |
| 572 |
$this->add_responsive_control( |
| 573 |
'badge_radius', |
| 574 |
[ |
| 575 |
'label' => esc_html__('Radius', 'ultimate-store-kit'), |
| 576 |
'type' => Controls_Manager::DIMENSIONS, |
| 577 |
'size_units' => ['px', '%', 'em'], |
| 578 |
'selectors' => [ |
| 579 |
'{{WRAPPER}} .usk-product-list .usk-item .usk-badge-label-wrapper div .usk-badge' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 580 |
], |
| 581 |
] |
| 582 |
); |
| 583 |
$this->add_group_control( |
| 584 |
Group_Control_Typography::get_type(), |
| 585 |
[ |
| 586 |
'name' => 'badge_typography', |
| 587 |
'label' => esc_html__('Typography', 'ultimate-store-kit'), |
| 588 |
'selector' => '{{WRAPPER}} .usk-product-list .usk-item .usk-badge-label-wrapper div .usk-badge', |
| 589 |
'separator' => 'before' |
| 590 |
] |
| 591 |
); |
| 592 |
$this->add_responsive_control( |
| 593 |
'badge_top_spacing', |
| 594 |
[ |
| 595 |
'label' => esc_html__('Top Spacing', 'ultimate-store-kit'), |
| 596 |
'type' => Controls_Manager::SLIDER, |
| 597 |
'default' => [ |
| 598 |
'unit' => 'px', |
| 599 |
'size' => 10, |
| 600 |
], |
| 601 |
'selectors' => [ |
| 602 |
'{{WRAPPER}} .usk-product-list .usk-item .usk-badge-label-wrapper' => 'top: {{SIZE}}{{UNIT}};', |
| 603 |
], |
| 604 |
'separator' => 'before' |
| 605 |
] |
| 606 |
); |
| 607 |
$this->add_responsive_control( |
| 608 |
'badge_right_spacing', |
| 609 |
[ |
| 610 |
'label' => esc_html__('Right Spacing', 'ultimate-store-kit'), |
| 611 |
'type' => Controls_Manager::SLIDER, |
| 612 |
'default' => [ |
| 613 |
'unit' => 'px', |
| 614 |
'size' => 10, |
| 615 |
], |
| 616 |
'selectors' => [ |
| 617 |
'{{WRAPPER}} .usk-product-list .usk-item .usk-badge-label-wrapper' => 'right: {{SIZE}}{{UNIT}};', |
| 618 |
], |
| 619 |
] |
| 620 |
); |
| 621 |
$this->end_controls_section(); |
| 622 |
} |
| 623 |
|
| 624 |
public function render_header() { ?> |
| 625 |
<div class="ultimate-store-kit"> |
| 626 |
<div class="usk-product-list"> |
| 627 |
<div class="usk-list-wrap"> |
| 628 |
<?php |
| 629 |
} |
| 630 |
public function render_footer() { |
| 631 |
?> |
| 632 |
</div> |
| 633 |
</div> |
| 634 |
</div> |
| 635 |
<?php |
| 636 |
} |
| 637 |
public function render_image() { |
| 638 |
$settings = $this->get_settings_for_display(); |
| 639 |
global $product; |
| 640 |
?> |
| 641 |
<div class="usk-image-wrap"> |
| 642 |
<a href="<?php echo esc_url($product->get_permalink()); ?>"> |
| 643 |
<img class="img image-default" src="<?php echo esc_url(wp_get_attachment_image_url(get_post_thumbnail_id(), $settings['image_size'])); ?>" alt="<?php echo esc_html(get_the_title()); ?>"> |
| 644 |
</a> |
| 645 |
</div> |
| 646 |
<?php |
| 647 |
} |
| 648 |
public function print_price_output($output) { |
| 649 |
$tags = [ |
| 650 |
'del' => ['aria-hidden' => []], |
| 651 |
'span' => ['class' => []], |
| 652 |
'bdi' => [], |
| 653 |
'ins' => [], |
| 654 |
]; |
| 655 |
|
| 656 |
if (isset($output)) { |
| 657 |
echo wp_kses($output, $tags); |
| 658 |
} |
| 659 |
} |
| 660 |
public function render_loop_item() { |
| 661 |
$settings = $this->get_settings_for_display(); |
| 662 |
$this->query_product(); |
| 663 |
$wp_query = $this->get_query(); |
| 664 |
if ($wp_query) { |
| 665 |
while ($wp_query->have_posts()) : $wp_query->the_post(); |
| 666 |
global $product; |
| 667 |
$average = $product->get_average_rating(); |
| 668 |
$rating_count = $product->get_rating_count(); |
| 669 |
?> |
| 670 |
<div class="usk-item"> |
| 671 |
<div class="usk-item-box"> |
| 672 |
<?php |
| 673 |
if ($settings['show_image']) : |
| 674 |
$this->render_image(); |
| 675 |
endif; |
| 676 |
?> |
| 677 |
<div class="usk-content"> |
| 678 |
<?php |
| 679 |
if ($settings['show_title']) : |
| 680 |
printf('<a href="%2$s" class="usk-title"><%1$s class="title">%3$s</%1$s></a>', esc_attr($settings['title_tags']), esc_url($product->get_permalink()), esc_html($product->get_title())); |
| 681 |
endif; ?> |
| 682 |
<?php if ($settings['show_rating']) : ?> |
| 683 |
<div class="usk-rating"> |
| 684 |
<?php echo wp_kses_post($this->register_global_template_wc_rating($average, $rating_count)); ?> |
| 685 |
</div> |
| 686 |
<?php endif; ?> |
| 687 |
<?php if ('yes' == $settings['show_price']) : ?> |
| 688 |
<div class="usk-price"> |
| 689 |
<?php $this->print_price_output($product->get_price_html()); ?> |
| 690 |
</div> |
| 691 |
<?php endif; ?> |
| 692 |
</div> |
| 693 |
<div class="usk-badge-label-wrapper"> |
| 694 |
<?php $this->register_global_template_badge_label(); ?> |
| 695 |
</div> |
| 696 |
</div> |
| 697 |
</div> |
| 698 |
<?php endwhile; ?> |
| 699 |
<?php |
| 700 |
wp_reset_postdata(); |
| 701 |
} else { |
| 702 |
echo '<div class="usk-alert-warning" usk-alert>' . esc_html__('Ops! There no product to display.', 'ultimate-store-kit') . '</div>'; |
| 703 |
} |
| 704 |
} |
| 705 |
|
| 706 |
public function render() { |
| 707 |
$this->render_header(); |
| 708 |
$this->render_loop_item(); |
| 709 |
$this->render_footer(); |
| 710 |
} |
| 711 |
public function query_product() { |
| 712 |
$default = $this->getGroupControlQueryArgs(); |
| 713 |
$default['post_type'] = 'product'; |
| 714 |
unset($default['p']); |
| 715 |
$this->_query = new WP_Query($default); |
| 716 |
} |
| 717 |
} |
| 718 |
|