| 1 |
<?php |
| 2 |
|
| 3 |
namespace UltimatePostKit\Modules\TagCloud\Widgets; |
| 4 |
|
| 5 |
use UltimatePostKit\Base\Module_Base; |
| 6 |
use Elementor\Controls_Manager; |
| 7 |
use Elementor\Group_Control_Border; |
| 8 |
use Elementor\Group_Control_Box_Shadow; |
| 9 |
use Elementor\Group_Control_Typography; |
| 10 |
use Elementor\Group_Control_Background; |
| 11 |
|
| 12 |
if (!defined('ABSPATH')) { |
| 13 |
exit; |
| 14 |
} // Exit if accessed directly |
| 15 |
|
| 16 |
class Tag_Cloud extends Module_Base { |
| 17 |
private $_query = null; |
| 18 |
|
| 19 |
public function get_name() { |
| 20 |
return 'upk-tag-cloud'; |
| 21 |
} |
| 22 |
|
| 23 |
public function get_title() { |
| 24 |
return BDTUPK . esc_html__('Tag Cloud', 'ultimate-post-kit'); |
| 25 |
} |
| 26 |
|
| 27 |
public function get_icon() { |
| 28 |
return 'upk-widget-icon upk-icon-tag-cloud'; |
| 29 |
} |
| 30 |
|
| 31 |
public function get_categories() { |
| 32 |
return ['ultimate-post-kit']; |
| 33 |
} |
| 34 |
|
| 35 |
public function get_keywords() { |
| 36 |
return ['post', 'list', 'blog', 'recent', 'news', 'category', 'tag', 'cloud', 'tags']; |
| 37 |
} |
| 38 |
|
| 39 |
public function get_style_depends() { |
| 40 |
if ($this->upk_is_edit_mode()) { |
| 41 |
return ['upk-all-styles']; |
| 42 |
} else { |
| 43 |
return ['upk-tag-cloud']; |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
public function get_custom_help_url() { |
| 48 |
return 'https://youtu.be/DLl_bqh_E2M'; |
| 49 |
} |
| 50 |
|
| 51 |
public function get_query() { |
| 52 |
return $this->_query; |
| 53 |
} |
| 54 |
|
| 55 |
public function has_widget_inner_wrapper(): bool { |
| 56 |
return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
protected function register_controls() { |
| 61 |
$this->start_controls_section( |
| 62 |
'section_content_layout', |
| 63 |
[ |
| 64 |
'label' => esc_html__('Layout', 'ultimate-post-kit'), |
| 65 |
] |
| 66 |
); |
| 67 |
|
| 68 |
$this->add_control( |
| 69 |
'layout_style', |
| 70 |
[ |
| 71 |
'label' => esc_html__('Style', 'ultimate-post-kit'), |
| 72 |
'type' => Controls_Manager::SELECT, |
| 73 |
'default' => 'inline', |
| 74 |
'options' => [ |
| 75 |
'inline' => esc_html__('Inline', 'ultimate-post-kit'), |
| 76 |
'grid' => esc_html__('Grid', 'ultimate-post-kit'), |
| 77 |
], |
| 78 |
'prefix_class' => 'upk-layout-style--', |
| 79 |
] |
| 80 |
); |
| 81 |
|
| 82 |
$this->add_responsive_control( |
| 83 |
'columns', |
| 84 |
[ |
| 85 |
'label' => __('Columns', 'ultimate-post-kit'), |
| 86 |
'type' => Controls_Manager::SELECT, |
| 87 |
'default' => '3', |
| 88 |
'tablet_default' => '2', |
| 89 |
'mobile_default' => '1', |
| 90 |
'options' => [ |
| 91 |
'1' => '1', |
| 92 |
'2' => '2', |
| 93 |
'3' => '3', |
| 94 |
'4' => '4', |
| 95 |
'5' => '5', |
| 96 |
'6' => '6', |
| 97 |
], |
| 98 |
'selectors' => [ |
| 99 |
'{{WRAPPER}} .upk-tag-cloud' => 'grid-template-columns: repeat({{SIZE}}, 1fr);', |
| 100 |
], |
| 101 |
'condition' => [ |
| 102 |
'layout_style' => 'grid' |
| 103 |
] |
| 104 |
] |
| 105 |
); |
| 106 |
|
| 107 |
$this->add_responsive_control( |
| 108 |
'row_gap', |
| 109 |
[ |
| 110 |
'label' => esc_html__('Row Gap', 'ultimate-post-kit') . BDTUPK_NC, |
| 111 |
'type' => Controls_Manager::SLIDER, |
| 112 |
'default' => [ |
| 113 |
'size' => 20, |
| 114 |
], |
| 115 |
'selectors' => [ |
| 116 |
'{{WRAPPER}} .upk-tag-cloud' => 'grid-row-gap: {{SIZE}}{{UNIT}};', |
| 117 |
], |
| 118 |
'condition' => [ |
| 119 |
'layout_style' => 'grid' |
| 120 |
] |
| 121 |
] |
| 122 |
); |
| 123 |
|
| 124 |
$this->add_responsive_control( |
| 125 |
'column_gap', |
| 126 |
[ |
| 127 |
'label' => esc_html__('Column Gap', 'ultimate-post-kit'), |
| 128 |
'type' => Controls_Manager::SLIDER, |
| 129 |
'default' => [ |
| 130 |
'size' => 20, |
| 131 |
], |
| 132 |
'selectors' => [ |
| 133 |
'{{WRAPPER}} .upk-tag-cloud' => 'grid-column-gap: {{SIZE}}{{UNIT}};', |
| 134 |
], |
| 135 |
'condition' => [ |
| 136 |
'layout_style' => 'grid' |
| 137 |
] |
| 138 |
] |
| 139 |
); |
| 140 |
|
| 141 |
$this->add_responsive_control( |
| 142 |
'item_gap', |
| 143 |
[ |
| 144 |
'label' => esc_html__('Item Gap', 'ultimate-post-kit'), |
| 145 |
'type' => Controls_Manager::SLIDER, |
| 146 |
'selectors' => [ |
| 147 |
'{{WRAPPER}} .upk-tag-cloud .upk-item' => 'margin-right: {{SIZE}}{{UNIT}}; margin-bottom: {{SIZE}}{{UNIT}};', |
| 148 |
], |
| 149 |
'condition' => [ |
| 150 |
'layout_style' => 'inline' |
| 151 |
] |
| 152 |
] |
| 153 |
); |
| 154 |
|
| 155 |
$this->add_responsive_control( |
| 156 |
'item_height', |
| 157 |
[ |
| 158 |
'label' => esc_html__('Item Height(px)', 'ultimate-post-kit'), |
| 159 |
'type' => Controls_Manager::SLIDER, |
| 160 |
'range' => [ |
| 161 |
'px' => [ |
| 162 |
'min' => 50, |
| 163 |
'max' => 200, |
| 164 |
], |
| 165 |
], |
| 166 |
'selectors' => [ |
| 167 |
'{{WRAPPER}} .upk-tag-cloud .upk-item' => 'height: {{SIZE}}{{UNIT}};', |
| 168 |
], |
| 169 |
'condition' => [ |
| 170 |
'layout_style' => 'grid' |
| 171 |
] |
| 172 |
] |
| 173 |
); |
| 174 |
|
| 175 |
$this->add_responsive_control( |
| 176 |
'alignment', |
| 177 |
[ |
| 178 |
'label' => __('Alignment', 'ultimate-post-kit'), |
| 179 |
'type' => Controls_Manager::CHOOSE, |
| 180 |
'options' => [ |
| 181 |
'left' => [ |
| 182 |
'title' => __('Left', 'ultimate-post-kit'), |
| 183 |
'icon' => 'eicon-text-align-left', |
| 184 |
], |
| 185 |
'center' => [ |
| 186 |
'title' => __('Center', 'ultimate-post-kit'), |
| 187 |
'icon' => 'eicon-text-align-center', |
| 188 |
], |
| 189 |
'flex-end' => [ |
| 190 |
'title' => __('Right', 'ultimate-post-kit'), |
| 191 |
'icon' => 'eicon-text-align-right', |
| 192 |
], |
| 193 |
'space-between' => [ |
| 194 |
'title' => __('justify', 'ultimate-post-kit'), |
| 195 |
'icon' => 'eicon-text-align-justify', |
| 196 |
] |
| 197 |
], |
| 198 |
'selectors' => [ |
| 199 |
'{{WRAPPER}} .upk-tag-cloud .upk-item' => 'justify-content: {{VALUE}};', |
| 200 |
], |
| 201 |
'condition' => [ |
| 202 |
'layout_style' => 'grid' |
| 203 |
] |
| 204 |
] |
| 205 |
); |
| 206 |
|
| 207 |
$this->add_control( |
| 208 |
'show_count', |
| 209 |
[ |
| 210 |
'label' => esc_html__('Show Count', 'ultimate-post-kit'), |
| 211 |
'type' => Controls_Manager::SWITCHER, |
| 212 |
'default' => 'yes', |
| 213 |
'separator' => 'before' |
| 214 |
] |
| 215 |
); |
| 216 |
|
| 217 |
$this->add_control( |
| 218 |
'show_text', |
| 219 |
[ |
| 220 |
'label' => esc_html__('Show Description as Tooltip', 'ultimate-post-kit'), |
| 221 |
'type' => Controls_Manager::SWITCHER, |
| 222 |
] |
| 223 |
); |
| 224 |
|
| 225 |
$this->add_control( |
| 226 |
'tooltip_position', |
| 227 |
[ |
| 228 |
'label' => esc_html__('Tooltip Position', 'ultimate-post-kit'), |
| 229 |
'type' => Controls_Manager::SELECT, |
| 230 |
'default' => 'top', |
| 231 |
'options' => [ |
| 232 |
'top' => esc_html__('Top', 'ultimate-post-kit'), |
| 233 |
'top-left' => esc_html__('Top Left', 'ultimate-post-kit'), |
| 234 |
'top-right' => esc_html__('Top Right', 'ultimate-post-kit'), |
| 235 |
'bottom' => esc_html__('Bottom', 'ultimate-post-kit'), |
| 236 |
'bottom-left' => esc_html__('Bottom Left', 'ultimate-post-kit'), |
| 237 |
'bottom-right' => esc_html__('Bottom Right', 'ultimate-post-kit'), |
| 238 |
'left' => esc_html__('Left', 'ultimate-post-kit'), |
| 239 |
'right' => esc_html__('Right', 'ultimate-post-kit'), |
| 240 |
], |
| 241 |
'condition' => [ |
| 242 |
'show_text' => 'yes' |
| 243 |
] |
| 244 |
] |
| 245 |
); |
| 246 |
|
| 247 |
$this->end_controls_section(); |
| 248 |
|
| 249 |
$this->start_controls_section( |
| 250 |
'section_post_grid_query', |
| 251 |
[ |
| 252 |
'label' => esc_html__('Query', 'ultimate-post-kit'), |
| 253 |
] |
| 254 |
); |
| 255 |
|
| 256 |
$this->add_control( |
| 257 |
'item_limit', |
| 258 |
[ |
| 259 |
'label' => esc_html__('Item Limit', 'ultimate-post-kit'), |
| 260 |
'type' => Controls_Manager::SLIDER, |
| 261 |
'range' => [ |
| 262 |
'px' => [ |
| 263 |
'min' => 1, |
| 264 |
'max' => 50, |
| 265 |
], |
| 266 |
], |
| 267 |
] |
| 268 |
); |
| 269 |
|
| 270 |
$this->add_control( |
| 271 |
'taxonomy', |
| 272 |
[ |
| 273 |
'label' => esc_html__('Taxonomy', 'ultimate-post-kit'), |
| 274 |
'type' => Controls_Manager::SELECT, |
| 275 |
'default' => 'post_tag', |
| 276 |
'options' => ultimate_post_kit_get_taxonomies(), |
| 277 |
] |
| 278 |
); |
| 279 |
|
| 280 |
$this->add_control( |
| 281 |
'orderby', |
| 282 |
[ |
| 283 |
'label' => esc_html__('Order By', 'ultimate-post-kit'), |
| 284 |
'type' => Controls_Manager::SELECT, |
| 285 |
'default' => 'name', |
| 286 |
'options' => [ |
| 287 |
'name' => esc_html__('Name', 'ultimate-post-kit'), |
| 288 |
'post_date' => esc_html__('Date', 'ultimate-post-kit'), |
| 289 |
'post_title' => esc_html__('Title', 'ultimate-post-kit'), |
| 290 |
'menu_order' => esc_html__('Menu Order', 'ultimate-post-kit'), |
| 291 |
'rand' => esc_html__('Random', 'ultimate-post-kit'), |
| 292 |
], |
| 293 |
] |
| 294 |
); |
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
$this->add_control( |
| 299 |
'order', |
| 300 |
[ |
| 301 |
'label' => esc_html__('Order', 'ultimate-post-kit'), |
| 302 |
'type' => Controls_Manager::SELECT, |
| 303 |
'default' => 'asc', |
| 304 |
'options' => [ |
| 305 |
'asc' => esc_html__('ASC', 'ultimate-post-kit'), |
| 306 |
'desc' => esc_html__('DESC', 'ultimate-post-kit'), |
| 307 |
], |
| 308 |
] |
| 309 |
); |
| 310 |
|
| 311 |
$this->add_control( |
| 312 |
'exclude', |
| 313 |
[ |
| 314 |
'label' => esc_html__('Exclude', 'ultimate-post-kit'), |
| 315 |
'type' => Controls_Manager::TEXT, |
| 316 |
'placeholder' => __('Tag ID: 12,3,1', 'ultimate-post-kit'), |
| 317 |
] |
| 318 |
); |
| 319 |
|
| 320 |
$this->add_control( |
| 321 |
'parent', |
| 322 |
[ |
| 323 |
'label' => esc_html__('Parent', 'ultimate-post-kit'), |
| 324 |
'type' => Controls_Manager::TEXT, |
| 325 |
'placeholder' => __('Tag ID: 12', 'ultimate-post-kit'), |
| 326 |
] |
| 327 |
); |
| 328 |
|
| 329 |
$this->end_controls_section(); |
| 330 |
|
| 331 |
//Style |
| 332 |
$this->start_controls_section( |
| 333 |
'upk_section_style', |
| 334 |
[ |
| 335 |
'label' => esc_html__('Items', 'ultimate-post-kit'), |
| 336 |
'tab' => Controls_Manager::TAB_STYLE, |
| 337 |
] |
| 338 |
); |
| 339 |
|
| 340 |
$this->start_controls_tabs('tabs_item_style'); |
| 341 |
|
| 342 |
$this->start_controls_tab( |
| 343 |
'tab_item_normal', |
| 344 |
[ |
| 345 |
'label' => esc_html__('Normal', 'ultimate-post-kit'), |
| 346 |
] |
| 347 |
); |
| 348 |
|
| 349 |
$this->add_control( |
| 350 |
'single_background', |
| 351 |
[ |
| 352 |
'label' => esc_html__('Single Background', 'ultimate-post-kit'), |
| 353 |
'type' => Controls_Manager::SWITCHER, |
| 354 |
] |
| 355 |
); |
| 356 |
|
| 357 |
$this->add_group_control( |
| 358 |
Group_Control_Background::get_type(), |
| 359 |
[ |
| 360 |
'name' => 'item_background', |
| 361 |
'selector' => '{{WRAPPER}} .upk-tag-cloud .upk-item', |
| 362 |
'condition' => [ |
| 363 |
'single_background' => 'yes' |
| 364 |
] |
| 365 |
] |
| 366 |
); |
| 367 |
|
| 368 |
$this->add_control( |
| 369 |
'multiple_background', |
| 370 |
[ |
| 371 |
'label' => esc_html__('Multiple Background', 'ultimate-post-kit'), |
| 372 |
'type' => Controls_Manager::TEXTAREA, |
| 373 |
'placeholder' => '#000000, #f5f5f5, #999999', |
| 374 |
'condition' => [ |
| 375 |
'single_background' => '' |
| 376 |
] |
| 377 |
] |
| 378 |
); |
| 379 |
|
| 380 |
$this->add_group_control( |
| 381 |
Group_Control_Border::get_type(), |
| 382 |
[ |
| 383 |
'name' => 'item_border', |
| 384 |
'selector' => '{{WRAPPER}} .upk-tag-cloud .upk-item', |
| 385 |
] |
| 386 |
); |
| 387 |
|
| 388 |
$this->add_responsive_control( |
| 389 |
'item_border_radius', |
| 390 |
[ |
| 391 |
'label' => esc_html__('Border Radius', 'ultimate-post-kit'), |
| 392 |
'type' => Controls_Manager::DIMENSIONS, |
| 393 |
'size_units' => ['px', '%'], |
| 394 |
'selectors' => [ |
| 395 |
'{{WRAPPER}} .upk-tag-cloud .upk-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 396 |
], |
| 397 |
] |
| 398 |
); |
| 399 |
|
| 400 |
$this->add_responsive_control( |
| 401 |
'item_padding', |
| 402 |
[ |
| 403 |
'label' => __('Padding', 'ultimate-post-kit'), |
| 404 |
'type' => Controls_Manager::DIMENSIONS, |
| 405 |
'size_units' => ['px', 'em', '%'], |
| 406 |
'selectors' => [ |
| 407 |
'{{WRAPPER}} .upk-tag-cloud .upk-item' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 408 |
], |
| 409 |
] |
| 410 |
); |
| 411 |
|
| 412 |
$this->add_group_control( |
| 413 |
Group_Control_Box_Shadow::get_type(), |
| 414 |
[ |
| 415 |
'name' => 'item_box_shadow', |
| 416 |
'selector' => '{{WRAPPER}} .upk-tag-cloud .upk-item', |
| 417 |
] |
| 418 |
); |
| 419 |
|
| 420 |
$this->end_controls_tab(); |
| 421 |
|
| 422 |
$this->start_controls_tab( |
| 423 |
'tab_item_hover', |
| 424 |
[ |
| 425 |
'label' => esc_html__('Hover', 'ultimate-post-kit'), |
| 426 |
] |
| 427 |
); |
| 428 |
|
| 429 |
$this->add_group_control( |
| 430 |
Group_Control_Background::get_type(), |
| 431 |
[ |
| 432 |
'name' => 'itam_background_hover', |
| 433 |
'selector' => '{{WRAPPER}} .upk-tag-cloud .upk-item:hover', |
| 434 |
] |
| 435 |
); |
| 436 |
|
| 437 |
$this->add_control( |
| 438 |
'item_border_color_hover', |
| 439 |
[ |
| 440 |
'label' => esc_html__('Border Color', 'ultimate-post-kit'), |
| 441 |
'type' => Controls_Manager::COLOR, |
| 442 |
'selectors' => [ |
| 443 |
'{{WRAPPER}} .upk-tag-cloud .upk-item:hover' => 'border-color: {{VALUE}};' |
| 444 |
], |
| 445 |
'condition' => [ |
| 446 |
'item_border_border!' => '' |
| 447 |
] |
| 448 |
] |
| 449 |
); |
| 450 |
|
| 451 |
$this->add_group_control( |
| 452 |
Group_Control_Box_Shadow::get_type(), |
| 453 |
[ |
| 454 |
'name' => 'item_box_shadow_hover', |
| 455 |
'selector' => '{{WRAPPER}} .upk-tag-cloud .upk-item:hover', |
| 456 |
] |
| 457 |
); |
| 458 |
|
| 459 |
// $this->add_control( |
| 460 |
// 'hover_animation', |
| 461 |
// [ |
| 462 |
// 'label' => esc_html__( 'Hover Animation', 'ultimate-post-kit' ), |
| 463 |
// 'type' => Controls_Manager::HOVER_ANIMATION, |
| 464 |
// 'separator' => 'before' |
| 465 |
// ] |
| 466 |
// ); |
| 467 |
|
| 468 |
$this->end_controls_tab(); |
| 469 |
|
| 470 |
$this->end_controls_tabs(); |
| 471 |
|
| 472 |
$this->end_controls_section(); |
| 473 |
|
| 474 |
$this->start_controls_section( |
| 475 |
'section_style_category_name', |
| 476 |
[ |
| 477 |
'label' => esc_html__('Name', 'ultimate-post-kit'), |
| 478 |
'tab' => Controls_Manager::TAB_STYLE, |
| 479 |
] |
| 480 |
); |
| 481 |
|
| 482 |
$this->add_control( |
| 483 |
'category_name_color', |
| 484 |
[ |
| 485 |
'label' => esc_html__('Color', 'ultimate-post-kit'), |
| 486 |
'type' => Controls_Manager::COLOR, |
| 487 |
'selectors' => [ |
| 488 |
'{{WRAPPER}} .upk-tag-cloud .upk-item .upk-name' => 'color: {{VALUE}};', |
| 489 |
], |
| 490 |
] |
| 491 |
); |
| 492 |
|
| 493 |
$this->add_control( |
| 494 |
'category_name_color_hover', |
| 495 |
[ |
| 496 |
'label' => esc_html__('Hover Color', 'ultimate-post-kit'), |
| 497 |
'type' => Controls_Manager::COLOR, |
| 498 |
'selectors' => [ |
| 499 |
'{{WRAPPER}} .upk-tag-cloud .upk-item:hover .upk-name' => 'color: {{VALUE}};', |
| 500 |
], |
| 501 |
] |
| 502 |
); |
| 503 |
|
| 504 |
$this->add_group_control( |
| 505 |
Group_Control_Typography::get_type(), |
| 506 |
[ |
| 507 |
'name' => 'category_name_typography', |
| 508 |
'label' => esc_html__('Typography', 'ultimate-post-kit'), |
| 509 |
'selector' => '{{WRAPPER}} .upk-tag-cloud .upk-item .upk-name', |
| 510 |
] |
| 511 |
); |
| 512 |
|
| 513 |
$this->end_controls_section(); |
| 514 |
|
| 515 |
$this->start_controls_section( |
| 516 |
'section_style_count', |
| 517 |
[ |
| 518 |
'label' => esc_html__('Count', 'ultimate-post-kit'), |
| 519 |
'tab' => Controls_Manager::TAB_STYLE, |
| 520 |
] |
| 521 |
); |
| 522 |
|
| 523 |
$this->add_control( |
| 524 |
'count_color', |
| 525 |
[ |
| 526 |
'label' => esc_html__('Color', 'ultimate-post-kit'), |
| 527 |
'type' => Controls_Manager::COLOR, |
| 528 |
'selectors' => [ |
| 529 |
'{{WRAPPER}} .upk-tag-cloud .upk-item .upk-count' => 'color: {{VALUE}};', |
| 530 |
], |
| 531 |
] |
| 532 |
); |
| 533 |
|
| 534 |
$this->add_control( |
| 535 |
'count_color_hover', |
| 536 |
[ |
| 537 |
'label' => esc_html__('Hover Color', 'ultimate-post-kit'), |
| 538 |
'type' => Controls_Manager::COLOR, |
| 539 |
'selectors' => [ |
| 540 |
'{{WRAPPER}} .upk-tag-cloud .upk-item:hover .upk-count' => 'color: {{VALUE}};', |
| 541 |
], |
| 542 |
] |
| 543 |
); |
| 544 |
|
| 545 |
$this->add_group_control( |
| 546 |
Group_Control_Background::get_type(), |
| 547 |
[ |
| 548 |
'name' => 'count_background', |
| 549 |
'selector' => '{{WRAPPER}} .upk-tag-cloud .upk-item .upk-count', |
| 550 |
] |
| 551 |
); |
| 552 |
|
| 553 |
$this->add_group_control( |
| 554 |
Group_Control_Border::get_type(), |
| 555 |
[ |
| 556 |
'name' => 'count_border', |
| 557 |
'selector' => '{{WRAPPER}} .upk-tag-cloud .upk-item .upk-count', |
| 558 |
] |
| 559 |
); |
| 560 |
|
| 561 |
$this->add_responsive_control( |
| 562 |
'count_border_radius', |
| 563 |
[ |
| 564 |
'label' => esc_html__('Border Radius', 'ultimate-post-kit'), |
| 565 |
'type' => Controls_Manager::DIMENSIONS, |
| 566 |
'size_units' => ['px', '%'], |
| 567 |
'selectors' => [ |
| 568 |
'{{WRAPPER}} .upk-tag-cloud .upk-item .upk-count' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 569 |
], |
| 570 |
] |
| 571 |
); |
| 572 |
|
| 573 |
$this->add_responsive_control( |
| 574 |
'count_padding', |
| 575 |
[ |
| 576 |
'label' => __('Padding', 'ultimate-post-kit'), |
| 577 |
'type' => Controls_Manager::DIMENSIONS, |
| 578 |
'size_units' => ['px', 'em', '%'], |
| 579 |
'selectors' => [ |
| 580 |
'{{WRAPPER}} .upk-tag-cloud .upk-item .upk-count' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 581 |
], |
| 582 |
] |
| 583 |
); |
| 584 |
|
| 585 |
$this->add_group_control( |
| 586 |
Group_Control_Box_Shadow::get_type(), |
| 587 |
[ |
| 588 |
'name' => 'count_box_shadow', |
| 589 |
'selector' => '{{WRAPPER}} .upk-tag-cloud .upk-item .upk-count', |
| 590 |
] |
| 591 |
); |
| 592 |
|
| 593 |
$this->add_group_control( |
| 594 |
Group_Control_Typography::get_type(), |
| 595 |
[ |
| 596 |
'name' => 'count_typography', |
| 597 |
'label' => esc_html__('Typography', 'ultimate-post-kit'), |
| 598 |
'selector' => '{{WRAPPER}} .upk-tag-cloud .upk-item .upk-count', |
| 599 |
] |
| 600 |
); |
| 601 |
|
| 602 |
$this->add_responsive_control( |
| 603 |
'count_spacing', |
| 604 |
[ |
| 605 |
'label' => __('Spacing', 'ultimate-post-kit'), |
| 606 |
'type' => Controls_Manager::SLIDER, |
| 607 |
'range' => [ |
| 608 |
'px' => [ |
| 609 |
'min' => 0, |
| 610 |
'max' => 50, |
| 611 |
], |
| 612 |
], |
| 613 |
'selectors' => [ |
| 614 |
'{{WRAPPER}} .upk-tag-cloud .upk-item .upk-count' => 'margin-left: {{SIZE}}px;' |
| 615 |
], |
| 616 |
] |
| 617 |
); |
| 618 |
|
| 619 |
$this->end_controls_section(); |
| 620 |
} |
| 621 |
|
| 622 |
public function render() { |
| 623 |
$settings = $this->get_settings_for_display(); |
| 624 |
|
| 625 |
$categories = get_categories([ |
| 626 |
'taxonomy' => $settings["taxonomy"], |
| 627 |
'orderby' => $settings["orderby"], |
| 628 |
'order' => $settings["order"], |
| 629 |
'hide_empty' => 0, |
| 630 |
// phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Elementor widget query built from user-configured controls; expected behaviour. |
| 631 |
'exclude' => explode(',', esc_attr($settings["exclude"])), |
| 632 |
'parent' => $settings["parent"], |
| 633 |
]); |
| 634 |
|
| 635 |
|
| 636 |
if (!empty($categories)) : |
| 637 |
|
| 638 |
if ( 'rand' == $settings["orderby"] ) { |
| 639 |
shuffle($categories); |
| 640 |
} |
| 641 |
|
| 642 |
?> |
| 643 |
<div class="upk-tag-cloud"> |
| 644 |
<?php |
| 645 |
|
| 646 |
if (isset($settings['multiple_background'])) { |
| 647 |
$multiple_bg_create = []; |
| 648 |
$multiple_bg = explode(',', rtrim($settings['multiple_background'], ',')); |
| 649 |
$total_category = count($categories); |
| 650 |
|
| 651 |
// re-creating array for the multiple colors |
| 652 |
$jCount = count($multiple_bg); |
| 653 |
$j = 0; |
| 654 |
for ($i = 0; $i < $total_category; $i++) { |
| 655 |
if ($j == $jCount) { |
| 656 |
$j = 0; |
| 657 |
} |
| 658 |
$multiple_bg_create[$i] = $multiple_bg[$j]; |
| 659 |
$j++; |
| 660 |
} |
| 661 |
} |
| 662 |
|
| 663 |
|
| 664 |
foreach ($categories as $index => $cat) : |
| 665 |
$output = ''; |
| 666 |
|
| 667 |
$this->add_render_attribute('category-item', 'class', 'upk-item', true); |
| 668 |
|
| 669 |
$this->add_render_attribute('category-item', 'href', get_category_link($cat->cat_ID), true); |
| 670 |
|
| 671 |
$bg_color = strToHex($cat->cat_name); |
| 672 |
|
| 673 |
if (!empty($settings['multiple_background'])) { |
| 674 |
$bg_color = $multiple_bg_create[$index]; |
| 675 |
if (!preg_match('/#([a-f]|[A-F]|[0-9]){3}(([a-f]|[A-F]|[0-9]){3})?\b/', $multiple_bg_create[$index])) { |
| 676 |
$bg_color = strToHex($cat->cat_name); |
| 677 |
} |
| 678 |
} |
| 679 |
|
| 680 |
if ($settings['single_background'] == '') { |
| 681 |
$this->add_render_attribute('category-item', 'style', "background-color: $bg_color", true); |
| 682 |
} |
| 683 |
|
| 684 |
if (!empty($cat->category_description) and $settings['show_text'] == 'yes') { |
| 685 |
$this->add_render_attribute('category-item', 'aria-label', $cat->category_description, true); |
| 686 |
$this->add_render_attribute('category-item', 'role', 'tooltip', true); |
| 687 |
$this->add_render_attribute('category-item', 'data-microtip-position', $settings['tooltip_position'], true); |
| 688 |
} |
| 689 |
|
| 690 |
?> |
| 691 |
|
| 692 |
<a <?php $this->print_render_attribute_string('category-item'); ?>> |
| 693 |
<span class="upk-name"><?php echo esc_html($cat->cat_name); ?></span> |
| 694 |
|
| 695 |
<?php if ($settings['show_count'] == 'yes') : ?> |
| 696 |
<span class="upk-count"><?php echo esc_html($cat->category_count); ?></span> |
| 697 |
<?php endif; ?> |
| 698 |
</a> |
| 699 |
<?php |
| 700 |
|
| 701 |
if (!empty($settings['item_limit']['size'])) { |
| 702 |
if ($index == ($settings['item_limit']['size'] - 1)) break; |
| 703 |
} |
| 704 |
|
| 705 |
endforeach; |
| 706 |
?> |
| 707 |
</div> |
| 708 |
<?php |
| 709 |
else : |
| 710 |
|
| 711 |
echo '<div class="upk-alert">' . esc_html__('Category Not Found!', 'ultimate-post-kit') . '</div>'; |
| 712 |
|
| 713 |
endif; |
| 714 |
} |
| 715 |
} |
| 716 |
|