| @@ -156,8 +156,9 @@ | ||
| 156 | 156 | $this->add_group_control( |
| 157 | 157 | Group_Control_Image_Size::get_type(), |
| 158 | 158 | [ |
| 159 | 159 | 'name' => 'primary_thumbnail', |
| 160 | + // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Elementor widget query built from user-configured controls; expected behaviour. | |
| 160 | 161 | 'exclude' => ['custom'], |
| 161 | 162 | 'default' => 'medium', |
| 162 | 163 | ] |
| 163 | 164 | ); |
| @@ -223,8 +224,11 @@ | ||
| 223 | 224 | ], |
| 224 | 225 | 'default' => [ |
| 225 | 226 | 'size' => 6, |
| 226 | 227 | ], |
| 228 | + 'condition' => [ | |
| 229 | + 'posts_source!' => 'current_query', | |
| 230 | + ] | |
| 227 | 231 | ] |
| 228 | 232 | ); |
| 229 | 233 | |
| 230 | 234 | $this->register_query_builder_controls(); |
| @@ -883,9 +887,9 @@ | ||
| 883 | 887 | [ |
| 884 | 888 | 'label' => esc_html__('Arrow Size', 'ultimate-post-kit'), |
| 885 | 889 | 'type' => Controls_Manager::SLIDER, |
| 886 | 890 | 'selectors' => [ |
| 887 | - '{{WRAPPER}} ul.upk-pagination li a svg' => 'height: {{SIZE}}px; width: auto;', | |
| 891 | + '{{WRAPPER}} ul.upk-pagination li a i' => 'font-size: {{SIZE}}px;', | |
| 888 | 892 | ], |
| 889 | 893 | ] |
| 890 | 894 | ); |
| 891 | 895 | |
| @@ -988,22 +992,35 @@ | ||
| 988 | 992 | $this->register_ajax_loadmore_style_controls(); |
| 989 | 993 | } |
| 990 | 994 | |
| 991 | 995 | /** |
| 992 | - * Main query render for this widget | |
| 993 | - * @param $posts_per_page number item query limit | |
| 994 | - */ | |
| 995 | - public function query_posts($posts_per_page) | |
| 996 | - { | |
| 997 | - $default = $this->getGroupControlQueryArgs(); | |
| 998 | - if ($posts_per_page) { | |
| 999 | - $args['posts_per_page'] = $posts_per_page; | |
| 1000 | - $args['paged'] = max(1, get_query_var('paged'), get_query_var('page')); | |
| 1001 | - } | |
| 1002 | - $args = array_merge($default, $args); | |
| 1003 | - $this->_query = new WP_Query($args); | |
| 1004 | - } | |
| 996 | + * Get post query builder arguments | |
| 997 | + */ | |
| 998 | + public function query_posts( $posts_per_page ) { | |
| 999 | + $settings = $this->get_settings(); | |
| 1000 | + $posts_per_page = isset( $posts_per_page ) ? (int) $posts_per_page : 0; | |
| 1001 | + $args = $this->getGroupControlQueryArgs(); | |
| 1002 | + $is_current_query = ( ! empty( $settings['posts_source'] ) && $settings['posts_source'] === 'current_query' ); | |
| 1005 | 1003 | |
| 1004 | + if ( $is_current_query ) { | |
| 1005 | + unset( $args['offset'] ); | |
| 1006 | + unset( $args['no_found_rows'] ); | |
| 1007 | + $posts_per_page = 0; | |
| 1008 | + } | |
| 1009 | + | |
| 1010 | + if ( $posts_per_page > 0 ) { | |
| 1011 | + $args['posts_per_page'] = $posts_per_page; | |
| 1012 | + } else { | |
| 1013 | + $args['posts_per_page'] = (int) get_option( 'posts_per_page', 10 ); | |
| 1014 | + } | |
| 1015 | + | |
| 1016 | + if ( $settings['show_pagination'] ) { | |
| 1017 | + $args['paged'] = max( 1, (int) get_query_var( 'paged' ), (int) get_query_var( 'page' ) ); | |
| 1018 | + } | |
| 1019 | + | |
| 1020 | + $this->_query = new \WP_Query( $args ); | |
| 1021 | + } | |
| 1022 | + | |
| 1006 | 1023 | public function render_comments($id = 0) |
| 1007 | 1024 | { |
| 1008 | 1025 | |
| 1009 | 1026 | if (!$this->get_settings('show_comments')) { |
| @@ -1011,10 +1028,10 @@ | ||
| 1011 | 1028 | } |
| 1012 | 1029 | ?> |
| 1013 | 1030 | |
| 1014 | 1031 | <div class="upk-comments upk-flex upk-flex-middle"> |
| 1015 | - <i class="upk-icon-post-comments"></i> | |
| 1016 | - <span><?php echo get_comments_number($id) ?></span> | |
| 1032 | + <i class="upk-icon-post-comments" aria-hidden="true"></i> | |
| 1033 | + <span><?php echo esc_html( $this->upk_get_localized_comment_count( $id ) ); ?></span> | |
| 1017 | 1034 | </div> |
| 1018 | 1035 | |
| 1019 | 1036 | <?php |
| 1020 | 1037 | } |
| @@ -1043,14 +1060,14 @@ | ||
| 1043 | 1060 | <div class="upk-meta upk-flex-inline upk-flex-middle"> |
| 1044 | 1061 | <?php $this->render_date();?> |
| 1045 | 1062 | <?php if (_is_upk_pro_activated()): |
| 1046 | 1063 | if ('yes' === $settings['show_reading_time']): ?> |
| 1047 | - <div class="upk-reading-time" data-separator="<?php echo esc_html($settings['meta_separator']); ?>"> | |
| 1048 | - <?php echo esc_html( ultimate_post_kit_reading_time( get_the_content(), $settings['avg_reading_speed'] ) );?> | |
| 1049 | - </div> | |
| 1050 | - <?php endif;?> | |
| 1064 | + <div class="upk-reading-time" data-separator="<?php echo esc_attr($settings['meta_separator']); ?>"> | |
| 1065 | + <?php echo esc_html( ultimate_post_kit_reading_time( get_the_content(), $settings['avg_reading_speed'], $settings['hide_seconds'] ?? 'no', $settings['hide_minutes'] ?? 'no' ) );?> | |
| 1066 | + </div> | |
| 1067 | + <?php endif;?> | |
| 1051 | 1068 | <?php endif;?> |
| 1052 | - <div data-separator="<?php echo esc_html($settings['meta_separator']); ?>"> | |
| 1069 | + <div data-separator="<?php echo esc_attr($settings['meta_separator']); ?>"> | |
| 1053 | 1070 | <?php $this->render_comments($post_id);?> |
| 1054 | 1071 | </div> |
| 1055 | 1072 | </div> |
| 1056 | 1073 | <?php endif;?> |
| @@ -1119,8 +1136,10 @@ | ||
| 1119 | 1136 | 'show_category' => isset( $settings['show_category'] ) ? $settings['show_category'] : 'yes', |
| 1120 | 1137 | 'show_comments' => isset( $settings['show_comments'] ) ? $settings['show_comments'] : 'yes', |
| 1121 | 1138 | 'show_reading_time' => isset( $settings['show_reading_time'] ) ? $settings['show_reading_time'] : 'no', |
| 1122 | 1139 | 'avg_reading_speed' => isset( $settings['avg_reading_speed'] ) ? $settings['avg_reading_speed'] : 200, |
| 1140 | + 'hide_seconds' => isset( $settings['hide_seconds'] ) ? $settings['hide_seconds'] : 'no', | |
| 1141 | + 'hide_minutes' => isset( $settings['hide_minutes'] ) ? $settings['hide_minutes'] : 'no', | |
| 1123 | 1142 | 'upk_link_new_tab' => isset( $settings['upk_link_new_tab'] ) ? $settings['upk_link_new_tab'] : 'no', |
| 1124 | 1143 | 'meta_separator' => isset( $settings['meta_separator'] ) ? $settings['meta_separator'] : '.', |
| 1125 | 1144 | 'human_diff_time' => isset( $settings['human_diff_time'] ) ? $settings['human_diff_time'] : 'no', |
| 1126 | 1145 | 'human_diff_time_short' => isset( $settings['human_diff_time_short'] ) ? $settings['human_diff_time_short'] : 'no', |