| 1 |
<?php |
| 2 |
|
| 3 |
namespace UltimatePostKit\Modules\TinyList\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 |
use Elementor\Group_Control_Text_Stroke; |
| 13 |
use Elementor\Icons_Manager; |
| 14 |
|
| 15 |
use UltimatePostKit\Traits\Global_Widget_Controls; |
| 16 |
use UltimatePostKit\Traits\Global_Widget_Functions; |
| 17 |
use UltimatePostKit\Includes\Controls\GroupQuery\Group_Control_Query; |
| 18 |
use WP_Query; |
| 19 |
|
| 20 |
if (!defined('ABSPATH')) { |
| 21 |
exit; |
| 22 |
} // Exit if accessed directly |
| 23 |
|
| 24 |
class Tiny_List extends Group_Control_Query { |
| 25 |
|
| 26 |
use Global_Widget_Controls; |
| 27 |
use Global_Widget_Functions; |
| 28 |
|
| 29 |
private $_query = null; |
| 30 |
|
| 31 |
public function get_name() { |
| 32 |
return 'upk-tiny-list'; |
| 33 |
} |
| 34 |
|
| 35 |
public function get_title() { |
| 36 |
return BDTUPK . esc_html__('Tiny List', 'ultimate-post-kit'); |
| 37 |
} |
| 38 |
|
| 39 |
public function get_icon() { |
| 40 |
return 'upk-widget-icon upk-icon-tiny-list'; |
| 41 |
} |
| 42 |
|
| 43 |
public function get_categories() { |
| 44 |
return ['ultimate-post-kit']; |
| 45 |
} |
| 46 |
|
| 47 |
public function get_keywords() { |
| 48 |
return ['post', 'tiny', 'blog', 'recent', 'news', 'tiny', 'list']; |
| 49 |
} |
| 50 |
|
| 51 |
public function get_style_depends() { |
| 52 |
if ($this->upk_is_edit_mode()) { |
| 53 |
return ['upk-all-styles']; |
| 54 |
} else { |
| 55 |
return ['upk-font', 'upk-tiny-list']; |
| 56 |
} |
| 57 |
} |
| 58 |
|
| 59 |
public function get_script_depends() { |
| 60 |
if ($this->upk_is_edit_mode()) { |
| 61 |
return ['upk-all-scripts']; |
| 62 |
} else { |
| 63 |
return ['upk-ajax-loadmore']; |
| 64 |
} |
| 65 |
} |
| 66 |
|
| 67 |
public function get_custom_help_url() { |
| 68 |
return 'https://youtu.be/PZlXofIOy68'; |
| 69 |
} |
| 70 |
|
| 71 |
public function get_query() { |
| 72 |
return $this->_query; |
| 73 |
} |
| 74 |
|
| 75 |
public function has_widget_inner_wrapper(): bool { |
| 76 |
return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); |
| 77 |
} |
| 78 |
|
| 79 |
|
| 80 |
protected function register_controls() { |
| 81 |
$this->start_controls_section( |
| 82 |
'section_content_layout', |
| 83 |
[ |
| 84 |
'label' => esc_html__('Layout', 'ultimate-post-kit'), |
| 85 |
] |
| 86 |
); |
| 87 |
|
| 88 |
$this->add_responsive_control( |
| 89 |
'columns', |
| 90 |
[ |
| 91 |
'label' => __('Columns', 'ultimate-post-kit'), |
| 92 |
'type' => Controls_Manager::SELECT, |
| 93 |
'default' => '1', |
| 94 |
'tablet_default' => '1', |
| 95 |
'mobile_default' => '1', |
| 96 |
'options' => [ |
| 97 |
'1' => esc_html__('1', 'ultimate-post-kit'), |
| 98 |
'2' => esc_html__('2', 'ultimate-post-kit'), |
| 99 |
'3' => esc_html__('3', 'ultimate-post-kit'), |
| 100 |
'4' => esc_html__('4', 'ultimate-post-kit'), |
| 101 |
'5' => esc_html__('5', 'ultimate-post-kit'), |
| 102 |
'6' => esc_html__('6', 'ultimate-post-kit'), |
| 103 |
], |
| 104 |
'selectors' => [ |
| 105 |
'{{WRAPPER}} .upk-tiny-list' => 'grid-template-columns: repeat({{SIZE}}, 1fr);', |
| 106 |
], |
| 107 |
] |
| 108 |
); |
| 109 |
|
| 110 |
$this->add_responsive_control( |
| 111 |
'row_gap', |
| 112 |
[ |
| 113 |
'label' => esc_html__('Row Gap', 'ultimate-post-kit'), |
| 114 |
'type' => Controls_Manager::SLIDER, |
| 115 |
'default' => [ |
| 116 |
'size' => 10, |
| 117 |
], |
| 118 |
'selectors' => [ |
| 119 |
'{{WRAPPER}} .upk-tiny-list' => 'grid-row-gap: {{SIZE}}{{UNIT}};', |
| 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' => 10, |
| 131 |
], |
| 132 |
'selectors' => [ |
| 133 |
'{{WRAPPER}} .upk-tiny-list' => 'grid-column-gap: {{SIZE}}{{UNIT}};', |
| 134 |
], |
| 135 |
] |
| 136 |
); |
| 137 |
|
| 138 |
$this->add_control( |
| 139 |
'show_title', |
| 140 |
[ |
| 141 |
'label' => esc_html__('Show Title', 'ultimate-post-kit'), |
| 142 |
'type' => Controls_Manager::SWITCHER, |
| 143 |
'default' => 'yes', |
| 144 |
'separator' => 'before' |
| 145 |
] |
| 146 |
); |
| 147 |
|
| 148 |
$this->add_control( |
| 149 |
'title_tags', |
| 150 |
[ |
| 151 |
'label' => __('Title HTML Tag', 'ultimate-post-kit'), |
| 152 |
'type' => Controls_Manager::SELECT, |
| 153 |
'default' => 'h3', |
| 154 |
'options' => ultimate_post_kit_title_tags(), |
| 155 |
] |
| 156 |
); |
| 157 |
|
| 158 |
$this->add_control( |
| 159 |
'hr_1', |
| 160 |
[ |
| 161 |
'type' => Controls_Manager::DIVIDER, |
| 162 |
] |
| 163 |
); |
| 164 |
|
| 165 |
$this->add_control( |
| 166 |
'show_image', |
| 167 |
[ |
| 168 |
'label' => esc_html__('Show Image', 'ultimate-post-kit'), |
| 169 |
'type' => Controls_Manager::SWITCHER, |
| 170 |
] |
| 171 |
); |
| 172 |
|
| 173 |
$this->add_group_control( |
| 174 |
Group_Control_Image_Size::get_type(), |
| 175 |
[ |
| 176 |
'name' => 'primary_thumbnail', |
| 177 |
// phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Elementor widget query built from user-configured controls; expected behaviour. |
| 178 |
'exclude' => ['custom'], |
| 179 |
'default' => 'thumbnail', |
| 180 |
'condition' => [ |
| 181 |
'show_image' => 'yes' |
| 182 |
] |
| 183 |
] |
| 184 |
); |
| 185 |
|
| 186 |
$this->add_control( |
| 187 |
'hr', |
| 188 |
[ |
| 189 |
'type' => Controls_Manager::DIVIDER, |
| 190 |
'condition' => [ |
| 191 |
'show_image' => 'yes' |
| 192 |
] |
| 193 |
] |
| 194 |
); |
| 195 |
|
| 196 |
$this->add_control( |
| 197 |
'show_counter_number', |
| 198 |
[ |
| 199 |
'label' => esc_html__('Show Counter Number', 'ultimate-post-kit'), |
| 200 |
'type' => Controls_Manager::SWITCHER, |
| 201 |
// 'default' => 'yes', |
| 202 |
] |
| 203 |
); |
| 204 |
|
| 205 |
$this->add_control( |
| 206 |
'show_item_icon', |
| 207 |
[ |
| 208 |
'label' => esc_html__('Icon', 'ultimate-post-kit'), |
| 209 |
'type' => Controls_Manager::ICONS, |
| 210 |
'label_block' => false, |
| 211 |
'skin' => 'inline', |
| 212 |
] |
| 213 |
); |
| 214 |
|
| 215 |
$this->add_control( |
| 216 |
'show_pagination', |
| 217 |
[ |
| 218 |
'label' => esc_html__('Show Pagination', 'ultimate-post-kit'), |
| 219 |
'type' => Controls_Manager::SWITCHER, |
| 220 |
'separator' => 'before' |
| 221 |
] |
| 222 |
); |
| 223 |
|
| 224 |
//Global Ajax Controls |
| 225 |
$this->register_ajax_loadmore_controls(); |
| 226 |
|
| 227 |
$this->add_control( |
| 228 |
'global_link', |
| 229 |
[ |
| 230 |
'label' => __('Item Wrapper Link', 'ultimate-post-kit'), |
| 231 |
'type' => Controls_Manager::SWITCHER, |
| 232 |
'prefix_class' => 'upk-global-link-', |
| 233 |
'description' => __('Be aware! When Item Wrapper Link activated then title link and read more link will not work', 'ultimate-post-kit'), |
| 234 |
'separator' => 'before' |
| 235 |
] |
| 236 |
); |
| 237 |
|
| 238 |
$this->end_controls_section(); |
| 239 |
|
| 240 |
// Query Settings |
| 241 |
$this->start_controls_section( |
| 242 |
'section_post_query_builder', |
| 243 |
[ |
| 244 |
'label' => __('Query', 'ultimate-post-kit'), |
| 245 |
'tab' => Controls_Manager::TAB_CONTENT, |
| 246 |
] |
| 247 |
); |
| 248 |
|
| 249 |
$this->add_control( |
| 250 |
'item_limit', |
| 251 |
[ |
| 252 |
'label' => esc_html__('Item Limit', 'ultimate-post-kit'), |
| 253 |
'type' => Controls_Manager::SLIDER, |
| 254 |
'range' => [ |
| 255 |
'px' => [ |
| 256 |
'min' => 1, |
| 257 |
'max' => 20, |
| 258 |
], |
| 259 |
], |
| 260 |
'default' => [ |
| 261 |
'size' => 4, |
| 262 |
], |
| 263 |
'condition' => [ |
| 264 |
'posts_source!' => 'current_query', |
| 265 |
] |
| 266 |
] |
| 267 |
); |
| 268 |
|
| 269 |
$this->register_query_builder_controls(); |
| 270 |
|
| 271 |
$this->end_controls_section(); |
| 272 |
|
| 273 |
//Style |
| 274 |
$this->start_controls_section( |
| 275 |
'upk_section_style', |
| 276 |
[ |
| 277 |
'label' => esc_html__('Item', 'ultimate-post-kit'), |
| 278 |
'tab' => Controls_Manager::TAB_STYLE, |
| 279 |
] |
| 280 |
); |
| 281 |
|
| 282 |
$this->start_controls_tabs('tabs_item_style'); |
| 283 |
|
| 284 |
$this->start_controls_tab( |
| 285 |
'tab_item_normal', |
| 286 |
[ |
| 287 |
'label' => esc_html__('Normal', 'ultimate-post-kit'), |
| 288 |
] |
| 289 |
); |
| 290 |
|
| 291 |
$this->add_group_control( |
| 292 |
Group_Control_Background::get_type(), |
| 293 |
[ |
| 294 |
'name' => 'item_background', |
| 295 |
'selector' => '{{WRAPPER}} .upk-tiny-list .upk-item', |
| 296 |
] |
| 297 |
); |
| 298 |
|
| 299 |
$this->add_group_control( |
| 300 |
Group_Control_Border::get_type(), |
| 301 |
[ |
| 302 |
'name' => 'item_border', |
| 303 |
'selector' => '{{WRAPPER}} .upk-tiny-list .upk-item', |
| 304 |
] |
| 305 |
); |
| 306 |
|
| 307 |
$this->add_responsive_control( |
| 308 |
'item_border_radius', |
| 309 |
[ |
| 310 |
'label' => esc_html__('Border Radius', 'ultimate-post-kit'), |
| 311 |
'type' => Controls_Manager::DIMENSIONS, |
| 312 |
'size_units' => ['px', '%'], |
| 313 |
'selectors' => [ |
| 314 |
'{{WRAPPER}} .upk-tiny-list .upk-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 315 |
], |
| 316 |
] |
| 317 |
); |
| 318 |
|
| 319 |
$this->add_responsive_control( |
| 320 |
'item_padding', |
| 321 |
[ |
| 322 |
'label' => esc_html__('Padding', 'ultimate-post-kit'), |
| 323 |
'type' => Controls_Manager::DIMENSIONS, |
| 324 |
'size_units' => ['px', 'em', '%'], |
| 325 |
'selectors' => [ |
| 326 |
'{{WRAPPER}} .upk-tiny-list .upk-item' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 327 |
], |
| 328 |
] |
| 329 |
); |
| 330 |
|
| 331 |
$this->add_group_control( |
| 332 |
Group_Control_Box_Shadow::get_type(), |
| 333 |
[ |
| 334 |
'name' => 'item_shadow', |
| 335 |
'selector' => '{{WRAPPER}} .upk-tiny-list .upk-item', |
| 336 |
] |
| 337 |
); |
| 338 |
|
| 339 |
$this->end_controls_tab(); |
| 340 |
|
| 341 |
$this->start_controls_tab( |
| 342 |
'tab_item_hover', |
| 343 |
[ |
| 344 |
'label' => esc_html__('Hover', 'ultimate-post-kit'), |
| 345 |
] |
| 346 |
); |
| 347 |
|
| 348 |
$this->add_group_control( |
| 349 |
Group_Control_Background::get_type(), |
| 350 |
[ |
| 351 |
'name' => 'item_hover_background', |
| 352 |
'selector' => '{{WRAPPER}} .upk-tiny-list .upk-item:hover', |
| 353 |
] |
| 354 |
); |
| 355 |
|
| 356 |
$this->add_control( |
| 357 |
'item_hover_border_color', |
| 358 |
[ |
| 359 |
'label' => esc_html__('Border Color', 'ultimate-post-kit'), |
| 360 |
'type' => Controls_Manager::COLOR, |
| 361 |
'condition' => [ |
| 362 |
'item_border_border!' => '', |
| 363 |
], |
| 364 |
'selectors' => [ |
| 365 |
'{{WRAPPER}} .upk-tiny-list .upk-item:hover' => 'border-color: {{VALUE}};', |
| 366 |
], |
| 367 |
] |
| 368 |
); |
| 369 |
|
| 370 |
$this->add_group_control( |
| 371 |
Group_Control_Box_Shadow::get_type(), |
| 372 |
[ |
| 373 |
'name' => 'item_hover_shadow', |
| 374 |
'selector' => '{{WRAPPER}} .upk-tiny-list .upk-item:hover', |
| 375 |
] |
| 376 |
); |
| 377 |
|
| 378 |
$this->end_controls_tab(); |
| 379 |
|
| 380 |
$this->end_controls_tabs(); |
| 381 |
|
| 382 |
$this->end_controls_section(); |
| 383 |
|
| 384 |
$this->start_controls_section( |
| 385 |
'section_style_image', |
| 386 |
[ |
| 387 |
'label' => esc_html__('Image', 'ultimate-post-kit'), |
| 388 |
'tab' => Controls_Manager::TAB_STYLE, |
| 389 |
'condition' => [ |
| 390 |
'show_image' => 'yes', |
| 391 |
], |
| 392 |
] |
| 393 |
); |
| 394 |
|
| 395 |
$this->add_responsive_control( |
| 396 |
'item_image_size', |
| 397 |
[ |
| 398 |
'label' => esc_html__('Size', 'ultimate-post-kit'), |
| 399 |
'type' => Controls_Manager::SLIDER, |
| 400 |
'range' => [ |
| 401 |
'px' => [ |
| 402 |
'min' => 10, |
| 403 |
'max' => 100, |
| 404 |
], |
| 405 |
], |
| 406 |
'selectors' => [ |
| 407 |
'{{WRAPPER}} .upk-tiny-list .upk-item .upk-img' => 'height: {{SIZE}}{{UNIT}}; width: {{SIZE}}{{UNIT}};', |
| 408 |
], |
| 409 |
] |
| 410 |
); |
| 411 |
|
| 412 |
$this->add_group_control( |
| 413 |
Group_Control_Border::get_type(), |
| 414 |
[ |
| 415 |
'name' => 'item_image_border', |
| 416 |
'selector' => '{{WRAPPER}} .upk-tiny-list .upk-item .upk-img', |
| 417 |
] |
| 418 |
); |
| 419 |
|
| 420 |
$this->add_responsive_control( |
| 421 |
'item_image_border_radius', |
| 422 |
[ |
| 423 |
'label' => esc_html__('Border Radius', 'ultimate-post-kit'), |
| 424 |
'type' => Controls_Manager::DIMENSIONS, |
| 425 |
'size_units' => ['px', '%'], |
| 426 |
'selectors' => [ |
| 427 |
'{{WRAPPER}} .upk-tiny-list .upk-item .upk-img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 428 |
], |
| 429 |
] |
| 430 |
); |
| 431 |
|
| 432 |
$this->add_responsive_control( |
| 433 |
'item_image_padding', |
| 434 |
[ |
| 435 |
'label' => esc_html__('Padding', 'ultimate-post-kit'), |
| 436 |
'type' => Controls_Manager::DIMENSIONS, |
| 437 |
'size_units' => ['px', 'em', '%'], |
| 438 |
'selectors' => [ |
| 439 |
'{{WRAPPER}} .upk-tiny-list .upk-item .upk-img' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 440 |
], |
| 441 |
] |
| 442 |
); |
| 443 |
|
| 444 |
$this->add_responsive_control( |
| 445 |
'item_image_margin', |
| 446 |
[ |
| 447 |
'label' => esc_html__('Margin', 'ultimate-post-kit'), |
| 448 |
'type' => Controls_Manager::DIMENSIONS, |
| 449 |
'size_units' => ['px', 'em', '%'], |
| 450 |
'selectors' => [ |
| 451 |
'{{WRAPPER}} .upk-tiny-list .upk-item .upk-img' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 452 |
], |
| 453 |
] |
| 454 |
); |
| 455 |
|
| 456 |
$this->add_group_control( |
| 457 |
Group_Control_Box_Shadow::get_type(), |
| 458 |
[ |
| 459 |
'name' => 'item_image_shadow', |
| 460 |
'selector' => '{{WRAPPER}} .upk-tiny-list .upk-item .upk-img', |
| 461 |
] |
| 462 |
); |
| 463 |
|
| 464 |
$this->end_controls_section(); |
| 465 |
|
| 466 |
$this->start_controls_section( |
| 467 |
'section_style_icon', |
| 468 |
[ |
| 469 |
'label' => esc_html__('Icon', 'ultimate-post-kit'), |
| 470 |
'tab' => Controls_Manager::TAB_STYLE, |
| 471 |
'condition' => [ |
| 472 |
'show_item_icon[value]!' => '', |
| 473 |
], |
| 474 |
] |
| 475 |
); |
| 476 |
|
| 477 |
$this->add_control( |
| 478 |
'item_icon_color', |
| 479 |
[ |
| 480 |
'label' => esc_html__('Color', 'ultimate-post-kit'), |
| 481 |
'type' => Controls_Manager::COLOR, |
| 482 |
'selectors' => [ |
| 483 |
'{{WRAPPER}} .upk-tiny-list .upk-item .upk-title-icon i' => 'color: {{VALUE}};', |
| 484 |
'{{WRAPPER}} .upk-tiny-list .upk-item .upk-title-icon svg *' => 'fill: {{VALUE}};', |
| 485 |
], |
| 486 |
] |
| 487 |
); |
| 488 |
|
| 489 |
$this->add_group_control( |
| 490 |
Group_Control_Background::get_type(), |
| 491 |
[ |
| 492 |
'name' => 'item_icon_background', |
| 493 |
'selector' => '{{WRAPPER}} .upk-tiny-list .upk-item .upk-title-icon', |
| 494 |
] |
| 495 |
); |
| 496 |
|
| 497 |
$this->add_group_control( |
| 498 |
Group_Control_Border::get_type(), |
| 499 |
[ |
| 500 |
'name' => 'item_icon_border', |
| 501 |
'selector' => '{{WRAPPER}} .upk-tiny-list .upk-item .upk-title-icon', |
| 502 |
] |
| 503 |
); |
| 504 |
|
| 505 |
$this->add_responsive_control( |
| 506 |
'item_icon_border_radius', |
| 507 |
[ |
| 508 |
'label' => esc_html__('Border Radius', 'ultimate-post-kit'), |
| 509 |
'type' => Controls_Manager::DIMENSIONS, |
| 510 |
'size_units' => ['px', '%'], |
| 511 |
'selectors' => [ |
| 512 |
'{{WRAPPER}} .upk-tiny-list .upk-item .upk-title-icon' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 513 |
], |
| 514 |
] |
| 515 |
); |
| 516 |
|
| 517 |
$this->add_responsive_control( |
| 518 |
'item_icon_padding', |
| 519 |
[ |
| 520 |
'label' => esc_html__('Padding', 'ultimate-post-kit'), |
| 521 |
'type' => Controls_Manager::DIMENSIONS, |
| 522 |
'size_units' => ['px', 'em', '%'], |
| 523 |
'selectors' => [ |
| 524 |
'{{WRAPPER}} .upk-tiny-list .upk-item .upk-title-icon' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 525 |
], |
| 526 |
] |
| 527 |
); |
| 528 |
|
| 529 |
$this->add_responsive_control( |
| 530 |
'item_icon_margin', |
| 531 |
[ |
| 532 |
'label' => esc_html__('Margin', 'ultimate-post-kit'), |
| 533 |
'type' => Controls_Manager::DIMENSIONS, |
| 534 |
'size_units' => ['px', 'em', '%'], |
| 535 |
'selectors' => [ |
| 536 |
'{{WRAPPER}} .upk-tiny-list .upk-item .upk-title-icon' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 537 |
], |
| 538 |
] |
| 539 |
); |
| 540 |
|
| 541 |
$this->add_group_control( |
| 542 |
Group_Control_Box_Shadow::get_type(), |
| 543 |
[ |
| 544 |
'name' => 'item_icon_shadow', |
| 545 |
'selector' => '{{WRAPPER}} .upk-tiny-list .upk-item .upk-title-icon', |
| 546 |
] |
| 547 |
); |
| 548 |
|
| 549 |
$this->add_responsive_control( |
| 550 |
'icon_size', |
| 551 |
[ |
| 552 |
'label' => esc_html__('Size', 'ultimate-post-kit'), |
| 553 |
'type' => Controls_Manager::SLIDER, |
| 554 |
'range' => [ |
| 555 |
'px' => [ |
| 556 |
'min' => 10, |
| 557 |
'max' => 100, |
| 558 |
], |
| 559 |
], |
| 560 |
'selectors' => [ |
| 561 |
'{{WRAPPER}} .upk-tiny-list .upk-item .upk-title-icon' => 'font-size: {{SIZE}}{{UNIT}};', |
| 562 |
], |
| 563 |
] |
| 564 |
); |
| 565 |
|
| 566 |
$this->end_controls_section(); |
| 567 |
|
| 568 |
$this->start_controls_section( |
| 569 |
'section_style_title', |
| 570 |
[ |
| 571 |
'label' => esc_html__('Title', 'ultimate-post-kit'), |
| 572 |
'tab' => Controls_Manager::TAB_STYLE, |
| 573 |
'condition' => [ |
| 574 |
'show_title' => 'yes' |
| 575 |
] |
| 576 |
] |
| 577 |
); |
| 578 |
|
| 579 |
$this->add_control( |
| 580 |
'title_style', |
| 581 |
[ |
| 582 |
'label' => esc_html__('Style', 'ultimate-post-kit'), |
| 583 |
'type' => Controls_Manager::SELECT, |
| 584 |
'default' => 'underline', |
| 585 |
'options' => [ |
| 586 |
'' => esc_html__('Default', 'ultimate-post-kit'), |
| 587 |
'underline' => esc_html__('Underline', 'ultimate-post-kit'), |
| 588 |
'middle-underline' => esc_html__('Middle Underline', 'ultimate-post-kit'), |
| 589 |
'overline' => esc_html__('Overline', 'ultimate-post-kit'), |
| 590 |
'middle-overline' => esc_html__('Middle Overline', 'ultimate-post-kit'), |
| 591 |
], |
| 592 |
] |
| 593 |
); |
| 594 |
|
| 595 |
$this->add_control( |
| 596 |
'title_color', |
| 597 |
[ |
| 598 |
'label' => esc_html__('Color', 'ultimate-post-kit'), |
| 599 |
'type' => Controls_Manager::COLOR, |
| 600 |
'selectors' => [ |
| 601 |
'{{WRAPPER}} .upk-tiny-list .upk-item .upk-title a' => 'color: {{VALUE}};', |
| 602 |
], |
| 603 |
'separator' => 'before' |
| 604 |
] |
| 605 |
); |
| 606 |
|
| 607 |
$this->add_control( |
| 608 |
'title_hover_color', |
| 609 |
[ |
| 610 |
'label' => esc_html__('Hover Color', 'ultimate-post-kit'), |
| 611 |
'type' => Controls_Manager::COLOR, |
| 612 |
'selectors' => [ |
| 613 |
'{{WRAPPER}} .upk-tiny-list .upk-item .upk-title a:hover' => 'color: {{VALUE}};', |
| 614 |
], |
| 615 |
] |
| 616 |
); |
| 617 |
|
| 618 |
$this->add_group_control( |
| 619 |
Group_Control_Typography::get_type(), |
| 620 |
[ |
| 621 |
'name' => 'title_typography', |
| 622 |
'label' => esc_html__('Typography', 'ultimate-post-kit'), |
| 623 |
'selector' => '{{WRAPPER}} .upk-tiny-list .upk-item .upk-title', |
| 624 |
] |
| 625 |
); |
| 626 |
|
| 627 |
$this->add_group_control( |
| 628 |
Group_Control_Text_Shadow::get_type(), |
| 629 |
[ |
| 630 |
'name' => 'title_text_shadow', |
| 631 |
'label' => __('Text Shadow', 'ultimate-post-kit'), |
| 632 |
'selector' => '{{WRAPPER}} .upk-tiny-list .upk-item .upk-title', |
| 633 |
] |
| 634 |
); |
| 635 |
|
| 636 |
$this->add_group_control( |
| 637 |
Group_Control_Text_Stroke::get_type(), |
| 638 |
[ |
| 639 |
'name' => 'title_text_stroke', |
| 640 |
'label' => esc_html__('Text Stroke', 'ultimate-post-kit'), |
| 641 |
'selector' => '{{WRAPPER}} .upk-tiny-list .upk-item .upk-title a', |
| 642 |
] |
| 643 |
); |
| 644 |
|
| 645 |
$this->add_control( |
| 646 |
'title_hover_transition_duration', |
| 647 |
[ |
| 648 |
'label' => esc_html__( 'Transition Duration', 'ultimate-post-kit' ), |
| 649 |
'type' => Controls_Manager::SLIDER, |
| 650 |
'size_units' => [ 's', 'ms', 'custom' ], |
| 651 |
'default' => [ |
| 652 |
'unit' => 's', |
| 653 |
], |
| 654 |
'selectors' => [ |
| 655 |
'{{WRAPPER}} .upk-tiny-list .upk-item .upk-title a' => 'transition-duration: {{SIZE}}{{UNIT}};', |
| 656 |
], |
| 657 |
] |
| 658 |
); |
| 659 |
|
| 660 |
$this->end_controls_section(); |
| 661 |
|
| 662 |
$this->start_controls_section( |
| 663 |
'section_style_counter_number', |
| 664 |
[ |
| 665 |
'label' => esc_html__('Counter Number', 'ultimate-post-kit'), |
| 666 |
'tab' => Controls_Manager::TAB_STYLE, |
| 667 |
'condition' => [ |
| 668 |
'show_counter_number' => 'yes', |
| 669 |
] |
| 670 |
] |
| 671 |
); |
| 672 |
|
| 673 |
$this->add_control( |
| 674 |
'counter_number_color', |
| 675 |
[ |
| 676 |
'label' => esc_html__('Color', 'ultimate-post-kit'), |
| 677 |
'type' => Controls_Manager::COLOR, |
| 678 |
'selectors' => [ |
| 679 |
'{{WRAPPER}} .upk-tiny-list .upk-item .upk-counter:before' => 'color: {{VALUE}};', |
| 680 |
], |
| 681 |
] |
| 682 |
); |
| 683 |
|
| 684 |
$this->add_group_control( |
| 685 |
Group_Control_Background::get_type(), |
| 686 |
[ |
| 687 |
'name' => 'counter_number_background', |
| 688 |
'selector' => '{{WRAPPER}} .upk-tiny-list .upk-item .upk-counter', |
| 689 |
] |
| 690 |
); |
| 691 |
|
| 692 |
$this->add_group_control( |
| 693 |
Group_Control_Border::get_type(), |
| 694 |
[ |
| 695 |
'name' => 'counter_number_border', |
| 696 |
'selector' => '{{WRAPPER}} .upk-tiny-list .upk-item .upk-counter', |
| 697 |
] |
| 698 |
); |
| 699 |
|
| 700 |
$this->add_responsive_control( |
| 701 |
'counter_number_border_radius', |
| 702 |
[ |
| 703 |
'label' => esc_html__('Border Radius', 'ultimate-post-kit'), |
| 704 |
'type' => Controls_Manager::DIMENSIONS, |
| 705 |
'size_units' => ['px', '%'], |
| 706 |
'selectors' => [ |
| 707 |
'{{WRAPPER}} .upk-tiny-list .upk-item .upk-counter' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 708 |
], |
| 709 |
] |
| 710 |
); |
| 711 |
|
| 712 |
$this->add_responsive_control( |
| 713 |
'counter_number_spacing', |
| 714 |
[ |
| 715 |
'label' => esc_html__('Spacing', 'ultimate-post-kit'), |
| 716 |
'type' => Controls_Manager::SLIDER, |
| 717 |
'range' => [ |
| 718 |
'px' => [ |
| 719 |
'min' => 0, |
| 720 |
'max' => 50, |
| 721 |
], |
| 722 |
], |
| 723 |
'selectors' => [ |
| 724 |
'{{WRAPPER}} .upk-tiny-list .upk-item .upk-counter' => 'margin-right: {{SIZE}}{{UNIT}};', |
| 725 |
], |
| 726 |
] |
| 727 |
); |
| 728 |
|
| 729 |
$this->add_responsive_control( |
| 730 |
'counter_number_size', |
| 731 |
[ |
| 732 |
'label' => esc_html__('Counter Size', 'ultimate-post-kit'), |
| 733 |
'type' => Controls_Manager::SLIDER, |
| 734 |
'range' => [ |
| 735 |
'px' => [ |
| 736 |
'min' => 20, |
| 737 |
'max' => 100, |
| 738 |
], |
| 739 |
], |
| 740 |
'selectors' => [ |
| 741 |
'{{WRAPPER}} .upk-tiny-list .upk-item .upk-counter' => 'height: {{SIZE}}{{UNIT}}; width: {{SIZE}}{{UNIT}}; min-width: {{SIZE}}{{UNIT}};', |
| 742 |
], |
| 743 |
] |
| 744 |
); |
| 745 |
|
| 746 |
$this->add_group_control( |
| 747 |
Group_Control_Typography::get_type(), |
| 748 |
[ |
| 749 |
'name' => 'counter_number_typography', |
| 750 |
'label' => esc_html__('Typography', 'ultimate-post-kit'), |
| 751 |
'selector' => '{{WRAPPER}} .upk-tiny-list .upk-item .upk-counter:before', |
| 752 |
] |
| 753 |
); |
| 754 |
|
| 755 |
$this->end_controls_section(); |
| 756 |
|
| 757 |
//Global Pagination Controls |
| 758 |
$this->register_pagination_controls(); |
| 759 |
|
| 760 |
//Global Ajax Loadmore Style Controls |
| 761 |
$this->register_ajax_loadmore_style_controls(); |
| 762 |
} |
| 763 |
|
| 764 |
/** |
| 765 |
* Get post query builder arguments |
| 766 |
*/ |
| 767 |
public function query_posts( $posts_per_page ) { |
| 768 |
$settings = $this->get_settings(); |
| 769 |
$posts_per_page = isset( $posts_per_page ) ? (int) $posts_per_page : 0; |
| 770 |
$args = $this->getGroupControlQueryArgs(); |
| 771 |
$is_current_query = ( ! empty( $settings['posts_source'] ) && $settings['posts_source'] === 'current_query' ); |
| 772 |
|
| 773 |
if ( $is_current_query ) { |
| 774 |
unset( $args['offset'] ); |
| 775 |
unset( $args['no_found_rows'] ); |
| 776 |
$posts_per_page = 0; |
| 777 |
} |
| 778 |
|
| 779 |
if ( $posts_per_page > 0 ) { |
| 780 |
$args['posts_per_page'] = $posts_per_page; |
| 781 |
} else { |
| 782 |
$args['posts_per_page'] = (int) get_option( 'posts_per_page', 10 ); |
| 783 |
} |
| 784 |
|
| 785 |
if ( $settings['show_pagination'] ) { |
| 786 |
$args['paged'] = max( 1, (int) get_query_var( 'paged' ), (int) get_query_var( 'page' ) ); |
| 787 |
} |
| 788 |
|
| 789 |
$this->_query = new \WP_Query( $args ); |
| 790 |
} |
| 791 |
|
| 792 |
public function render_post_grid_item($post_id, $image_size) { |
| 793 |
$settings = $this->get_settings_for_display(); |
| 794 |
|
| 795 |
if ('yes' == $settings['global_link']) { |
| 796 |
|
| 797 |
$this->add_render_attribute('list-item', 'onclick', "window.open('" . esc_url(get_permalink()) . "', '_self')", true); |
| 798 |
} |
| 799 |
$this->add_render_attribute('list-item', 'class', 'upk-item', true); |
| 800 |
|
| 801 |
?> |
| 802 |
<div <?php $this->print_render_attribute_string('list-item'); ?>> |
| 803 |
<div class="upk-content upk-flex upk-flex-middle"> |
| 804 |
|
| 805 |
<?php if ($settings['show_counter_number'] == 'yes') : ?> |
| 806 |
<div class="upk-counter"></div> |
| 807 |
<?php endif; ?> |
| 808 |
|
| 809 |
<?php if ($settings['show_image'] == 'yes') : ?> |
| 810 |
<?php $this->render_image(get_post_thumbnail_id($post_id), $image_size); ?> |
| 811 |
<?php endif; ?> |
| 812 |
|
| 813 |
<?php if ($settings['show_item_icon']['value']) : ?> |
| 814 |
<div class="upk-title-icon"> |
| 815 |
<?php Icons_Manager::render_icon($settings['show_item_icon'], ['aria-hidden' => 'true', 'class' => 'fa-fw']); ?> |
| 816 |
</div> |
| 817 |
<?php endif; ?> |
| 818 |
|
| 819 |
<?php $this->render_title(substr($this->get_name(), 4)); ?> |
| 820 |
</div> |
| 821 |
</div> |
| 822 |
|
| 823 |
<?php |
| 824 |
} |
| 825 |
|
| 826 |
protected function render() { |
| 827 |
$settings = $this->get_settings_for_display(); |
| 828 |
|
| 829 |
$this->query_posts($settings['item_limit']['size']); |
| 830 |
$wp_query = $this->get_query(); |
| 831 |
|
| 832 |
if (!$wp_query->found_posts) { |
| 833 |
return; |
| 834 |
} |
| 835 |
|
| 836 |
$this->add_render_attribute('list-wrap', 'class', 'upk-tiny-list upk-ajax-grid-wrap'); |
| 837 |
|
| 838 |
$this->add_render_attribute( |
| 839 |
[ |
| 840 |
'upk-tiny-list' => [ |
| 841 |
'class' => 'upk-tiny-list-container upk-ajax-grid', |
| 842 |
'data-loadmore' => [ |
| 843 |
wp_json_encode( |
| 844 |
array_filter([ |
| 845 |
'loadmore_enable' => $settings['ajax_loadmore_enable'], |
| 846 |
'loadmore_btn' => $settings['ajax_loadmore_btn'], |
| 847 |
'infinite_scroll' => $settings['ajax_loadmore_infinite_scroll'], |
| 848 |
]) |
| 849 |
), |
| 850 |
], |
| 851 |
], |
| 852 |
] |
| 853 |
); |
| 854 |
|
| 855 |
if ($settings['ajax_loadmore_enable'] == 'yes') { |
| 856 |
$ajax_settings = [ |
| 857 |
'posts_source' => isset($settings['posts_source']) ? $settings['posts_source'] : 'post', |
| 858 |
'posts_per_page' => isset($settings['item_limit']['size']) ? $settings['item_limit']['size'] : 4, |
| 859 |
'ajax_item_load' => isset($settings['ajax_loadmore_items']) ? $settings['ajax_loadmore_items'] : 3, |
| 860 |
'posts_selected_ids' => isset($settings['posts_selected_ids']) ? $settings['posts_selected_ids'] : '', |
| 861 |
'posts_include_by' => isset($settings['posts_include_by']) ? $settings['posts_include_by'] : [], |
| 862 |
'posts_include_author_ids' => isset($settings['posts_include_author_ids']) ? $settings['posts_include_author_ids'] : '', |
| 863 |
'posts_include_term_ids' => isset($settings['posts_include_term_ids']) ? $settings['posts_include_term_ids'] : '', |
| 864 |
'posts_exclude_by' => isset($settings['posts_exclude_by']) ? $settings['posts_exclude_by'] : [], |
| 865 |
'posts_exclude_ids' => isset($settings['posts_exclude_ids']) ? $settings['posts_exclude_ids'] : '', |
| 866 |
'posts_exclude_author_ids' => isset($settings['posts_exclude_author_ids']) ? $settings['posts_exclude_author_ids'] : '', |
| 867 |
'posts_exclude_term_ids' => isset($settings['posts_exclude_term_ids']) ? $settings['posts_exclude_term_ids'] : '', |
| 868 |
'posts_offset' => isset($settings['posts_offset']) ? $settings['posts_offset'] : 0, |
| 869 |
'posts_select_date' => isset($settings['posts_select_date']) ? $settings['posts_select_date'] : '', |
| 870 |
'posts_date_before' => isset($settings['posts_date_before']) ? $settings['posts_date_before'] : '', |
| 871 |
'posts_date_after' => isset($settings['posts_date_after']) ? $settings['posts_date_after'] : '', |
| 872 |
'posts_orderby' => isset($settings['posts_orderby']) ? $settings['posts_orderby'] : 'date', |
| 873 |
'posts_order' => isset($settings['posts_order']) ? $settings['posts_order'] : 'DESC', |
| 874 |
'posts_ignore_sticky_posts' => isset($settings['posts_ignore_sticky_posts']) ? $settings['posts_ignore_sticky_posts'] : 'no', |
| 875 |
'posts_only_with_featured_image'=> isset($settings['posts_only_with_featured_image']) ? $settings['posts_only_with_featured_image'] : 'no', |
| 876 |
// List Settings |
| 877 |
'show_title' => isset($settings['show_title']) ? $settings['show_title'] : 'yes', |
| 878 |
'title_tags' => isset( $settings['title_tags'] ) ? $settings['title_tags'] : 'h3', |
| 879 |
'title_style' => isset($settings['title_style']) ? $settings['title_style'] : '', |
| 880 |
'show_image' => isset($settings['show_image']) ? $settings['show_image'] : 'no', |
| 881 |
'primary_thumbnail_size' => isset($settings['primary_thumbnail_size']) ? $settings['primary_thumbnail_size'] : 'thumbnail', |
| 882 |
'show_counter_number' => isset($settings['show_counter_number']) ? $settings['show_counter_number'] : 'no', |
| 883 |
'show_item_icon' => isset($settings['show_item_icon']) ? $settings['show_item_icon'] : [], |
| 884 |
'global_link' => isset($settings['global_link']) ? $settings['global_link'] : 'no', |
| 885 |
]; |
| 886 |
|
| 887 |
$this->add_render_attribute( |
| 888 |
[ |
| 889 |
'upk-tiny-list' => [ |
| 890 |
'data-settings' => [ |
| 891 |
wp_json_encode($ajax_settings) |
| 892 |
], |
| 893 |
], |
| 894 |
] |
| 895 |
); |
| 896 |
} |
| 897 |
|
| 898 |
if (isset($settings['upk_in_animation_show']) && ($settings['upk_in_animation_show'] == 'yes')) { |
| 899 |
$this->add_render_attribute('list-wrap', 'class', 'upk-in-animation'); |
| 900 |
if (isset($settings['upk_in_animation_delay']['size'])) { |
| 901 |
$this->add_render_attribute('list-wrap', 'data-in-animation-delay', $settings['upk_in_animation_delay']['size']); |
| 902 |
} |
| 903 |
} |
| 904 |
|
| 905 |
?> |
| 906 |
<div <?php $this->print_render_attribute_string('upk-tiny-list'); ?>> |
| 907 |
<div <?php $this->print_render_attribute_string('list-wrap'); ?>> |
| 908 |
<?php while ($wp_query->have_posts()) : |
| 909 |
$wp_query->the_post(); |
| 910 |
|
| 911 |
$thumbnail_size = $settings['primary_thumbnail_size']; |
| 912 |
|
| 913 |
?> |
| 914 |
|
| 915 |
<?php $this->render_post_grid_item(get_the_ID(), $thumbnail_size); ?> |
| 916 |
|
| 917 |
<?php endwhile; ?> |
| 918 |
</div> |
| 919 |
</div> |
| 920 |
|
| 921 |
<?php $this->render_ajax_loadmore(); ?> |
| 922 |
|
| 923 |
<?php |
| 924 |
|
| 925 |
if ($settings['show_pagination']) { ?> |
| 926 |
<div class="ep-pagination"> |
| 927 |
<?php ultimate_post_kit_post_pagination($wp_query, $this->get_id()); ?> |
| 928 |
</div> |
| 929 |
<?php |
| 930 |
} |
| 931 |
wp_reset_postdata(); |
| 932 |
} |
| 933 |
} |
| 934 |
|