| @@ -49,9 +49,9 @@ | ||
| 49 | 49 | public function get_style_depends() { |
| 50 | 50 | if ($this->upk_is_edit_mode()) { |
| 51 | 51 | return ['upk-all-styles']; |
| 52 | 52 | } else { |
| 53 | - return ['upk-buzz-list']; | |
| 53 | + return ['upk-font', 'upk-buzz-list']; | |
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | public function get_script_depends() { |
| @@ -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 | ); |
| @@ -233,8 +234,11 @@ | ||
| 233 | 234 | ], |
| 234 | 235 | 'default' => [ |
| 235 | 236 | 'size' => 6, |
| 236 | 237 | ], |
| 238 | + 'condition' => [ | |
| 239 | + 'posts_source!' => 'current_query', | |
| 240 | + ] | |
| 237 | 241 | ] |
| 238 | 242 | ); |
| 239 | 243 | |
| 240 | 244 | $this->register_query_builder_controls(); |
| @@ -799,21 +803,33 @@ | ||
| 799 | 803 | $this->register_ajax_loadmore_style_controls(); |
| 800 | 804 | } |
| 801 | 805 | |
| 802 | 806 | /** |
| 803 | - * Main query render for this widget | |
| 804 | - * @param $posts_per_page number item query limit | |
| 807 | + * Get post query builder arguments | |
| 805 | 808 | */ |
| 806 | - public function query_posts($posts_per_page) { | |
| 809 | + public function query_posts( $posts_per_page ) { | |
| 810 | + $settings = $this->get_settings(); | |
| 811 | + $posts_per_page = isset( $posts_per_page ) ? (int) $posts_per_page : 0; | |
| 812 | + $args = $this->getGroupControlQueryArgs(); | |
| 813 | + $is_current_query = ( ! empty( $settings['posts_source'] ) && $settings['posts_source'] === 'current_query' ); | |
| 807 | 814 | |
| 808 | - $default = $this->getGroupControlQueryArgs(); | |
| 809 | - $args = []; | |
| 810 | - if ($posts_per_page) { | |
| 815 | + if ( $is_current_query ) { | |
| 816 | + unset( $args['offset'] ); | |
| 817 | + unset( $args['no_found_rows'] ); | |
| 818 | + $posts_per_page = 0; | |
| 819 | + } | |
| 820 | + | |
| 821 | + if ( $posts_per_page > 0 ) { | |
| 811 | 822 | $args['posts_per_page'] = $posts_per_page; |
| 812 | - $args['paged'] = max(1, get_query_var('paged'), get_query_var('page')); | |
| 823 | + } else { | |
| 824 | + $args['posts_per_page'] = (int) get_option( 'posts_per_page', 10 ); | |
| 813 | 825 | } |
| 814 | - $args = array_merge($default, $args); | |
| 815 | - $this->_query = new WP_Query($args); | |
| 826 | + | |
| 827 | + if ( $settings['show_pagination'] ) { | |
| 828 | + $args['paged'] = max( 1, (int) get_query_var( 'paged' ), (int) get_query_var( 'page' ) ); | |
| 829 | + } | |
| 830 | + | |
| 831 | + $this->_query = new \WP_Query( $args ); | |
| 816 | 832 | } |
| 817 | 833 | |
| 818 | 834 | public function render_author() { |
| 819 | 835 | |
| @@ -834,13 +850,12 @@ | ||
| 834 | 850 | |
| 835 | 851 | if (!$this->get_settings('show_comments')) { |
| 836 | 852 | return; |
| 837 | 853 | } |
| 838 | - ?> | |
| 854 | + ?> | |
| 839 | 855 | |
| 840 | 856 | <div class="upk-comments"> |
| 841 | - <?php echo get_comments_number($id) ?> | |
| 842 | - <?php echo esc_html_x('Comments', 'Frontend', 'ultimate-post-kit') ?> | |
| 857 | + <?php echo esc_html( $this->upk_get_formatted_comments_count( $id ) ); ?> | |
| 843 | 858 | </div> |
| 844 | 859 | |
| 845 | 860 | <?php |
| 846 | 861 | } |
| @@ -870,9 +885,9 @@ | ||
| 870 | 885 | <?php $this->render_author(); ?> |
| 871 | 886 | <?php endif; ?> |
| 872 | 887 | |
| 873 | 888 | <?php if ($settings['show_date']) : ?> |
| 874 | - <div data-separator="<?php echo esc_html($settings['meta_separator']); ?>"> | |
| 889 | + <div data-separator="<?php echo esc_attr($settings['meta_separator']); ?>"> | |
| 875 | 890 | <?php $this->render_date(); ?> |
| 876 | 891 | </div> |
| 877 | 892 | <?php endif; ?> |
| 878 | 893 | |
| @@ -877,9 +892,9 @@ | ||
| 877 | 892 | <?php endif; ?> |
| 878 | 893 | |
| 879 | 894 | <?php if (_is_upk_pro_activated()) : |
| 880 | 895 | if ('yes' === $settings['show_reading_time']) : ?> |
| 881 | - <div class="upk-reading-time" data-separator="<?php echo esc_html($settings['meta_separator']); ?>"> | |
| 896 | + <div class="upk-reading-time" data-separator="<?php echo esc_attr($settings['meta_separator']); ?>"> | |
| 882 | 897 | <?php echo esc_html( ultimate_post_kit_reading_time( get_the_content(), $settings['avg_reading_speed'], $settings['hide_seconds'] ?? 'no', $settings['hide_minutes'] ?? 'no' ) ); ?> |
| 883 | 898 | </div> |
| 884 | 899 | <?php endif; ?> |
| 885 | 900 | <?php endif; ?> |
| @@ -884,9 +899,9 @@ | ||
| 884 | 899 | <?php endif; ?> |
| 885 | 900 | <?php endif; ?> |
| 886 | 901 | |
| 887 | 902 | <?php if ($settings['show_comments']) : ?> |
| 888 | - <div data-separator="<?php echo esc_html($settings['meta_separator']); ?>"> | |
| 903 | + <div data-separator="<?php echo esc_attr($settings['meta_separator']); ?>"> | |
| 889 | 904 | <?php $this->render_comments($post_id); ?> |
| 890 | 905 | </div> |
| 891 | 906 | <?php endif; ?> |
| 892 | 907 | |