| 1 |
<?php |
| 2 |
|
| 3 |
namespace UltimateStoreKit\Modules\SubCategory\Widgets; |
| 4 |
|
| 5 |
use Elementor\Controls_Manager; |
| 6 |
use Elementor\Group_Control_Background; |
| 7 |
use Elementor\Group_Control_Border; |
| 8 |
use Elementor\Group_Control_Box_Shadow; |
| 9 |
use Elementor\Group_Control_Image_Size; |
| 10 |
use Elementor\Group_Control_Typography; |
| 11 |
// use Elementor\Utils; |
| 12 |
use UltimateStoreKit\Base\Module_Base; |
| 13 |
use UltimateStoreKit\Traits\Global_Terms_Query_Controls; |
| 14 |
use UltimateStoreKit\Classes\Utils; |
| 15 |
|
| 16 |
use WP_Query; |
| 17 |
|
| 18 |
|
| 19 |
if (!defined('ABSPATH')) { |
| 20 |
exit; |
| 21 |
} |
| 22 |
// Exit if accessed directly |
| 23 |
|
| 24 |
class Sub_Category extends Module_Base { |
| 25 |
use Global_Terms_Query_Controls; |
| 26 |
public function get_name() { |
| 27 |
return 'usk-sub-category'; |
| 28 |
} |
| 29 |
|
| 30 |
public function get_title() { |
| 31 |
return BDTUSK . esc_html__('Sub Category', 'ultimate-store-kit'); |
| 32 |
} |
| 33 |
|
| 34 |
public function get_icon() { |
| 35 |
return 'usk-widget-icon usk-icon-sub-category'; |
| 36 |
} |
| 37 |
|
| 38 |
public function get_categories() { |
| 39 |
return ['ultimate-store-kit']; |
| 40 |
} |
| 41 |
|
| 42 |
public function get_keywords() { |
| 43 |
return ['ultimate-store-kit', 'shop', 'store', 'sub', 'heading', 'product']; |
| 44 |
} |
| 45 |
|
| 46 |
public function get_style_depends() { |
| 47 |
if ($this->usk_is_edit_mode()) { |
| 48 |
return ['swiper', 'usk-all-styles']; |
| 49 |
} else { |
| 50 |
return ['swiper', 'usk-sub-category']; |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
public function get_script_depends() { |
| 55 |
if ($this->usk_is_edit_mode()) { |
| 56 |
return ['swiper', 'usk-all-styles']; |
| 57 |
} else { |
| 58 |
return ['swiper', 'usk-sub-category']; |
| 59 |
} |
| 60 |
} |
| 61 |
// public function get_custom_help_url() { |
| 62 |
// return 'https://youtu.be/ksy2uZ5Hg3M'; |
| 63 |
// } |
| 64 |
|
| 65 |
public function has_widget_inner_wrapper(): bool { |
| 66 |
return ! \Elementor\Plugin::$instance->experiments->is_feature_active('e_optimized_markup'); |
| 67 |
} |
| 68 |
protected function register_controls() { |
| 69 |
$this->start_controls_section( |
| 70 |
'section_content_layout', |
| 71 |
[ |
| 72 |
'label' => esc_html__('Layout', 'ultimate-store-kit'), |
| 73 |
] |
| 74 |
); |
| 75 |
$this->add_responsive_control( |
| 76 |
'columns', |
| 77 |
[ |
| 78 |
'label' => __('Columns', 'ultimate-store-kit'), |
| 79 |
'type' => Controls_Manager::SELECT, |
| 80 |
'default' => 3, |
| 81 |
'tablet_default' => 2, |
| 82 |
'mobile_default' => 1, |
| 83 |
'options' => [ |
| 84 |
1 => '1', |
| 85 |
2 => '2', |
| 86 |
3 => '3', |
| 87 |
4 => '4', |
| 88 |
5 => '5', |
| 89 |
6 => '6', |
| 90 |
], |
| 91 |
'selectors' => [ |
| 92 |
'{{WRAPPER}} .usk-sub-category' => 'grid-template-columns:repeat({{VALUE}}, 1fr)' |
| 93 |
] |
| 94 |
] |
| 95 |
); |
| 96 |
|
| 97 |
$this->add_responsive_control( |
| 98 |
'item_gap', |
| 99 |
[ |
| 100 |
'label' => __('Item Gap', 'ultimate-store-kit'), |
| 101 |
'type' => Controls_Manager::SLIDER, |
| 102 |
'default' => [ |
| 103 |
'size' => 20, |
| 104 |
], |
| 105 |
'selectors' => [ |
| 106 |
'{{WRAPPER}} .usk-sub-category' => 'grid-gap: {{SIZE}}{{UNIT}};', |
| 107 |
], |
| 108 |
] |
| 109 |
); |
| 110 |
|
| 111 |
$this->add_control( |
| 112 |
'title_tags', |
| 113 |
[ |
| 114 |
'label' => esc_html__('Title HTML Tag', 'ultimate-store-kit'), |
| 115 |
'type' => Controls_Manager::SELECT, |
| 116 |
'default' => 'h3', |
| 117 |
'options' => ultimate_store_kit_title_tags(), |
| 118 |
] |
| 119 |
); |
| 120 |
|
| 121 |
$this->add_group_control( |
| 122 |
Group_Control_Image_Size::get_type(), |
| 123 |
[ |
| 124 |
'name' => 'category_thumbnail', |
| 125 |
'exclude' => ['custom'], |
| 126 |
'default' => 'medium', |
| 127 |
] |
| 128 |
); |
| 129 |
|
| 130 |
$this->add_responsive_control( |
| 131 |
'item_flex_direction', |
| 132 |
[ |
| 133 |
'label' => esc_html__('Direction', 'ultimate-store-kit'), |
| 134 |
'type' => Controls_Manager::CHOOSE, |
| 135 |
'options' => [ |
| 136 |
'row' => [ |
| 137 |
'title' => esc_html__('Row - horizontal', 'ultimate-store-kit'), |
| 138 |
'icon' => 'eicon-arrow-right', |
| 139 |
], |
| 140 |
'column' => [ |
| 141 |
'title' => esc_html__('Column - vertical', 'ultimate-store-kit'), |
| 142 |
'icon' => 'eicon-arrow-down', |
| 143 |
], |
| 144 |
'row-reverse' => [ |
| 145 |
'title' => esc_html__('Row - reversed', 'ultimate-store-kit'), |
| 146 |
'icon' => 'eicon-arrow-left', |
| 147 |
], |
| 148 |
'column-reverse' => [ |
| 149 |
'title' => esc_html__('Column - reversed', 'ultimate-store-kit'), |
| 150 |
'icon' => 'eicon-arrow-up', |
| 151 |
], |
| 152 |
], |
| 153 |
'selectors' => [ |
| 154 |
'{{WRAPPER}} .usk-sub-category .usk-item' => 'flex-direction: {{VALUE}};', |
| 155 |
], |
| 156 |
] |
| 157 |
); |
| 158 |
|
| 159 |
$this->add_responsive_control( |
| 160 |
'text_align', |
| 161 |
[ |
| 162 |
'label' => esc_html__('Text Align', 'ultimate-store-kit'), |
| 163 |
'type' => Controls_Manager::CHOOSE, |
| 164 |
'options' => [ |
| 165 |
'left' => [ |
| 166 |
'title' => esc_html__('Left', 'ultimate-store-kit'), |
| 167 |
'icon' => 'eicon-text-align-left', |
| 168 |
], |
| 169 |
'center' => [ |
| 170 |
'title' => esc_html__('Center', 'ultimate-store-kit'), |
| 171 |
'icon' => 'eicon-text-align-center', |
| 172 |
], |
| 173 |
'right' => [ |
| 174 |
'title' => esc_html__('Right', 'ultimate-store-kit'), |
| 175 |
'icon' => 'eicon-text-align-right', |
| 176 |
], |
| 177 |
'justify' => [ |
| 178 |
'title' => esc_html__('Justify', 'ultimate-store-kit'), |
| 179 |
'icon' => 'eicon-text-align-justify', |
| 180 |
], |
| 181 |
], |
| 182 |
'selectors' => [ |
| 183 |
'{{WRAPPER}} .usk-sub-category .usk-content' => 'text-align: {{VALUE}};', |
| 184 |
], |
| 185 |
] |
| 186 |
); |
| 187 |
|
| 188 |
$this->end_controls_section(); |
| 189 |
$this->start_controls_section( |
| 190 |
'section_term_query', |
| 191 |
[ |
| 192 |
'label' => __('Query', 'ultimate-store-kit'), |
| 193 |
'tab' => Controls_Manager::TAB_CONTENT, |
| 194 |
] |
| 195 |
); |
| 196 |
|
| 197 |
$this->start_controls_tabs( |
| 198 |
'tabs_terms_include_exclude', |
| 199 |
[] |
| 200 |
); |
| 201 |
$this->start_controls_tab( |
| 202 |
'tab_term_include', |
| 203 |
[ |
| 204 |
'label' => __('Include', 'ultimate-store-kit'), |
| 205 |
] |
| 206 |
); |
| 207 |
|
| 208 |
$this->add_control( |
| 209 |
'cats_include_by_id', |
| 210 |
[ |
| 211 |
'label' => __('Categories', 'ultimate-store-kit'), |
| 212 |
'type' => Controls_Manager::SELECT2, |
| 213 |
'multiple' => true, |
| 214 |
'label_block' => true, |
| 215 |
'options' => ultimate_store_kit_get_only_parent_cats('product_cat'), |
| 216 |
] |
| 217 |
); |
| 218 |
|
| 219 |
$this->end_controls_tab(); |
| 220 |
|
| 221 |
$this->start_controls_tab( |
| 222 |
'tab_term_exclude', |
| 223 |
[ |
| 224 |
'label' => __('Exclude', 'ultimate-store-kit'), |
| 225 |
] |
| 226 |
); |
| 227 |
|
| 228 |
$this->add_control( |
| 229 |
'cats_exclude_by_id', |
| 230 |
[ |
| 231 |
'label' => __('Categories', 'ultimate-store-kit'), |
| 232 |
'type' => Controls_Manager::SELECT2, |
| 233 |
'multiple' => true, |
| 234 |
'label_block' => true, |
| 235 |
'options' => ultimate_store_kit_get_only_parent_cats('product_cat'), |
| 236 |
] |
| 237 |
); |
| 238 |
|
| 239 |
$this->end_controls_tab(); |
| 240 |
$this->end_controls_tabs(); |
| 241 |
$this->add_control( |
| 242 |
'orderby', |
| 243 |
[ |
| 244 |
'label' => __('Order By', 'ultimate-store-kit'), |
| 245 |
'type' => Controls_Manager::SELECT, |
| 246 |
'default' => 'name', |
| 247 |
'options' => [ |
| 248 |
'name' => esc_html__('Name', 'ultimate-store-kit'), |
| 249 |
'count' => esc_html__('Count', 'ultimate-store-kit'), |
| 250 |
'slug' => esc_html__('Slug', 'ultimate-store-kit'), |
| 251 |
], |
| 252 |
] |
| 253 |
); |
| 254 |
|
| 255 |
$this->add_control( |
| 256 |
'order', |
| 257 |
[ |
| 258 |
'label' => __('Order', 'ultimate-store-kit'), |
| 259 |
'type' => Controls_Manager::SELECT, |
| 260 |
'default' => 'desc', |
| 261 |
'options' => [ |
| 262 |
'desc' => __('DESC', 'ultimate-store-kit'), |
| 263 |
'asc' => __('ASC', 'ultimate-store-kit'), |
| 264 |
], |
| 265 |
] |
| 266 |
); |
| 267 |
$this->add_control( |
| 268 |
'hide_empty', |
| 269 |
[ |
| 270 |
'label' => __('Hide Empty', 'ultimate-store-kit'), |
| 271 |
'type' => Controls_Manager::SWITCHER, |
| 272 |
'default' => 'yes', |
| 273 |
] |
| 274 |
); |
| 275 |
|
| 276 |
$this->end_controls_section(); |
| 277 |
|
| 278 |
/** |
| 279 |
* Style Tab |
| 280 |
*/ |
| 281 |
$this->start_controls_section( |
| 282 |
'section_style_item', |
| 283 |
[ |
| 284 |
'label' => esc_html__('Item', 'ultimate-store-kit'), |
| 285 |
'tab' => Controls_Manager::TAB_STYLE, |
| 286 |
] |
| 287 |
); |
| 288 |
$this->start_controls_tabs( |
| 289 |
'item_tabs' |
| 290 |
); |
| 291 |
$this->start_controls_tab( |
| 292 |
'item_tab_normal', |
| 293 |
[ |
| 294 |
'label' => esc_html__('Normal', 'ultimate-store-kit'), |
| 295 |
] |
| 296 |
); |
| 297 |
$this->add_group_control( |
| 298 |
Group_Control_Background::get_type(), |
| 299 |
[ |
| 300 |
'name' => 'item_background', |
| 301 |
'selector' => '{{WRAPPER}} .usk-sub-category .usk-item', |
| 302 |
] |
| 303 |
); |
| 304 |
|
| 305 |
$this->add_group_control( |
| 306 |
Group_Control_Border::get_type(), |
| 307 |
[ |
| 308 |
'name' => 'item_border', |
| 309 |
'label' => esc_html__('Border', 'ultimate-store-kit'), |
| 310 |
'selector' => '{{WRAPPER}} .usk-sub-category .usk-item', |
| 311 |
'separator' => 'before', |
| 312 |
] |
| 313 |
); |
| 314 |
$this->add_responsive_control( |
| 315 |
'item_radius', |
| 316 |
[ |
| 317 |
'label' => esc_html__('Border Radius', 'ultimate-store-kit'), |
| 318 |
'type' => Controls_Manager::DIMENSIONS, |
| 319 |
'size_units' => ['px', '%', 'em'], |
| 320 |
'selectors' => [ |
| 321 |
'{{WRAPPER}} .usk-sub-category .usk-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 322 |
], |
| 323 |
] |
| 324 |
); |
| 325 |
$this->add_responsive_control( |
| 326 |
'item_padding', |
| 327 |
[ |
| 328 |
'label' => esc_html__('Padding', 'ultimate-store-kit'), |
| 329 |
'type' => Controls_Manager::DIMENSIONS, |
| 330 |
'size_units' => ['px', '%', 'em'], |
| 331 |
'selectors' => [ |
| 332 |
'{{WRAPPER}} .usk-sub-category .usk-item' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 333 |
], |
| 334 |
] |
| 335 |
); |
| 336 |
$this->add_responsive_control( |
| 337 |
'item_margin', |
| 338 |
[ |
| 339 |
'label' => esc_html__('Margin', 'ultimate-store-kit'), |
| 340 |
'type' => Controls_Manager::DIMENSIONS, |
| 341 |
'size_units' => ['px', '%', 'em'], |
| 342 |
'selectors' => [ |
| 343 |
'{{WRAPPER}} .usk-sub-category .usk-item' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 344 |
], |
| 345 |
] |
| 346 |
); |
| 347 |
$this->add_responsive_control( |
| 348 |
'space_between', |
| 349 |
[ |
| 350 |
'label' => esc_html__('Space Between', 'ultimate-store-kit'), |
| 351 |
'type' => Controls_Manager::SLIDER, |
| 352 |
'size_units' => ['px', 'em', '%'], |
| 353 |
'selectors' => [ |
| 354 |
'{{WRAPPER}} .usk-sub-category .usk-item' => 'gap: {{SIZE}}{{UNIT}};', |
| 355 |
], |
| 356 |
] |
| 357 |
); |
| 358 |
|
| 359 |
$this->add_group_control( |
| 360 |
Group_Control_Box_Shadow::get_type(), |
| 361 |
[ |
| 362 |
'name' => 'item_shadow', |
| 363 |
'selector' => '{{WRAPPER}} .usk-sub-category .usk-item', |
| 364 |
] |
| 365 |
); |
| 366 |
|
| 367 |
$this->end_controls_tab(); |
| 368 |
$this->start_controls_tab( |
| 369 |
'item_tab_hover', |
| 370 |
[ |
| 371 |
'label' => esc_html__('Hover', 'ultimate-store-kit'), |
| 372 |
] |
| 373 |
); |
| 374 |
$this->add_control( |
| 375 |
'item_hover_border_color', |
| 376 |
[ |
| 377 |
'label' => esc_html__('Border Color', 'ultimate-store-kit'), |
| 378 |
'type' => Controls_Manager::COLOR, |
| 379 |
'selectors' => [ |
| 380 |
'{{WRAPPER}} .usk-sub-category .usk-item:hover' => 'border-color: {{VALUE}}', |
| 381 |
], |
| 382 |
] |
| 383 |
); |
| 384 |
$this->add_group_control( |
| 385 |
Group_Control_Box_Shadow::get_type(), |
| 386 |
[ |
| 387 |
'name' => 'item_hover_shadow', |
| 388 |
'selector' => '{{WRAPPER}} .usk-sub-category .usk-item:hover', |
| 389 |
] |
| 390 |
); |
| 391 |
$this->end_controls_tab(); |
| 392 |
$this->end_controls_tabs(); |
| 393 |
$this->end_controls_section(); |
| 394 |
$this->start_controls_section( |
| 395 |
'section_style_image', |
| 396 |
[ |
| 397 |
'label' => esc_html__('Image', 'ultimate-store-kit'), |
| 398 |
'tab' => Controls_Manager::TAB_STYLE, |
| 399 |
] |
| 400 |
); |
| 401 |
$this->add_responsive_control( |
| 402 |
'image_height', |
| 403 |
[ |
| 404 |
'label' => esc_html__('Height', 'ultimate-store-kit'), |
| 405 |
'type' => Controls_Manager::SLIDER, |
| 406 |
'size_units' => ['px', '%'], |
| 407 |
'range' => [ |
| 408 |
'px' => [ |
| 409 |
'min' => 50, |
| 410 |
'max' => 500, |
| 411 |
'step' => 1, |
| 412 |
], |
| 413 |
'%' => [ |
| 414 |
'min' => 10, |
| 415 |
'max' => 100, |
| 416 |
'step' => 1, |
| 417 |
], |
| 418 |
], |
| 419 |
'selectors' => [ |
| 420 |
'{{WRAPPER}} .usk-sub-category .usk-image-slider .swiper-slide' => 'height: {{SIZE}}{{UNIT}};', |
| 421 |
], |
| 422 |
] |
| 423 |
); |
| 424 |
$this->add_responsive_control( |
| 425 |
'image_width', |
| 426 |
[ |
| 427 |
'label' => esc_html__('Width', 'ultimate-store-kit'), |
| 428 |
'type' => Controls_Manager::SLIDER, |
| 429 |
'size_units' => ['px', '%'], |
| 430 |
'range' => [ |
| 431 |
'px' => [ |
| 432 |
'min' => 50, |
| 433 |
'max' => 500, |
| 434 |
'step' => 1, |
| 435 |
], |
| 436 |
'%' => [ |
| 437 |
'min' => 10, |
| 438 |
'max' => 100, |
| 439 |
'step' => 1, |
| 440 |
], |
| 441 |
], |
| 442 |
'selectors' => [ |
| 443 |
'{{WRAPPER}} .usk-sub-category .usk-image-slider' => 'width: {{SIZE}}{{UNIT}};', |
| 444 |
], |
| 445 |
] |
| 446 |
); |
| 447 |
$this->add_responsive_control( |
| 448 |
'image_alignment', |
| 449 |
[ |
| 450 |
'label' => esc_html__('Alignment', 'ultimate-store-kit'), |
| 451 |
'type' => Controls_Manager::CHOOSE, |
| 452 |
'options' => [ |
| 453 |
'left' => [ |
| 454 |
'title' => esc_html__('Left', 'ultimate-store-kit'), |
| 455 |
'icon' => 'eicon-h-align-left', |
| 456 |
], |
| 457 |
'center' => [ |
| 458 |
'title' => esc_html__('Center', 'ultimate-store-kit'), |
| 459 |
'icon' => 'eicon-h-align-center', |
| 460 |
], |
| 461 |
'right' => [ |
| 462 |
'title' => esc_html__('Right', 'ultimate-store-kit'), |
| 463 |
'icon' => 'eicon-h-align-right', |
| 464 |
], |
| 465 |
], |
| 466 |
'selectors_dictionary' => [ |
| 467 |
'left' => 'margin-left: inherit;', |
| 468 |
'center' => 'margin-left: auto; margin-right: auto;', |
| 469 |
'right' => 'margin-right: inherit;', |
| 470 |
], |
| 471 |
'selectors' => [ |
| 472 |
'{{WRAPPER}} .usk-sub-category .usk-image-slider' => '{{VALUE}}', |
| 473 |
], |
| 474 |
'conditions' => [ |
| 475 |
'relation' => 'and', |
| 476 |
'terms' => [ |
| 477 |
[ |
| 478 |
'name' => 'image_width[size]', |
| 479 |
'operator' => '>', |
| 480 |
'value' => 0, |
| 481 |
], |
| 482 |
[ |
| 483 |
'relation' => 'or', |
| 484 |
'terms' => [ |
| 485 |
[ |
| 486 |
'name' => 'item_flex_direction', |
| 487 |
'operator' => '==', |
| 488 |
'value' => 'column', |
| 489 |
], |
| 490 |
[ |
| 491 |
'name' => 'item_flex_direction', |
| 492 |
'operator' => '==', |
| 493 |
'value' => 'column-reverse', |
| 494 |
], |
| 495 |
], |
| 496 |
], |
| 497 |
], |
| 498 |
], |
| 499 |
] |
| 500 |
); |
| 501 |
|
| 502 |
$this->add_group_control( |
| 503 |
Group_Control_Border::get_type(), |
| 504 |
[ |
| 505 |
'name' => 'image_border', |
| 506 |
'label' => esc_html__('Image Border', 'ultimate-store-kit'), |
| 507 |
'selector' => '{{WRAPPER}} .usk-sub-category .usk-image-slider .swiper-slide', |
| 508 |
'separator' => 'before', |
| 509 |
] |
| 510 |
); |
| 511 |
|
| 512 |
$this->add_responsive_control( |
| 513 |
'image_border_radius', |
| 514 |
[ |
| 515 |
'label' => esc_html__('Border Radius', 'ultimate-store-kit'), |
| 516 |
'type' => Controls_Manager::DIMENSIONS, |
| 517 |
'size_units' => ['px', '%'], |
| 518 |
'selectors' => [ |
| 519 |
'{{WRAPPER}} .usk-sub-category .usk-image-slider .swiper-slide' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 520 |
], |
| 521 |
] |
| 522 |
); |
| 523 |
|
| 524 |
$this->end_controls_section(); |
| 525 |
$this->start_controls_section( |
| 526 |
'section_style_title', |
| 527 |
[ |
| 528 |
'label' => esc_html__('Title', 'ultimate-store-kit'), |
| 529 |
'tab' => Controls_Manager::TAB_STYLE, |
| 530 |
] |
| 531 |
); |
| 532 |
$this->add_control( |
| 533 |
'title_color', |
| 534 |
[ |
| 535 |
'label' => esc_html__('Color', 'ultimate-store-kit'), |
| 536 |
'type' => Controls_Manager::COLOR, |
| 537 |
'selectors' => [ |
| 538 |
'{{WRAPPER}} .usk-sub-category .usk-name' => 'color: {{VALUE}}', |
| 539 |
], |
| 540 |
] |
| 541 |
); |
| 542 |
$this->add_responsive_control( |
| 543 |
'title_margin', |
| 544 |
[ |
| 545 |
'label' => esc_html__('Margin', 'ultimate-store-kit'), |
| 546 |
'type' => Controls_Manager::DIMENSIONS, |
| 547 |
'size_units' => ['px', '%'], |
| 548 |
'selectors' => [ |
| 549 |
'{{WRAPPER}} .usk-sub-category .usk-name' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 550 |
], |
| 551 |
] |
| 552 |
); |
| 553 |
$this->add_group_control( |
| 554 |
Group_Control_Typography::get_type(), |
| 555 |
[ |
| 556 |
'name' => 'title_typography', |
| 557 |
'label' => esc_html__('Typography', 'ultimate-store-kit'), |
| 558 |
'selector' => '{{WRAPPER}} .usk-sub-category .usk-name', |
| 559 |
] |
| 560 |
); |
| 561 |
$this->end_controls_section(); |
| 562 |
$this->start_controls_section( |
| 563 |
'section_style_sub_category', |
| 564 |
[ |
| 565 |
'label' => esc_html__('Sub Category', 'ultimate-store-kit'), |
| 566 |
'tab' => Controls_Manager::TAB_STYLE, |
| 567 |
] |
| 568 |
); |
| 569 |
|
| 570 |
$this->add_control( |
| 571 |
'sub_category_color', |
| 572 |
[ |
| 573 |
'label' => esc_html__('Color', 'ultimate-store-kit'), |
| 574 |
'type' => Controls_Manager::COLOR, |
| 575 |
'selectors' => [ |
| 576 |
'{{WRAPPER}} .usk-sub-category .usk-list a' => 'color: {{VALUE}}', |
| 577 |
], |
| 578 |
] |
| 579 |
); |
| 580 |
|
| 581 |
$this->add_control( |
| 582 |
'hover_sub_category_color', |
| 583 |
[ |
| 584 |
'label' => esc_html__('Hover Color', 'ultimate-store-kit'), |
| 585 |
'type' => Controls_Manager::COLOR, |
| 586 |
'selectors' => [ |
| 587 |
'{{WRAPPER}} .usk-sub-category .usk-list a:hover' => 'color: {{VALUE}};', |
| 588 |
], |
| 589 |
] |
| 590 |
); |
| 591 |
|
| 592 |
$this->add_responsive_control( |
| 593 |
'sub_category_margin', |
| 594 |
[ |
| 595 |
'label' => esc_html__('Margin', 'ultimate-store-kit'), |
| 596 |
'type' => Controls_Manager::DIMENSIONS, |
| 597 |
'size_units' => ['px', '%'], |
| 598 |
'selectors' => [ |
| 599 |
'{{WRAPPER}} .usk-sub-category .usk-list' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 600 |
], |
| 601 |
] |
| 602 |
); |
| 603 |
$this->add_group_control( |
| 604 |
Group_Control_Typography::get_type(), |
| 605 |
[ |
| 606 |
'name' => 'sub_category_typography', |
| 607 |
'label' => esc_html__('Typography', 'ultimate-store-kit'), |
| 608 |
'selector' => '{{WRAPPER}} .usk-sub-category .usk-list a', |
| 609 |
] |
| 610 |
); |
| 611 |
$this->end_controls_section(); |
| 612 |
$this->start_controls_section( |
| 613 |
'section_style_all_category', |
| 614 |
[ |
| 615 |
'label' => esc_html__('Read More', 'ultimate-store-kit'), |
| 616 |
'tab' => Controls_Manager::TAB_STYLE, |
| 617 |
] |
| 618 |
); |
| 619 |
|
| 620 |
$this->add_control( |
| 621 |
'all_category_color', |
| 622 |
[ |
| 623 |
'label' => esc_html__('Color', 'ultimate-store-kit'), |
| 624 |
'type' => Controls_Manager::COLOR, |
| 625 |
'selectors' => [ |
| 626 |
'{{WRAPPER}} .usk-sub-category .usk-link-btn a' => 'color: {{VALUE}}', |
| 627 |
], |
| 628 |
] |
| 629 |
); |
| 630 |
|
| 631 |
$this->add_control( |
| 632 |
'hover_all_category_color', |
| 633 |
[ |
| 634 |
'label' => esc_html__('Hover Color', 'ultimate-store-kit'), |
| 635 |
'type' => Controls_Manager::COLOR, |
| 636 |
'selectors' => [ |
| 637 |
'{{WRAPPER}} .usk-sub-category .usk-link-btn a:hover' => 'color: {{VALUE}};', |
| 638 |
], |
| 639 |
] |
| 640 |
); |
| 641 |
|
| 642 |
$this->add_responsive_control( |
| 643 |
'all_category_margin', |
| 644 |
[ |
| 645 |
'label' => esc_html__('Margin', 'ultimate-store-kit'), |
| 646 |
'type' => Controls_Manager::DIMENSIONS, |
| 647 |
'size_units' => ['px', '%'], |
| 648 |
'selectors' => [ |
| 649 |
'{{WRAPPER}} .usk-sub-category .usk-link-btn a' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 650 |
], |
| 651 |
] |
| 652 |
); |
| 653 |
$this->add_group_control( |
| 654 |
Group_Control_Typography::get_type(), |
| 655 |
[ |
| 656 |
'name' => 'all_category_typography', |
| 657 |
'label' => esc_html__('Typography', 'ultimate-store-kit'), |
| 658 |
'selector' => '{{WRAPPER}} .usk-sub-category .usk-link-btn a', |
| 659 |
] |
| 660 |
); |
| 661 |
$this->end_controls_section(); |
| 662 |
$this->render_thumbs_settings(); |
| 663 |
} |
| 664 |
|
| 665 |
public function render_thumbs_settings() { |
| 666 |
$this->start_controls_section( |
| 667 |
'section_content_thumbs_settings', |
| 668 |
[ |
| 669 |
'label' => __('Settings', 'ultimate-store-kit'), |
| 670 |
'tab' => Controls_Manager::TAB_CONTENT, |
| 671 |
] |
| 672 |
); |
| 673 |
|
| 674 |
$this->add_control( |
| 675 |
'thumbs_autoplay', |
| 676 |
[ |
| 677 |
'label' => __('Auto Play', 'ultimate-store-kit'), |
| 678 |
'type' => Controls_Manager::SWITCHER, |
| 679 |
'label_on' => __('Yes', 'ultimate-store-kit'), |
| 680 |
'label_off' => __('No', 'ultimate-store-kit'), |
| 681 |
'return_value' => 'yes', |
| 682 |
'default' => 'yes', |
| 683 |
] |
| 684 |
); |
| 685 |
|
| 686 |
$this->add_control( |
| 687 |
'thumbs_loop', |
| 688 |
[ |
| 689 |
'label' => __('Loop', 'ultimate-store-kit'), |
| 690 |
'type' => Controls_Manager::SWITCHER, |
| 691 |
'label_on' => __('Yes', 'ultimate-store-kit'), |
| 692 |
'label_off' => __('No', 'ultimate-store-kit'), |
| 693 |
'return_value' => 'yes', |
| 694 |
'default' => 'yes', |
| 695 |
] |
| 696 |
); |
| 697 |
|
| 698 |
$this->add_control( |
| 699 |
'thumbs_autoplay_speed', |
| 700 |
[ |
| 701 |
'label' => __('Delay', 'ultimate-store-kit'), |
| 702 |
'type' => Controls_Manager::NUMBER, |
| 703 |
'min' => 0, |
| 704 |
'max' => 10000, |
| 705 |
'step' => 5, |
| 706 |
'default' => 1500, |
| 707 |
'dynamic' => ['active' => true], |
| 708 |
'condition' => [ |
| 709 |
'thumbs_autoplay' => 'yes' |
| 710 |
] |
| 711 |
] |
| 712 |
); |
| 713 |
|
| 714 |
$this->add_responsive_control( |
| 715 |
'thumbs_slide_speed', |
| 716 |
[ |
| 717 |
'label' => __('Speed', 'ultimate-store-kit'), |
| 718 |
'type' => Controls_Manager::SLIDER, |
| 719 |
'size_units' => ['px'], |
| 720 |
'range' => [ |
| 721 |
'px' => [ |
| 722 |
'min' => 0, |
| 723 |
'max' => 5000, |
| 724 |
'step' => 1, |
| 725 |
] |
| 726 |
], |
| 727 |
'default' => [ |
| 728 |
'unit' => 'px', |
| 729 |
'size' => 1500, |
| 730 |
] |
| 731 |
] |
| 732 |
); |
| 733 |
|
| 734 |
$this->add_control( |
| 735 |
'thumbs_effect', |
| 736 |
[ |
| 737 |
'label' => __('Effect', 'ultimate-store-kit'), |
| 738 |
'type' => Controls_Manager::SELECT, |
| 739 |
'options' => [ |
| 740 |
'fade' => __('Fade', 'ultimate-store-kit'), |
| 741 |
'slide' => __('Slide', 'ultimate-store-kit'), |
| 742 |
'creative' => __('Creative', 'ultimate-store-kit'), |
| 743 |
], |
| 744 |
'default' => 'fade', |
| 745 |
'dynamic' => ['active' => true], |
| 746 |
] |
| 747 |
); |
| 748 |
//creative effect control |
| 749 |
$this->add_control( |
| 750 |
'creative_effect', |
| 751 |
[ |
| 752 |
'label' => esc_html__('Creative Effect', 'ultimate-store-kit'), |
| 753 |
'type' => Controls_Manager::SELECT, |
| 754 |
'default' => 'creative-1', |
| 755 |
'options' => [ |
| 756 |
'creative-1' => esc_html__('Creative 1', 'ultimate-store-kit'), |
| 757 |
'creative-2' => esc_html__('Creative 2', 'ultimate-store-kit'), |
| 758 |
'creative-3' => esc_html__('Creative 3', 'ultimate-store-kit'), |
| 759 |
'creative-4' => esc_html__('Creative 4', 'ultimate-store-kit'), |
| 760 |
'creative-5' => esc_html__('Creative 5', 'ultimate-store-kit'), |
| 761 |
], |
| 762 |
'condition' => [ |
| 763 |
'thumbs_effect' => 'creative', |
| 764 |
], |
| 765 |
] |
| 766 |
); |
| 767 |
|
| 768 |
$this->end_controls_section(); |
| 769 |
} |
| 770 |
|
| 771 |
public function render_items() { |
| 772 |
$settings = $this->get_settings_for_display(); |
| 773 |
$args = [ |
| 774 |
'taxonomy' => 'product_cat', |
| 775 |
'orderby' => isset($settings['orderby']) ? $settings['orderby'] : 'name', |
| 776 |
'order' => isset($settings['order']) ? $settings['order'] : 'ASC', |
| 777 |
'hide_empty' => isset($settings['hide_empty']) && ($settings['hide_empty'] == 'yes') ? 1 : 0, |
| 778 |
]; |
| 779 |
if (isset($settings['cats_include_by_id']) && !empty($settings['cats_include_by_id'])) { |
| 780 |
$args['include'] = $settings['cats_include_by_id']; |
| 781 |
} |
| 782 |
if (isset($settings['cats_exclude_by_id']) && !empty($settings['cats_exclude_by_id'])) { |
| 783 |
$args['exclude'] = $settings['cats_exclude_by_id']; |
| 784 |
} |
| 785 |
// print_r($args); |
| 786 |
$taxonomies = get_terms($args); |
| 787 |
if (!(empty($taxonomies))) : |
| 788 |
$index = 50; |
| 789 |
foreach ($taxonomies as $category) : |
| 790 |
if ($category->parent == 0 && get_term_children($category->term_id, 'product_cat')) : |
| 791 |
$this->add_render_attribute('sub-category-item', [ |
| 792 |
'class' => [ |
| 793 |
'usk-item' |
| 794 |
], |
| 795 |
'data-settings' => [ |
| 796 |
wp_json_encode(array_filter([ |
| 797 |
"autoplay" => ("yes" == $settings["thumbs_autoplay"]) ? ["delay" => $settings["thumbs_autoplay_speed"] + $index += rand(500, 1500)] : false, |
| 798 |
"loop" => ($settings["thumbs_loop"] == "yes") ? true : false, |
| 799 |
"speed" => $settings["thumbs_slide_speed"]["size"], |
| 800 |
"fadeEffect" => ['crossFade' => true], |
| 801 |
"effect" => $settings["thumbs_effect"], |
| 802 |
"creativeEffect" => isset($settings["creative_effect"]) ? $settings["creative_effect"] : false, |
| 803 |
])) |
| 804 |
] |
| 805 |
], null, true); |
| 806 |
?> |
| 807 |
<div <?php $this->print_render_attribute_string('sub-category-item'); ?>> |
| 808 |
<div class="swiper usk-image-slider"> |
| 809 |
<div class="swiper-wrapper"> |
| 810 |
<?php |
| 811 |
$parentcategory_thumb_id = get_term_meta($category->term_id, 'thumbnail_id', true); |
| 812 |
$images = [$parentcategory_thumb_id]; |
| 813 |
|
| 814 |
// Get subcategories for the specified parent category |
| 815 |
$args = array( |
| 816 |
'taxonomy' => 'product_cat', |
| 817 |
'orderby' => isset($settings['orderby']) ? $settings['orderby'] : 'name', |
| 818 |
'order' => isset($settings['order']) ? $settings['order'] : 'ASC', |
| 819 |
'hide_empty' => isset($settings['hide_empty']) && ($settings['hide_empty'] == 'yes') ? 1 : 0, |
| 820 |
'parent' => $category->term_id, |
| 821 |
); |
| 822 |
|
| 823 |
$subcategories = get_terms($args); |
| 824 |
|
| 825 |
foreach ($subcategories as $subcategory) : |
| 826 |
if ($subcategory->parent == $category->term_id) { |
| 827 |
$subcategory_thumb_id = get_term_meta($subcategory->term_id, 'thumbnail_id', true); |
| 828 |
$images[] = $subcategory_thumb_id; |
| 829 |
} |
| 830 |
endforeach; |
| 831 |
|
| 832 |
foreach ($images as $image_id) : |
| 833 |
$img_url = wp_get_attachment_image_url($image_id, $settings['category_thumbnail_size']); |
| 834 |
if (!(empty($img_url))) : ?> |
| 835 |
<div class="swiper-slide"> |
| 836 |
<div class="usk-image-wrap"> |
| 837 |
<img class="usk-img" src="<?php echo esc_url($img_url); ?>" /> |
| 838 |
</div> |
| 839 |
</div> |
| 840 |
<?php |
| 841 |
endif; |
| 842 |
endforeach; |
| 843 |
?> |
| 844 |
</div> |
| 845 |
</div> |
| 846 |
<div class="usk-content"> |
| 847 |
|
| 848 |
<?php printf( |
| 849 |
'<%1$s class="usk-name">%2$s</%1$s>', |
| 850 |
esc_attr( Utils::get_valid_html_tag($settings['title_tags']) ), |
| 851 |
esc_html($category->name) |
| 852 |
); |
| 853 |
?> |
| 854 |
<div class="usk-list"> |
| 855 |
<?php |
| 856 |
foreach ($subcategories as $key => $subcategory) : |
| 857 |
if ($subcategory->parent == $category->term_id) { |
| 858 |
printf('<a href="%1$s">%2$s</a>', esc_url(get_term_link($subcategory->term_id, 'product_cat')), esc_html($subcategory->name)); |
| 859 |
} |
| 860 |
endforeach; |
| 861 |
?> |
| 862 |
</div> |
| 863 |
|
| 864 |
<div class="usk-link-btn"> |
| 865 |
<?php |
| 866 |
printf( |
| 867 |
'<a href="%2$s"><span>%1$s</span><i class="usk-icon-arrow-right-8"></i></a>', |
| 868 |
/* translators: %s: Category name */ |
| 869 |
sprintf(esc_html__('All %s', 'ultimate-store-kit'), $category->name), |
| 870 |
esc_url(get_term_link($category->term_id, 'product_cat')) |
| 871 |
); |
| 872 |
?> |
| 873 |
</div> |
| 874 |
</div> |
| 875 |
</div> |
| 876 |
<?php |
| 877 |
endif; |
| 878 |
$index++; |
| 879 |
endforeach; |
| 880 |
endif; |
| 881 |
} |
| 882 |
public function render() { |
| 883 |
?> |
| 884 |
<div class="usk-sub-category"> |
| 885 |
<?php $this->render_items(); ?> |
| 886 |
</div> |
| 887 |
<?php |
| 888 |
} |
| 889 |
} |
| 890 |
|