| 1 |
<?php |
| 2 |
|
| 3 |
namespace UltimateStoreKit\Modules\SubCategoryCarousel\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\traits\Global_Widget_Controls; |
| 15 |
use UltimateStoreKit\traits\Global_Widget_Template; |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
if (!defined('ABSPATH')) { |
| 20 |
exit; |
| 21 |
} |
| 22 |
// Exit if accessed directly |
| 23 |
|
| 24 |
class Sub_Category_Carousel extends Module_Base { |
| 25 |
use Global_Widget_Controls; |
| 26 |
use Global_Terms_Query_Controls; |
| 27 |
use Global_Widget_Template; |
| 28 |
public function get_name() { |
| 29 |
return 'usk-sub-category-carousel'; |
| 30 |
} |
| 31 |
|
| 32 |
public function get_title() { |
| 33 |
return BDTUSK . esc_html__('Sub Category Carousel', 'ultimate-store-kit'); |
| 34 |
} |
| 35 |
|
| 36 |
public function get_icon() { |
| 37 |
return 'usk-widget-icon usk-icon-sub-category-carousel'; |
| 38 |
} |
| 39 |
|
| 40 |
public function get_categories() { |
| 41 |
return ['ultimate-store-kit']; |
| 42 |
} |
| 43 |
|
| 44 |
public function get_keywords() { |
| 45 |
return ['ultimate-store-kit', 'shop', 'store', 'sub', 'heading', 'product']; |
| 46 |
} |
| 47 |
|
| 48 |
public function get_style_depends() { |
| 49 |
if ($this->usk_is_edit_mode()) { |
| 50 |
return ['usk-all-styles']; |
| 51 |
} else { |
| 52 |
return ['ultimate-store-kit-font', 'usk-sub-category-carousel']; |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
public function get_script_depends() { |
| 57 |
if ($this->usk_is_edit_mode()) { |
| 58 |
return ['usk-all-styles']; |
| 59 |
} else { |
| 60 |
return ['usk-sub-category-carousel']; |
| 61 |
} |
| 62 |
} |
| 63 |
// public function get_custom_help_url() { |
| 64 |
// return 'https://youtu.be/ksy2uZ5Hg3M'; |
| 65 |
// } |
| 66 |
|
| 67 |
protected function register_controls() { |
| 68 |
$this->start_controls_section( |
| 69 |
'section_content_layout', |
| 70 |
[ |
| 71 |
'label' => esc_html__('Layout', 'ultimate-store-kit'), |
| 72 |
] |
| 73 |
); |
| 74 |
$this->add_responsive_control( |
| 75 |
'columns', |
| 76 |
[ |
| 77 |
'label' => __('Columns', 'ultimate-store-kit'), |
| 78 |
'type' => Controls_Manager::SELECT, |
| 79 |
'default' => 3, |
| 80 |
'tablet_default' => 2, |
| 81 |
'mobile_default' => 1, |
| 82 |
'options' => [ |
| 83 |
1 => '1', |
| 84 |
2 => '2', |
| 85 |
3 => '3', |
| 86 |
4 => '4', |
| 87 |
5 => '5', |
| 88 |
6 => '6', |
| 89 |
], |
| 90 |
] |
| 91 |
); |
| 92 |
$this->add_control( |
| 93 |
'alignment', |
| 94 |
[ |
| 95 |
'label' => __('Title', 'ultimate-store-kit'), |
| 96 |
'type' => Controls_Manager::HIDDEN, |
| 97 |
'default' => 'traditional', |
| 98 |
] |
| 99 |
); |
| 100 |
$this->add_responsive_control( |
| 101 |
'items_gap', |
| 102 |
[ |
| 103 |
'label' => esc_html__('Item Gap', 'ultimate-store-kit'), |
| 104 |
'type' => Controls_Manager::SLIDER, |
| 105 |
'default' => [ |
| 106 |
'size' => 30, |
| 107 |
], |
| 108 |
'range' => [ |
| 109 |
'px' => [ |
| 110 |
'min' => 0, |
| 111 |
'max' => 100, |
| 112 |
], |
| 113 |
], |
| 114 |
'tablet_default' => [ |
| 115 |
'size' => 20, |
| 116 |
], |
| 117 |
'mobile_default' => [ |
| 118 |
'size' => 20, |
| 119 |
], |
| 120 |
] |
| 121 |
); |
| 122 |
$this->add_control( |
| 123 |
'title_tags', |
| 124 |
[ |
| 125 |
'label' => esc_html__('Title HTML Tag', 'ultimate-store-kit'), |
| 126 |
'type' => Controls_Manager::SELECT, |
| 127 |
'default' => 'h3', |
| 128 |
'options' => ultimate_store_kit_title_tags(), |
| 129 |
] |
| 130 |
); |
| 131 |
$this->add_group_control( |
| 132 |
Group_Control_Image_Size::get_type(), |
| 133 |
[ |
| 134 |
'name' => 'category_thumbnail', |
| 135 |
'label' => esc_html__('Image Size', 'ultimate-store-kit'), |
| 136 |
'exclude' => ['custom'], |
| 137 |
'default' => 'medium', |
| 138 |
] |
| 139 |
); |
| 140 |
$this->end_controls_section(); |
| 141 |
$this->start_controls_section( |
| 142 |
'section_term_query', |
| 143 |
[ |
| 144 |
'label' => __('Query', 'ultimate-store-kit'), |
| 145 |
'tab' => Controls_Manager::TAB_CONTENT, |
| 146 |
] |
| 147 |
); |
| 148 |
|
| 149 |
$this->start_controls_tabs( |
| 150 |
'tabs_terms_include_exclude', |
| 151 |
[] |
| 152 |
); |
| 153 |
$this->start_controls_tab( |
| 154 |
'tab_term_include', |
| 155 |
[ |
| 156 |
'label' => __('Include', 'ultimate-store-kit'), |
| 157 |
] |
| 158 |
); |
| 159 |
|
| 160 |
$this->add_control( |
| 161 |
'cats_include_by_id', |
| 162 |
[ |
| 163 |
'label' => __('Categories', 'ultimate-store-kit'), |
| 164 |
'type' => Controls_Manager::SELECT2, |
| 165 |
'multiple' => true, |
| 166 |
'label_block' => true, |
| 167 |
'options' => ultimate_store_kit_get_only_parent_cats('product_cat'), |
| 168 |
] |
| 169 |
); |
| 170 |
|
| 171 |
$this->end_controls_tab(); |
| 172 |
|
| 173 |
$this->start_controls_tab( |
| 174 |
'tab_term_exclude', |
| 175 |
[ |
| 176 |
'label' => __('Exclude', 'ultimate-store-kit'), |
| 177 |
] |
| 178 |
); |
| 179 |
|
| 180 |
$this->add_control( |
| 181 |
'cats_exclude_by_id', |
| 182 |
[ |
| 183 |
'label' => __('Categories', 'ultimate-store-kit'), |
| 184 |
'type' => Controls_Manager::SELECT2, |
| 185 |
'multiple' => true, |
| 186 |
'label_block' => true, |
| 187 |
'options' => ultimate_store_kit_get_only_parent_cats('product_cat'), |
| 188 |
] |
| 189 |
); |
| 190 |
|
| 191 |
$this->end_controls_tab(); |
| 192 |
$this->end_controls_tabs(); |
| 193 |
$this->add_control( |
| 194 |
'orderby', |
| 195 |
[ |
| 196 |
'label' => __('Order By', 'ultimate-store-kit'), |
| 197 |
'type' => Controls_Manager::SELECT, |
| 198 |
'default' => 'name', |
| 199 |
'options' => [ |
| 200 |
'name' => esc_html__('Name', 'ultimate-store-kit'), |
| 201 |
'count' => esc_html__('Count', 'ultimate-store-kit'), |
| 202 |
'slug' => esc_html__('Slug', 'ultimate-store-kit'), |
| 203 |
], |
| 204 |
] |
| 205 |
); |
| 206 |
|
| 207 |
$this->add_control( |
| 208 |
'order', |
| 209 |
[ |
| 210 |
'label' => __('Order', 'ultimate-store-kit'), |
| 211 |
'type' => Controls_Manager::SELECT, |
| 212 |
'default' => 'desc', |
| 213 |
'options' => [ |
| 214 |
'desc' => __('Descending', 'ultimate-store-kit'), |
| 215 |
'asc' => __('Ascending', 'ultimate-store-kit'), |
| 216 |
], |
| 217 |
] |
| 218 |
); |
| 219 |
$this->add_control( |
| 220 |
'hide_empty', |
| 221 |
[ |
| 222 |
'label' => __('Hide Empty', 'ultimate-store-kit'), |
| 223 |
'type' => Controls_Manager::SWITCHER, |
| 224 |
] |
| 225 |
); |
| 226 |
|
| 227 |
$this->end_controls_section(); |
| 228 |
$this->register_global_controls_carousel_navigation(); |
| 229 |
$this->register_global_controls_carousel_settings(); |
| 230 |
|
| 231 |
$this->start_controls_section( |
| 232 |
'section_style_item', |
| 233 |
[ |
| 234 |
'label' => esc_html__('Item', 'ultimate-store-kit'), |
| 235 |
'tab' => Controls_Manager::TAB_STYLE, |
| 236 |
] |
| 237 |
); |
| 238 |
$this->start_controls_tabs( |
| 239 |
'item_tabs' |
| 240 |
); |
| 241 |
$this->start_controls_tab( |
| 242 |
'item_tab_normal', |
| 243 |
[ |
| 244 |
'label' => esc_html__('Normal', 'ultimate-store-kit'), |
| 245 |
] |
| 246 |
); |
| 247 |
$this->add_group_control( |
| 248 |
Group_Control_Background::get_type(), |
| 249 |
[ |
| 250 |
'name' => 'item_background', |
| 251 |
'selector' => '{{WRAPPER}} .usk-sub-category-carousel .usk-sub-category-item', |
| 252 |
] |
| 253 |
); |
| 254 |
$this->add_responsive_control( |
| 255 |
'item_padding', |
| 256 |
[ |
| 257 |
'label' => esc_html__('Padding', 'ultimate-store-kit'), |
| 258 |
'type' => Controls_Manager::DIMENSIONS, |
| 259 |
'size_units' => ['px', '%', 'em'], |
| 260 |
'selectors' => [ |
| 261 |
'{{WRAPPER}} .usk-sub-category-carousel .usk-sub-category-item' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 262 |
], |
| 263 |
] |
| 264 |
); |
| 265 |
$this->add_responsive_control( |
| 266 |
'item_margin', |
| 267 |
[ |
| 268 |
'label' => esc_html__('Margin', 'ultimate-store-kit'), |
| 269 |
'type' => Controls_Manager::DIMENSIONS, |
| 270 |
'size_units' => ['px', '%', 'em'], |
| 271 |
'selectors' => [ |
| 272 |
'{{WRAPPER}} .usk-sub-category-carousel .usk-sub-category-item' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 273 |
], |
| 274 |
] |
| 275 |
); |
| 276 |
$this->add_group_control( |
| 277 |
Group_Control_Border::get_type(), |
| 278 |
[ |
| 279 |
'name' => 'item_border', |
| 280 |
'label' => esc_html__('Border', 'ultimate-store-kit'), |
| 281 |
'selector' => '{{WRAPPER}} .usk-sub-category-carousel .usk-sub-category-item', |
| 282 |
] |
| 283 |
); |
| 284 |
$this->add_responsive_control( |
| 285 |
'item_radius', |
| 286 |
[ |
| 287 |
'label' => esc_html__('Radius', 'ultimate-store-kit'), |
| 288 |
'type' => Controls_Manager::DIMENSIONS, |
| 289 |
'size_units' => ['px', '%', 'em'], |
| 290 |
'selectors' => [ |
| 291 |
'{{WRAPPER}} .usk-sub-category-carousel .usk-sub-category-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 292 |
], |
| 293 |
] |
| 294 |
); |
| 295 |
|
| 296 |
$this->add_group_control( |
| 297 |
Group_Control_Box_Shadow::get_type(), |
| 298 |
[ |
| 299 |
'name' => 'item_shadow', |
| 300 |
'selector' => '{{WRAPPER}} .usk-sub-category-carousel .usk-sub-category-item', |
| 301 |
] |
| 302 |
); |
| 303 |
$this->end_controls_tab(); |
| 304 |
$this->start_controls_tab( |
| 305 |
'item_tab_hover', |
| 306 |
[ |
| 307 |
'label' => esc_html__('Hover', 'ultimate-store-kit'), |
| 308 |
] |
| 309 |
); |
| 310 |
$this->add_control( |
| 311 |
'item_hover_border_color', |
| 312 |
[ |
| 313 |
'label' => esc_html__('Border Color', 'ultimate-store-kit'), |
| 314 |
'type' => Controls_Manager::COLOR, |
| 315 |
'selectors' => [ |
| 316 |
'{{WRAPPER}} .usk-sub-category-carousel .usk-sub-category-item:hover' => 'border-color: {{VALUE}}', |
| 317 |
], |
| 318 |
] |
| 319 |
); |
| 320 |
$this->add_group_control( |
| 321 |
Group_Control_Box_Shadow::get_type(), |
| 322 |
[ |
| 323 |
'name' => 'item_hover_shadow', |
| 324 |
'selector' => '{{WRAPPER}} .usk-sub-category-carousel .usk-sub-category-item:hover', |
| 325 |
] |
| 326 |
); |
| 327 |
$this->end_controls_tab(); |
| 328 |
$this->end_controls_tabs(); |
| 329 |
$this->end_controls_section(); |
| 330 |
$this->start_controls_section( |
| 331 |
'section_style_image', |
| 332 |
[ |
| 333 |
'label' => esc_html__('Image', 'ultimate-store-kit'), |
| 334 |
'tab' => Controls_Manager::TAB_STYLE, |
| 335 |
] |
| 336 |
); |
| 337 |
|
| 338 |
$this->add_group_control( |
| 339 |
Group_Control_Border::get_type(), |
| 340 |
[ |
| 341 |
'name' => 'image_border', |
| 342 |
'label' => esc_html__('Image Border', 'ultimate-store-kit'), |
| 343 |
'selector' => '{{WRAPPER}} .usk-sub-category-carousel .usk-image-slider .usk-image-wrap .usk-img', |
| 344 |
] |
| 345 |
); |
| 346 |
|
| 347 |
$this->add_responsive_control( |
| 348 |
'image_border_radius', |
| 349 |
[ |
| 350 |
'label' => esc_html__('Border Radius', 'ultimate-store-kit'), |
| 351 |
'type' => Controls_Manager::DIMENSIONS, |
| 352 |
'size_units' => ['px', '%'], |
| 353 |
'selectors' => [ |
| 354 |
'{{WRAPPER}} .usk-sub-category-carousel .usk-image-slider .usk-image-wrap .usk-img ' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 355 |
], |
| 356 |
] |
| 357 |
); |
| 358 |
|
| 359 |
// $this->add_group_control( |
| 360 |
// Group_Control_Box_Shadow::get_type(), |
| 361 |
// [ |
| 362 |
// 'name' => 'image_shadow', |
| 363 |
// 'exclude' => [ |
| 364 |
// 'shadow_position', |
| 365 |
// ], |
| 366 |
// 'selector' => '{{WRAPPER}} .usk-sub-category-carousel .usk-image-slider .usk-image-wrap .usk-img', |
| 367 |
// ] |
| 368 |
// ); |
| 369 |
|
| 370 |
$this->end_controls_section(); |
| 371 |
$this->start_controls_section( |
| 372 |
'section_style_title', |
| 373 |
[ |
| 374 |
'label' => esc_html__('Title', 'ultimate-store-kit'), |
| 375 |
'tab' => Controls_Manager::TAB_STYLE, |
| 376 |
] |
| 377 |
); |
| 378 |
|
| 379 |
$this->add_control( |
| 380 |
'title_color', |
| 381 |
[ |
| 382 |
'label' => esc_html__('Color', 'ultimate-store-kit'), |
| 383 |
'type' => Controls_Manager::COLOR, |
| 384 |
'selectors' => [ |
| 385 |
'{{WRAPPER}} .usk-sub-category-carousel .usk-category-name' => 'color: {{VALUE}}', |
| 386 |
], |
| 387 |
] |
| 388 |
); |
| 389 |
|
| 390 |
$this->add_control( |
| 391 |
'hover_title_color', |
| 392 |
[ |
| 393 |
'label' => esc_html__('Hover Color', 'ultimate-store-kit'), |
| 394 |
'type' => Controls_Manager::COLOR, |
| 395 |
'selectors' => [ |
| 396 |
'{{WRAPPER}} .usk-sub-category-carousel .usk-category-name:hover' => 'color: {{VALUE}};', |
| 397 |
], |
| 398 |
] |
| 399 |
); |
| 400 |
|
| 401 |
$this->add_responsive_control( |
| 402 |
'title_margin', |
| 403 |
[ |
| 404 |
'label' => esc_html__('Margin', 'ultimate-store-kit'), |
| 405 |
'type' => Controls_Manager::DIMENSIONS, |
| 406 |
'size_units' => ['px', '%'], |
| 407 |
'selectors' => [ |
| 408 |
'{{WRAPPER}} .usk-sub-category-carousel .usk-category-name' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 409 |
], |
| 410 |
] |
| 411 |
); |
| 412 |
$this->add_group_control( |
| 413 |
Group_Control_Typography::get_type(), |
| 414 |
[ |
| 415 |
'name' => 'title_typography', |
| 416 |
'label' => esc_html__('Typography', 'ultimate-store-kit'), |
| 417 |
'selector' => '{{WRAPPER}} .usk-sub-category-carousel .usk-category-name', |
| 418 |
] |
| 419 |
); |
| 420 |
$this->end_controls_section(); |
| 421 |
$this->start_controls_section( |
| 422 |
'section_style_sub_category', |
| 423 |
[ |
| 424 |
'label' => esc_html__('Sub Category', 'ultimate-store-kit'), |
| 425 |
'tab' => Controls_Manager::TAB_STYLE, |
| 426 |
] |
| 427 |
); |
| 428 |
|
| 429 |
$this->add_control( |
| 430 |
'sub_category_color', |
| 431 |
[ |
| 432 |
'label' => esc_html__('Color', 'ultimate-store-kit'), |
| 433 |
'type' => Controls_Manager::COLOR, |
| 434 |
'selectors' => [ |
| 435 |
'{{WRAPPER}} .usk-sub-category-carousel .usk-category-list li a' => 'color: {{VALUE}}', |
| 436 |
], |
| 437 |
] |
| 438 |
); |
| 439 |
|
| 440 |
$this->add_control( |
| 441 |
'hover_sub_category_color', |
| 442 |
[ |
| 443 |
'label' => esc_html__('Hover Color', 'ultimate-store-kit'), |
| 444 |
'type' => Controls_Manager::COLOR, |
| 445 |
'selectors' => [ |
| 446 |
'{{WRAPPER}} .usk-sub-category-carousel .usk-category-list li a:hover' => 'color: {{VALUE}};', |
| 447 |
], |
| 448 |
] |
| 449 |
); |
| 450 |
|
| 451 |
$this->add_responsive_control( |
| 452 |
'sub_category_margin', |
| 453 |
[ |
| 454 |
'label' => esc_html__('Margin', 'ultimate-store-kit'), |
| 455 |
'type' => Controls_Manager::DIMENSIONS, |
| 456 |
'size_units' => ['px', '%'], |
| 457 |
'selectors' => [ |
| 458 |
'{{WRAPPER}} .usk-sub-category-carousel .usk-category-list li' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 459 |
], |
| 460 |
] |
| 461 |
); |
| 462 |
$this->add_group_control( |
| 463 |
Group_Control_Typography::get_type(), |
| 464 |
[ |
| 465 |
'name' => 'sub_category_typography', |
| 466 |
'label' => esc_html__('Typography', 'ultimate-store-kit'), |
| 467 |
'selector' => '{{WRAPPER}} .usk-sub-category-carousel .usk-category-list li a', |
| 468 |
] |
| 469 |
); |
| 470 |
$this->end_controls_section(); |
| 471 |
$this->start_controls_section( |
| 472 |
'section_style_all_category', |
| 473 |
[ |
| 474 |
'label' => esc_html__('All Category', 'ultimate-store-kit'), |
| 475 |
'tab' => Controls_Manager::TAB_STYLE, |
| 476 |
] |
| 477 |
); |
| 478 |
|
| 479 |
$this->add_control( |
| 480 |
'all_category_color', |
| 481 |
[ |
| 482 |
'label' => esc_html__('Color', 'ultimate-store-kit'), |
| 483 |
'type' => Controls_Manager::COLOR, |
| 484 |
'selectors' => [ |
| 485 |
'{{WRAPPER}} .usk-sub-category-carousel .usk-link-btn a' => 'color: {{VALUE}}', |
| 486 |
], |
| 487 |
] |
| 488 |
); |
| 489 |
|
| 490 |
$this->add_control( |
| 491 |
'hover_all_category_color', |
| 492 |
[ |
| 493 |
'label' => esc_html__('Hover Color', 'ultimate-store-kit'), |
| 494 |
'type' => Controls_Manager::COLOR, |
| 495 |
'selectors' => [ |
| 496 |
'{{WRAPPER}} .usk-sub-category-carousel .usk-link-btn a:hover' => 'color: {{VALUE}};', |
| 497 |
], |
| 498 |
] |
| 499 |
); |
| 500 |
|
| 501 |
$this->add_responsive_control( |
| 502 |
'all_category_margin', |
| 503 |
[ |
| 504 |
'label' => esc_html__('Margin', 'ultimate-store-kit'), |
| 505 |
'type' => Controls_Manager::DIMENSIONS, |
| 506 |
'size_units' => ['px', '%'], |
| 507 |
'selectors' => [ |
| 508 |
'{{WRAPPER}} .usk-sub-category-carousel .usk-link-btn a' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 509 |
], |
| 510 |
] |
| 511 |
); |
| 512 |
$this->add_group_control( |
| 513 |
Group_Control_Typography::get_type(), |
| 514 |
[ |
| 515 |
'name' => 'all_category_typography', |
| 516 |
'label' => esc_html__('Typography', 'ultimate-store-kit'), |
| 517 |
'selector' => '{{WRAPPER}} .usk-sub-category-carousel .usk-link-btn a', |
| 518 |
] |
| 519 |
); |
| 520 |
$this->end_controls_section(); |
| 521 |
|
| 522 |
$this->register_global_controls_navigation_style(); |
| 523 |
} |
| 524 |
|
| 525 |
public function render_items() { |
| 526 |
$settings = $this->get_settings_for_display(); |
| 527 |
$args = [ |
| 528 |
'taxonomy' => 'product_cat', |
| 529 |
'orderby' => isset($settings['orderby']) ? $settings['orderby'] : 'name', |
| 530 |
'order' => isset($settings['order']) ? $settings['order'] : 'ASC', |
| 531 |
'hide_empty' => isset($settings['hide_empty']) && ($settings['hide_empty'] == 'yes') ? 0 : 1, |
| 532 |
]; |
| 533 |
if (isset($settings['cats_include_by_id']) && !empty($settings['cats_include_by_id'])) { |
| 534 |
$args['include'] = $settings['cats_include_by_id']; |
| 535 |
} |
| 536 |
if (isset($settings['cats_exclude_by_id']) && !empty($settings['cats_exclude_by_id'])) { |
| 537 |
$args['exclude'] = $settings['cats_exclude_by_id']; |
| 538 |
} |
| 539 |
// print_r($args); |
| 540 |
$taxonomies = get_terms($args); |
| 541 |
if (!(empty($taxonomies))) : |
| 542 |
foreach ($taxonomies as $category) : |
| 543 |
if ($category->parent == 0 && get_term_children($category->term_id, 'product_cat')) : |
| 544 |
$this->add_render_attribute('sub-category-item', [ |
| 545 |
'class' => [ |
| 546 |
'usk-sub-category-item swiper-slide' |
| 547 |
], |
| 548 |
// 'data-settings' => [ |
| 549 |
// wp_json_encode(array_filter([ |
| 550 |
// "autoplay" => ("yes" == $settings["thumbs_autoplay"]) ? ["delay" => $settings["thumbs_autoplay_speed"]] : false, |
| 551 |
// "loop" => ($settings["thumbs_loop"] == "yes") ? true : false, |
| 552 |
// "speed" => $settings["thumbs_slide_speed"]["size"], |
| 553 |
// "effect" => $settings["thumbs_effect"], |
| 554 |
// ])) |
| 555 |
// ] |
| 556 |
], null, true); |
| 557 |
?> |
| 558 |
<div <?php $this->print_render_attribute_string('sub-category-item'); ?>> |
| 559 |
<div class="swiper usk-image-slider"> |
| 560 |
<div class="swiper-wrapper"> |
| 561 |
<?php |
| 562 |
$parentcategory_thumb_id = get_term_meta($category->term_id, 'thumbnail_id', true); |
| 563 |
$images = [$parentcategory_thumb_id]; |
| 564 |
|
| 565 |
foreach ($taxonomies as $subcategory) : |
| 566 |
if ($subcategory->parent == $category->term_id) { |
| 567 |
$subcategory_thumb_id = get_term_meta($subcategory->term_id, 'thumbnail_id', true); |
| 568 |
$images[] = $subcategory_thumb_id; |
| 569 |
} |
| 570 |
endforeach; |
| 571 |
|
| 572 |
foreach ($images as $image_id) : |
| 573 |
$img_url = wp_get_attachment_image_url($image_id, $settings['category_thumbnail_size']); |
| 574 |
if (!(empty($img_url))) : ?> |
| 575 |
<div class="usk-item swiper-slide"> |
| 576 |
<a href="#" class="usk-image-wrap"> |
| 577 |
<img class="usk-img" src="<?php echo esc_url($img_url); ?>" /> |
| 578 |
</a> |
| 579 |
</div> |
| 580 |
<?php |
| 581 |
endif; |
| 582 |
endforeach; |
| 583 |
?> |
| 584 |
</div> |
| 585 |
</div> |
| 586 |
<div class="usk-category-content"> |
| 587 |
|
| 588 |
<?php printf('<%1$s class="usk-category-name">%2$s</%1$s>', esc_attr($settings['title_tags']), esc_html($category->name)); ?> |
| 589 |
<ul class="usk-category-list"> |
| 590 |
<?php |
| 591 |
foreach ($taxonomies as $key => $subcategory) : |
| 592 |
if (($subcategory->parent == $category->term_id) && ($subcategory->count > 0)) { |
| 593 |
printf('<li><a href="%1$s">%2$s</a></li>', esc_url(get_term_link($subcategory->term_id, 'product_cat')), esc_html($subcategory->name)); |
| 594 |
} |
| 595 |
endforeach; |
| 596 |
?> |
| 597 |
</ul> |
| 598 |
|
| 599 |
<div class="usk-link-btn"> |
| 600 |
<?php printf('<a href="%2$s"><span>%1$s</span><i class="usk-icon-arrow-right-8"></i>', esc_html('All ' . $category->name . ''), esc_url(get_term_link($category->term_id, 'product_cat'))); ?> |
| 601 |
</a> |
| 602 |
</div> |
| 603 |
</div> |
| 604 |
</div> |
| 605 |
<?php |
| 606 |
endif; |
| 607 |
endforeach; |
| 608 |
endif; |
| 609 |
} |
| 610 |
public function render() { |
| 611 |
$this->register_global_template_carousel_header(); |
| 612 |
$this->render_items(); |
| 613 |
$this->usk_register_global_template_carousel_footer(); |
| 614 |
} |
| 615 |
} |
| 616 |
|