| 1 |
<?php |
| 2 |
|
| 3 |
namespace UltimatePostKit\Modules\AmoxCarousel\Widgets; |
| 4 |
|
| 5 |
use Elementor\Controls_Manager; |
| 6 |
use Elementor\Group_Control_Border; |
| 7 |
use Elementor\Group_Control_Box_Shadow; |
| 8 |
use Elementor\Group_Control_Typography; |
| 9 |
use Elementor\Group_Control_Text_Shadow; |
| 10 |
use Elementor\Group_Control_Image_Size; |
| 11 |
use Elementor\Group_Control_Background; |
| 12 |
|
| 13 |
use UltimatePostKit\Traits\Global_Widget_Controls; |
| 14 |
use UltimatePostKit\Traits\Global_Widget_Functions; |
| 15 |
use UltimatePostKit\Traits\Global_Swiper_Functions; |
| 16 |
use UltimatePostKit\Includes\Controls\GroupQuery\Group_Control_Query; |
| 17 |
use WP_Query; |
| 18 |
|
| 19 |
if (!defined('ABSPATH')) exit; // Exit if accessed directly |
| 20 |
|
| 21 |
class Amox_Carousel extends Group_Control_Query |
| 22 |
{ |
| 23 |
|
| 24 |
use Global_Widget_Controls; |
| 25 |
use Global_Widget_Functions; |
| 26 |
use Global_Swiper_Functions; |
| 27 |
|
| 28 |
private $_query = null; |
| 29 |
|
| 30 |
public function get_name() |
| 31 |
{ |
| 32 |
return 'upk-amox-carousel'; |
| 33 |
} |
| 34 |
|
| 35 |
public function get_title() |
| 36 |
{ |
| 37 |
return BDTUPK . esc_html__('Amox Carousel', 'ultimate-post-kit'); |
| 38 |
} |
| 39 |
|
| 40 |
public function get_icon() |
| 41 |
{ |
| 42 |
return 'upk-widget-icon upk-icon-amox-carousel'; |
| 43 |
} |
| 44 |
|
| 45 |
public function get_categories() |
| 46 |
{ |
| 47 |
return ['ultimate-post-kit']; |
| 48 |
} |
| 49 |
|
| 50 |
public function get_keywords() |
| 51 |
{ |
| 52 |
return ['post', 'carousel', 'blog', 'recent', 'news', 'amox']; |
| 53 |
} |
| 54 |
|
| 55 |
public function get_style_depends() |
| 56 |
{ |
| 57 |
if ($this->upk_is_edit_mode()) { |
| 58 |
return ['swiper', 'upk-all-styles']; |
| 59 |
} else { |
| 60 |
return ['swiper', 'upk-font', 'upk-amox-carousel']; |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
public function get_script_depends() |
| 65 |
{ |
| 66 |
if ($this->upk_is_edit_mode()) { |
| 67 |
return ['swiper', 'upk-all-scripts']; |
| 68 |
} else { |
| 69 |
return ['swiper', 'upk-amox-carousel']; |
| 70 |
} |
| 71 |
} |
| 72 |
|
| 73 |
public function get_custom_help_url() |
| 74 |
{ |
| 75 |
return 'https://youtu.be/3FoLaHsyB0g'; |
| 76 |
} |
| 77 |
|
| 78 |
public function get_query() |
| 79 |
{ |
| 80 |
return $this->_query; |
| 81 |
} |
| 82 |
|
| 83 |
public function has_widget_inner_wrapper(): bool { |
| 84 |
return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); |
| 85 |
} |
| 86 |
|
| 87 |
|
| 88 |
protected function register_controls() { |
| 89 |
$this->start_controls_section( |
| 90 |
'section_content_layout', |
| 91 |
[ |
| 92 |
'label' => esc_html__('Layout', 'ultimate-post-kit'), |
| 93 |
] |
| 94 |
); |
| 95 |
|
| 96 |
$this->add_responsive_control( |
| 97 |
'columns', |
| 98 |
[ |
| 99 |
'label' => __('Columns', 'ultimate-post-kit'), |
| 100 |
'type' => Controls_Manager::SELECT, |
| 101 |
'default' => 3, |
| 102 |
'tablet_default' => 2, |
| 103 |
'mobile_default' => 1, |
| 104 |
'options' => [ |
| 105 |
1 => '1', |
| 106 |
2 => '2', |
| 107 |
3 => '3', |
| 108 |
4 => '4', |
| 109 |
5 => '5', |
| 110 |
6 => '6', |
| 111 |
], |
| 112 |
] |
| 113 |
); |
| 114 |
|
| 115 |
$this->add_responsive_control( |
| 116 |
'item_gap', |
| 117 |
[ |
| 118 |
'label' => __('Item Gap', 'ultimate-post-kit'), |
| 119 |
'type' => Controls_Manager::SLIDER, |
| 120 |
'default' => [ |
| 121 |
'size' => 20, |
| 122 |
], |
| 123 |
'tablet_default' => [ |
| 124 |
'size' => 20, |
| 125 |
], |
| 126 |
'mobile_default' => [ |
| 127 |
'size' => 20, |
| 128 |
], |
| 129 |
'range' => [ |
| 130 |
'px' => [ |
| 131 |
'min' => 0, |
| 132 |
'max' => 100, |
| 133 |
], |
| 134 |
], |
| 135 |
] |
| 136 |
); |
| 137 |
|
| 138 |
$this->add_responsive_control( |
| 139 |
'image_height', |
| 140 |
[ |
| 141 |
'label' => esc_html__('Image Height', 'ultimate-post-kit') . BDTUPK_NC, |
| 142 |
'type' => Controls_Manager::SLIDER, |
| 143 |
'range' => [ |
| 144 |
'px' => [ |
| 145 |
'min' => 100, |
| 146 |
'max' => 800, |
| 147 |
], |
| 148 |
], |
| 149 |
'selectors' => [ |
| 150 |
'{{WRAPPER}} .upk-amox-carousel .upk-img-wrap' => 'height: {{SIZE}}px;', |
| 151 |
], |
| 152 |
] |
| 153 |
); |
| 154 |
|
| 155 |
$this->add_group_control( |
| 156 |
Group_Control_Image_Size::get_type(), |
| 157 |
[ |
| 158 |
'name' => 'primary_thumbnail', |
| 159 |
// phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Elementor widget query built from user-configured controls; expected behaviour. |
| 160 |
'exclude' => ['custom'], |
| 161 |
'default' => 'medium', |
| 162 |
] |
| 163 |
); |
| 164 |
|
| 165 |
$this->add_responsive_control( |
| 166 |
'content_alignment', |
| 167 |
[ |
| 168 |
'label' => __('Alignment', 'ultimate-post-kit'), |
| 169 |
'type' => Controls_Manager::CHOOSE, |
| 170 |
'options' => [ |
| 171 |
'left' => [ |
| 172 |
'title' => __('Left', 'ultimate-post-kit'), |
| 173 |
'icon' => 'eicon-text-align-left', |
| 174 |
], |
| 175 |
'center' => [ |
| 176 |
'title' => __('Center', 'ultimate-post-kit'), |
| 177 |
'icon' => 'eicon-text-align-center', |
| 178 |
], |
| 179 |
'right' => [ |
| 180 |
'title' => __('Right', 'ultimate-post-kit'), |
| 181 |
'icon' => 'eicon-text-align-right', |
| 182 |
], |
| 183 |
], |
| 184 |
'selectors' => [ |
| 185 |
'{{WRAPPER}} .upk-amox-carousel .upk-item .upk-content' => 'text-align: {{VALUE}};', |
| 186 |
], |
| 187 |
] |
| 188 |
); |
| 189 |
|
| 190 |
$this->add_control( |
| 191 |
'carousel_active_item', |
| 192 |
[ |
| 193 |
'label' => __('Carousel Active Item', 'ultimate-post-kit') . BDTUPK_PC, |
| 194 |
'type' => Controls_Manager::SWITCHER, |
| 195 |
'prefix_class' => 'upk-amox-carousel-active--', |
| 196 |
'render_type' => 'template', |
| 197 |
'separator' => 'before', |
| 198 |
'classes' => BDTUPK_IS_PC, |
| 199 |
] |
| 200 |
); |
| 201 |
|
| 202 |
$this->add_control( |
| 203 |
'active_item', |
| 204 |
[ |
| 205 |
'label' => __('Custom Active Item', 'ultimate-post-kit') . BDTUPK_PC, |
| 206 |
'type' => Controls_Manager::NUMBER, |
| 207 |
'default' => 2, |
| 208 |
'description' => __('Be more creative with your design by typing in your item number.', 'ultimate-post-kit'), |
| 209 |
'classes' => BDTUPK_IS_PC, |
| 210 |
'condition' => [ |
| 211 |
'carousel_active_item' => '' |
| 212 |
], |
| 213 |
'render_type' => 'template' |
| 214 |
] |
| 215 |
); |
| 216 |
|
| 217 |
$this->end_controls_section(); |
| 218 |
|
| 219 |
//New Query Builder Settings |
| 220 |
$this->start_controls_section( |
| 221 |
'section_post_query_builder', |
| 222 |
[ |
| 223 |
'label' => __('Query', 'ultimate-post-kit'), |
| 224 |
'tab' => Controls_Manager::TAB_CONTENT, |
| 225 |
] |
| 226 |
); |
| 227 |
|
| 228 |
$this->add_control( |
| 229 |
'item_limit', |
| 230 |
[ |
| 231 |
'label' => esc_html__('Item Limit', 'ultimate-post-kit'), |
| 232 |
'type' => Controls_Manager::SLIDER, |
| 233 |
'range' => [ |
| 234 |
'px' => [ |
| 235 |
'min' => 0, |
| 236 |
'max' => 21, |
| 237 |
], |
| 238 |
], |
| 239 |
'default' => [ |
| 240 |
'size' => 6, |
| 241 |
], |
| 242 |
'condition' => [ |
| 243 |
'posts_source!' => 'current_query', |
| 244 |
] |
| 245 |
] |
| 246 |
); |
| 247 |
|
| 248 |
$this->register_query_builder_controls(); |
| 249 |
|
| 250 |
$this->end_controls_section(); |
| 251 |
|
| 252 |
$this->start_controls_section( |
| 253 |
'section_content_additional', |
| 254 |
[ |
| 255 |
'label' => esc_html__('Additional Options', 'ultimate-post-kit'), |
| 256 |
] |
| 257 |
); |
| 258 |
|
| 259 |
//Global Title Controls |
| 260 |
$this->register_title_controls(); |
| 261 |
|
| 262 |
$this->add_control( |
| 263 |
'show_category', |
| 264 |
[ |
| 265 |
'label' => esc_html__('Category', 'ultimate-post-kit'), |
| 266 |
'type' => Controls_Manager::SWITCHER, |
| 267 |
'default' => 'yes', |
| 268 |
'separator' => 'before' |
| 269 |
] |
| 270 |
); |
| 271 |
|
| 272 |
//Global Date Controls |
| 273 |
$this->register_date_controls(); |
| 274 |
|
| 275 |
//Global Reading Time Controls |
| 276 |
$this->register_reading_time_controls(); |
| 277 |
|
| 278 |
$this->add_control( |
| 279 |
'meta_separator', |
| 280 |
[ |
| 281 |
'label' => __('Separator', 'ultimate-post-kit') . BDTUPK_NC, |
| 282 |
'type' => Controls_Manager::TEXT, |
| 283 |
'default' => '.', |
| 284 |
'label_block' => false, |
| 285 |
] |
| 286 |
); |
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
$this->add_control( |
| 291 |
'show_comments', |
| 292 |
[ |
| 293 |
'label' => esc_html__('Show Comments', 'ultimate-post-kit'), |
| 294 |
'type' => Controls_Manager::SWITCHER, |
| 295 |
'default' => 'yes', |
| 296 |
] |
| 297 |
); |
| 298 |
|
| 299 |
$this->add_control( |
| 300 |
'item_match_height', |
| 301 |
[ |
| 302 |
'label' => __('Item Match Height', 'ultimate-post-kit'), |
| 303 |
'type' => Controls_Manager::SWITCHER, |
| 304 |
'default' => 'yes', |
| 305 |
'prefix_class' => 'upk-item-match-height--', |
| 306 |
'separator' => 'before' |
| 307 |
] |
| 308 |
); |
| 309 |
|
| 310 |
$this->add_control( |
| 311 |
'global_link', |
| 312 |
[ |
| 313 |
'label' => __('Item Wrapper Link', 'ultimate-post-kit'), |
| 314 |
'type' => Controls_Manager::SWITCHER, |
| 315 |
'prefix_class' => 'upk-global-link-', |
| 316 |
'description' => __('Be aware! When Item Wrapper Link activated then title link and read more link will not work', 'ultimate-post-kit'), |
| 317 |
] |
| 318 |
); |
| 319 |
|
| 320 |
$this->end_controls_section(); |
| 321 |
|
| 322 |
//Navigaiton Global Controls |
| 323 |
$this->register_navigation_controls('amox'); |
| 324 |
|
| 325 |
//Style |
| 326 |
$this->start_controls_section( |
| 327 |
'upk_section_style', |
| 328 |
[ |
| 329 |
'label' => esc_html__('Items', 'ultimate-post-kit'), |
| 330 |
'tab' => Controls_Manager::TAB_STYLE, |
| 331 |
] |
| 332 |
); |
| 333 |
|
| 334 |
$this->add_responsive_control( |
| 335 |
'content_padding', |
| 336 |
[ |
| 337 |
'label' => __('Content Padding', 'ultimate-post-kit'), |
| 338 |
'type' => Controls_Manager::DIMENSIONS, |
| 339 |
'size_units' => ['px', 'em', '%'], |
| 340 |
'selectors' => [ |
| 341 |
'{{WRAPPER}} .upk-amox-carousel .upk-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 342 |
], |
| 343 |
] |
| 344 |
); |
| 345 |
|
| 346 |
$this->start_controls_tabs('tabs_item_style'); |
| 347 |
|
| 348 |
$this->start_controls_tab( |
| 349 |
'tab_item_normal', |
| 350 |
[ |
| 351 |
'label' => esc_html__('Normal', 'ultimate-post-kit'), |
| 352 |
] |
| 353 |
); |
| 354 |
|
| 355 |
$this->add_group_control( |
| 356 |
Group_Control_Background::get_type(), |
| 357 |
[ |
| 358 |
'name' => 'content_background', |
| 359 |
'selector' => '{{WRAPPER}} .upk-amox-carousel .upk-item', |
| 360 |
] |
| 361 |
); |
| 362 |
|
| 363 |
$this->add_group_control( |
| 364 |
Group_Control_Border::get_type(), |
| 365 |
[ |
| 366 |
'name' => 'item_border', |
| 367 |
'selector' => '{{WRAPPER}} .upk-amox-carousel .upk-item', |
| 368 |
] |
| 369 |
); |
| 370 |
|
| 371 |
$this->add_responsive_control( |
| 372 |
'item_border_radius', |
| 373 |
[ |
| 374 |
'label' => esc_html__('Border Radius', 'ultimate-post-kit'), |
| 375 |
'type' => Controls_Manager::DIMENSIONS, |
| 376 |
'size_units' => ['px', '%'], |
| 377 |
'selectors' => [ |
| 378 |
'{{WRAPPER}} .upk-amox-carousel .upk-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 379 |
], |
| 380 |
] |
| 381 |
); |
| 382 |
|
| 383 |
$this->add_responsive_control( |
| 384 |
'item_padding', |
| 385 |
[ |
| 386 |
'label' => __('Padding', 'ultimate-post-kit'), |
| 387 |
'type' => Controls_Manager::DIMENSIONS, |
| 388 |
'size_units' => ['px', 'em', '%'], |
| 389 |
'selectors' => [ |
| 390 |
'{{WRAPPER}} .upk-amox-carousel .upk-item' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 391 |
], |
| 392 |
] |
| 393 |
); |
| 394 |
|
| 395 |
$this->add_group_control( |
| 396 |
Group_Control_Box_Shadow::get_type(), |
| 397 |
[ |
| 398 |
'name' => 'item_box_shadow', |
| 399 |
'selector' => '{{WRAPPER}} .upk-amox-carousel .upk-item', |
| 400 |
] |
| 401 |
); |
| 402 |
|
| 403 |
$this->end_controls_tab(); |
| 404 |
|
| 405 |
$this->start_controls_tab( |
| 406 |
'tab_item_hover', |
| 407 |
[ |
| 408 |
'label' => esc_html__('Hover', 'ultimate-post-kit'), |
| 409 |
] |
| 410 |
); |
| 411 |
|
| 412 |
$this->add_group_control( |
| 413 |
Group_Control_Background::get_type(), |
| 414 |
[ |
| 415 |
'name' => 'content_hover_background', |
| 416 |
'selector' => '{{WRAPPER}} .upk-amox-carousel .upk-item:hover', |
| 417 |
] |
| 418 |
); |
| 419 |
|
| 420 |
$this->add_control( |
| 421 |
'item_hover_border_color', |
| 422 |
[ |
| 423 |
'label' => esc_html__('Border Color', 'ultimate-post-kit'), |
| 424 |
'type' => Controls_Manager::COLOR, |
| 425 |
'condition' => [ |
| 426 |
'item_border_border!' => '', |
| 427 |
], |
| 428 |
'selectors' => [ |
| 429 |
'{{WRAPPER}} .upk-amox-carousel .upk-item:hover' => 'border-color: {{VALUE}};', |
| 430 |
], |
| 431 |
] |
| 432 |
); |
| 433 |
|
| 434 |
$this->add_group_control( |
| 435 |
Group_Control_Box_Shadow::get_type(), |
| 436 |
[ |
| 437 |
'name' => 'item_hover_box_shadow', |
| 438 |
'selector' => '{{WRAPPER}} .upk-amox-carousel .upk-item:hover', |
| 439 |
] |
| 440 |
); |
| 441 |
|
| 442 |
$this->add_responsive_control( |
| 443 |
'item_shadow_padding', |
| 444 |
[ |
| 445 |
'label' => __('Match Padding', 'ultimate-post-kit'), |
| 446 |
'description' => __('You have to add padding for matching overlaping normal/hover box shadow when you used Box Shadow option.', 'ultimate-post-kit'), |
| 447 |
'type' => Controls_Manager::SLIDER, |
| 448 |
'range' => [ |
| 449 |
'px' => [ |
| 450 |
'min' => 0, |
| 451 |
'step' => 1, |
| 452 |
'max' => 50, |
| 453 |
] |
| 454 |
], |
| 455 |
'selectors' => [ |
| 456 |
'{{WRAPPER}} .swiper-carousel' => 'padding: {{SIZE}}{{UNIT}}; margin: 0 -{{SIZE}}{{UNIT}};' |
| 457 |
], |
| 458 |
] |
| 459 |
); |
| 460 |
|
| 461 |
$this->end_controls_tab(); |
| 462 |
|
| 463 |
$this->end_controls_tabs(); |
| 464 |
|
| 465 |
$this->end_controls_section(); |
| 466 |
|
| 467 |
$this->start_controls_section( |
| 468 |
'section_style_title', |
| 469 |
[ |
| 470 |
'label' => esc_html__('Title', 'ultimate-post-kit'), |
| 471 |
'tab' => Controls_Manager::TAB_STYLE, |
| 472 |
'condition' => [ |
| 473 |
'show_title' => 'yes', |
| 474 |
], |
| 475 |
] |
| 476 |
); |
| 477 |
|
| 478 |
$this->add_control( |
| 479 |
'title_style', |
| 480 |
[ |
| 481 |
'label' => esc_html__('Style', 'ultimate-post-kit'), |
| 482 |
'type' => Controls_Manager::SELECT, |
| 483 |
'default' => 'underline', |
| 484 |
'options' => [ |
| 485 |
'' => esc_html__('Default', 'ultimate-post-kit'), |
| 486 |
'underline' => esc_html__('Underline', 'ultimate-post-kit'), |
| 487 |
'middle-underline' => esc_html__('Middle Underline', 'ultimate-post-kit'), |
| 488 |
'overline' => esc_html__('Overline', 'ultimate-post-kit'), |
| 489 |
'middle-overline' => esc_html__('Middle Overline', 'ultimate-post-kit'), |
| 490 |
], |
| 491 |
] |
| 492 |
); |
| 493 |
|
| 494 |
$this->add_responsive_control( |
| 495 |
'title_spacing', |
| 496 |
[ |
| 497 |
'label' => esc_html__('Spacing', 'ultimate-post-kit'), |
| 498 |
'type' => Controls_Manager::SLIDER, |
| 499 |
'range' => [ |
| 500 |
'px' => [ |
| 501 |
'min' => 0, |
| 502 |
'max' => 50, |
| 503 |
], |
| 504 |
], |
| 505 |
'selectors' => [ |
| 506 |
'{{WRAPPER}} .upk-amox-carousel .upk-title' => 'padding-bottom: {{SIZE}}{{UNIT}};', |
| 507 |
], |
| 508 |
] |
| 509 |
); |
| 510 |
|
| 511 |
$this->add_group_control( |
| 512 |
Group_Control_Typography::get_type(), |
| 513 |
[ |
| 514 |
'name' => 'title_typography', |
| 515 |
'label' => esc_html__('Typography', 'ultimate-post-kit'), |
| 516 |
'selector' => '{{WRAPPER}} .upk-amox-carousel .upk-title', |
| 517 |
] |
| 518 |
); |
| 519 |
|
| 520 |
$this->add_group_control( |
| 521 |
Group_Control_Text_Shadow::get_type(), |
| 522 |
[ |
| 523 |
'name' => 'title_text_shadow', |
| 524 |
'label' => __('Text Shadow', 'ultimate-post-kit'), |
| 525 |
'selector' => '{{WRAPPER}} .upk-amox-carousel .upk-title', |
| 526 |
] |
| 527 |
); |
| 528 |
|
| 529 |
$this->start_controls_tabs('tabs_title_style'); |
| 530 |
|
| 531 |
$this->start_controls_tab( |
| 532 |
'tab_title_normal', |
| 533 |
[ |
| 534 |
'label' => esc_html__('Normal', 'ultimate-post-kit'), |
| 535 |
] |
| 536 |
); |
| 537 |
|
| 538 |
$this->add_control( |
| 539 |
'title_color', |
| 540 |
[ |
| 541 |
'label' => esc_html__('Color', 'ultimate-post-kit'), |
| 542 |
'type' => Controls_Manager::COLOR, |
| 543 |
'selectors' => [ |
| 544 |
'{{WRAPPER}} .upk-amox-carousel .upk-title a' => 'color: {{VALUE}};', |
| 545 |
], |
| 546 |
] |
| 547 |
); |
| 548 |
|
| 549 |
$this->end_controls_tab(); |
| 550 |
|
| 551 |
$this->start_controls_tab( |
| 552 |
'tab_title_hover', |
| 553 |
[ |
| 554 |
'label' => esc_html__('Hover', 'ultimate-post-kit'), |
| 555 |
] |
| 556 |
); |
| 557 |
|
| 558 |
$this->add_control( |
| 559 |
'title_color_hover', |
| 560 |
[ |
| 561 |
'label' => esc_html__('Color', 'ultimate-post-kit'), |
| 562 |
'type' => Controls_Manager::COLOR, |
| 563 |
'selectors' => [ |
| 564 |
'{{WRAPPER}} .upk-amox-carousel .upk-title a:hover' => 'color: {{VALUE}};', |
| 565 |
], |
| 566 |
] |
| 567 |
); |
| 568 |
|
| 569 |
$this->end_controls_tab(); |
| 570 |
|
| 571 |
$this->end_controls_tabs(); |
| 572 |
|
| 573 |
$this->end_controls_section(); |
| 574 |
|
| 575 |
$this->start_controls_section( |
| 576 |
'section_style_meta', |
| 577 |
[ |
| 578 |
'label' => esc_html__('Meta', 'ultimate-post-kit'), |
| 579 |
'tab' => Controls_Manager::TAB_STYLE, |
| 580 |
'conditions' => [ |
| 581 |
'relation' => 'or', |
| 582 |
'terms' => [ |
| 583 |
[ |
| 584 |
'name' => 'show_date', |
| 585 |
'value' => 'yes' |
| 586 |
], |
| 587 |
[ |
| 588 |
'name' => 'show_comments', |
| 589 |
'value' => 'yes' |
| 590 |
] |
| 591 |
] |
| 592 |
], |
| 593 |
] |
| 594 |
); |
| 595 |
|
| 596 |
$this->add_control( |
| 597 |
'meta_color', |
| 598 |
[ |
| 599 |
'label' => esc_html__('Color', 'ultimate-post-kit'), |
| 600 |
'type' => Controls_Manager::COLOR, |
| 601 |
'selectors' => [ |
| 602 |
'{{WRAPPER}} .upk-amox-carousel .upk-meta' => 'color: {{VALUE}};', |
| 603 |
], |
| 604 |
] |
| 605 |
); |
| 606 |
|
| 607 |
$this->add_responsive_control( |
| 608 |
'meta_space_between', |
| 609 |
[ |
| 610 |
'label' => esc_html__('Space Between', 'ultimate-post-kit'), |
| 611 |
'type' => Controls_Manager::SLIDER, |
| 612 |
'range' => [ |
| 613 |
'px' => [ |
| 614 |
'min' => 0, |
| 615 |
'max' => 50, |
| 616 |
], |
| 617 |
], |
| 618 |
'selectors' => [ |
| 619 |
'{{WRAPPER}} .upk-amox-carousel .upk-meta > div:before' => 'margin: 0 {{SIZE}}{{UNIT}};', |
| 620 |
], |
| 621 |
] |
| 622 |
); |
| 623 |
|
| 624 |
$this->add_group_control( |
| 625 |
Group_Control_Typography::get_type(), |
| 626 |
[ |
| 627 |
'name' => 'meta_typography', |
| 628 |
'label' => esc_html__('Typography', 'ultimate-post-kit'), |
| 629 |
'selector' => '{{WRAPPER}} .upk-amox-carousel .upk-meta', |
| 630 |
] |
| 631 |
); |
| 632 |
|
| 633 |
$this->end_controls_section(); |
| 634 |
|
| 635 |
$this->start_controls_section( |
| 636 |
'section_style_category', |
| 637 |
[ |
| 638 |
'label' => esc_html__('Category', 'ultimate-post-kit'), |
| 639 |
'tab' => Controls_Manager::TAB_STYLE, |
| 640 |
'condition' => [ |
| 641 |
'show_category' => 'yes', |
| 642 |
], |
| 643 |
] |
| 644 |
); |
| 645 |
|
| 646 |
$this->add_responsive_control( |
| 647 |
'category_bottom_spacing', |
| 648 |
[ |
| 649 |
'label' => esc_html__('Spacing', 'ultimate-post-kit'), |
| 650 |
'type' => Controls_Manager::SLIDER, |
| 651 |
'range' => [ |
| 652 |
'px' => [ |
| 653 |
'min' => 0, |
| 654 |
'max' => 50, |
| 655 |
], |
| 656 |
], |
| 657 |
'selectors' => [ |
| 658 |
'{{WRAPPER}} .upk-amox-carousel .upk-category' => 'margin-bottom: {{SIZE}}{{UNIT}};', |
| 659 |
], |
| 660 |
] |
| 661 |
); |
| 662 |
|
| 663 |
$this->start_controls_tabs('tabs_category_style'); |
| 664 |
|
| 665 |
$this->start_controls_tab( |
| 666 |
'tab_category_normal', |
| 667 |
[ |
| 668 |
'label' => esc_html__('Normal', 'ultimate-post-kit'), |
| 669 |
] |
| 670 |
); |
| 671 |
|
| 672 |
$this->add_control( |
| 673 |
'category_color', |
| 674 |
[ |
| 675 |
'label' => esc_html__('Color', 'ultimate-post-kit'), |
| 676 |
'type' => Controls_Manager::COLOR, |
| 677 |
'selectors' => [ |
| 678 |
'{{WRAPPER}} .upk-amox-carousel .upk-category a' => 'color: {{VALUE}};', |
| 679 |
], |
| 680 |
] |
| 681 |
); |
| 682 |
|
| 683 |
$this->add_group_control( |
| 684 |
Group_Control_Background::get_type(), |
| 685 |
[ |
| 686 |
'name' => 'category_background', |
| 687 |
'selector' => '{{WRAPPER}} .upk-amox-carousel .upk-category a', |
| 688 |
] |
| 689 |
); |
| 690 |
|
| 691 |
$this->add_group_control( |
| 692 |
Group_Control_Border::get_type(), |
| 693 |
[ |
| 694 |
'name' => 'category_border', |
| 695 |
'selector' => '{{WRAPPER}} .upk-amox-carousel .upk-category a', |
| 696 |
] |
| 697 |
); |
| 698 |
|
| 699 |
$this->add_responsive_control( |
| 700 |
'category_border_radius', |
| 701 |
[ |
| 702 |
'label' => esc_html__('Border Radius', 'ultimate-post-kit'), |
| 703 |
'type' => Controls_Manager::DIMENSIONS, |
| 704 |
'size_units' => ['px', '%'], |
| 705 |
'selectors' => [ |
| 706 |
'{{WRAPPER}} .upk-amox-carousel .upk-category a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 707 |
], |
| 708 |
] |
| 709 |
); |
| 710 |
|
| 711 |
$this->add_responsive_control( |
| 712 |
'category_padding', |
| 713 |
[ |
| 714 |
'label' => esc_html__('Padding', 'ultimate-post-kit'), |
| 715 |
'type' => Controls_Manager::DIMENSIONS, |
| 716 |
'size_units' => ['px', 'em', '%'], |
| 717 |
'selectors' => [ |
| 718 |
'{{WRAPPER}} .upk-amox-carousel .upk-category a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 719 |
], |
| 720 |
] |
| 721 |
); |
| 722 |
|
| 723 |
$this->add_responsive_control( |
| 724 |
'category_spacing', |
| 725 |
[ |
| 726 |
'label' => esc_html__('Space Between', 'ultimate-post-kit'), |
| 727 |
'type' => Controls_Manager::SLIDER, |
| 728 |
'range' => [ |
| 729 |
'px' => [ |
| 730 |
'min' => 0, |
| 731 |
'max' => 50, |
| 732 |
'step' => 2, |
| 733 |
], |
| 734 |
], |
| 735 |
'selectors' => [ |
| 736 |
'{{WRAPPER}} .upk-amox-carousel .upk-category' => 'gap: {{SIZE}}{{UNIT}};', |
| 737 |
], |
| 738 |
] |
| 739 |
); |
| 740 |
|
| 741 |
$this->add_group_control( |
| 742 |
Group_Control_Box_Shadow::get_type(), |
| 743 |
[ |
| 744 |
'name' => 'category_shadow', |
| 745 |
'selector' => '{{WRAPPER}} .upk-amox-carousel .upk-category a', |
| 746 |
] |
| 747 |
); |
| 748 |
|
| 749 |
$this->add_group_control( |
| 750 |
Group_Control_Typography::get_type(), |
| 751 |
[ |
| 752 |
'name' => 'category_typography', |
| 753 |
'label' => esc_html__('Typography', 'ultimate-post-kit'), |
| 754 |
'selector' => '{{WRAPPER}} .upk-amox-carousel .upk-category a', |
| 755 |
] |
| 756 |
); |
| 757 |
|
| 758 |
$this->end_controls_tab(); |
| 759 |
|
| 760 |
$this->start_controls_tab( |
| 761 |
'tab_category_hover', |
| 762 |
[ |
| 763 |
'label' => esc_html__('Hover', 'ultimate-post-kit'), |
| 764 |
] |
| 765 |
); |
| 766 |
|
| 767 |
$this->add_control( |
| 768 |
'category_hover_color', |
| 769 |
[ |
| 770 |
'label' => esc_html__('Color', 'ultimate-post-kit'), |
| 771 |
'type' => Controls_Manager::COLOR, |
| 772 |
'selectors' => [ |
| 773 |
'{{WRAPPER}} .upk-amox-carousel .upk-category a:hover' => 'color: {{VALUE}};', |
| 774 |
], |
| 775 |
] |
| 776 |
); |
| 777 |
|
| 778 |
$this->add_group_control( |
| 779 |
Group_Control_Background::get_type(), |
| 780 |
[ |
| 781 |
'name' => 'category_hover_background', |
| 782 |
'selector' => '{{WRAPPER}} .upk-amox-carousel .upk-category a:hover', |
| 783 |
] |
| 784 |
); |
| 785 |
|
| 786 |
$this->add_control( |
| 787 |
'category_hover_border_color', |
| 788 |
[ |
| 789 |
'label' => esc_html__('Border Color', 'ultimate-post-kit'), |
| 790 |
'type' => Controls_Manager::COLOR, |
| 791 |
'condition' => [ |
| 792 |
'category_border_border!' => '', |
| 793 |
], |
| 794 |
'selectors' => [ |
| 795 |
'{{WRAPPER}} .upk-amox-carousel .upk-category a:hover' => 'border-color: {{VALUE}};', |
| 796 |
], |
| 797 |
] |
| 798 |
); |
| 799 |
|
| 800 |
$this->end_controls_tab(); |
| 801 |
|
| 802 |
if (_is_upk_pro_activated()) { |
| 803 |
|
| 804 |
$this->start_controls_tab( |
| 805 |
'tab_category_active', |
| 806 |
[ |
| 807 |
'label' => esc_html__('Active', 'ultimate-post-kit'), |
| 808 |
] |
| 809 |
); |
| 810 |
|
| 811 |
$this->add_control( |
| 812 |
'category_active_normal_heading', |
| 813 |
[ |
| 814 |
'label' => esc_html__('NORMAL', 'ultimate-post-kit'), |
| 815 |
'type' => Controls_Manager::HEADING, |
| 816 |
] |
| 817 |
); |
| 818 |
|
| 819 |
$this->end_controls_tab(); |
| 820 |
} |
| 821 |
|
| 822 |
$this->end_controls_tabs(); |
| 823 |
|
| 824 |
$this->end_controls_section(); |
| 825 |
|
| 826 |
//Navigation Global Controls |
| 827 |
$this->register_navigation_style('swiper'); |
| 828 |
} |
| 829 |
|
| 830 |
/** |
| 831 |
* Main query render for this widget |
| 832 |
* @param $posts_per_page number item query limit |
| 833 |
*/ |
| 834 |
public function query_posts($posts_per_page) |
| 835 |
{ |
| 836 |
|
| 837 |
$default = $this->getGroupControlQueryArgs(); |
| 838 |
$args = []; |
| 839 |
if ($posts_per_page) { |
| 840 |
$args['posts_per_page'] = $posts_per_page; |
| 841 |
} |
| 842 |
$args = array_merge($default, $args); |
| 843 |
$this->_query = new WP_Query($args); |
| 844 |
} |
| 845 |
|
| 846 |
public function render_comments($id = 0) |
| 847 |
{ |
| 848 |
|
| 849 |
if (!$this->get_settings('show_comments')) { |
| 850 |
return; |
| 851 |
} |
| 852 |
?> |
| 853 |
|
| 854 |
<div class="upk-comments upk-flex upk-flex-middle"> |
| 855 |
<i class="upk-icon-post-comments" aria-hidden="true"></i> |
| 856 |
<span><?php echo esc_html( $this->upk_get_localized_comment_count( $id ) ); ?></span> |
| 857 |
</div> |
| 858 |
|
| 859 |
<?php |
| 860 |
} |
| 861 |
|
| 862 |
public function render_header() |
| 863 |
{ |
| 864 |
//Global Function |
| 865 |
$this->render_header_attribute('amox'); |
| 866 |
|
| 867 |
?> |
| 868 |
<div <?php $this->print_render_attribute_string('carousel'); ?>> |
| 869 |
<div class="upk-post-wrapper"> |
| 870 |
<div <?php $this->print_render_attribute_string('swiper'); ?>> |
| 871 |
<div class="swiper-wrapper"> |
| 872 |
<?php |
| 873 |
} |
| 874 |
|
| 875 |
public function render_post_grid_item($post_id, $image_size, $active_item) |
| 876 |
{ |
| 877 |
$settings = $this->get_settings_for_display(); |
| 878 |
|
| 879 |
if ('yes' == $settings['global_link']) { |
| 880 |
|
| 881 |
$this->add_render_attribute('grid-item', 'onclick', "window.open('" . esc_url(get_permalink()) . "', '_self')", true); |
| 882 |
} |
| 883 |
|
| 884 |
$this->add_render_attribute('grid-item', 'class', 'upk-item swiper-slide ' . $active_item, true); |
| 885 |
|
| 886 |
?> |
| 887 |
<div <?php $this->print_render_attribute_string('grid-item'); ?>> |
| 888 |
<div class="upk-img-wrap"> |
| 889 |
<?php $this->render_image(get_post_thumbnail_id($post_id), $image_size); ?> |
| 890 |
</div> |
| 891 |
<div class="upk-content"> |
| 892 |
<?php $this->render_category(); ?> |
| 893 |
<?php $this->render_title(substr($this->get_name(), 4)); ?> |
| 894 |
|
| 895 |
<?php if ($settings['show_comments'] or $settings['show_date'] or $settings['show_reading_time']) : ?> |
| 896 |
<div class="upk-meta upk-flex-inline upk-flex-middle"> |
| 897 |
<?php $this->render_date(); ?> |
| 898 |
<?php if (_is_upk_pro_activated()) : |
| 899 |
if ('yes' === $settings['show_reading_time']) : ?> |
| 900 |
<div class="upk-reading-time" data-separator="<?php echo esc_attr($settings['meta_separator']); ?>"> |
| 901 |
<?php echo esc_html( ultimate_post_kit_reading_time( get_the_content(), $settings['avg_reading_speed'], $settings['hide_seconds'] ?? 'no', $settings['hide_minutes'] ?? 'no' ) ); ?> |
| 902 |
</div> |
| 903 |
<?php endif; ?> |
| 904 |
<?php endif; ?> |
| 905 |
<div data-separator="<?php echo esc_attr($settings['meta_separator']); ?>"> |
| 906 |
<?php $this->render_comments($post_id); ?> |
| 907 |
</div> |
| 908 |
</div> |
| 909 |
<?php endif; ?> |
| 910 |
</div> |
| 911 |
</div> |
| 912 |
|
| 913 |
|
| 914 |
<?php |
| 915 |
} |
| 916 |
|
| 917 |
public function render() |
| 918 |
{ |
| 919 |
$settings = $this->get_settings_for_display(); |
| 920 |
|
| 921 |
$this->query_posts($settings['item_limit']['size']); |
| 922 |
$wp_query = $this->get_query(); |
| 923 |
|
| 924 |
if (!$wp_query->found_posts) { |
| 925 |
return; |
| 926 |
} |
| 927 |
|
| 928 |
$this->render_header(); |
| 929 |
|
| 930 |
$i = 0; |
| 931 |
while ($wp_query->have_posts()) { |
| 932 |
$wp_query->the_post(); |
| 933 |
$thumbnail_size = $settings['primary_thumbnail_size']; |
| 934 |
|
| 935 |
$active_item = ''; |
| 936 |
$i++; |
| 937 |
if (_is_upk_pro_activated()) { |
| 938 |
$active_item = apply_filters('amox_carousel_active_item', $this, $i); |
| 939 |
} |
| 940 |
|
| 941 |
$this->render_post_grid_item(get_the_ID(), $thumbnail_size, $active_item); |
| 942 |
} |
| 943 |
|
| 944 |
$this->render_footer(); |
| 945 |
|
| 946 |
wp_reset_postdata(); |
| 947 |
} |
| 948 |
} |
| 949 |
|