PluginProbe
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets / 4.5.6
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets v4.5.6
4.5.6 4.5.5 4.5.4 4.2.1 4.2.2 4.2.3 4.5.0 4.5.2 4.5.3 4.2.0 4.1.18 4.1.17 4.1.16 4.1.15 4.1.14 4.1.13 4.1.12 4.1.11 4.1.10 4.1.9 4.1.8 4.0.9 4.1.0 4.1.1 4.1.2 All 148 releases
← All changes | modules/gratis-grid/widgets/gratis-grid.php +36 -14 4.1.2 → 4.5.6 View file →
@@ -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();
@@ -351,8 +355,9 @@
351 355 [
352 356 'name' => 'overlay_color',
353 357 'label' => esc_html__('Background', 'ultimate-post-kit'),
354 358 'types' => ['classic', 'gradient'],
359 + // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Elementor widget query built from user-configured controls; expected behaviour.
355 360 'exclude' => ['image'],
356 361 'selector' => '{{WRAPPER}} .upk-gratis-grid .upk-img-wrap::before',
357 362 'fields_options' => [
358 363 'background' => [
@@ -441,8 +446,9 @@
441 446 [
442 447 'name' => 'overlay_hover_color',
443 448 'label' => esc_html__('Background', 'ultimate-post-kit'),
444 449 'types' => ['classic', 'gradient'],
450 + // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Elementor widget query built from user-configured controls; expected behaviour.
445 451 'exclude' => ['image'],
446 452 'selector' => '{{WRAPPER}} .upk-gratis-grid .upk-img-wrap::after',
447 453 'fields_options' => [
448 454 'background' => [
@@ -503,8 +509,9 @@
503 509 [
504 510 'name' => 'overlay_active_color',
505 511 'label' => esc_html__('Background', 'ultimate-post-kit'),
506 512 'types' => ['classic', 'gradient'],
513 + // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Elementor widget query built from user-configured controls; expected behaviour.
507 514 'exclude' => ['image'],
508 515 'selector' => '{{WRAPPER}} .upk-gratis-grid .upk-item.active .upk-img-wrap::after',
509 516 ]
510 517 );
@@ -1163,22 +1170,33 @@
1163 1170 $this->register_ajax_loadmore_style_controls();
1164 1171 }
1165 1172
1166 1173 /**
1167 - * Main query render for this widget
1168 - * @param $posts_per_page number item query limit
1174 + * Get post query builder arguments
1169 1175 */
1170 - public function query_posts($posts_per_page)
1171 - {
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' );
1172 1181
1173 - $default = $this->getGroupControlQueryArgs();
1174 - $args = [];
1175 - 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 ) {
1176 1189 $args['posts_per_page'] = $posts_per_page;
1177 - $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 );
1178 1192 }
1179 - $args = array_merge($default, $args);
1180 - $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 );
1181 1199 }
1182 1200
1183 1201 public function render_image($image_id, $size)
1184 1202 {
@@ -1193,9 +1211,9 @@
1193 1211 }
1194 1212
1195 1213 ?>
1196 1214
1197 - <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()); ?>">
1198 1216
1199 1217 <?php
1200 1218 }
1201 1219
@@ -1206,9 +1224,9 @@
1206 1224 return;
1207 1225 }
1208 1226 ?>
1209 1227 <div class="upk-category">
1210 - <?php echo upk_get_category($this->get_settings('posts_source')); ?>
1228 + <?php echo wp_kses_post( upk_get_category($this->get_settings('posts_source')) ); ?>
1211 1229 </div>
1212 1230 <?php
1213 1231 }
1214 1232
@@ -1259,9 +1277,12 @@
1259 1277 <span><?php echo esc_html__('by', 'ultimate-post-kit') ?></span>
1260 1278 <a
1261 1279 class="upk-author-name"
1262 1280 href="<?php echo esc_url( get_author_posts_url(get_the_author_meta('ID')) ); ?>"
1263 - aria-label="<?php echo esc_attr( sprintf( __( 'View all posts by %s', 'ultimate-post-kit' ), get_the_author() ) ); ?>"
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 + ?>"
1264 1285 >
1265 1286 <span><?php echo esc_html( get_the_author() ); ?></span>
1266 1287 </a>
1267 1288 </div>
@@ -1296,9 +1317,9 @@
1296 1317 <?php if ($settings['show_date'] or $settings['show_reading_time']) : ?>
1297 1318 <div class="upk-date-reading upk-flex upk-flex-middle">
1298 1319 <?php $this->render_date(); ?>
1299 1320 <?php if ('yes' === $settings['show_reading_time']) : ?>
1300 - <div class="upk-reading-time" data-separator="<?php echo esc_html($settings['meta_separator']); ?>">
1321 + <div class="upk-reading-time" data-separator="<?php echo esc_attr($settings['meta_separator']); ?>">
1301 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' ) ); ?>
1302 1323 </div>
1303 1324 <?php endif; ?>
1304 1325 </div>
@@ -1431,8 +1452,9 @@
1431 1452
1432 1453 $i++;
1433 1454 $active_item = '';
1434 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.
1435 1457 $active_item = apply_filters('gratis_grid_active_item', $this, $i);
1436 1458 }
1437 1459
1438 1460 ?>