PluginProbe
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets / 4.5.6
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets v4.5.6
4.5.6 4.5.5 4.5.4 4.2.1 4.2.2 4.2.3 4.5.0 4.5.2 4.5.3 4.2.0 4.1.18 4.1.17 4.1.16 4.1.15 4.1.14 4.1.13 4.1.12 4.1.11 4.1.10 4.1.9 4.1.8 4.0.9 4.1.0 4.1.1 4.1.2 All 148 releases
← All changes | modules/author/widgets/author.php +90 -10 4.0.9 → 4.5.6 View file →
@@ -10,8 +10,10 @@
10 10 use Elementor\Group_Control_Text_Shadow;
11 11 use Elementor\Group_Control_Background;
12 12 use Elementor\Group_Control_Css_Filter;
13 13
14 +use UltimatePostKit\Traits\Global_Widget_Controls;
15 +
14 16 if (!defined('ABSPATH')) {
15 17 exit;
16 18 } // Exit if accessed directly
17 19
@@ -17,8 +19,10 @@
17 19
18 20 class Author extends Module_Base {
19 21 private $_query = null;
20 22
23 + use Global_Widget_Controls;
24 +
21 25 public function get_name() {
22 26 return 'upk-author';
23 27 }
24 28
@@ -290,8 +294,17 @@
290 294 ]
291 295 ]
292 296 );
293 297
298 + $this->add_control(
299 + 'show_pagination',
300 + [
301 + 'label' => esc_html__('Show Pagination', 'ultimate-post-kit') . BDTUPK_NC,
302 + 'type' => Controls_Manager::SWITCHER,
303 + 'separator' => 'before',
304 + ]
305 + );
306 +
294 307 $this->end_controls_section();
295 308
296 309 $this->start_controls_section(
297 310 'section_post_grid_query',
@@ -343,8 +356,30 @@
343 356 ]
344 357 );
345 358
346 359 $this->add_control(
360 + 'min_published_posts',
361 + [
362 + 'label' => esc_html__( 'Minimum Author Posts', 'ultimate-post-kit' ) . BDTUPK_NC,
363 + 'type' => Controls_Manager::SLIDER,
364 + 'range' => [
365 + 'px' => [
366 + 'min' => 0,
367 + 'max' => 100,
368 + 'step' => 1,
369 + ],
370 + ],
371 + 'default' => [
372 + 'size' => 0,
373 + ],
374 + 'description' => esc_html__(
375 + 'Only show authors who have at least this number of published posts. Set 0 to show all.',
376 + 'ultimate-post-kit'
377 + ),
378 + ]
379 + );
380 +
381 + $this->add_control(
347 382 'orderby',
348 383 [
349 384 'label' => esc_html__('Order By', 'ultimate-post-kit'),
350 385 'type' => Controls_Manager::SELECT,
@@ -408,9 +443,9 @@
408 443 [
409 444 'label' => esc_html__('Glassmorphism', 'ultimate-post-kit'),
410 445 'type' => Controls_Manager::SWITCHER,
411 446 // translators: %1s: Opening anchor tag with link to MDN backdrop-filter documentation, %2s: Closing anchor tag
412 - 'description' => sprintf(__('This feature will not work in the Firefox browser untill you enable browser compatibility so please %1s look here %2s', 'ultimate-post-kit'), '<a href="https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility" target="_blank">', '</a>'),
447 + 'description' => sprintf(__('This feature will not work in the Firefox browser untill you enable browser compatibility so please %1$s look here %2$s', 'ultimate-post-kit'), '<a href="https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility" target="_blank">', '</a>'),
413 448
414 449 ]
415 450 );
416 451
@@ -620,8 +655,9 @@
620 655 'image_mask_shape_custom',
621 656 [
622 657 'label' => _x('Custom Shape', 'Mask Image', 'ultimate-post-kit'),
623 658 'type' => Controls_Manager::MEDIA,
659 + 'dynamic' => ['active' => true],
624 660 'show_label' => false,
625 661 'selectors' => [
626 662 '{{WRAPPER}} .upk-author-wrapper .upk-image a img' => '-webkit-mask-image: url({{URL}}); mask-image: url({{URL}});',
627 663 ],
@@ -1354,26 +1390,59 @@
1354 1390
1355 1391 $this->end_controls_tabs();
1356 1392
1357 1393 $this->end_controls_section();
1394 +
1395 + //Global Pagination Style Controls
1396 + $this->register_pagination_controls();
1358 1397 }
1359 1398
1360 1399 public function render() {
1361 1400 $settings = $this->get_settings_for_display();
1362 1401
1402 + $min_published_posts = isset($settings['min_published_posts']['size']) ? absint($settings['min_published_posts']['size']) : 0;
1403 + $item_limit = (int) $settings['item_limit']['size'];
1404 + $show_pagination = !empty($settings['show_pagination']);
1405 +
1406 + $number = ($min_published_posts > 0 || $show_pagination) ? -1 : $item_limit;
1407 +
1363 1408 $users = get_users([
1364 1409 'orderby' => $settings['orderby'],
1365 1410 'order' => $settings['order'],
1366 1411 'role__in' => (!empty($settings['role'])) ? $settings['role'] : null,
1367 - 'number' => $settings['item_limit']['size'],
1368 - 'exclude' => explode(',', esc_attr($settings["exclude"])),
1412 + 'number' => $number,
1413 + // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Elementor widget query built from user-configured controls; expected behaviour.
1414 + 'exclude' => array_filter(array_map('absint', explode(',', esc_attr($settings['exclude'])))),
1369 1415 ]);
1370 1416
1371 - $social_links = $settings['social_links'];
1417 + if ($min_published_posts > 0) {
1418 + $users = array_filter($users, function ($user) use ($min_published_posts) {
1419 + return count_user_posts($user->ID) >= $min_published_posts;
1420 + });
1421 + $users = array_values($users);
1422 + }
1372 1423
1424 + $total_users = count($users);
1425 + $total_pages = $item_limit > 0 ? (int) ceil($total_users / $item_limit) : 1;
1426 + $paged = max(1, (int) get_query_var('paged'), (int) get_query_var('page'));
1427 +
1428 + if ($show_pagination) {
1429 + $offset = ($paged - 1) * $item_limit;
1430 + $users = array_slice($users, $offset, $item_limit);
1431 + } else {
1432 + $users = array_slice($users, 0, $item_limit);
1433 + }
1434 +
1435 + // Elementor stores control values verbatim, so the saved list must be checked
1436 + // against the control's own options before any value is used as a user field name.
1437 + $allowed_links = array_keys(ultimate_post_kit_user_contact_methods([], true));
1438 + $social_links = array_values(array_filter((array) $settings['social_links'], function ($link) use ($allowed_links) {
1439 + return is_string($link) && in_array($link, $allowed_links, true);
1440 + }));
1441 +
1373 1442 ?>
1374 1443 <div class="upk-author">
1375 - <div class="upk-author-wrapper upk-<?php echo esc_html($settings['layout_style']) ?>">
1444 + <div class="upk-author-wrapper upk-<?php echo esc_attr($settings['layout_style']) ?>">
1376 1445 <?php
1377 1446 foreach ($users as $author) {
1378 1447
1379 1448 ?>
@@ -1390,10 +1459,10 @@
1390 1459
1391 1460 <div class="upk-content">
1392 1461 <?php if ($settings['show_author_name']) : ?>
1393 1462 <div class="upk-name">
1394 - <a href="<?php echo get_bloginfo('url') . "/?author=" . esc_attr($author->ID); ?>">
1395 - <?php echo get_the_author_meta('display_name', $author->ID); ?>
1463 + <a href="<?php echo esc_url(get_author_posts_url($author->ID)); ?>">
1464 + <?php echo esc_html(get_the_author_meta('display_name', $author->ID)); ?>
1396 1465 </a>
1397 1466 </div>
1398 1467 <?php endif; ?>
1399 1468
@@ -1398,15 +1467,15 @@
1398 1467 <?php endif; ?>
1399 1468
1400 1469 <?php if ($settings['show_author_role']) : ?>
1401 1470 <div class="upk-role">
1402 - <?php echo ucwords(get_user_role($author->ID)); ?>
1471 + <?php echo esc_html( get_user_role( $author->ID ) ); ?>
1403 1472 </div>
1404 1473 <?php endif; ?>
1405 1474
1406 1475 <?php if ($settings['show_author_description'] and get_the_author_meta('description', $author->ID)) : ?>
1407 1476 <div class="upk-description">
1408 - <?php echo get_the_author_meta('description', $author->ID); ?>
1477 + <?php echo wp_kses_post(get_the_author_meta('description', $author->ID)); ?>
1409 1478 </div>
1410 1479 <?php endif; ?>
1411 1480
1412 1481 <?php if ($settings['show_author_link'] and !empty($social_links)) : ?>
@@ -1428,9 +1497,9 @@
1428 1497 }
1429 1498
1430 1499 ?>
1431 1500
1432 - <a href="<?php echo esc_url($final_url); ?>" title="<?php echo esc_html($alt_title); ?>">
1501 + <a href="<?php echo esc_url($final_url); ?>" title="<?php echo esc_attr($alt_title); ?>">
1433 1502 <i class="upk-icon-<?php echo esc_attr($link); ?>" aria-hidden="true"></i>
1434 1503 </a>
1435 1504 <?php endif; ?>
1436 1505
@@ -1460,7 +1529,18 @@
1460 1529 </div>
1461 1530 <?php } ?>
1462 1531 </div>
1463 1532 </div>
1533 +
1534 + <?php if ($show_pagination && $total_pages > 1) : ?>
1535 + <div class="ep-pagination">
1536 + <?php
1537 + $author_pagination_query = new \stdClass();
1538 + $author_pagination_query->max_num_pages = $total_pages;
1539 + $author_pagination_query->query_vars = ['paged' => $paged, 'page' => $paged];
1540 + ultimate_post_kit_post_pagination($author_pagination_query, $this->get_id());
1541 + ?>
1542 + </div>
1543 + <?php endif; ?>
1464 1544 <?php
1465 1545 }
1466 1546 }