| @@ -152,8 +152,9 @@ | ||
| 152 | 152 | $this->add_group_control( |
| 153 | 153 | Group_Control_Image_Size::get_type(), |
| 154 | 154 | [ |
| 155 | 155 | 'name' => 'primary_thumbnail', |
| 156 | + // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Elementor widget query built from user-configured controls; expected behaviour. | |
| 156 | 157 | 'exclude' => ['custom'], |
| 157 | 158 | 'default' => 'medium', |
| 158 | 159 | ] |
| 159 | 160 | ); |
| @@ -182,8 +183,11 @@ | ||
| 182 | 183 | ], |
| 183 | 184 | 'default' => [ |
| 184 | 185 | 'size' => 6, |
| 185 | 186 | ], |
| 187 | + 'condition' => [ | |
| 188 | + 'posts_source!' => 'current_query', | |
| 189 | + ] | |
| 186 | 190 | ] |
| 187 | 191 | ); |
| 188 | 192 | |
| 189 | 193 | $this->register_query_builder_controls(); |
| @@ -1227,21 +1231,33 @@ | ||
| 1227 | 1231 | $this->register_ajax_loadmore_style_controls(); |
| 1228 | 1232 | } |
| 1229 | 1233 | |
| 1230 | 1234 | /** |
| 1231 | - * Main query render for this widget | |
| 1232 | - * @param $posts_per_page number item query limit | |
| 1235 | + * Get post query builder arguments | |
| 1233 | 1236 | */ |
| 1234 | - public function query_posts($posts_per_page) { | |
| 1237 | + public function query_posts( $posts_per_page ) { | |
| 1238 | + $settings = $this->get_settings(); | |
| 1239 | + $posts_per_page = isset( $posts_per_page ) ? (int) $posts_per_page : 0; | |
| 1240 | + $args = $this->getGroupControlQueryArgs(); | |
| 1241 | + $is_current_query = ( ! empty( $settings['posts_source'] ) && $settings['posts_source'] === 'current_query' ); | |
| 1235 | 1242 | |
| 1236 | - $default = $this->getGroupControlQueryArgs(); | |
| 1237 | - $args = []; | |
| 1238 | - if ($posts_per_page) { | |
| 1243 | + if ( $is_current_query ) { | |
| 1244 | + unset( $args['offset'] ); | |
| 1245 | + unset( $args['no_found_rows'] ); | |
| 1246 | + $posts_per_page = 0; | |
| 1247 | + } | |
| 1248 | + | |
| 1249 | + if ( $posts_per_page > 0 ) { | |
| 1239 | 1250 | $args['posts_per_page'] = $posts_per_page; |
| 1240 | - $args['paged'] = max(1, get_query_var('paged'), get_query_var('page')); | |
| 1251 | + } else { | |
| 1252 | + $args['posts_per_page'] = (int) get_option( 'posts_per_page', 10 ); | |
| 1241 | 1253 | } |
| 1242 | - $args = array_merge($default, $args); | |
| 1243 | - $this->_query = new WP_Query($args); | |
| 1254 | + | |
| 1255 | + if ( $settings['show_pagination'] ) { | |
| 1256 | + $args['paged'] = max( 1, (int) get_query_var( 'paged' ), (int) get_query_var( 'page' ) ); | |
| 1257 | + } | |
| 1258 | + | |
| 1259 | + $this->_query = new \WP_Query( $args ); | |
| 1244 | 1260 | } |
| 1245 | 1261 | |
| 1246 | 1262 | public function render_post_meta() { |
| 1247 | 1263 | $settings = $this->get_settings_for_display(); |
| @@ -1266,9 +1282,9 @@ | ||
| 1266 | 1282 | |
| 1267 | 1283 | <?php if ($settings['show_date'] or $settings['show_reading_time']) : ?> |
| 1268 | 1284 | <div class="upk-date-reading-time upk-flex upk-flex-middle"> |
| 1269 | 1285 | <?php if ($settings['show_date'] == 'yes') : ?> |
| 1270 | - <div data-separator="<?php echo esc_html($settings['meta_separator']); ?>"> | |
| 1286 | + <div data-separator="<?php echo esc_attr($settings['meta_separator']); ?>"> | |
| 1271 | 1287 | <?php $this->render_date(); ?> |
| 1272 | 1288 | </div> |
| 1273 | 1289 | <?php endif; ?> |
| 1274 | 1290 | |
| @@ -1273,9 +1289,9 @@ | ||
| 1273 | 1289 | <?php endif; ?> |
| 1274 | 1290 | |
| 1275 | 1291 | <?php if (_is_upk_pro_activated()) : |
| 1276 | 1292 | if ('yes' === $settings['show_reading_time']) : ?> |
| 1277 | - <div class="upk-reading-time" data-separator="<?php echo esc_html($settings['meta_separator']); ?>"> | |
| 1293 | + <div class="upk-reading-time" data-separator="<?php echo esc_attr($settings['meta_separator']); ?>"> | |
| 1278 | 1294 | <?php echo esc_html( ultimate_post_kit_reading_time( get_the_content(), $settings['avg_reading_speed'], $settings['hide_seconds'] ?? 'no', $settings['hide_minutes'] ?? 'no' ) ); ?> |
| 1279 | 1295 | </div> |
| 1280 | 1296 | <?php endif; ?> |
| 1281 | 1297 | <?php endif; ?> |
| @@ -1295,13 +1311,12 @@ | ||
| 1295 | 1311 | |
| 1296 | 1312 | if (!$this->get_settings('show_comments')) { |
| 1297 | 1313 | return; |
| 1298 | 1314 | } |
| 1299 | - ?> | |
| 1315 | + ?> | |
| 1300 | 1316 | |
| 1301 | 1317 | <div class="upk-comments"> |
| 1302 | - <?php echo get_comments_number($id) ?> | |
| 1303 | - <?php echo esc_html_x('Comments', 'Frontend', 'ultimate-post-kit') ?> | |
| 1318 | + <?php echo esc_html( $this->upk_get_formatted_comments_count( $id ) ); ?> | |
| 1304 | 1319 | </div> |
| 1305 | 1320 | |
| 1306 | 1321 | <?php |
| 1307 | 1322 | } |
| @@ -1315,14 +1330,14 @@ | ||
| 1315 | 1330 | |
| 1316 | 1331 | $animation = ($this->get_settings('readmore_hover_animation')) ? ' elementor-animation-' . $this->get_settings('readmore_hover_animation') : ''; |
| 1317 | 1332 | |
| 1318 | 1333 | ?> |
| 1319 | - <a href="<?php echo esc_url(get_permalink()); ?>" class="upk-readmore <?php echo esc_html($animation); ?>"> | |
| 1334 | + <a href="<?php echo esc_url(get_permalink()); ?>" class="upk-readmore <?php echo esc_attr($animation); ?>"> | |
| 1320 | 1335 | <span class="upk-flex upk-flex-middle"> |
| 1321 | 1336 | <?php echo esc_html($this->get_settings('readmore_text')); ?> |
| 1322 | 1337 | |
| 1323 | 1338 | <?php if ($settings['readmore_icon']['value']) : ?> |
| 1324 | - <span class="upk-readmore-btn-icon upk-flex-align-<?php echo esc_html($this->get_settings('icon_align')); ?>"> | |
| 1339 | + <span class="upk-readmore-btn-icon upk-flex-align-<?php echo esc_attr($this->get_settings('icon_align')); ?>"> | |
| 1325 | 1340 | |
| 1326 | 1341 | <?php Icons_Manager::render_icon($settings['readmore_icon'], ['aria-hidden' => 'true', 'class' => 'fa-fw']); ?> |
| 1327 | 1342 | |
| 1328 | 1343 | </span> |