Skip to content

Commit 770277a

Browse files
committed
Adding fix for query loop class name conflict
1 parent 87948a0 commit 770277a

13 files changed

+85
-49
lines changed

README.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Tags: infinite scroll, load more, lazy load, endless scroll, ajax load more
55
Requires at least: 5.0
66
Requires PHP: 5.6
77
Tested up to: 6.7
8-
Stable tag: 7.3.0
8+
Stable tag: 7.3.1
99
License: GPLv2 or later
1010
License URI: http://www.gnu.org/licenses/gpl-2.0.html
1111

@@ -269,6 +269,11 @@ How to install Ajax Load More.
269269

270270
== Changelog ==
271271

272+
= 7.3.1 - February 12, 2025 =
273+
* UPDATE: Updated new Date Query feature to parse compare value. This was previously not functioning as expected. e.g. `[ajax_load_more date_query="2024-01-01;2020-01-01" date_query_compare=">=;<=" date_query_relation="OR"]
274+
* NEW: Added date_query_column parameter to allow for querying the post_date or post_modified column. e.g. `[ajax_load_more date_query="2020-01-01" date_query_column="post_modified"]
275+
* HOTFIX: Fixed issue with conflicting `wp-block-query` class the new Query Loop add-on.
276+
272277
= 7.3.0 - February 6, 2025 =
273278
* NEW: Added Date Query support with `date_query`, `date_query_before` and `date_query_after` parameters.
274279
* UPDATE: Various admin UI/UX updates and code cleanup throughout plugin.

ajax-load-more.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@
77
* Author: Darren Cooney
88
* Twitter: @KaptonKaos
99
* Author URI: https://connekthq.com
10-
* Version: 7.3.0
10+
* Version: 7.3.1
1111
* License: GPL
1212
* Copyright: Darren Cooney & Connekt Media
1313
*
1414
* @package AjaxLoadMore
1515
*/
16-
17-
define( 'ALM_VERSION', '7.3.0' );
18-
define( 'ALM_RELEASE', 'February 6, 2025' );
16+
define( 'ALM_VERSION', '7.3.1' );
17+
define( 'ALM_RELEASE', 'February 12, 2025' );
1918
define( 'ALM_STORE_URL', 'https://connekthq.com' );
2019

2120
// Plugin installation helpers.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array(), 'version' => 'c7ee979ef153ffed67c6');
1+
<?php return array('dependencies' => array(), 'version' => '9909c29c175a064d9232');

