possibly fixed ajax fetch

This commit is contained in:
2026-02-01 13:39:40 +01:00
parent 4bd996cd5c
commit 12b896e366
3 changed files with 24 additions and 25 deletions

View File

@@ -23,7 +23,7 @@ if ( ! defined( 'WPINC' ) ) {
die;
}
define( 'PARTNEREXPO_CORE_VERSION', '1.0.3' );
define( 'PARTNEREXPO_CORE_VERSION', '1.0.4' );
function activate_partnerexpo_core() {
require_once plugin_dir_path( __FILE__ ) . 'includes/class-partnerexpo-core-activator.php';

View File

@@ -78,6 +78,7 @@ class Partnerexpo_Core_Public {
'title' => $post->post_title,
'image' => get_the_post_thumbnail_url($post->ID),
'excerpt' => $post->post_excerpt,
'modif' => $post->post_modified,
'url' => get_permalink($post),
];
}

View File

@@ -31,25 +31,25 @@ document.addEventListener('DOMContentLoaded', () => {
let activeSortKey = "relevance";
let results = []; // Fills via Ajax
// ---------- Sort Definitions ----------
const SORTS = {
relevance: {
label: "Relevance",
compare: (a, b) => (b.relevance - a.relevance) || (b.score - a.score)
},
score_desc: {
label: "Score (high → low)",
compare: (a, b) => (b.score - a.score)
},
date_desc: {
label: "Date (new → old)",
compare: (a, b) => new Date(b.updated) - new Date(a.updated)
},
title_asc: {
label: "Title (A → Z)",
compare: (a, b) => (a.title || "").localeCompare(b.title || "")
}
};
// // ---------- Sort Definitions ----------
// const SORTS = {
// relevance: {
// label: "Relevance",
// compare: (a, b) => (b.relevance - a.relevance) || (b.score - a.score)
// },
// score_desc: {
// label: "Score (high → low)",
// compare: (a, b) => (b.score - a.score)
// },
// date_desc: {
// label: "Date (new → old)",
// compare: (a, b) => new Date(b.updated) - new Date(a.updated)
// },
// title_asc: {
// label: "Title (A → Z)",
// compare: (a, b) => (a.title || "").localeCompare(b.title || "")
// }
// };
// ---------- Helpers ----------
function escapeHtml(str) {
@@ -58,26 +58,24 @@ document.addEventListener('DOMContentLoaded', () => {
}[s]));
}
// Generates HTML with the correct 'pexpo-core-' classes
function cardEl(r) {
const div = document.createElement("div");
div.className = "pexpo-core-card";
div.innerHTML = `
<div class="pexpo-core-imageWrap">
<img src="${escapeHtml(r.image_url || 'https://placehold.co/600x400')}"
<img src="${escapeHtml(r.image || 'https://placehold.co/600x400')}"
alt="${escapeHtml(r.title)}"
style="width:100%; border-radius:10px; object-fit:cover;" />
</div>
<div class="pexpo-core-cardTop">
<div class="pexpo-core-title">${escapeHtml(r.title)}</div>
</div>
<div class="pexpo-core-desc">${escapeHtml(r.desc)}</div>
<div class="pexpo-core-desc">${escapeHtml(r.excerpt)}</div>
<div class="pexpo-core-foot">
<div class="pexpo-core-status">
<span class="pexpo-core-dot"></span>
score: <b style="margin-left:6px;color:rgba(16,24,40,.86)">${r.score}</b>
</div>
<div>${escapeHtml(r.updated)}</div>
<div>${escapeHtml(r.modif)}</div>
</div>
`;
return div;