| @@ -97,8 +97,9 @@ | ||
| 97 | 97 | ], |
| 98 | 98 | ] |
| 99 | 99 | ); |
| 100 | 100 | |
| 101 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- established hook name relied on across the plugin family; renaming would break integration. | |
| 101 | 102 | $column_size = apply_filters('upk_column_size', ''); |
| 102 | 103 | |
| 103 | 104 | $this->add_responsive_control( |
| 104 | 105 | 'columns', |
| @@ -211,8 +212,9 @@ | ||
| 211 | 212 | $this->add_group_control( |
| 212 | 213 | Group_Control_Image_Size::get_type(), |
| 213 | 214 | [ |
| 214 | 215 | 'name' => 'primary_thumbnail', |
| 216 | + // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Elementor widget query built from user-configured controls; expected behaviour. | |
| 215 | 217 | 'exclude' => ['custom'], |
| 216 | 218 | 'default' => 'medium', |
| 217 | 219 | ] |
| 218 | 220 | ); |
| @@ -310,9 +312,10 @@ | ||
| 310 | 312 | 'default' => [ |
| 311 | 313 | 'size' => 6, |
| 312 | 314 | ], |
| 313 | 315 | 'condition' => [ |
| 314 | - 'grid_style' => ['1'] | |
| 316 | + 'grid_style' => ['1'], | |
| 317 | + 'posts_source!' => 'current_query' | |
| 315 | 318 | ] |
| 316 | 319 | ] |
| 317 | 320 | ); |
| 318 | 321 | |
| @@ -331,9 +334,10 @@ | ||
| 331 | 334 | 'default' => [ |
| 332 | 335 | 'size' => 4, |
| 333 | 336 | ], |
| 334 | 337 | 'condition' => [ |
| 335 | - 'grid_style' => ['2'] | |
| 338 | + 'grid_style' => ['2'], | |
| 339 | + 'posts_source!' => 'current_query' | |
| 336 | 340 | ] |
| 337 | 341 | ] |
| 338 | 342 | ); |
| 339 | 343 | |
| @@ -352,9 +356,10 @@ | ||
| 352 | 356 | 'default' => [ |
| 353 | 357 | 'size' => 5, |
| 354 | 358 | ], |
| 355 | 359 | 'condition' => [ |
| 356 | - 'grid_style' => ['3'] | |
| 360 | + 'grid_style' => ['3'], | |
| 361 | + 'posts_source!' => 'current_query' | |
| 357 | 362 | ] |
| 358 | 363 | ] |
| 359 | 364 | ); |
| 360 | 365 | |
| @@ -575,9 +580,9 @@ | ||
| 575 | 580 | [ |
| 576 | 581 | 'label' => esc_html__('Glassmorphism', 'ultimate-post-kit'), |
| 577 | 582 | 'type' => Controls_Manager::SWITCHER, |
| 578 | 583 | // translators: %1s: Opening anchor tag with link to MDN backdrop-filter documentation, %2s: Closing anchor tag |
| 579 | - '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>'), | |
| 584 | + '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>'), | |
| 580 | 585 | 'default' => 'yes', |
| 581 | 586 | 'condition' => [ |
| 582 | 587 | 'content_on_image' => 'yes' |
| 583 | 588 | ] |
| @@ -645,8 +650,9 @@ | ||
| 645 | 650 | Group_Control_Background::get_type(), |
| 646 | 651 | [ |
| 647 | 652 | 'name' => 'itam_content_background', |
| 648 | 653 | 'selector' => '{{WRAPPER}}.upk-content-on-image-yes .upk-alter-grid .upk-content', |
| 654 | + // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Elementor widget query built from user-configured controls; expected behaviour. | |
| 649 | 655 | 'exclude' => ['image'], |
| 650 | 656 | 'condition' => [ |
| 651 | 657 | 'content_on_image' => 'yes' |
| 652 | 658 | ] |
| @@ -709,8 +715,9 @@ | ||
| 709 | 715 | Group_Control_Background::get_type(), |
| 710 | 716 | [ |
| 711 | 717 | 'name' => 'itam_content_hover_background', |
| 712 | 718 | 'selector' => '{{WRAPPER}}.upk-content-on-image-yes .upk-alter-grid .upk-item:hover .upk-content', |
| 719 | + // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Elementor widget query built from user-configured controls; expected behaviour. | |
| 713 | 720 | 'exclude' => ['image'], |
| 714 | 721 | 'condition' => [ |
| 715 | 722 | 'content_on_image' => 'yes' |
| 716 | 723 | ] |
| @@ -1571,21 +1578,33 @@ | ||
| 1571 | 1578 | $this->register_ajax_loadmore_style_controls(); |
| 1572 | 1579 | } |
| 1573 | 1580 | |
| 1574 | 1581 | /** |
| 1575 | - * Main query render for this widget | |
| 1576 | - * @param $posts_per_page number item query limit | |
| 1582 | + * Get post query builder arguments | |
| 1577 | 1583 | */ |
| 1578 | - public function query_posts($posts_per_page) { | |
| 1584 | + public function query_posts( $posts_per_page ) { | |
| 1585 | + $settings = $this->get_settings(); | |
| 1586 | + $posts_per_page = isset( $posts_per_page ) ? (int) $posts_per_page : 0; | |
| 1587 | + $args = $this->getGroupControlQueryArgs(); | |
| 1588 | + $is_current_query = ( ! empty( $settings['posts_source'] ) && $settings['posts_source'] === 'current_query' ); | |
| 1579 | 1589 | |
| 1580 | - $default = $this->getGroupControlQueryArgs(); | |
| 1581 | - $args = []; | |
| 1582 | - if ($posts_per_page) { | |
| 1590 | + if ( $is_current_query ) { | |
| 1591 | + unset( $args['offset'] ); | |
| 1592 | + unset( $args['no_found_rows'] ); | |
| 1593 | + $posts_per_page = 0; | |
| 1594 | + } | |
| 1595 | + | |
| 1596 | + if ( $posts_per_page > 0 ) { | |
| 1583 | 1597 | $args['posts_per_page'] = $posts_per_page; |
| 1584 | - $args['paged'] = max(1, get_query_var('paged'), get_query_var('page')); | |
| 1598 | + } else { | |
| 1599 | + $args['posts_per_page'] = (int) get_option( 'posts_per_page', 10 ); | |
| 1585 | 1600 | } |
| 1586 | - $args = array_merge($default, $args); | |
| 1587 | - $this->_query = new WP_Query($args); | |
| 1601 | + | |
| 1602 | + if ( $settings['show_pagination'] ) { | |
| 1603 | + $args['paged'] = max( 1, (int) get_query_var( 'paged' ), (int) get_query_var( 'page' ) ); | |
| 1604 | + } | |
| 1605 | + | |
| 1606 | + $this->_query = new \WP_Query( $args ); | |
| 1588 | 1607 | } |
| 1589 | 1608 | |
| 1590 | 1609 | public function render_readmore() { |
| 1591 | 1610 | $settings = $this->get_settings_for_display(); |
| @@ -1664,9 +1683,9 @@ | ||
| 1664 | 1683 | |
| 1665 | 1684 | <?php if ($settings['show_author'] or $settings['show_date'] or $settings['show_reading_time']) : ?> |
| 1666 | 1685 | <div class="upk-meta"> |
| 1667 | 1686 | <?php if ($settings['show_author']) : ?> |
| 1668 | - <div class="upk-blog-author" data-separator="<?php echo esc_html($settings['meta_separator']); ?>"> | |
| 1687 | + <div class="upk-blog-author" data-separator="<?php echo esc_attr($settings['meta_separator']); ?>"> | |
| 1669 | 1688 | <a |
| 1670 | 1689 | class="author-name" |
| 1671 | 1690 | href="<?php echo esc_url( get_author_posts_url(get_the_author_meta('ID')) ); ?>" |
| 1672 | 1691 | aria-label="<?php echo esc_attr( 'View all posts by ' . get_the_author() ); ?>" |
| @@ -1675,9 +1694,9 @@ | ||
| 1675 | 1694 | </a> |
| 1676 | 1695 | </div> |
| 1677 | 1696 | <?php endif; ?> |
| 1678 | 1697 | <?php if ('yes' === $settings['show_date']) : ?> |
| 1679 | - <div data-separator="<?php echo esc_html($settings['meta_separator']); ?>"> | |
| 1698 | + <div data-separator="<?php echo esc_attr($settings['meta_separator']); ?>"> | |
| 1680 | 1699 | <?php $this->render_date(); ?> |
| 1681 | 1700 | </div> |
| 1682 | 1701 | <?php endif; ?> |
| 1683 | 1702 | |
| @@ -1682,9 +1701,9 @@ | ||
| 1682 | 1701 | <?php endif; ?> |
| 1683 | 1702 | |
| 1684 | 1703 | <?php if (_is_upk_pro_activated()) : |
| 1685 | 1704 | if ('yes' === $settings['show_reading_time']) : ?> |
| 1686 | - <div class="upk-reading-time" data-separator="<?php echo esc_html($settings['meta_separator']); ?>"> | |
| 1705 | + <div class="upk-reading-time" data-separator="<?php echo esc_attr($settings['meta_separator']); ?>"> | |
| 1687 | 1706 | <?php echo esc_html( ultimate_post_kit_reading_time( get_the_content(), $settings['avg_reading_speed'], $settings['hide_seconds'] ?? 'no', $settings['hide_minutes'] ?? 'no' ) ); ?> |
| 1688 | 1707 | </div> |
| 1689 | 1708 | <?php endif; ?> |
| 1690 | 1709 | <?php endif; ?> |