| 1 |
<?php |
| 2 |
|
| 3 |
namespace UltimatePostKit\Modules\FeaturedList\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 UltimatePostKit\Traits\Global_Widget_Controls; |
| 14 |
use UltimatePostKit\Traits\Global_Widget_Functions; |
| 15 |
use UltimatePostKit\Includes\Controls\GroupQuery\Group_Control_Query; |
| 16 |
use WP_Query; |
| 17 |
|
| 18 |
if (!defined('ABSPATH')) { |
| 19 |
exit; |
| 20 |
} // Exit if accessed directly |
| 21 |
|
| 22 |
class Featured_List extends Group_Control_Query { |
| 23 |
|
| 24 |
use Global_Widget_Controls; |
| 25 |
use Global_Widget_Functions; |
| 26 |
|
| 27 |
private $_query = null; |
| 28 |
|
| 29 |
public function get_name() { |
| 30 |
return 'upk-featured-list'; |
| 31 |
} |
| 32 |
|
| 33 |
public function get_title() { |
| 34 |
return BDTUPK . esc_html__('Featured List', 'ultimate-post-kit'); |
| 35 |
} |
| 36 |
|
| 37 |
public function get_icon() { |
| 38 |
return 'upk-widget-icon upk-icon-featured-list'; |
| 39 |
} |
| 40 |
|
| 41 |
public function get_categories() { |
| 42 |
return ['ultimate-post-kit']; |
| 43 |
} |
| 44 |
|
| 45 |
public function get_keywords() { |
| 46 |
return ['post', 'grid', 'blog', 'recent', 'news', 'featured', 'list']; |
| 47 |
} |
| 48 |
|
| 49 |
public function get_style_depends() { |
| 50 |
if ($this->upk_is_edit_mode()) { |
| 51 |
return ['upk-all-styles']; |
| 52 |
} else { |
| 53 |
return ['upk-font', 'upk-featured-list']; |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
public function get_script_depends() { |
| 58 |
if ($this->upk_is_edit_mode()) { |
| 59 |
return ['upk-all-scripts']; |
| 60 |
} else { |
| 61 |
return ['upk-ajax-loadmore']; |
| 62 |
} |
| 63 |
} |
| 64 |
|
| 65 |
public function get_custom_help_url() { |
| 66 |
return 'https://youtu.be/Q-Pm-6Kkmr4'; |
| 67 |
} |
| 68 |
|
| 69 |
public function get_query() { |
| 70 |
return $this->_query; |
| 71 |
} |
| 72 |
|
| 73 |
public function has_widget_inner_wrapper(): bool { |
| 74 |
return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); |
| 75 |
} |
| 76 |
|
| 77 |
|
| 78 |
protected function register_controls() { |
| 79 |
$this->start_controls_section( |
| 80 |
'section_content_layout', |
| 81 |
[ |
| 82 |
'label' => esc_html__('Layout', 'ultimate-post-kit'), |
| 83 |
] |
| 84 |
); |
| 85 |
|
| 86 |
|
| 87 |
$this->add_control( |
| 88 |
'layout_style', |
| 89 |
[ |
| 90 |
'label' => esc_html__('Layout Style', 'ultimate-post-kit'), |
| 91 |
'type' => Controls_Manager::SELECT, |
| 92 |
'default' => 'style-1', |
| 93 |
'options' => [ |
| 94 |
'style-1' => esc_html__('Style 01', 'ultimate-post-kit'), |
| 95 |
'style-2' => esc_html__('Style 02', 'ultimate-post-kit'), |
| 96 |
'style-3' => esc_html__('Style 03', 'ultimate-post-kit'), |
| 97 |
], |
| 98 |
] |
| 99 |
); |
| 100 |
|
| 101 |
|
| 102 |
$this->add_responsive_control( |
| 103 |
'item_image_height', |
| 104 |
[ |
| 105 |
'label' => esc_html__('Image Height(px)', 'ultimate-post-kit'), |
| 106 |
'type' => Controls_Manager::SLIDER, |
| 107 |
'range' => [ |
| 108 |
'px' => [ |
| 109 |
'min' => 200, |
| 110 |
'max' => 600, |
| 111 |
], |
| 112 |
], |
| 113 |
'selectors' => [ |
| 114 |
'{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-image-wrap .upk-img' => 'height: {{SIZE}}{{UNIT}};', |
| 115 |
], |
| 116 |
] |
| 117 |
); |
| 118 |
|
| 119 |
$this->add_group_control( |
| 120 |
Group_Control_Image_Size::get_type(), |
| 121 |
[ |
| 122 |
'name' => 'primary_thumbnail', |
| 123 |
'exclude' => ['custom'], |
| 124 |
'default' => 'medium', |
| 125 |
] |
| 126 |
); |
| 127 |
|
| 128 |
$this->add_control( |
| 129 |
'hr', |
| 130 |
[ |
| 131 |
'type' => Controls_Manager::DIVIDER, |
| 132 |
] |
| 133 |
); |
| 134 |
|
| 135 |
//Global Title Controls |
| 136 |
$this->register_title_controls(); |
| 137 |
|
| 138 |
$this->add_control( |
| 139 |
'show_category', |
| 140 |
[ |
| 141 |
'label' => esc_html__('Show Category', 'ultimate-post-kit'), |
| 142 |
'type' => Controls_Manager::SWITCHER, |
| 143 |
'default' => 'yes', |
| 144 |
] |
| 145 |
); |
| 146 |
|
| 147 |
$this->add_control( |
| 148 |
'show_counter_number', |
| 149 |
[ |
| 150 |
'label' => esc_html__('Show Counter Number', 'ultimate-post-kit'), |
| 151 |
'type' => Controls_Manager::SWITCHER, |
| 152 |
'default' => 'yes', |
| 153 |
] |
| 154 |
); |
| 155 |
|
| 156 |
$this->add_control( |
| 157 |
'show_author', |
| 158 |
[ |
| 159 |
'label' => esc_html__('Show Author', 'ultimate-post-kit'), |
| 160 |
'type' => Controls_Manager::SWITCHER, |
| 161 |
'separator' => 'before' |
| 162 |
] |
| 163 |
); |
| 164 |
|
| 165 |
$this->add_control( |
| 166 |
'show_comments', |
| 167 |
[ |
| 168 |
'label' => esc_html__('Show Comments', 'ultimate-post-kit'), |
| 169 |
'type' => Controls_Manager::SWITCHER, |
| 170 |
] |
| 171 |
); |
| 172 |
|
| 173 |
$this->add_control( |
| 174 |
'meta_separator', |
| 175 |
[ |
| 176 |
'label' => __('Separator', 'ultimate-post-kit'), |
| 177 |
'type' => Controls_Manager::TEXT, |
| 178 |
'default' => '//', |
| 179 |
'label_block' => false, |
| 180 |
] |
| 181 |
); |
| 182 |
|
| 183 |
//Global Date Controls |
| 184 |
$this->register_date_controls(); |
| 185 |
|
| 186 |
//Global Reading Time Controls |
| 187 |
$this->register_reading_time_controls(); |
| 188 |
|
| 189 |
$this->add_control( |
| 190 |
'show_pagination', |
| 191 |
[ |
| 192 |
'label' => esc_html__('Show Pagination', 'ultimate-post-kit'), |
| 193 |
'type' => Controls_Manager::SWITCHER, |
| 194 |
'separator' => 'before' |
| 195 |
] |
| 196 |
); |
| 197 |
|
| 198 |
//Global Ajax Controls |
| 199 |
$this->register_ajax_loadmore_controls(); |
| 200 |
|
| 201 |
$this->add_control( |
| 202 |
'global_link', |
| 203 |
[ |
| 204 |
'label' => esc_html__('Item Wrapper Link', 'ultimate-post-kit'), |
| 205 |
'type' => Controls_Manager::SWITCHER, |
| 206 |
'prefix_class' => 'upk-global-link-', |
| 207 |
'description' => esc_html__('Be aware! When Item Wrapper Link activated then title link and read more link will not work', 'ultimate-post-kit'), |
| 208 |
] |
| 209 |
); |
| 210 |
|
| 211 |
$this->end_controls_section(); |
| 212 |
|
| 213 |
// Query Settings |
| 214 |
$this->start_controls_section( |
| 215 |
'section_post_query_builder', |
| 216 |
[ |
| 217 |
'label' => esc_html__('Query', 'ultimate-post-kit'), |
| 218 |
'tab' => Controls_Manager::TAB_CONTENT, |
| 219 |
] |
| 220 |
); |
| 221 |
|
| 222 |
$this->add_control( |
| 223 |
'item_limit', |
| 224 |
[ |
| 225 |
'label' => esc_html__('Item Limit', 'ultimate-post-kit'), |
| 226 |
'type' => Controls_Manager::SLIDER, |
| 227 |
'range' => [ |
| 228 |
'px' => [ |
| 229 |
'min' => 1, |
| 230 |
'max' => 20, |
| 231 |
], |
| 232 |
], |
| 233 |
'default' => [ |
| 234 |
'size' => 4, |
| 235 |
], |
| 236 |
] |
| 237 |
); |
| 238 |
|
| 239 |
$this->register_query_builder_controls(); |
| 240 |
|
| 241 |
$this->end_controls_section(); |
| 242 |
|
| 243 |
//Style |
| 244 |
$this->start_controls_section( |
| 245 |
'upk_section_style', |
| 246 |
[ |
| 247 |
'label' => esc_html__('Item', 'ultimate-post-kit'), |
| 248 |
'tab' => Controls_Manager::TAB_STYLE, |
| 249 |
] |
| 250 |
); |
| 251 |
|
| 252 |
$this->add_responsive_control( |
| 253 |
'item_bottom_spacing', |
| 254 |
[ |
| 255 |
'label' => esc_html__('Item Gap', 'ultimate-post-kit'), |
| 256 |
'type' => Controls_Manager::SLIDER, |
| 257 |
'range' => [ |
| 258 |
'px' => [ |
| 259 |
'min' => 0, |
| 260 |
'max' => 50, |
| 261 |
], |
| 262 |
], |
| 263 |
'selectors' => [ |
| 264 |
'{{WRAPPER}} .upk-featured-list' => 'grid-row-gap: {{SIZE}}{{UNIT}};', |
| 265 |
], |
| 266 |
] |
| 267 |
); |
| 268 |
|
| 269 |
$this->add_responsive_control( |
| 270 |
'featured_item_padding', |
| 271 |
[ |
| 272 |
'label' => esc_html__('Featured Item Padding', 'ultimate-post-kit'), |
| 273 |
'type' => Controls_Manager::DIMENSIONS, |
| 274 |
'size_units' => ['px', 'em', '%'], |
| 275 |
'selectors' => [ |
| 276 |
'{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 277 |
], |
| 278 |
] |
| 279 |
); |
| 280 |
|
| 281 |
$this->add_responsive_control( |
| 282 |
'item_padding', |
| 283 |
[ |
| 284 |
'label' => esc_html__('Padding', 'ultimate-post-kit'), |
| 285 |
'type' => Controls_Manager::DIMENSIONS, |
| 286 |
'size_units' => ['px', 'em', '%'], |
| 287 |
'selectors' => [ |
| 288 |
'{{WRAPPER}} .upk-featured-list .upk-item .upk-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 289 |
|
| 290 |
// '{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-content, |
| 291 |
// {{WRAPPER}} .upk-featured-list .upk-item:nth-last-child(1) .upk-content' => 'padding-bottom: calc(2 * {{TOP}}{{UNIT}});', |
| 292 |
// '{{WRAPPER}} .upk-featured-list .upk-item:nth-child(2) .upk-content' => 'padding-top: calc(2 * {{TOP}}{{UNIT}});', |
| 293 |
], |
| 294 |
] |
| 295 |
); |
| 296 |
|
| 297 |
$this->add_control( |
| 298 |
'image_heading', |
| 299 |
[ |
| 300 |
'label' => esc_html__('Image', 'ultimate-post-kit'), |
| 301 |
'type' => Controls_Manager::HEADING, |
| 302 |
'separator' => 'before' |
| 303 |
] |
| 304 |
); |
| 305 |
|
| 306 |
$this->add_control( |
| 307 |
'item_overlay_color', |
| 308 |
[ |
| 309 |
'label' => esc_html__('Overlay Color', 'ultimate-post-kit'), |
| 310 |
'type' => Controls_Manager::COLOR, |
| 311 |
'selectors' => [ |
| 312 |
'{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-image-wrap:before' => 'background: linear-gradient(0deg, {{VALUE}} 0, rgba(141, 153, 174, 0.1) 100%);', |
| 313 |
], |
| 314 |
] |
| 315 |
); |
| 316 |
|
| 317 |
$this->add_group_control( |
| 318 |
Group_Control_Border::get_type(), |
| 319 |
[ |
| 320 |
'name' => 'item_image_border', |
| 321 |
'selector' => '{{WRAPPER}} .upk-featured-list .upk-image-wrap', |
| 322 |
] |
| 323 |
); |
| 324 |
|
| 325 |
$this->add_responsive_control( |
| 326 |
'item_image_border_radius', |
| 327 |
[ |
| 328 |
'label' => esc_html__('Border Radius', 'ultimate-post-kit'), |
| 329 |
'type' => Controls_Manager::DIMENSIONS, |
| 330 |
'size_units' => ['px', '%'], |
| 331 |
'selectors' => [ |
| 332 |
'{{WRAPPER}} .upk-featured-list .upk-image-wrap' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 333 |
], |
| 334 |
] |
| 335 |
); |
| 336 |
|
| 337 |
$this->add_responsive_control( |
| 338 |
'image_spacing', |
| 339 |
[ |
| 340 |
'label' => esc_html__('Spacing', 'ultimate-post-kit'), |
| 341 |
'type' => Controls_Manager::SLIDER, |
| 342 |
'range' => [ |
| 343 |
'px' => [ |
| 344 |
'min' => 0, |
| 345 |
'max' => 50, |
| 346 |
], |
| 347 |
], |
| 348 |
'selectors' => [ |
| 349 |
'{{WRAPPER}} .upk-featured-list.upk-featured-style-2 .upk-item-box' => 'grid-column-gap: {{SIZE}}{{UNIT}};', |
| 350 |
'{{WRAPPER}} .upk-featured-list.upk-featured-style-3 .upk-item-box' => 'grid-column-gap: {{SIZE}}{{UNIT}};', |
| 351 |
], |
| 352 |
] |
| 353 |
); |
| 354 |
|
| 355 |
|
| 356 |
$this->end_controls_section(); |
| 357 |
|
| 358 |
$this->start_controls_section( |
| 359 |
'section_style_title', |
| 360 |
[ |
| 361 |
'label' => esc_html__('Title', 'ultimate-post-kit'), |
| 362 |
'tab' => Controls_Manager::TAB_STYLE, |
| 363 |
'condition' => [ |
| 364 |
'show_title' => 'yes', |
| 365 |
], |
| 366 |
] |
| 367 |
); |
| 368 |
|
| 369 |
$this->add_control( |
| 370 |
'title_style', |
| 371 |
[ |
| 372 |
'label' => esc_html__('Style', 'ultimate-post-kit'), |
| 373 |
'type' => Controls_Manager::SELECT, |
| 374 |
'default' => 'underline', |
| 375 |
'options' => [ |
| 376 |
'underline' => esc_html__('Underline', 'ultimate-post-kit'), |
| 377 |
'middle-underline' => esc_html__('Middle Underline', 'ultimate-post-kit'), |
| 378 |
'overline' => esc_html__('Overline', 'ultimate-post-kit'), |
| 379 |
'middle-overline' => esc_html__('Middle Overline', 'ultimate-post-kit'), |
| 380 |
], |
| 381 |
] |
| 382 |
); |
| 383 |
|
| 384 |
//title tabs control |
| 385 |
$this->start_controls_tabs('tabs_title_style'); |
| 386 |
//title normal tab |
| 387 |
$this->start_controls_tab( |
| 388 |
'tab_title_normal', |
| 389 |
[ |
| 390 |
'label' => esc_html__('Normal', 'ultimate-post-kit'), |
| 391 |
] |
| 392 |
); |
| 393 |
|
| 394 |
$this->add_control( |
| 395 |
'title_color', |
| 396 |
[ |
| 397 |
'label' => esc_html__('Color', 'ultimate-post-kit'), |
| 398 |
'type' => Controls_Manager::COLOR, |
| 399 |
'selectors' => [ |
| 400 |
'{{WRAPPER}} .upk-featured-list .upk-item .upk-title a' => 'color: {{VALUE}};', |
| 401 |
], |
| 402 |
] |
| 403 |
); |
| 404 |
|
| 405 |
$this->add_control( |
| 406 |
'title_hover_color', |
| 407 |
[ |
| 408 |
'label' => esc_html__('Hover Color', 'ultimate-post-kit'), |
| 409 |
'type' => Controls_Manager::COLOR, |
| 410 |
'selectors' => [ |
| 411 |
'{{WRAPPER}} .upk-featured-list .upk-item .upk-title a:hover' => 'color: {{VALUE}};', |
| 412 |
], |
| 413 |
] |
| 414 |
); |
| 415 |
|
| 416 |
$this->add_group_control( |
| 417 |
Group_Control_Typography::get_type(), |
| 418 |
[ |
| 419 |
'name' => 'title_typography', |
| 420 |
'label' => esc_html__('Typography', 'ultimate-post-kit'), |
| 421 |
'selector' => '{{WRAPPER}} .upk-featured-list .upk-item .upk-title', |
| 422 |
] |
| 423 |
); |
| 424 |
|
| 425 |
$this->add_group_control( |
| 426 |
Group_Control_Text_Shadow::get_type(), |
| 427 |
[ |
| 428 |
'name' => 'title_text_shadow', |
| 429 |
'label' => esc_html__('Text Shadow', 'ultimate-post-kit'), |
| 430 |
'selector' => '{{WRAPPER}} .upk-featured-list .upk-item .upk-title a', |
| 431 |
] |
| 432 |
); |
| 433 |
//title text stroke control |
| 434 |
$this->add_group_control( |
| 435 |
Group_Control_Text_Stroke::get_type(), |
| 436 |
[ |
| 437 |
'name' => 'title_text_stroke', |
| 438 |
'label' => esc_html__('Text Stroke', 'ultimate-post-kit') . BDTUPK_PC, |
| 439 |
'selector' => '{{WRAPPER}} .upk-featured-list .upk-item .upk-title a', |
| 440 |
] |
| 441 |
); |
| 442 |
|
| 443 |
//title normal tab end |
| 444 |
$this->end_controls_tab(); |
| 445 |
//title featured tab |
| 446 |
$this->start_controls_tab( |
| 447 |
'tab_title_featured', |
| 448 |
[ |
| 449 |
'label' => esc_html__('Featured', 'ultimate-post-kit'), |
| 450 |
] |
| 451 |
); |
| 452 |
|
| 453 |
$this->add_control( |
| 454 |
'title_featured_color', |
| 455 |
[ |
| 456 |
'label' => esc_html__('Color', 'ultimate-post-kit'), |
| 457 |
'type' => Controls_Manager::COLOR, |
| 458 |
'selectors' => [ |
| 459 |
'{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-title a' => 'color: {{VALUE}};', |
| 460 |
], |
| 461 |
'separator' => 'before' |
| 462 |
] |
| 463 |
); |
| 464 |
|
| 465 |
$this->add_control( |
| 466 |
'title_featured_hover_color', |
| 467 |
[ |
| 468 |
'label' => esc_html__('Hover Color', 'ultimate-post-kit'), |
| 469 |
'type' => Controls_Manager::COLOR, |
| 470 |
'selectors' => [ |
| 471 |
'{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-title a:hover' => 'color: {{VALUE}};', |
| 472 |
], |
| 473 |
] |
| 474 |
); |
| 475 |
|
| 476 |
$this->add_group_control( |
| 477 |
Group_Control_Typography::get_type(), |
| 478 |
[ |
| 479 |
'name' => 'featured_title_typography', |
| 480 |
'label' => esc_html__('Typography', 'ultimate-post-kit') . BDTUPK_PC, |
| 481 |
'selector' => '{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-title', |
| 482 |
] |
| 483 |
); |
| 484 |
|
| 485 |
$this->add_group_control( |
| 486 |
Group_Control_Text_Shadow::get_type(), |
| 487 |
[ |
| 488 |
'name' => 'featured_title_text_shadow', |
| 489 |
'label' => esc_html__('Text Shadow', 'ultimate-post-kit') . BDTUPK_PC, |
| 490 |
'selector' => '{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-title a', |
| 491 |
] |
| 492 |
); |
| 493 |
|
| 494 |
$this->add_group_control( |
| 495 |
Group_Control_Text_Stroke::get_type(), |
| 496 |
[ |
| 497 |
'name' => 'featured_title_text_stroke', |
| 498 |
'label' => esc_html__('Text Stroke', 'ultimate-post-kit') . BDTUPK_PC, |
| 499 |
'selector' => '{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-title a', |
| 500 |
] |
| 501 |
); |
| 502 |
//title featured tab end |
| 503 |
$this->end_controls_tab(); |
| 504 |
//title tabs control end |
| 505 |
$this->end_controls_tabs(); |
| 506 |
|
| 507 |
$this->end_controls_section(); |
| 508 |
|
| 509 |
$this->start_controls_section( |
| 510 |
'section_style_meta', |
| 511 |
[ |
| 512 |
'label' => esc_html__('Meta', 'ultimate-post-kit'), |
| 513 |
'tab' => Controls_Manager::TAB_STYLE, |
| 514 |
'conditions' => [ |
| 515 |
'relation' => 'or', |
| 516 |
'terms' => [ |
| 517 |
[ |
| 518 |
'name' => 'show_author', |
| 519 |
'value' => 'yes' |
| 520 |
], |
| 521 |
[ |
| 522 |
'name' => 'show_date', |
| 523 |
'value' => 'yes' |
| 524 |
], |
| 525 |
[ |
| 526 |
'name' => 'show_comments', |
| 527 |
'value' => 'yes' |
| 528 |
] |
| 529 |
] |
| 530 |
], |
| 531 |
] |
| 532 |
); |
| 533 |
|
| 534 |
$this->add_control( |
| 535 |
'meta_color', |
| 536 |
[ |
| 537 |
'label' => esc_html__('Color', 'ultimate-post-kit'), |
| 538 |
'type' => Controls_Manager::COLOR, |
| 539 |
'selectors' => [ |
| 540 |
'{{WRAPPER}} .upk-featured-list .upk-item .upk-featured-meta, {{WRAPPER}} .upk-featured-list .upk-item .upk-featured-meta .upk-author-name-wrap .upk-author-name' => 'color: {{VALUE}};', |
| 541 |
], |
| 542 |
] |
| 543 |
); |
| 544 |
|
| 545 |
$this->add_control( |
| 546 |
'meta_featured_color', |
| 547 |
[ |
| 548 |
'label' => esc_html__('Featured Color', 'ultimate-post-kit'), |
| 549 |
'type' => Controls_Manager::COLOR, |
| 550 |
'selectors' => [ |
| 551 |
'{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-featured-meta, {{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-featured-meta .upk-author-name-wrap .upk-author-name' => 'color: {{VALUE}};', |
| 552 |
], |
| 553 |
] |
| 554 |
); |
| 555 |
|
| 556 |
$this->add_responsive_control( |
| 557 |
'meta_spacing', |
| 558 |
[ |
| 559 |
'label' => esc_html__('Spacing', 'ultimate-post-kit'), |
| 560 |
'type' => Controls_Manager::SLIDER, |
| 561 |
'range' => [ |
| 562 |
'px' => [ |
| 563 |
'min' => 0, |
| 564 |
'max' => 50, |
| 565 |
], |
| 566 |
], |
| 567 |
'selectors' => [ |
| 568 |
'{{WRAPPER}} .upk-featured-list .upk-item .upk-featured-meta' => 'padding-top: {{SIZE}}{{UNIT}};', |
| 569 |
], |
| 570 |
] |
| 571 |
); |
| 572 |
|
| 573 |
$this->add_responsive_control( |
| 574 |
'meta_space_between', |
| 575 |
[ |
| 576 |
'label' => esc_html__('Space Between', 'ultimate-post-kit'), |
| 577 |
'type' => Controls_Manager::SLIDER, |
| 578 |
'range' => [ |
| 579 |
'px' => [ |
| 580 |
'min' => 0, |
| 581 |
'max' => 50, |
| 582 |
], |
| 583 |
], |
| 584 |
'selectors' => [ |
| 585 |
'{{WRAPPER}} .upk-featured-list .upk-item .upk-featured-meta > div:before' => 'margin: 0 {{SIZE}}{{UNIT}};', |
| 586 |
], |
| 587 |
] |
| 588 |
); |
| 589 |
|
| 590 |
$this->add_group_control( |
| 591 |
Group_Control_Typography::get_type(), |
| 592 |
[ |
| 593 |
'name' => 'meta_typography', |
| 594 |
'label' => esc_html__('Typography', 'ultimate-post-kit'), |
| 595 |
'selector' => '{{WRAPPER}} .upk-featured-list .upk-item .upk-featured-meta', |
| 596 |
] |
| 597 |
); |
| 598 |
|
| 599 |
$this->end_controls_section(); |
| 600 |
|
| 601 |
$this->start_controls_section( |
| 602 |
'section_style_category', |
| 603 |
[ |
| 604 |
'label' => esc_html__('Category', 'ultimate-post-kit'), |
| 605 |
'tab' => Controls_Manager::TAB_STYLE, |
| 606 |
'condition' => [ |
| 607 |
'show_category' => 'yes', |
| 608 |
], |
| 609 |
] |
| 610 |
); |
| 611 |
|
| 612 |
$this->add_responsive_control( |
| 613 |
'category_bottom_spacing', |
| 614 |
[ |
| 615 |
'label' => esc_html__('Spacing', 'ultimate-post-kit'), |
| 616 |
'type' => Controls_Manager::SLIDER, |
| 617 |
'range' => [ |
| 618 |
'px' => [ |
| 619 |
'min' => 0, |
| 620 |
'max' => 50, |
| 621 |
], |
| 622 |
], |
| 623 |
'selectors' => [ |
| 624 |
'{{WRAPPER}} .upk-featured-list .upk-item .upk-category' => 'padding-bottom: {{SIZE}}{{UNIT}};', |
| 625 |
], |
| 626 |
] |
| 627 |
); |
| 628 |
|
| 629 |
$this->add_control( |
| 630 |
'category_style_color', |
| 631 |
[ |
| 632 |
'label' => esc_html__('Dot Style Color', 'ultimate-post-kit'), |
| 633 |
'type' => Controls_Manager::COLOR, |
| 634 |
'selectors' => [ |
| 635 |
'{{WRAPPER}} .upk-featured-list .upk-item .upk-category a span' => 'background-color: {{VALUE}} !important;', |
| 636 |
], |
| 637 |
] |
| 638 |
); |
| 639 |
|
| 640 |
$this->start_controls_tabs('tabs_category_style'); |
| 641 |
|
| 642 |
$this->start_controls_tab( |
| 643 |
'tab_category_normal', |
| 644 |
[ |
| 645 |
'label' => esc_html__('Normal', 'ultimate-post-kit'), |
| 646 |
] |
| 647 |
); |
| 648 |
|
| 649 |
$this->add_control( |
| 650 |
'category_color', |
| 651 |
[ |
| 652 |
'label' => esc_html__('Color', 'ultimate-post-kit'), |
| 653 |
'type' => Controls_Manager::COLOR, |
| 654 |
'selectors' => [ |
| 655 |
'{{WRAPPER}} .upk-featured-list .upk-item .upk-category a' => 'color: {{VALUE}};', |
| 656 |
], |
| 657 |
] |
| 658 |
); |
| 659 |
|
| 660 |
$this->add_group_control( |
| 661 |
Group_Control_Background::get_type(), |
| 662 |
[ |
| 663 |
'name' => 'category_background', |
| 664 |
'selector' => '{{WRAPPER}} .upk-featured-list .upk-item .upk-category a', |
| 665 |
] |
| 666 |
); |
| 667 |
|
| 668 |
$this->add_group_control( |
| 669 |
Group_Control_Border::get_type(), |
| 670 |
[ |
| 671 |
'name' => 'category_border', |
| 672 |
'selector' => '{{WRAPPER}} .upk-featured-list .upk-item .upk-category a', |
| 673 |
] |
| 674 |
); |
| 675 |
|
| 676 |
$this->add_responsive_control( |
| 677 |
'category_border_radius', |
| 678 |
[ |
| 679 |
'label' => esc_html__('Border Radius', 'ultimate-post-kit'), |
| 680 |
'type' => Controls_Manager::DIMENSIONS, |
| 681 |
'size_units' => ['px', '%'], |
| 682 |
'selectors' => [ |
| 683 |
'{{WRAPPER}} .upk-featured-list .upk-item .upk-category a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 684 |
], |
| 685 |
] |
| 686 |
); |
| 687 |
|
| 688 |
$this->add_responsive_control( |
| 689 |
'category_padding', |
| 690 |
[ |
| 691 |
'label' => esc_html__('Padding', 'ultimate-post-kit'), |
| 692 |
'type' => Controls_Manager::DIMENSIONS, |
| 693 |
'size_units' => ['px', 'em', '%'], |
| 694 |
'selectors' => [ |
| 695 |
'{{WRAPPER}} .upk-featured-list .upk-item .upk-category a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 696 |
], |
| 697 |
] |
| 698 |
); |
| 699 |
|
| 700 |
$this->add_responsive_control( |
| 701 |
'category_spacing', |
| 702 |
[ |
| 703 |
'label' => esc_html__('Space Between', 'ultimate-post-kit'), |
| 704 |
'type' => Controls_Manager::SLIDER, |
| 705 |
'range' => [ |
| 706 |
'px' => [ |
| 707 |
'min' => 0, |
| 708 |
'max' => 50, |
| 709 |
'step' => 2, |
| 710 |
], |
| 711 |
], |
| 712 |
'selectors' => [ |
| 713 |
'{{WRAPPER}} .upk-featured-list .upk-item .upk-category a+a' => 'margin-left: {{SIZE}}{{UNIT}};', |
| 714 |
], |
| 715 |
] |
| 716 |
); |
| 717 |
|
| 718 |
$this->add_group_control( |
| 719 |
Group_Control_Box_Shadow::get_type(), |
| 720 |
[ |
| 721 |
'name' => 'category_shadow', |
| 722 |
'selector' => '{{WRAPPER}} .upk-featured-list .upk-item .upk-category a', |
| 723 |
] |
| 724 |
); |
| 725 |
|
| 726 |
$this->add_group_control( |
| 727 |
Group_Control_Typography::get_type(), |
| 728 |
[ |
| 729 |
'name' => 'category_typography', |
| 730 |
'label' => esc_html__('Typography', 'ultimate-post-kit'), |
| 731 |
'selector' => '{{WRAPPER}} .upk-featured-list .upk-item .upk-category a', |
| 732 |
] |
| 733 |
); |
| 734 |
|
| 735 |
$this->end_controls_tab(); |
| 736 |
|
| 737 |
$this->start_controls_tab( |
| 738 |
'tab_category_hover', |
| 739 |
[ |
| 740 |
'label' => esc_html__('Hover', 'ultimate-post-kit'), |
| 741 |
] |
| 742 |
); |
| 743 |
|
| 744 |
$this->add_control( |
| 745 |
'category_hover_color', |
| 746 |
[ |
| 747 |
'label' => esc_html__('Color', 'ultimate-post-kit'), |
| 748 |
'type' => Controls_Manager::COLOR, |
| 749 |
'selectors' => [ |
| 750 |
'{{WRAPPER}} .upk-featured-list .upk-item .upk-category a:hover' => 'color: {{VALUE}};', |
| 751 |
], |
| 752 |
] |
| 753 |
); |
| 754 |
|
| 755 |
$this->add_group_control( |
| 756 |
Group_Control_Background::get_type(), |
| 757 |
[ |
| 758 |
'name' => 'category_hover_background', |
| 759 |
'selector' => '{{WRAPPER}} .upk-featured-list .upk-item .upk-category a:hover', |
| 760 |
] |
| 761 |
); |
| 762 |
|
| 763 |
$this->add_control( |
| 764 |
'category_hover_border_color', |
| 765 |
[ |
| 766 |
'label' => esc_html__('Border Color', 'ultimate-post-kit'), |
| 767 |
'type' => Controls_Manager::COLOR, |
| 768 |
'condition' => [ |
| 769 |
'category_border_border!' => '', |
| 770 |
], |
| 771 |
'selectors' => [ |
| 772 |
'{{WRAPPER}} .upk-featured-list .upk-item .upk-category a:hover' => 'border-color: {{VALUE}};', |
| 773 |
], |
| 774 |
] |
| 775 |
); |
| 776 |
|
| 777 |
$this->end_controls_tab(); |
| 778 |
|
| 779 |
$this->start_controls_tab( |
| 780 |
'tab_category_featured', |
| 781 |
[ |
| 782 |
'label' => esc_html__('Featured', 'ultimate-post-kit'), |
| 783 |
] |
| 784 |
); |
| 785 |
|
| 786 |
$this->add_control( |
| 787 |
'category_featured_heading', |
| 788 |
[ |
| 789 |
'label' => esc_html__('NORMAL', 'ultimate-post-kit'), |
| 790 |
'type' => Controls_Manager::HEADING, |
| 791 |
] |
| 792 |
); |
| 793 |
|
| 794 |
$this->add_control( |
| 795 |
'category_featured_color', |
| 796 |
[ |
| 797 |
'label' => esc_html__('Color', 'ultimate-post-kit'), |
| 798 |
'type' => Controls_Manager::COLOR, |
| 799 |
'selectors' => [ |
| 800 |
'{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-category a' => 'color: {{VALUE}};', |
| 801 |
], |
| 802 |
] |
| 803 |
); |
| 804 |
|
| 805 |
$this->add_group_control( |
| 806 |
Group_Control_Background::get_type(), |
| 807 |
[ |
| 808 |
'name' => 'category_featured_background', |
| 809 |
'selector' => '{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-category a', |
| 810 |
] |
| 811 |
); |
| 812 |
|
| 813 |
$this->add_control( |
| 814 |
'category_featured_border_color', |
| 815 |
[ |
| 816 |
'label' => esc_html__('Border Color', 'ultimate-post-kit'), |
| 817 |
'type' => Controls_Manager::COLOR, |
| 818 |
'condition' => [ |
| 819 |
'category_border_border!' => '', |
| 820 |
], |
| 821 |
'selectors' => [ |
| 822 |
'{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-category a' => 'border-color: {{VALUE}};', |
| 823 |
], |
| 824 |
] |
| 825 |
); |
| 826 |
|
| 827 |
$this->add_control( |
| 828 |
'heading_category_featured_hover_style', |
| 829 |
[ |
| 830 |
'label' => esc_html__('HOVER', 'ultimate-post-kit'), |
| 831 |
'type' => Controls_Manager::HEADING, |
| 832 |
'separator' => 'before', |
| 833 |
] |
| 834 |
); |
| 835 |
|
| 836 |
$this->add_control( |
| 837 |
'category_featured_color_hover', |
| 838 |
[ |
| 839 |
'label' => esc_html__('Color', 'ultimate-post-kit'), |
| 840 |
'type' => Controls_Manager::COLOR, |
| 841 |
'selectors' => [ |
| 842 |
'{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-category a:hover' => 'color: {{VALUE}};', |
| 843 |
], |
| 844 |
] |
| 845 |
); |
| 846 |
|
| 847 |
$this->add_group_control( |
| 848 |
Group_Control_Background::get_type(), |
| 849 |
[ |
| 850 |
'name' => 'category_featured_background_hover', |
| 851 |
'selector' => '{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-category a:hover', |
| 852 |
] |
| 853 |
); |
| 854 |
|
| 855 |
$this->add_control( |
| 856 |
'category_featured_border_color_hover', |
| 857 |
[ |
| 858 |
'label' => esc_html__('Border Color', 'ultimate-post-kit'), |
| 859 |
'type' => Controls_Manager::COLOR, |
| 860 |
'condition' => [ |
| 861 |
'category_border_border!' => '', |
| 862 |
], |
| 863 |
'selectors' => [ |
| 864 |
'{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-category a:hover' => 'border-color: {{VALUE}};', |
| 865 |
], |
| 866 |
] |
| 867 |
); |
| 868 |
|
| 869 |
$this->end_controls_tab(); |
| 870 |
|
| 871 |
|
| 872 |
$this->end_controls_tabs(); |
| 873 |
|
| 874 |
$this->end_controls_section(); |
| 875 |
|
| 876 |
$this->start_controls_section( |
| 877 |
'section_style_counter_number', |
| 878 |
[ |
| 879 |
'label' => esc_html__('Counter Number', 'ultimate-post-kit'), |
| 880 |
'tab' => Controls_Manager::TAB_STYLE, |
| 881 |
'condition' => [ |
| 882 |
'show_counter_number' => 'yes', |
| 883 |
'layout_style' => 'style-1', |
| 884 |
] |
| 885 |
] |
| 886 |
); |
| 887 |
|
| 888 |
$this->start_controls_tabs( |
| 889 |
'counter_number_style_tabs' |
| 890 |
); |
| 891 |
|
| 892 |
$this->start_controls_tab( |
| 893 |
'conter_number_style_normal_tab', |
| 894 |
[ |
| 895 |
'label' => esc_html__( 'Normal', 'ultimate-post-kit' ), |
| 896 |
] |
| 897 |
); |
| 898 |
|
| 899 |
$this->add_control( |
| 900 |
'counter_number_color', |
| 901 |
[ |
| 902 |
'label' => esc_html__('Color', 'ultimate-post-kit'), |
| 903 |
'type' => Controls_Manager::COLOR, |
| 904 |
'selectors' => [ |
| 905 |
'{{WRAPPER}} .upk-featured-list .upk-item .upk-counter:before' => 'color: {{VALUE}};', |
| 906 |
], |
| 907 |
] |
| 908 |
); |
| 909 |
|
| 910 |
$this->add_group_control( |
| 911 |
Group_Control_Background::get_type(), |
| 912 |
[ |
| 913 |
'name' => 'counter_number_background', |
| 914 |
'selector' => '{{WRAPPER}} .upk-featured-list .upk-item .upk-counter', |
| 915 |
] |
| 916 |
); |
| 917 |
|
| 918 |
$this->add_group_control( |
| 919 |
Group_Control_Border::get_type(), |
| 920 |
[ |
| 921 |
'name' => 'counter_number_border', |
| 922 |
'selector' => '{{WRAPPER}} .upk-featured-list .upk-item .upk-counter', |
| 923 |
] |
| 924 |
); |
| 925 |
|
| 926 |
$this->add_responsive_control( |
| 927 |
'counter_number_border_radius', |
| 928 |
[ |
| 929 |
'label' => esc_html__('Border Radius', 'ultimate-post-kit'), |
| 930 |
'type' => Controls_Manager::DIMENSIONS, |
| 931 |
'size_units' => ['px', '%'], |
| 932 |
'selectors' => [ |
| 933 |
'{{WRAPPER}} .upk-featured-list .upk-item .upk-counter' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 934 |
], |
| 935 |
] |
| 936 |
); |
| 937 |
|
| 938 |
$this->add_responsive_control( |
| 939 |
'counter_number_spacing', |
| 940 |
[ |
| 941 |
'label' => esc_html__('Spacing', 'ultimate-post-kit'), |
| 942 |
'type' => Controls_Manager::SLIDER, |
| 943 |
'range' => [ |
| 944 |
'px' => [ |
| 945 |
'min' => 0, |
| 946 |
'max' => 50, |
| 947 |
], |
| 948 |
], |
| 949 |
'selectors' => [ |
| 950 |
'{{WRAPPER}} .upk-featured-list .upk-item .upk-counter' => 'margin-right: {{SIZE}}{{UNIT}};', |
| 951 |
], |
| 952 |
] |
| 953 |
); |
| 954 |
|
| 955 |
$this->add_responsive_control( |
| 956 |
'counter_number_size', |
| 957 |
[ |
| 958 |
'label' => esc_html__('Counter Size', 'ultimate-post-kit'), |
| 959 |
'type' => Controls_Manager::SLIDER, |
| 960 |
'range' => [ |
| 961 |
'px' => [ |
| 962 |
'min' => 20, |
| 963 |
'max' => 100, |
| 964 |
], |
| 965 |
], |
| 966 |
'selectors' => [ |
| 967 |
'{{WRAPPER}} .upk-featured-list .upk-item .upk-counter' => 'height: {{SIZE}}{{UNIT}}; width: {{SIZE}}{{UNIT}}; min-width: {{SIZE}}{{UNIT}};', |
| 968 |
], |
| 969 |
] |
| 970 |
); |
| 971 |
|
| 972 |
$this->add_group_control( |
| 973 |
Group_Control_Typography::get_type(), |
| 974 |
[ |
| 975 |
'name' => 'counter_number_typography', |
| 976 |
'label' => esc_html__('Typography', 'ultimate-post-kit'), |
| 977 |
'selector' => '{{WRAPPER}} .upk-featured-list .upk-item .upk-counter:before', |
| 978 |
] |
| 979 |
); |
| 980 |
|
| 981 |
|
| 982 |
$this->end_controls_tab(); |
| 983 |
|
| 984 |
$this->start_controls_tab( |
| 985 |
'conter_number__featured_style_normal_tab', |
| 986 |
[ |
| 987 |
'label' => esc_html__( 'Featured', 'ultimate-post-kit' ), |
| 988 |
] |
| 989 |
); |
| 990 |
|
| 991 |
$this->add_control( |
| 992 |
'featured_counter_number_color', |
| 993 |
[ |
| 994 |
'label' => esc_html__('Color', 'ultimate-post-kit'), |
| 995 |
'type' => Controls_Manager::COLOR, |
| 996 |
'selectors' => [ |
| 997 |
'{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-counter:before' => 'color: {{VALUE}};', |
| 998 |
], |
| 999 |
] |
| 1000 |
); |
| 1001 |
|
| 1002 |
$this->add_group_control( |
| 1003 |
Group_Control_Background::get_type(), |
| 1004 |
[ |
| 1005 |
'name' => 'featured_counter_number_background', |
| 1006 |
'selector' => '{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-counter', |
| 1007 |
] |
| 1008 |
); |
| 1009 |
|
| 1010 |
$this->add_control( |
| 1011 |
'featured_counter_number_border_color', |
| 1012 |
[ |
| 1013 |
'label' => esc_html__('Border Color', 'ultimate-post-kit'), |
| 1014 |
'type' => Controls_Manager::COLOR, |
| 1015 |
'condition' => [ |
| 1016 |
'counter_number_border_border!' => '', |
| 1017 |
], |
| 1018 |
'selectors' => [ |
| 1019 |
'{{WRAPPER}} .upk-featured-list .upk-item:nth-child(1) .upk-counter' => 'border-color: {{VALUE}};', |
| 1020 |
], |
| 1021 |
] |
| 1022 |
); |
| 1023 |
|
| 1024 |
$this->end_controls_tab(); |
| 1025 |
|
| 1026 |
$this->end_controls_tabs(); |
| 1027 |
|
| 1028 |
$this->end_controls_section(); |
| 1029 |
|
| 1030 |
//Global Pagination Controls |
| 1031 |
$this->register_pagination_controls(); |
| 1032 |
|
| 1033 |
//Global Ajax Loadmore Style Controls |
| 1034 |
$this->register_ajax_loadmore_style_controls(); |
| 1035 |
} |
| 1036 |
|
| 1037 |
/** |
| 1038 |
* Main query render for this widget |
| 1039 |
* @param $posts_per_page number item query limit |
| 1040 |
*/ |
| 1041 |
public function query_posts($posts_per_page) { |
| 1042 |
|
| 1043 |
$default = $this->getGroupControlQueryArgs(); |
| 1044 |
$args = []; |
| 1045 |
if ($posts_per_page) { |
| 1046 |
$args['posts_per_page'] = $posts_per_page; |
| 1047 |
$args['paged'] = max(1, get_query_var('paged'), get_query_var('page')); |
| 1048 |
} |
| 1049 |
$args = array_merge($default, $args); |
| 1050 |
$this->_query = new WP_Query($args); |
| 1051 |
} |
| 1052 |
|
| 1053 |
public function print_category_output($output) { |
| 1054 |
|
| 1055 |
|
| 1056 |
$tags = [ |
| 1057 |
'a' => ['href' => [], 'target' => [], 'class' => []], |
| 1058 |
'span' => ['style' => [], 'class' => []], |
| 1059 |
]; |
| 1060 |
|
| 1061 |
if (isset($output)) { |
| 1062 |
echo wp_kses($output, $tags); |
| 1063 |
} |
| 1064 |
} |
| 1065 |
|
| 1066 |
public function render_category() { |
| 1067 |
if (!$this->get_settings('show_category')) { |
| 1068 |
return; |
| 1069 |
} |
| 1070 |
?> |
| 1071 |
<div class="upk-category"> |
| 1072 |
|
| 1073 |
<?php |
| 1074 |
$post_type = $this->get_settings('posts_source'); |
| 1075 |
switch ($post_type) { |
| 1076 |
case 'campaign': |
| 1077 |
$taxonomy = 'campaign_category'; |
| 1078 |
break; |
| 1079 |
case 'lightbox_library': |
| 1080 |
$taxonomy = 'ngg_tag'; |
| 1081 |
break; |
| 1082 |
case 'give_forms': |
| 1083 |
$taxonomy = 'give_forms_category'; |
| 1084 |
break; |
| 1085 |
case 'tribe_events': |
| 1086 |
$taxonomy = 'tribe_events_cat'; |
| 1087 |
break; |
| 1088 |
case 'product': |
| 1089 |
$taxonomy = 'product_cat'; |
| 1090 |
break; |
| 1091 |
default: |
| 1092 |
$taxonomy = 'category'; |
| 1093 |
break; |
| 1094 |
} |
| 1095 |
|
| 1096 |
$categories = get_the_terms(get_the_ID(), $taxonomy); |
| 1097 |
|
| 1098 |
$_categories = []; |
| 1099 |
|
| 1100 |
if ($categories) { |
| 1101 |
foreach ($categories as $category) { |
| 1102 |
$bg_color = strToHex($category->name); |
| 1103 |
$link = '<a href="' . esc_url(get_category_link($category->term_id)) . '"><span style="background-color:' . $bg_color . '"></span>' . $category->name . '</a>'; |
| 1104 |
$_categories[$category->slug] = $link; |
| 1105 |
} |
| 1106 |
} |
| 1107 |
|
| 1108 |
$category_link = implode(' ', $_categories); |
| 1109 |
|
| 1110 |
$this->print_category_output($category_link); |
| 1111 |
|
| 1112 |
?> |
| 1113 |
</div> |
| 1114 |
<?php |
| 1115 |
} |
| 1116 |
|
| 1117 |
public function render_author() { |
| 1118 |
|
| 1119 |
if (!$this->get_settings('show_author')) { |
| 1120 |
return; |
| 1121 |
} |
| 1122 |
?> |
| 1123 |
<div class="upk-author-name-wrap"> |
| 1124 |
<span class="upk-by"><?php echo esc_html_x('by', 'Frontend', 'ultimate-post-kit'); ?></span> |
| 1125 |
<a class="upk-author-name" href="<?php echo esc_url( get_author_posts_url(get_the_author_meta('ID')) ); ?>"> |
| 1126 |
<?php echo esc_html( get_the_author() ); ?> |
| 1127 |
</a> |
| 1128 |
</div> |
| 1129 |
<?php |
| 1130 |
} |
| 1131 |
|
| 1132 |
public function render_comments($id = 0) { |
| 1133 |
|
| 1134 |
if (!$this->get_settings('show_comments')) { |
| 1135 |
return; |
| 1136 |
} |
| 1137 |
?> |
| 1138 |
|
| 1139 |
<div class="upk-featured-comments"> |
| 1140 |
<?php echo get_comments_number($id) ?> |
| 1141 |
<?php echo esc_html_x('Comments', 'Frontend', 'ultimate-post-kit') ?> |
| 1142 |
</div> |
| 1143 |
|
| 1144 |
<?php |
| 1145 |
} |
| 1146 |
|
| 1147 |
public function render_post_grid_item($post_id, $image_size) { |
| 1148 |
$settings = $this->get_settings_for_display(); |
| 1149 |
|
| 1150 |
if ('yes' == $settings['global_link']) { |
| 1151 |
|
| 1152 |
$this->add_render_attribute('list-item', 'onclick', "window.open('" . esc_url(get_permalink()) . "', '_self')", true); |
| 1153 |
} |
| 1154 |
$this->add_render_attribute('list-item', 'class', 'upk-item', true); |
| 1155 |
|
| 1156 |
?> |
| 1157 |
<div <?php $this->print_render_attribute_string('list-item'); ?>> |
| 1158 |
<div class="upk-item-box"> |
| 1159 |
|
| 1160 |
<div class="upk-image-wrap"> |
| 1161 |
<?php $this->render_image(get_post_thumbnail_id($post_id), $image_size); ?> |
| 1162 |
</div> |
| 1163 |
<div class="upk-content"> |
| 1164 |
<?php if ($settings['show_counter_number'] == 'yes') : ?> |
| 1165 |
<div class="upk-counter"></div> |
| 1166 |
<?php endif; ?> |
| 1167 |
|
| 1168 |
<div> |
| 1169 |
<?php $this->render_category(); ?> |
| 1170 |
<?php $this->render_title(substr($this->get_name(), 4)); ?> |
| 1171 |
|
| 1172 |
<?php if ($settings['show_author'] or $settings['show_comments'] or $settings['show_date'] or $settings['show_reading_time']) : ?> |
| 1173 |
<div class="upk-featured-meta"> |
| 1174 |
<?php if ($settings['show_author']) : ?> |
| 1175 |
<?php $this->render_author(); ?> |
| 1176 |
<?php endif; ?> |
| 1177 |
<?php if ($settings['show_date']) : ?> |
| 1178 |
<div data-separator="<?php echo esc_html($settings['meta_separator']); ?>"> |
| 1179 |
<?php $this->render_date(); ?> |
| 1180 |
</div> |
| 1181 |
<?php endif; ?> |
| 1182 |
<?php if ($settings['show_comments']) : ?> |
| 1183 |
<div data-separator="<?php echo esc_html($settings['meta_separator']); ?>"> |
| 1184 |
<?php $this->render_comments($post_id); ?> |
| 1185 |
</div> |
| 1186 |
<?php endif; ?> |
| 1187 |
<?php if (_is_upk_pro_activated()) : |
| 1188 |
if ('yes' === $settings['show_reading_time']) : ?> |
| 1189 |
<div class="upk-reading-time" data-separator="<?php echo esc_html($settings['meta_separator']); ?>"> |
| 1190 |
<?php echo esc_html( ultimate_post_kit_reading_time( get_the_content(), $settings['avg_reading_speed'], $settings['hide_seconds'] ?? 'no', $settings['hide_minutes'] ?? 'no' ) ); ?> |
| 1191 |
</div> |
| 1192 |
<?php endif; ?> |
| 1193 |
<?php endif; ?> |
| 1194 |
</div> |
| 1195 |
<?php endif; ?> |
| 1196 |
|
| 1197 |
</div> |
| 1198 |
</div> |
| 1199 |
|
| 1200 |
</div> |
| 1201 |
</div> |
| 1202 |
|
| 1203 |
<?php |
| 1204 |
} |
| 1205 |
|
| 1206 |
protected function render() { |
| 1207 |
$settings = $this->get_settings_for_display(); |
| 1208 |
|
| 1209 |
$this->query_posts($settings['item_limit']['size']); |
| 1210 |
$wp_query = $this->get_query(); |
| 1211 |
|
| 1212 |
if (!$wp_query->found_posts) { |
| 1213 |
return; |
| 1214 |
} |
| 1215 |
|
| 1216 |
$this->add_render_attribute( |
| 1217 |
[ |
| 1218 |
'upk-featured-list' => [ |
| 1219 |
'class' => 'upk-featured-list upk-featured-' . $settings['layout_style'] . ' upk-ajax-grid', |
| 1220 |
'data-loadmore' => [ |
| 1221 |
wp_json_encode( |
| 1222 |
array_filter([ |
| 1223 |
'loadmore_enable' => $settings['ajax_loadmore_enable'], |
| 1224 |
'loadmore_btn' => $settings['ajax_loadmore_btn'], |
| 1225 |
'infinite_scroll' => $settings['ajax_loadmore_infinite_scroll'], |
| 1226 |
]) |
| 1227 |
), |
| 1228 |
], |
| 1229 |
], |
| 1230 |
] |
| 1231 |
); |
| 1232 |
|
| 1233 |
if ($settings['ajax_loadmore_enable'] == 'yes') { |
| 1234 |
$ajax_settings = [ |
| 1235 |
'posts_source' => isset($settings['posts_source']) ? $settings['posts_source'] : 'post', |
| 1236 |
'posts_per_page' => isset($settings['item_limit']['size']) ? $settings['item_limit']['size'] : 4, |
| 1237 |
'ajax_item_load' => isset($settings['ajax_loadmore_items']) ? $settings['ajax_loadmore_items'] : 4, |
| 1238 |
'posts_selected_ids' => isset($settings['posts_selected_ids']) ? $settings['posts_selected_ids'] : '', |
| 1239 |
'posts_include_by' => isset($settings['posts_include_by']) ? $settings['posts_include_by'] : [], |
| 1240 |
'posts_include_author_ids' => isset($settings['posts_include_author_ids']) ? $settings['posts_include_author_ids'] : '', |
| 1241 |
'posts_include_term_ids' => isset($settings['posts_include_term_ids']) ? $settings['posts_include_term_ids'] : '', |
| 1242 |
'posts_exclude_by' => isset($settings['posts_exclude_by']) ? $settings['posts_exclude_by'] : [], |
| 1243 |
'posts_exclude_ids' => isset($settings['posts_exclude_ids']) ? $settings['posts_exclude_ids'] : '', |
| 1244 |
'posts_exclude_author_ids' => isset($settings['posts_exclude_author_ids']) ? $settings['posts_exclude_author_ids'] : '', |
| 1245 |
'posts_exclude_term_ids' => isset($settings['posts_exclude_term_ids']) ? $settings['posts_exclude_term_ids'] : '', |
| 1246 |
'posts_offset' => isset($settings['posts_offset']) ? $settings['posts_offset'] : 0, |
| 1247 |
'posts_select_date' => isset($settings['posts_select_date']) ? $settings['posts_select_date'] : '', |
| 1248 |
'posts_date_before' => isset($settings['posts_date_before']) ? $settings['posts_date_before'] : '', |
| 1249 |
'posts_date_after' => isset($settings['posts_date_after']) ? $settings['posts_date_after'] : '', |
| 1250 |
'posts_orderby' => isset($settings['posts_orderby']) ? $settings['posts_orderby'] : 'date', |
| 1251 |
'posts_order' => isset($settings['posts_order']) ? $settings['posts_order'] : 'DESC', |
| 1252 |
'posts_ignore_sticky_posts' => isset($settings['posts_ignore_sticky_posts']) ? $settings['posts_ignore_sticky_posts'] : 'no', |
| 1253 |
'posts_only_with_featured_image'=> isset($settings['posts_only_with_featured_image']) ? $settings['posts_only_with_featured_image'] : 'no', |
| 1254 |
// List Settings |
| 1255 |
'layout_style' => isset($settings['layout_style']) ? $settings['layout_style'] : 'style-1', |
| 1256 |
'show_title' => isset($settings['show_title']) ? $settings['show_title'] : 'yes', |
| 1257 |
'title_tags' => isset( $settings['title_tags'] ) ? $settings['title_tags'] : 'h3', |
| 1258 |
'title_style' => isset($settings['title_style']) ? $settings['title_style'] : '', |
| 1259 |
'show_category' => isset($settings['show_category']) ? $settings['show_category'] : 'yes', |
| 1260 |
'show_counter_number' => isset($settings['show_counter_number']) ? $settings['show_counter_number'] : 'yes', |
| 1261 |
'show_author' => isset($settings['show_author']) ? $settings['show_author'] : 'no', |
| 1262 |
'show_comments' => isset($settings['show_comments']) ? $settings['show_comments'] : 'no', |
| 1263 |
'meta_separator' => isset($settings['meta_separator']) ? $settings['meta_separator'] : '//', |
| 1264 |
'show_date' => isset($settings['show_date']) ? $settings['show_date'] : 'no', |
| 1265 |
'show_time' => isset($settings['show_time']) ? $settings['show_time'] : 'no', |
| 1266 |
'human_diff_time' => isset($settings['human_diff_time']) ? $settings['human_diff_time'] : 'no', |
| 1267 |
'human_diff_time_short' => isset($settings['human_diff_time_short']) ? $settings['human_diff_time_short'] : 'no', |
| 1268 |
'show_reading_time' => isset($settings['show_reading_time']) ? $settings['show_reading_time'] : 'no', |
| 1269 |
'avg_reading_speed' => isset($settings['avg_reading_speed']) ? $settings['avg_reading_speed'] : 200, |
| 1270 |
'hide_seconds' => isset($settings['hide_seconds']) ? $settings['hide_seconds'] : 'no', |
| 1271 |
'hide_minutes' => isset($settings['hide_minutes']) ? $settings['hide_minutes'] : 'no', |
| 1272 |
'primary_thumbnail_size' => isset($settings['primary_thumbnail_size']) ? $settings['primary_thumbnail_size'] : 'medium', |
| 1273 |
'upk_link_new_tab' => isset($settings['upk_link_new_tab']) ? $settings['upk_link_new_tab'] : 'no', |
| 1274 |
'global_link' => isset($settings['global_link']) ? $settings['global_link'] : 'no', |
| 1275 |
]; |
| 1276 |
|
| 1277 |
$this->add_render_attribute( |
| 1278 |
[ |
| 1279 |
'upk-featured-list' => [ |
| 1280 |
'data-settings' => [ |
| 1281 |
wp_json_encode($ajax_settings) |
| 1282 |
], |
| 1283 |
], |
| 1284 |
] |
| 1285 |
); |
| 1286 |
} |
| 1287 |
|
| 1288 |
$this->add_render_attribute('list-wrap', 'class', 'upk-featured-list upk-featured-' . $settings['layout_style'] . ' upk-ajax-grid-wrap'); |
| 1289 |
|
| 1290 |
if (isset($settings['upk_in_animation_show']) && ($settings['upk_in_animation_show'] == 'yes')) { |
| 1291 |
$this->add_render_attribute('list-wrap', 'class', 'upk-in-animation'); |
| 1292 |
if (isset($settings['upk_in_animation_delay']['size'])) { |
| 1293 |
$this->add_render_attribute('list-wrap', 'data-in-animation-delay', $settings['upk_in_animation_delay']['size']); |
| 1294 |
} |
| 1295 |
} |
| 1296 |
|
| 1297 |
?> |
| 1298 |
<div <?php $this->print_render_attribute_string('upk-featured-list'); ?>> |
| 1299 |
<div <?php $this->print_render_attribute_string('list-wrap'); ?>> |
| 1300 |
<?php while ($wp_query->have_posts()) : |
| 1301 |
$wp_query->the_post(); |
| 1302 |
|
| 1303 |
$thumbnail_size = $settings['primary_thumbnail_size']; |
| 1304 |
|
| 1305 |
?> |
| 1306 |
|
| 1307 |
<?php $this->render_post_grid_item(get_the_ID(), $thumbnail_size); ?> |
| 1308 |
|
| 1309 |
<?php endwhile; ?> |
| 1310 |
</div> |
| 1311 |
</div> |
| 1312 |
|
| 1313 |
<?php $this->render_ajax_loadmore(); ?> |
| 1314 |
|
| 1315 |
<?php |
| 1316 |
|
| 1317 |
if ($settings['show_pagination']) { ?> |
| 1318 |
<div class="ep-pagination"> |
| 1319 |
<?php ultimate_post_kit_post_pagination($wp_query, $this->get_id()); ?> |
| 1320 |
</div> |
| 1321 |
<?php |
| 1322 |
} |
| 1323 |
wp_reset_postdata(); |
| 1324 |
} |
| 1325 |
} |
| 1326 |
|