build/frontend/ajax-load-more.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10093,7 +10093,7 @@ function queryLoopLoaded(alm) {
1009310093
function getQueryLoopConfig(element) {
1009410094
var raw = element === null || element === void 0 ? void 0 : element.querySelector('pre[data-rel="ajax-load-more"]');
1009510095
if (!raw) {
10096-
return;
10096+
return {};
1009710097
}
1009810098
return JSON.parse(raw === null || raw === void 0 ? void 0 : raw.innerHTML);
1009910099
}
@@ -11226,6 +11226,9 @@ function getAjaxParams(alm, queryType) {
1122611226
if (alm.listing.dataset.dateQueryBefore) {
1122711227
data.date_query_before = alm.listing.dataset.dateQueryBefore;
1122811228
}
11229+
if (alm.listing.dataset.dateQueryColumn) {
11230+
data.date_query_column = alm.listing.dataset.dateQueryColumn;
11231+
}
1122911232
if (alm.listing.dataset.dateQueryCompare) {
1123011233
data.date_query_compare = alm.listing.dataset.dateQueryCompare;
1123111234
}
@@ -11395,6 +11398,7 @@ function getRestAPIParams(alm) {
1139511398
date_query: alm.listing.dataset.dateQuery,
1139611399
date_query_after: alm.listing.dataset.dateQueryAfter,
1139711400
date_query_before: alm.listing.dataset.dateQueryBefore,
11401+
date_query_column: alm.listing.dataset.dateQueryColumn,
1139811402
date_query_compare: alm.listing.dataset.dateQueryCompare,
1139911403
date_query_inclusive: alm.listing.dataset.dateQueryInclusive,
1140011404
date_query_relation: alm.listing.dataset.dateQueryRelation,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array(), 'version' => '9af341a9172898f23fbd');
1+
<?php return array('dependencies' => array(), 'version' => '552f6033e2f08c4a1be8');

build/frontend/ajax-load-more.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/classes/class-alm-noscript.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public static function alm_get_noscript( $params, $container = 'ul', $css_classe
6565
} else {
6666
// Standard ALM.
6767
// Build the $args array to use with this WP_Query.
68-
$query_args = ALM_QUERY_ARGS::alm_build_queryargs( $params, false );
68+
$args = ALM_QUERY_ARGS::alm_build_queryargs( $params, false );
6969

7070
$filters = $params['filters'];
7171
if ( $filters ) {
@@ -75,20 +75,19 @@ public static function alm_get_noscript( $params, $container = 'ul', $css_classe
7575
/**
7676
* ALM Core Filter Hook
7777
*
78-
* @return $query_args;
78+
* @return array Modified array.
7979
*/
80-
$query_args = apply_filters( 'alm_query_args_' . $params['id'], $query_args, $params['post_id'] );
81-
82-
$posts_per_page = $query_args['posts_per_page'];
80+
$args = apply_filters( 'alm_query_args_' . $params['id'], $args, $params['post_id'] );
8381

8482
// Update Paged and offset.
85-
$query_args['paged'] = $paged;
86-
$query_args['offset'] = self::set_offset( $paged, $posts_per_page, $params['offset'] );
83+
$posts_per_page = $args['posts_per_page'];
84+
$args['paged'] = $paged;
85+
$args['offset'] = self::set_offset( $paged, $posts_per_page, $params['offset'] );
8786

8887
$output = '';
8988
$i = 0;
9089

91-
$noscript_query = new WP_Query( $query_args );
90+
$noscript_query = new WP_Query( $args );
9291

9392
if ( $noscript_query->have_posts() ) :
9493
$alm_found_posts = $noscript_query->found_posts;
@@ -97,8 +96,8 @@ public static function alm_get_noscript( $params, $container = 'ul', $css_classe
9796
$noscript_query->the_post();
9897
++$i;
9998
$alm_current = $i;
100-
$alm_item = $query_args['offset'] + $i;
101-
$output .= alm_loop( $params['repeater'], $params['theme_repeater'], $alm_found_posts, $alm_page, $alm_item, $alm_current, $query_args );
99+
$alm_item = $args['offset'] + $i;
100+
$output .= alm_loop( $params['repeater'], $params['theme_repeater'], $alm_found_posts, $alm_page, $alm_item, $alm_current, $args );
102101
endwhile;
103102
wp_reset_postdata();
104103

core/classes/class-alm-queryargs.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public static function alm_build_queryargs( $a, $is_ajax = true ) {
9090
$date_query_before = isset( $a['date_query_before'] ) ? $a['date_query_before'] : '';
9191
$date_query_after = isset( $a['date_query_after'] ) ? $a['date_query_after'] : '';
9292
$date_query_inclusive = isset( $a['date_query_inclusive'] ) ? $a['date_query_inclusive'] : '';
93+
$date_query_column = isset( $a['date_query_column'] ) ? $a['date_query_column'] : '';
9394
$date_query_compare = isset( $a['date_query_compare'] ) ? $a['date_query_compare'] : '';
9495
$date_query_relation = isset( $a['date_query_relation'] ) ? $a['date_query_relation'] : '';
9596

@@ -284,13 +285,10 @@ public static function alm_build_queryargs( $a, $is_ajax = true ) {
284285
if ( ! empty( $date_query_relation ) ) {
285286
$args['date_query']['relation'] = $date_query_relation;
286287
}
287-
if ( $date_query_compare ) {
288-
$args['date_query']['compare'] = $date_query_compare;
289-
}
290288

291289
// Standard Date Query.
292290
if ( $date_query ) {
293-
$args = alm_get_date_query( $date_query, $args );
291+
$args = alm_get_date_query( $date_query, $date_query_compare, $date_query_column, $args );
294292
}
295293

296294
// Date Query (Before/After).

core/classes/class-alm-shortcode.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ public static function alm_render_shortcode( $atts ) {
195195
'date_query' => '',
196196
'date_query_before' => '',
197197
'date_query_after' => '',
198+
'date_query_column' => '',
198199
'date_query_compare' => '',
199200
'date_query_inclusive' => '',
200201
'date_query_relation' => '',
@@ -833,6 +834,7 @@ public static function alm_render_shortcode( $atts ) {
833834
'date_query' => $date_query,
834835
'date_query_before' => $date_query_before,
835836
'date_query_after' => $date_query_after,
837+
'date_query_column' => $date_query_column,
836838
'date_query_compare' => $date_query_compare,
837839
'date_query_inclusive' => $date_query_inclusive,
838840
'date_query_relation' => $date_query_relation,
@@ -1194,6 +1196,7 @@ public static function alm_render_shortcode( $atts ) {
11941196
$ajaxloadmore .= $date_query_after ? ' data-date-query-after="' . esc_attr( $date_query_after ) . '"' : '';
11951197
$ajaxloadmore .= $date_query_before ? ' data-date-query-before="' . esc_attr( $date_query_before ) . '"' : '';
11961198
$ajaxloadmore .= $date_query_inclusive ? ' data-date-query-inclusive="' . esc_attr( $date_query_inclusive ) . '"' : '';
1199+
$ajaxloadmore .= $date_query_column ? ' data-date-query-column="' . esc_attr( $date_query_column ) . '"' : '';
11971200
$ajaxloadmore .= $date_query_compare ? ' data-date-query-compare="' . esc_attr( $date_query_compare ) . '"' : '';
11981201
$ajaxloadmore .= $date_query_relation ? ' data-date-query-relation="' . esc_attr( $date_query_relation ) . '"' : '';
11991202

core/functions.php

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -233,23 +233,29 @@ function alm_get_date_query_before_after( array $args = [], string $before = '',
233233
* Build and parse a date query.
234234
*
235235
* @see https://developer.wordpress.org/reference/classes/wp_query/#date-parameters
236-
* @param string $param The date query parameter.
237-
* @param array $data The date query data.
238-
* @param array $args The WP_Query args.
239-
* @return array Modified args.
236+
* @param string $data The date query data.
237+
* @param string $compare The date query compare.
238+
* @param string $columm The date query columm.
239+
* @param array $args The WP_Query args.
240+
* @return array The modified args.
240241
*/
241-
function alm_get_date_query( $data = '', $args = [] ) {
242+
function alm_get_date_query( $data = '', $compare = '', $columm = '', $args = [] ) {
242243
if ( ! $data ) {
243244
return $args;
244245
}
245246

246-
// Explode the date query data.
247-
$data = explode( ';', $data );
247+
// Explode the date query params.
248+
$data = explode( ';', $data );
249+
$compare = explode( ';', $compare );
250+
$columm = explode( ';', $columm );
248251

249252
// Loop each date query.
250-
foreach ( $data as $value ) {
251-
$params = explode( '-', $value );
252-
$array = [];
253+
foreach ( $data as $key => $value ) {
254+
$params = explode( '-', $value );
255+
$date_compare = isset( $compare[ $key ] ) ? alm_parse_query_compare( $compare[ $key ] ) : '';
256+
$date_columm = isset( $columm[ $key ] ) ? $columm[ $key ] : '';
257+
258+
$array = [];
253259
if ( isset( $params[0] ) && $params[0] ) {
254260
$array['year'] = $params[0];
255261
}
@@ -271,6 +277,12 @@ function alm_get_date_query( $data = '', $args = [] ) {
271277
if ( isset( $params[6] ) && $params[6] ) {
272278
$array['week'] = $params[6];
273279
}
280+
if ( $date_compare ) {
281+
$array['compare'] = $date_compare;
282+
}
283+
if ( $date_columm ) {
284+
$array['column'] = $date_columm;
285+
}
274286
$args['date_query'][] = $array;
275287
}
276288
return $args;
@@ -356,6 +368,23 @@ function alm_parse_tax_terms( $terms ) {
356368
return $terms;
357369
}
358370

371+
/**
372+
* do_shortcode fix (shortcode renders as HTML when using < OR <==).
373+
*
374+
* @param string $compare The compare operator.
375+
* @return void
376+
*/
377+
function alm_parse_query_compare( $compare ) {
378+
if ( ! $compare ) {
379+
return;
380+
}
381+
$compare = 'lessthan' === $compare ? '<' : $compare;
382+
$compare = 'lessthanequalto' === $compare ? '<=' : $compare;
383+
$compare = 'greaterthan' === $compare ? '>' : $compare;
384+
$compare = 'greaterthanequalto' === $compare ? '>=' : $compare;
385+
return $compare;
386+
}
387+
359388
/**
360389
* Query by custom field values.
361390
*
@@ -370,11 +399,7 @@ function alm_get_meta_query( $params ) {
370399
$meta_type = esc_sql( $params['type'] );
371400

372401
if ( ! empty( $meta_key ) ) {
373-
// do_shortcode fix (shortcode was rendering as HTML when using < OR <==).
374-
$meta_compare = 'lessthan' === $meta_compare ? '<' : $meta_compare;
375-
$meta_compare = 'lessthanequalto' === $meta_compare ? '<=' : $meta_compare;
376-
$meta_compare = 'greaterthan' === $meta_compare ? '>' : $meta_compare;
377-
$meta_compare = 'greaterthanequalto' === $meta_compare ? '>=' : $meta_compare;
402+
$meta_compare = alm_parse_query_compare( $meta_compare );
378403

379404
// Get optimized `meta_value` parameter.
380405
$meta_values = alm_parse_meta_value( $meta_value, $meta_compare );
@@ -409,7 +434,6 @@ function alm_get_meta_query( $params ) {
409434
* eg. `Country Code` = `country_code_clause`
410435
*
411436
* @see https://wordpress.stackexchange.com/questions/246355/order-by-multiple-meta-key-and-meta-value/246358#246358
412-
*
413437
* @param string $key The meta key name.
414438
* @return string Formatted meta name.
415439
*/

0 commit comments

Comments
 (0)