| @@ -128,8 +128,9 @@ | ||
| 128 | 128 | $this->add_group_control( |
| 129 | 129 | Group_Control_Image_Size::get_type(), |
| 130 | 130 | [ |
| 131 | 131 | 'name' => 'primary_thumbnail', |
| 132 | + // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Elementor widget query built from user-configured controls; expected behaviour. | |
| 132 | 133 | 'exclude' => [ 'custom' ], |
| 133 | 134 | 'default' => 'medium', |
| 134 | 135 | ] |
| 135 | 136 | ); |
| @@ -158,8 +159,11 @@ | ||
| 158 | 159 | ], |
| 159 | 160 | 'default' => [ |
| 160 | 161 | 'size' => 3, |
| 161 | 162 | ], |
| 163 | + 'condition' => [ | |
| 164 | + 'posts_source!' => 'current_query', | |
| 165 | + ] | |
| 162 | 166 | ] |
| 163 | 167 | ); |
| 164 | 168 | |
| 165 | 169 | $this->register_query_builder_controls(); |
| @@ -746,20 +750,33 @@ | ||
| 746 | 750 | $this->register_pagination_controls(); |
| 747 | 751 | } |
| 748 | 752 | |
| 749 | 753 | /** |
| 750 | - * Main query render for this widget | |
| 751 | - * @param $posts_per_page number item query limit | |
| 754 | + * Get post query builder arguments | |
| 752 | 755 | */ |
| 753 | 756 | public function query_posts( $posts_per_page ) { |
| 754 | - | |
| 755 | - $default = $this->getGroupControlQueryArgs(); | |
| 756 | - if ( $posts_per_page ) { | |
| 757 | + $settings = $this->get_settings(); | |
| 758 | + $posts_per_page = isset( $posts_per_page ) ? (int) $posts_per_page : 0; | |
| 759 | + $args = $this->getGroupControlQueryArgs(); | |
| 760 | + $is_current_query = ( ! empty( $settings['posts_source'] ) && $settings['posts_source'] === 'current_query' ); | |
| 761 | + | |
| 762 | + if ( $is_current_query ) { | |
| 763 | + unset( $args['offset'] ); | |
| 764 | + unset( $args['no_found_rows'] ); | |
| 765 | + $posts_per_page = 0; | |
| 766 | + } | |
| 767 | + | |
| 768 | + if ( $posts_per_page > 0 ) { | |
| 757 | 769 | $args['posts_per_page'] = $posts_per_page; |
| 758 | - $args['paged'] = max( 1, get_query_var( 'paged' ), get_query_var( 'page' ) ); | |
| 770 | + } else { | |
| 771 | + $args['posts_per_page'] = (int) get_option( 'posts_per_page', 10 ); | |
| 759 | 772 | } |
| 760 | - $args = array_merge( $default, $args ); | |
| 761 | - $this->_query = new WP_Query( $args ); | |
| 773 | + | |
| 774 | + if ( $settings['show_pagination'] ) { | |
| 775 | + $args['paged'] = max( 1, (int) get_query_var( 'paged' ), (int) get_query_var( 'page' ) ); | |
| 776 | + } | |
| 777 | + | |
| 778 | + $this->_query = new \WP_Query( $args ); | |
| 762 | 779 | } |
| 763 | 780 | |
| 764 | 781 | public function render_author() { |
| 765 | 782 | |
| @@ -823,15 +840,15 @@ | ||
| 823 | 840 | <div class="upk-meta"> |
| 824 | 841 | <?php $this->render_category(); ?> |
| 825 | 842 | |
| 826 | 843 | <?php if ($settings['show_author']) : ?> |
| 827 | - <div data-separator="<?php echo esc_html($settings['meta_separator']); ?>"> | |
| 844 | + <div data-separator="<?php echo esc_attr($settings['meta_separator']); ?>"> | |
| 828 | 845 | <?php $this->render_author(); ?> |
| 829 | 846 | </div> |
| 830 | 847 | <?php endif; ?> |
| 831 | 848 | <?php if (_is_upk_pro_activated()) : |
| 832 | 849 | if ('yes' === $settings['show_reading_time']) : ?> |
| 833 | - <div class="upk-reading-time" data-separator="<?php echo esc_html($settings['meta_separator']); ?>"> | |
| 850 | + <div class="upk-reading-time" data-separator="<?php echo esc_attr($settings['meta_separator']); ?>"> | |
| 834 | 851 | <?php echo esc_html( ultimate_post_kit_reading_time( get_the_content(), $settings['avg_reading_speed'], $settings['hide_seconds'] ?? 'no', $settings['hide_minutes'] ?? 'no' ) ); ?> |
| 835 | 852 | </div> |
| 836 | 853 | <?php endif; ?> |
| 837 | 854 | <?php endif; ?> |