| @@ -96,8 +96,9 @@ | ||
| 96 | 96 | ], |
| 97 | 97 | ] |
| 98 | 98 | ); |
| 99 | 99 | |
| 100 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- established hook name relied on across the plugin family; renaming would break integration. | |
| 100 | 101 | $column_size = apply_filters('upk_column_size', ''); |
| 101 | 102 | |
| 102 | 103 | $this->add_responsive_control( |
| 103 | 104 | 'columns', |
| @@ -190,8 +191,9 @@ | ||
| 190 | 191 | $this->add_group_control( |
| 191 | 192 | Group_Control_Image_Size::get_type(), |
| 192 | 193 | [ |
| 193 | 194 | 'name' => 'primary_thumbnail', |
| 195 | + // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Elementor widget query built from user-configured controls; expected behaviour. | |
| 194 | 196 | 'exclude' => ['custom'], |
| 195 | 197 | 'default' => 'medium', |
| 196 | 198 | ] |
| 197 | 199 | ); |
| @@ -222,9 +224,10 @@ | ||
| 222 | 224 | 'default' => [ |
| 223 | 225 | 'size' => 6, |
| 224 | 226 | ], |
| 225 | 227 | 'condition' => [ |
| 226 | - 'grid_style' => ['1'] | |
| 228 | + 'grid_style' => ['1'], | |
| 229 | + 'posts_source!' => 'current_query' | |
| 227 | 230 | ] |
| 228 | 231 | ] |
| 229 | 232 | ); |
| 230 | 233 | |
| @@ -243,9 +246,10 @@ | ||
| 243 | 246 | 'default' => [ |
| 244 | 247 | 'size' => 5, |
| 245 | 248 | ], |
| 246 | 249 | 'condition' => [ |
| 247 | - 'grid_style' => ['2'] | |
| 250 | + 'grid_style' => ['2'], | |
| 251 | + 'posts_source!' => 'current_query' | |
| 248 | 252 | ] |
| 249 | 253 | ] |
| 250 | 254 | ); |
| 251 | 255 | |
| @@ -264,9 +268,10 @@ | ||
| 264 | 268 | 'default' => [ |
| 265 | 269 | 'size' => 4, |
| 266 | 270 | ], |
| 267 | 271 | 'condition' => [ |
| 268 | - 'grid_style' => ['3'] | |
| 272 | + 'grid_style' => ['3'], | |
| 273 | + 'posts_source!' => 'current_query' | |
| 269 | 274 | ] |
| 270 | 275 | ] |
| 271 | 276 | ); |
| 272 | 277 | |
| @@ -1201,20 +1206,33 @@ | ||
| 1201 | 1206 | $this->register_ajax_loadmore_style_controls(); |
| 1202 | 1207 | } |
| 1203 | 1208 | |
| 1204 | 1209 | /** |
| 1205 | - * Main query render for this widget | |
| 1206 | - * @param $posts_per_page number item query limit | |
| 1210 | + * Get post query builder arguments | |
| 1207 | 1211 | */ |
| 1208 | - public function query_posts($posts_per_page) { | |
| 1212 | + public function query_posts( $posts_per_page ) { | |
| 1213 | + $settings = $this->get_settings(); | |
| 1214 | + $posts_per_page = isset( $posts_per_page ) ? (int) $posts_per_page : 0; | |
| 1215 | + $args = $this->getGroupControlQueryArgs(); | |
| 1216 | + $is_current_query = ( ! empty( $settings['posts_source'] ) && $settings['posts_source'] === 'current_query' ); | |
| 1209 | 1217 | |
| 1210 | - $default = $this->getGroupControlQueryArgs(); | |
| 1211 | - if ($posts_per_page) { | |
| 1218 | + if ( $is_current_query ) { | |
| 1219 | + unset( $args['offset'] ); | |
| 1220 | + unset( $args['no_found_rows'] ); | |
| 1221 | + $posts_per_page = 0; | |
| 1222 | + } | |
| 1223 | + | |
| 1224 | + if ( $posts_per_page > 0 ) { | |
| 1212 | 1225 | $args['posts_per_page'] = $posts_per_page; |
| 1213 | - $args['paged'] = max(1, get_query_var('paged'), get_query_var('page')); | |
| 1226 | + } else { | |
| 1227 | + $args['posts_per_page'] = (int) get_option( 'posts_per_page', 10 ); | |
| 1214 | 1228 | } |
| 1215 | - $args = array_merge($default, $args); | |
| 1216 | - $this->_query = new WP_Query($args); | |
| 1229 | + | |
| 1230 | + if ( $settings['show_pagination'] ) { | |
| 1231 | + $args['paged'] = max( 1, (int) get_query_var( 'paged' ), (int) get_query_var( 'page' ) ); | |
| 1232 | + } | |
| 1233 | + | |
| 1234 | + $this->_query = new \WP_Query( $args ); | |
| 1217 | 1235 | } |
| 1218 | 1236 | |
| 1219 | 1237 | public function render_author() { |
| 1220 | 1238 | |
| @@ -1261,9 +1279,9 @@ | ||
| 1261 | 1279 | |
| 1262 | 1280 | <span class="author-depertment"> |
| 1263 | 1281 | <?php |
| 1264 | 1282 | $aid = get_the_author_meta('ID'); |
| 1265 | - echo ucwords(get_user_role($aid)); | |
| 1283 | + echo esc_html( get_user_role( $aid ) ); | |
| 1266 | 1284 | ?> |
| 1267 | 1285 | </span> |
| 1268 | 1286 | </div> |
| 1269 | 1287 | </div> |
| @@ -1278,10 +1296,10 @@ | ||
| 1278 | 1296 | <?php $this->render_date(); ?> |
| 1279 | 1297 | |
| 1280 | 1298 | <?php if (_is_upk_pro_activated()) : |
| 1281 | 1299 | if ('yes' === $settings['show_reading_time']) : ?> |
| 1282 | - <div class="upk-reading-time" data-separator="<?php echo esc_html($settings['meta_separator']); ?>"> | |
| 1283 | - <?php echo esc_html( ultimate_post_kit_reading_time(get_the_content(), $settings['avg_reading_speed']) ); ?> | |
| 1300 | + <div class="upk-reading-time" data-separator="<?php echo esc_attr($settings['meta_separator']); ?>"> | |
| 1301 | + <?php echo esc_html( ultimate_post_kit_reading_time( get_the_content(), $settings['avg_reading_speed'], $settings['hide_seconds'] ?? 'no', $settings['hide_minutes'] ?? 'no' ) ); ?> | |
| 1284 | 1302 | </div> |
| 1285 | 1303 | <?php endif; ?> |
| 1286 | 1304 | <?php endif; ?> |
| 1287 | 1305 | </div> |
| @@ -1309,10 +1327,10 @@ | ||
| 1309 | 1327 | <?php $this->render_date(); ?> |
| 1310 | 1328 | |
| 1311 | 1329 | <?php if (_is_upk_pro_activated()) : |
| 1312 | 1330 | if ('yes' === $settings['show_reading_time']) : ?> |
| 1313 | - <div class="upk-reading-time" data-separator="<?php echo esc_html($settings['meta_separator']); ?>"> | |
| 1314 | - <?php echo esc_html( ultimate_post_kit_reading_time( get_the_content(), $settings['avg_reading_speed'] ) ); ?> | |
| 1331 | + <div class="upk-reading-time" data-separator="<?php echo esc_attr($settings['meta_separator']); ?>"> | |
| 1332 | + <?php echo esc_html( ultimate_post_kit_reading_time( get_the_content(), $settings['avg_reading_speed'], $settings['hide_seconds'] ?? 'no', $settings['hide_minutes'] ?? 'no' ) ); ?> | |
| 1315 | 1333 | </div> |
| 1316 | 1334 | <?php endif; ?> |
| 1317 | 1335 | <?php endif; ?> |
| 1318 | 1336 | </div> |
| @@ -1398,8 +1416,10 @@ | ||
| 1398 | 1416 | 'show_time' => isset( $settings['show_time'] ) ? $settings['show_time'] : 'no', |
| 1399 | 1417 | 'show_category' => isset( $settings['show_category'] ) ? $settings['show_category'] : 'yes', |
| 1400 | 1418 | 'show_reading_time' => isset( $settings['show_reading_time'] ) ? $settings['show_reading_time'] : 'no', |
| 1401 | 1419 | 'avg_reading_speed' => isset( $settings['avg_reading_speed'] ) ? $settings['avg_reading_speed'] : 200, |
| 1420 | + 'hide_seconds' => isset( $settings['hide_seconds'] ) ? $settings['hide_seconds'] : 'no', | |
| 1421 | + 'hide_minutes' => isset( $settings['hide_minutes'] ) ? $settings['hide_minutes'] : 'no', | |
| 1402 | 1422 | 'upk_link_new_tab' => isset( $settings['upk_link_new_tab'] ) ? $settings['upk_link_new_tab'] : 'no', |
| 1403 | 1423 | 'meta_separator' => isset( $settings['meta_separator'] ) ? $settings['meta_separator'] : '|', |
| 1404 | 1424 | 'human_diff_time' => isset( $settings['human_diff_time'] ) ? $settings['human_diff_time'] : 'no', |
| 1405 | 1425 | 'human_diff_time_short' => isset( $settings['human_diff_time_short'] ) ? $settings['human_diff_time_short'] : 'no', |