| @@ -98,8 +98,9 @@ | ||
| 98 | 98 | ], |
| 99 | 99 | ] |
| 100 | 100 | ); |
| 101 | 101 | |
| 102 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- established hook name relied on across the plugin family; renaming would break integration. | |
| 102 | 103 | $column_size = apply_filters('upk_column_size', ''); |
| 103 | 104 | |
| 104 | 105 | $this->add_responsive_control( |
| 105 | 106 | 'columns', |
| @@ -212,8 +213,9 @@ | ||
| 212 | 213 | $this->add_group_control( |
| 213 | 214 | Group_Control_Image_Size::get_type(), |
| 214 | 215 | [ |
| 215 | 216 | 'name' => 'primary_thumbnail', |
| 217 | + // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Elementor widget query built from user-configured controls; expected behaviour. | |
| 216 | 218 | 'exclude' => ['custom'], |
| 217 | 219 | 'default' => 'medium', |
| 218 | 220 | ] |
| 219 | 221 | ); |
| @@ -271,9 +273,10 @@ | ||
| 271 | 273 | 'default' => [ |
| 272 | 274 | 'size' => 6, |
| 273 | 275 | ], |
| 274 | 276 | 'condition' => [ |
| 275 | - 'grid_style!' => ['2', '5'] | |
| 277 | + 'grid_style!' => ['2', '5'], | |
| 278 | + 'posts_source!' => 'current_query' | |
| 276 | 279 | ] |
| 277 | 280 | ] |
| 278 | 281 | ); |
| 279 | 282 | |
| @@ -292,9 +295,10 @@ | ||
| 292 | 295 | 'default' => [ |
| 293 | 296 | 'size' => 5, |
| 294 | 297 | ], |
| 295 | 298 | 'condition' => [ |
| 296 | - 'grid_style' => ['2', '5'] | |
| 299 | + 'grid_style' => ['2', '5'], | |
| 300 | + 'posts_source!' => 'current_query' | |
| 297 | 301 | ] |
| 298 | 302 | ] |
| 299 | 303 | ); |
| 300 | 304 | |
| @@ -1220,21 +1224,33 @@ | ||
| 1220 | 1224 | $this->register_ajax_loadmore_style_controls(); |
| 1221 | 1225 | } |
| 1222 | 1226 | |
| 1223 | 1227 | /** |
| 1224 | - * Main query render for this widget | |
| 1225 | - * @param $posts_per_page number item query limit | |
| 1228 | + * Get post query builder arguments | |
| 1226 | 1229 | */ |
| 1227 | - public function query_posts($posts_per_page) { | |
| 1230 | + public function query_posts( $posts_per_page ) { | |
| 1231 | + $settings = $this->get_settings(); | |
| 1232 | + $posts_per_page = isset( $posts_per_page ) ? (int) $posts_per_page : 0; | |
| 1233 | + $args = $this->getGroupControlQueryArgs(); | |
| 1234 | + $is_current_query = ( ! empty( $settings['posts_source'] ) && $settings['posts_source'] === 'current_query' ); | |
| 1228 | 1235 | |
| 1229 | - $default = $this->getGroupControlQueryArgs(); | |
| 1230 | - $args = []; | |
| 1231 | - if ($posts_per_page) { | |
| 1236 | + if ( $is_current_query ) { | |
| 1237 | + unset( $args['offset'] ); | |
| 1238 | + unset( $args['no_found_rows'] ); | |
| 1239 | + $posts_per_page = 0; | |
| 1240 | + } | |
| 1241 | + | |
| 1242 | + if ( $posts_per_page > 0 ) { | |
| 1232 | 1243 | $args['posts_per_page'] = $posts_per_page; |
| 1233 | - $args['paged'] = max(1, get_query_var('paged'), get_query_var('page')); | |
| 1244 | + } else { | |
| 1245 | + $args['posts_per_page'] = (int) get_option( 'posts_per_page', 10 ); | |
| 1234 | 1246 | } |
| 1235 | - $args = array_merge($default, $args); | |
| 1236 | - $this->_query = new WP_Query($args); | |
| 1247 | + | |
| 1248 | + if ( $settings['show_pagination'] ) { | |
| 1249 | + $args['paged'] = max( 1, (int) get_query_var( 'paged' ), (int) get_query_var( 'page' ) ); | |
| 1250 | + } | |
| 1251 | + | |
| 1252 | + $this->_query = new \WP_Query( $args ); | |
| 1237 | 1253 | } |
| 1238 | 1254 | |
| 1239 | 1255 | public function render_author() { |
| 1240 | 1256 | $settings = $this->get_settings_for_display(); |
| @@ -1302,9 +1318,9 @@ | ||
| 1302 | 1318 | <?php $this->render_author(); ?> |
| 1303 | 1319 | <?php endif; ?> |
| 1304 | 1320 | |
| 1305 | 1321 | <?php if ($settings['show_date'] == 'yes') : ?> |
| 1306 | - <div class="upk-blog-date" data-separator="<?php echo esc_html($settings['meta_separator']); ?>"> | |
| 1322 | + <div class="upk-blog-date" data-separator="<?php echo esc_attr($settings['meta_separator']); ?>"> | |
| 1307 | 1323 | <div class="upk-blog-date"> |
| 1308 | 1324 | <a class="date" href="#"> |
| 1309 | 1325 | <i class="upk-icon-calendar" aria-hidden="true"></i><?php $this->render_date(); ?> |
| 1310 | 1326 | </a> |
| @@ -1320,9 +1336,9 @@ | ||
| 1320 | 1336 | <?php endif; ?> |
| 1321 | 1337 | |
| 1322 | 1338 | <?php if (_is_upk_pro_activated()) : |
| 1323 | 1339 | if ('yes' === $settings['show_reading_time']) : ?> |
| 1324 | - <div class="upk-reading-time" data-separator="<?php echo esc_html($settings['meta_separator']); ?>"> | |
| 1340 | + <div class="upk-reading-time" data-separator="<?php echo esc_attr($settings['meta_separator']); ?>"> | |
| 1325 | 1341 | <?php echo esc_html( ultimate_post_kit_reading_time( get_the_content(), $settings['avg_reading_speed'], $settings['hide_seconds'] ?? 'no', $settings['hide_minutes'] ?? 'no' ) ); ?> |
| 1326 | 1342 | </div> |
| 1327 | 1343 | <?php endif; ?> |
| 1328 | 1344 | <?php endif; ?> |