Skip to content

Commit 84d405a

Browse files
committed
Bring in changes from previous release
1 parent dcb17cb commit 84d405a

File tree

6 files changed

+1437
-120
lines changed

6 files changed

+1437
-120
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array(), 'version' => '52ba44d7ced59bb3bc05');
1+
<?php return array('dependencies' => array(), 'version' => '4461a320a7fb2fa056a9');

build/frontend/ajax-load-more.js

Lines changed: 1411 additions & 79 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array(), 'version' => 'fc4df552f90365c4b09b');
1+
<?php return array('dependencies' => array(), 'version' => '7ce74d0284b6a2c0b803');

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

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lang/ajax-load-more.pot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ msgstr ""
99
"MIME-Version: 1.0\n"
1010
"Content-Type: text/plain; charset=UTF-8\n"
1111
"Content-Transfer-Encoding: 8bit\n"
12-
"POT-Creation-Date: 2025-06-10T11:24:21+00:00\n"
12+
"POT-Creation-Date: 2025-06-10T11:33:15+00:00\n"
1313
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1414
"X-Generator: WP-CLI 2.11.0\n"
1515
"X-Domain: ajax-load-more\n"

src/frontend/js/ajax-load-more.js

Lines changed: 19 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ALM Modules
22
import axios from 'axios';
3-
import '../scss/ajax-load-more.scss';
3+
import DOMPurify from 'dompurify';
44
import { cacheCreateParams, getCache } from './addons/cache';
55
import { ctaCreateParams } from './addons/call-to-actions';
66
import { commentsCreateParams } from './addons/comments';
@@ -33,15 +33,16 @@ import * as resultsText from './modules/resultsText';
3333
import setLocalizedVars from './modules/setLocalizedVars';
3434
import { tableOfContents } from './modules/tableofcontents';
3535

36+
import '../scss/ajax-load-more.scss';
37+
3638
// External packages.
3739
const qs = require('qs');
3840
const imagesLoaded = require('imagesloaded');
3941

4042
// Axios Config.
4143
axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
42-
43-
// Axios Interceptor for nested data objects
4444
axios.interceptors.request.use((config) => {
45+
// Axios Interceptor for nested data objects
4546
config.paramsSerializer = (params) => {
4647
// Qs is already included in the Axios package
4748
return qs.stringify(params, {
@@ -144,15 +145,16 @@ const isBlockEditor = document.body.classList.contains('wp-admin');
144145
alm.trigger = alm.btnWrap[alm.btnWrap.length - 1];
145146
alm.button = alm?.trigger?.querySelector('button.alm-load-more-btn') || null;
146147

148+
// Button Labels.
147149
alm.button_labels = {
148-
default: alm?.listing?.dataset?.buttonLabel || alm_localize?.button_label,
149-
loading: alm?.listing?.dataset?.buttonLoadingLabel || null,
150-
done: alm?.listing?.dataset?.buttonDoneLabel || null,
150+
default: DOMPurify.sanitize(alm?.listing?.dataset?.buttonLabel) || DOMPurify.sanitize(alm_localize?.button_label),
151+
loading: DOMPurify.sanitize(alm?.listing?.dataset?.buttonLoadingLabel) || null,
152+
done: DOMPurify.sanitize(alm?.listing?.dataset?.buttonDoneLabel) || null,
151153
};
152154
alm.prev_button_labels = {
153-
default: alm?.listing?.dataset?.prevButtonLabel,
154-
loading: alm?.listing?.dataset?.prevButtonLoadingLabel || null,
155-
done: alm?.listing?.dataset?.prevButtonDoneLabel || null,
155+
default: DOMPurify.sanitize(alm?.listing?.dataset?.prevButtonLabel),
156+
loading: DOMPurify.sanitize(alm?.listing?.dataset?.prevButtonLoadingLabel) || null,
157+
done: DOMPurify.sanitize(alm?.listing?.dataset?.prevButtonDoneLabel) || null,
156158
};
157159

158160
alm.urls = alm?.listing?.dataset?.urls === 'false' ? false : true;
@@ -433,7 +435,7 @@ const isBlockEditor = document.body.classList.contains('wp-admin');
433435
params = '';
434436
}
435437

436-
// HTTP request via axios.
438+
// Make API request.
437439
const data = await axios
438440
.get(url, { params })
439441
.then(function (response) {
@@ -449,7 +451,7 @@ const isBlockEditor = document.body.classList.contains('wp-admin');
449451
return response.data; // Standard ALM.
450452
})
451453
.catch(function (error) {
452-
alm.AjaxLoadMore.error(error, 'adminajax');
454+
alm.AjaxLoadMore.error(error);
453455
});
454456

455457
switch (type) {
@@ -518,7 +520,7 @@ const isBlockEditor = document.body.classList.contains('wp-admin');
518520
})
519521
.catch(function (error) {
520522
// Error
521-
alm.AjaxLoadMore.error(error, 'restapi');
523+
alm.AjaxLoadMore.error(error);
522524
});
523525
};
524526

@@ -988,7 +990,7 @@ const isBlockEditor = document.body.classList.contains('wp-admin');
988990
})
989991
.catch(function (error) {
990992
// Error
991-
alm.AjaxLoadMore.error(error, 'getSinglePost');
993+
alm.AjaxLoadMore.error(error);
992994
alm.fetchingPreviousPost = false;
993995
});
994996

@@ -1531,37 +1533,18 @@ const isBlockEditor = document.body.classList.contains('wp-admin');
15311533
};
15321534

15331535
/**
1534-
* Handle error messages.
1536+
* Handle API errors by reseting the loading state and button text.
15351537
*
1536-
* @param {string} error The error message.
1537-
* @param {string} location The location the error occured.
1538+
* @param {string} error The error message.
15381539
* @since 2.6.0
15391540
*/
1540-
alm.AjaxLoadMore.error = function (error, location = null) {
1541+
alm.AjaxLoadMore.error = function (error) {
1542+
console.error('Ajax Load More: There was an error with the Ajax request.', error); //eslint-disable-line no-console
15411543
alm.loading = false;
15421544
if (!alm.addons.paging) {
15431545
alm.button.classList.remove('loading');
15441546
alm.AjaxLoadMore.resetBtnText();
15451547
}
1546-
console.warn('Error: ', error);
1547-
1548-
if (error.response) {
1549-
// The request was made and the server responded with a status code that falls out of the range of 2xx.
1550-
console.error('Error Msg: ', error.message);
1551-
} else if (error.request) {
1552-
// The request was made but no response was received.
1553-
console.error(error.request);
1554-
} else {
1555-
// Something happened in setting up the request that triggered an Error.
1556-
console.error('Error Msg: ', error.message);
1557-
}
1558-
1559-
if (location) {
1560-
console.error('ALM Error started in ' + location);
1561-
}
1562-
if (error.config) {
1563-
console.error('ALM Error Debug: ', error.config);
1564-
}
15651548
};
15661549

15671550
/**

0 commit comments

Comments
 (0)