✨refactor: Update README for latest release link and enhance filter display with taxonomy names #release
Some checks failed
Add release / Create release (push) Has been cancelled
Some checks failed
Add release / Create release (push) Has been cancelled
This commit is contained in:
@@ -28,18 +28,48 @@ jQuery(document).ready(function ($) {
|
||||
taxonomyFilters[taxonomy] = [];
|
||||
}
|
||||
|
||||
taxonomyFilters[taxonomy].push($(this).val());
|
||||
taxonomyFilters[taxonomy].push({
|
||||
value: $(this).val(),
|
||||
text: $(this).closest('label').text().trim() // Get the text associated with the checkbox
|
||||
});
|
||||
});
|
||||
|
||||
const toTitleCase = (phrase) => {
|
||||
return phrase
|
||||
.toLowerCase()
|
||||
.split('_')
|
||||
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
||||
.join(' ');
|
||||
};
|
||||
|
||||
// Build applied filters for display
|
||||
let dropdownFilters = [];
|
||||
let finalFilters = {};
|
||||
|
||||
for (let taxonomy in taxonomyFilters) {
|
||||
taxonomyFilters[taxonomy].forEach(function (term) {
|
||||
let taxName = toTitleCase(taxonomy);
|
||||
|
||||
appliedFilters.push(
|
||||
`<span class="filter-item" data-type="${taxonomy}" data-value="${term}">
|
||||
<strong>${taxonomy}:</strong> ${term}
|
||||
<button class="remove-filter" aria-label="Remove ${term}">×</button>
|
||||
`<span class="filter-item" data-type="${taxonomy}" data-value="${term.value}">
|
||||
<strong>${taxName}:</strong> ${term.text}
|
||||
<button class="remove-filter" aria-label="Remove ${term.text}">×</button>
|
||||
</span>`
|
||||
);
|
||||
|
||||
dropdownFilters.push(term.text);
|
||||
|
||||
if (!finalFilters[taxonomy]) {
|
||||
finalFilters[taxonomy] = [];
|
||||
}
|
||||
|
||||
finalFilters[taxonomy].push(
|
||||
term.value,
|
||||
);
|
||||
|
||||
$(`#${taxonomy}_text`).html(
|
||||
dropdownFilters ? dropdownFilters.join(', ') : taxName
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -51,7 +81,7 @@ jQuery(document).ready(function ($) {
|
||||
search: searchTerm,
|
||||
paged: paged,
|
||||
sort_order: $('#sortOrder').val(),
|
||||
...taxonomyFilters, // Include taxonomy filters dynamically
|
||||
...finalFilters, // Include taxonomy filters dynamically
|
||||
};
|
||||
|
||||
// Perform AJAX request
|
||||
|
||||
Reference in New Issue
Block a user