| @@ -161,8 +161,9 @@ | ||
| 161 | 161 | $this->add_group_control( |
| 162 | 162 | Group_Control_Image_Size::get_type(), |
| 163 | 163 | [ |
| 164 | 164 | 'name' => 'primary_thumbnail', |
| 165 | + // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Elementor widget query built from user-configured controls; expected behaviour. | |
| 165 | 166 | 'exclude' => ['custom'], |
| 166 | 167 | 'default' => 'medium', |
| 167 | 168 | ] |
| 168 | 169 | ); |
| @@ -203,8 +204,11 @@ | ||
| 203 | 204 | ], |
| 204 | 205 | 'default' => [ |
| 205 | 206 | 'size' => 6, |
| 206 | 207 | ], |
| 208 | + 'condition' => [ | |
| 209 | + 'posts_source!' => 'current_query', | |
| 210 | + ] | |
| 207 | 211 | ] |
| 208 | 212 | ); |
| 209 | 213 | |
| 210 | 214 | $this->register_query_builder_controls(); |
| @@ -252,10 +256,11 @@ | ||
| 252 | 256 | |
| 253 | 257 | $this->add_control( |
| 254 | 258 | 'readmore_text', |
| 255 | 259 | [ |
| 256 | - 'label' => __('Readmore Text', 'ultimate-post-kit'), | |
| 260 | + 'label' => __('Read More Text', 'ultimate-post-kit'), | |
| 257 | 261 | 'type' => Controls_Manager::TEXT, |
| 262 | + 'dynamic' => [ 'active' => true ], | |
| 258 | 263 | 'default' => esc_html__('Explore', 'ultimate-post-kit'), |
| 259 | 264 | 'label_block' => false, |
| 260 | 265 | 'condition' => [ |
| 261 | 266 | 'show_readmore' => 'yes' |
| @@ -350,8 +355,9 @@ | ||
| 350 | 355 | [ |
| 351 | 356 | 'name' => 'overlay_color', |
| 352 | 357 | 'label' => esc_html__('Background', 'ultimate-post-kit'), |
| 353 | 358 | 'types' => ['classic', 'gradient'], |
| 359 | + // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Elementor widget query built from user-configured controls; expected behaviour. | |
| 354 | 360 | 'exclude' => ['image'], |
| 355 | 361 | 'selector' => '{{WRAPPER}} .upk-gratis-grid .upk-img-wrap::before', |
| 356 | 362 | 'fields_options' => [ |
| 357 | 363 | 'background' => [ |
| @@ -440,8 +446,9 @@ | ||
| 440 | 446 | [ |
| 441 | 447 | 'name' => 'overlay_hover_color', |
| 442 | 448 | 'label' => esc_html__('Background', 'ultimate-post-kit'), |
| 443 | 449 | 'types' => ['classic', 'gradient'], |
| 450 | + // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Elementor widget query built from user-configured controls; expected behaviour. | |
| 444 | 451 | 'exclude' => ['image'], |
| 445 | 452 | 'selector' => '{{WRAPPER}} .upk-gratis-grid .upk-img-wrap::after', |
| 446 | 453 | 'fields_options' => [ |
| 447 | 454 | 'background' => [ |
| @@ -502,8 +509,9 @@ | ||
| 502 | 509 | [ |
| 503 | 510 | 'name' => 'overlay_active_color', |
| 504 | 511 | 'label' => esc_html__('Background', 'ultimate-post-kit'), |
| 505 | 512 | 'types' => ['classic', 'gradient'], |
| 513 | + // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Elementor widget query built from user-configured controls; expected behaviour. | |
| 506 | 514 | 'exclude' => ['image'], |
| 507 | 515 | 'selector' => '{{WRAPPER}} .upk-gratis-grid .upk-item.active .upk-img-wrap::after', |
| 508 | 516 | ] |
| 509 | 517 | ); |
| @@ -1162,21 +1170,33 @@ | ||
| 1162 | 1170 | $this->register_ajax_loadmore_style_controls(); |
| 1163 | 1171 | } |
| 1164 | 1172 | |
| 1165 | 1173 | /** |
| 1166 | - * Main query render for this widget | |
| 1167 | - * @param $posts_per_page number item query limit | |
| 1174 | + * Get post query builder arguments | |
| 1168 | 1175 | */ |
| 1169 | - public function query_posts($posts_per_page) | |
| 1170 | - { | |
| 1176 | + public function query_posts( $posts_per_page ) { | |
| 1177 | + $settings = $this->get_settings(); | |
| 1178 | + $posts_per_page = isset( $posts_per_page ) ? (int) $posts_per_page : 0; | |
| 1179 | + $args = $this->getGroupControlQueryArgs(); | |
| 1180 | + $is_current_query = ( ! empty( $settings['posts_source'] ) && $settings['posts_source'] === 'current_query' ); | |
| 1171 | 1181 | |
| 1172 | - $default = $this->getGroupControlQueryArgs(); | |
| 1173 | - if ($posts_per_page) { | |
| 1182 | + if ( $is_current_query ) { | |
| 1183 | + unset( $args['offset'] ); | |
| 1184 | + unset( $args['no_found_rows'] ); | |
| 1185 | + $posts_per_page = 0; | |
| 1186 | + } | |
| 1187 | + | |
| 1188 | + if ( $posts_per_page > 0 ) { | |
| 1174 | 1189 | $args['posts_per_page'] = $posts_per_page; |
| 1175 | - $args['paged'] = max(1, get_query_var('paged'), get_query_var('page')); | |
| 1190 | + } else { | |
| 1191 | + $args['posts_per_page'] = (int) get_option( 'posts_per_page', 10 ); | |
| 1176 | 1192 | } |
| 1177 | - $args = array_merge($default, $args); | |
| 1178 | - $this->_query = new WP_Query($args); | |
| 1193 | + | |
| 1194 | + if ( $settings['show_pagination'] ) { | |
| 1195 | + $args['paged'] = max( 1, (int) get_query_var( 'paged' ), (int) get_query_var( 'page' ) ); | |
| 1196 | + } | |
| 1197 | + | |
| 1198 | + $this->_query = new \WP_Query( $args ); | |
| 1179 | 1199 | } |
| 1180 | 1200 | |
| 1181 | 1201 | public function render_image($image_id, $size) |
| 1182 | 1202 | { |
| @@ -1191,9 +1211,9 @@ | ||
| 1191 | 1211 | } |
| 1192 | 1212 | |
| 1193 | 1213 | ?> |
| 1194 | 1214 | |
| 1195 | - <img class="upk-img" src="<?php echo esc_url($image_src); ?>" alt="<?php echo esc_html(get_the_title()); ?>"> | |
| 1215 | + <img class="upk-img" src="<?php echo esc_url($image_src); ?>" alt="<?php echo esc_attr(get_the_title()); ?>"> | |
| 1196 | 1216 | |
| 1197 | 1217 | <?php |
| 1198 | 1218 | } |
| 1199 | 1219 | |
| @@ -1204,9 +1224,9 @@ | ||
| 1204 | 1224 | return; |
| 1205 | 1225 | } |
| 1206 | 1226 | ?> |
| 1207 | 1227 | <div class="upk-category"> |
| 1208 | - <?php echo upk_get_category($this->get_settings('posts_source')); ?> | |
| 1228 | + <?php echo wp_kses_post( upk_get_category($this->get_settings('posts_source')) ); ?> | |
| 1209 | 1229 | </div> |
| 1210 | 1230 | <?php |
| 1211 | 1231 | } |
| 1212 | 1232 | |
| @@ -1254,9 +1274,16 @@ | ||
| 1254 | 1274 | <path d="M11 6a3 3 0 1 1-6 0 3 3 0 0 1 6 0z" /> |
| 1255 | 1275 | <path fill-rule="evenodd" d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8zm8-7a7 7 0 0 0-5.468 11.37C3.242 11.226 4.805 10 8 10s4.757 1.225 5.468 2.37A7 7 0 0 0 8 1z" /> |
| 1256 | 1276 | </svg> |
| 1257 | 1277 | <span><?php echo esc_html__('by', 'ultimate-post-kit') ?></span> |
| 1258 | - <a class="upk-author-name" href="<?php echo esc_url( get_author_posts_url(get_the_author_meta('ID')) ); ?>"> | |
| 1278 | + <a | |
| 1279 | + class="upk-author-name" | |
| 1280 | + href="<?php echo esc_url( get_author_posts_url(get_the_author_meta('ID')) ); ?>" | |
| 1281 | + aria-label="<?php | |
| 1282 | + /* translators: %s: author name */ | |
| 1283 | + echo esc_attr( sprintf( __( 'View all posts by %s', 'ultimate-post-kit' ), get_the_author() ) ); | |
| 1284 | + ?>" | |
| 1285 | + > | |
| 1259 | 1286 | <span><?php echo esc_html( get_the_author() ); ?></span> |
| 1260 | 1287 | </a> |
| 1261 | 1288 | </div> |
| 1262 | 1289 | |
| @@ -1290,10 +1317,10 @@ | ||
| 1290 | 1317 | <?php if ($settings['show_date'] or $settings['show_reading_time']) : ?> |
| 1291 | 1318 | <div class="upk-date-reading upk-flex upk-flex-middle"> |
| 1292 | 1319 | <?php $this->render_date(); ?> |
| 1293 | 1320 | <?php if ('yes' === $settings['show_reading_time']) : ?> |
| 1294 | - <div class="upk-reading-time" data-separator="<?php echo esc_html($settings['meta_separator']); ?>"> | |
| 1295 | - <?php echo esc_html( ultimate_post_kit_reading_time( get_the_content(), $settings['avg_reading_speed'] ) ); ?> | |
| 1321 | + <div class="upk-reading-time" data-separator="<?php echo esc_attr($settings['meta_separator']); ?>"> | |
| 1322 | + <?php echo esc_html( ultimate_post_kit_reading_time( get_the_content(), $settings['avg_reading_speed'], $settings['hide_seconds'] ?? 'no', $settings['hide_minutes'] ?? 'no' ) ); ?> | |
| 1296 | 1323 | </div> |
| 1297 | 1324 | <?php endif; ?> |
| 1298 | 1325 | </div> |
| 1299 | 1326 | <?php endif; ?> |
| @@ -1384,8 +1411,9 @@ | ||
| 1384 | 1411 | 'show_meta' => isset( $settings['show_meta'] ) ? $settings['show_meta'] : 'yes', |
| 1385 | 1412 | 'show_author' => isset( $settings['show_author'] ) ? $settings['show_author'] : 'yes', |
| 1386 | 1413 | 'show_date' => isset( $settings['show_date'] ) ? $settings['show_date'] : 'yes', |
| 1387 | 1414 | 'human_diff_time' => isset( $settings['human_diff_time'] ) ? $settings['human_diff_time'] : 'no', |
| 1415 | + 'human_diff_time_short' => isset( $settings['human_diff_time_short'] ) ? $settings['human_diff_time_short'] : 'no', | |
| 1388 | 1416 | 'show_time' => isset( $settings['show_time'] ) ? $settings['show_time'] : '', |
| 1389 | 1417 | 'show_category' => isset( $settings['show_category'] ) ? $settings['show_category'] : 'yes', |
| 1390 | 1418 | 'show_readmore' => isset( $settings['show_readmore'] ) ? $settings['show_readmore'] : 'yes', |
| 1391 | 1419 | 'readmore_text' => isset( $settings['readmore_text'] ) ? $settings['readmore_text'] : '', |
| @@ -1390,8 +1418,10 @@ | ||
| 1390 | 1418 | 'show_readmore' => isset( $settings['show_readmore'] ) ? $settings['show_readmore'] : 'yes', |
| 1391 | 1419 | 'readmore_text' => isset( $settings['readmore_text'] ) ? $settings['readmore_text'] : '', |
| 1392 | 1420 | 'show_reading_time' => isset( $settings['show_reading_time'] ) ? $settings['show_reading_time'] : 'no', |
| 1393 | 1421 | 'avg_reading_speed' => isset( $settings['avg_reading_speed'] ) ? $settings['avg_reading_speed'] : 200, |
| 1422 | + 'hide_seconds' => isset( $settings['hide_seconds'] ) ? $settings['hide_seconds'] : 'no', | |
| 1423 | + 'hide_minutes' => isset( $settings['hide_minutes'] ) ? $settings['hide_minutes'] : 'no', | |
| 1394 | 1424 | 'meta_separator' => isset( $settings['meta_separator'] ) ? $settings['meta_separator'] : '/', |
| 1395 | 1425 | 'primary_thumbnail_size' => isset( $settings['primary_thumbnail_size'] ) ? $settings['primary_thumbnail_size'] : 'full', |
| 1396 | 1426 | 'title_style' => isset( $settings['title_style'] ) ? $settings['title_style'] : 'underline', |
| 1397 | 1427 | 'upk_link_new_tab' => isset( $settings['upk_link_new_tab'] ) ? $settings['upk_link_new_tab'] : 'no', |
| @@ -1422,8 +1452,9 @@ | ||
| 1422 | 1452 | |
| 1423 | 1453 | $i++; |
| 1424 | 1454 | $active_item = ''; |
| 1425 | 1455 | if (_is_upk_pro_activated()) { |
| 1456 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- established hook name relied on across the plugin family; renaming would break integration. | |
| 1426 | 1457 | $active_item = apply_filters('gratis_grid_active_item', $this, $i); |
| 1427 | 1458 | } |
| 1428 | 1459 | |
| 1429 | 1460 | ?> |