Skip to content

Commit

Permalink
Fixed issue with display of Single Posts data when being used with El…
Browse files Browse the repository at this point in the history
…ementor.
  • Loading branch information
dcooney committed Jan 23, 2024
1 parent 89ec288 commit 9a1e18e
Show file tree
Hide file tree
Showing 12 changed files with 8,617 additions and 13,652 deletions.
3 changes: 2 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ How to install Ajax Load More.
== Changelog ==

= 7.0.1 - January 23, 2024 =
* HOTFIX: Fixed Filters add-on issue that would appear when using the Paging add-on. Filters would remain disabled after interacting with a filter due to a missing callback function.
* HOTFIX: Fixed issue with Filters add-on that would appear when using the Paging add-on. Filters would remain disabled after interacting with a filter due to a missing callback function.
* HOTFIX: Fixed issue with display of Single Posts data when being used with Elementor.


= 7.0.0 - January 16, 2024 =
Expand Down
2 changes: 1 addition & 1 deletion build/admin/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array(), 'version' => 'c3869ab83f8f89db72f3');
<?php return array('dependencies' => array(), 'version' => 'db8c5f1625d83040facf');
5,168 changes: 5,167 additions & 1 deletion build/admin/index.css

Large diffs are not rendered by default.

998 changes: 83 additions & 915 deletions build/admin/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/frontend/ajax-load-more.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array(), 'version' => '2e9ff0296f42003aa2a7');
<?php return array('dependencies' => array(), 'version' => 'b024125f38e4689ed1b6');
519 changes: 518 additions & 1 deletion build/frontend/ajax-load-more.css

Large diffs are not rendered by default.

13,670 changes: 960 additions & 12,710 deletions build/frontend/ajax-load-more.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/frontend/ajax-load-more.min.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array(), 'version' => '4bbb02238c5bd1549e0b');
<?php return array('dependencies' => array(), 'version' => 'b024125f38e4689ed1b6');
519 changes: 518 additions & 1 deletion build/frontend/ajax-load-more.min.css

Large diffs are not rendered by default.

1,357 changes: 1,351 additions & 6 deletions build/frontend/ajax-load-more.min.js

Large diffs are not rendered by default.

12 changes: 5 additions & 7 deletions src/frontend/js/addons/singleposts.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,13 @@ function singlepostsGetCustomElements(content = '', customElements = [], id) {
/**
* Create data attributes for a Single Post item.
*
* @param {Object} alm The ALM object.
* @param {Array} elements The elements HTML nodes as an array.
* @param {Object} alm The ALM object.
* @param {Element} element The elements HTML element to add data params.
* @return {Array} Modified HTML element.
*/
export function addSinglePostsAttributes(alm, elements) {
// Get first element in NodeList.
const element = elements?.length ? elements[0] : false;
export function addSinglePostsAttributes(alm, element) {
if (!element) {
return elements;
return [];
}

const { page, addons } = alm;
Expand All @@ -168,5 +166,5 @@ export function addSinglePostsAttributes(alm, elements) {
element.dataset.url = addons.single_post_permalink;
element.dataset.page = addons.single_post_target ? parseInt(page) + 1 : page;
element.dataset.title = addons.single_post_title;
return elements;
return element;
}
17 changes: 10 additions & 7 deletions src/frontend/js/functions/formatHTML.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { addSinglePostsAttributes } from '../addons/singleposts';
import stripEmptyNodes from '../functions/stripEmptyNodes';

/**
* Create data attributes for SEO and Filter paged results.
* Create data attributes for Single Posts, SEO and Filter paged results.
*
* @param {Object} alm The ALM object.
* @param {Array} elements The element HTML nodes.
Expand All @@ -20,17 +20,20 @@ export default function formatHTML(alm, elements) {

// Single Posts.
if (addons?.single_post) {
// Single Posts only.
elements = addSinglePostsAttributes(alm, elements);
let singleWrap = document.createElement('div');
singleWrap.innerHTML = alm.html;
singleWrap = addSinglePostsAttributes(alm, singleWrap);

// Single Post Preview.
if (addons.single_post_preview && addons.single_post_preview_data && typeof almSinglePostCreatePreview === 'function') {
const singlePreview = almSinglePostCreatePreview(elements[0], addons.single_post_id, addons.single_post_preview_data);
if (addons?.single_post_preview && addons?.single_post_preview_data && typeof almSinglePostCreatePreview === 'function') {
const singlePreview = almSinglePostCreatePreview(singleWrap, addons.single_post_id, addons.single_post_preview_data);
if (singlePreview) {
elements[0].replaceChildren(singlePreview);
singleWrap.replaceChildren(singlePreview);
}
}
return elements;

alm.last_loaded = [singleWrap];
return [singleWrap];
}

// Exit if not SEO or Filters.
Expand Down

0 comments on commit 9a1e18e

Please sign in to comment.