Refactoring : sécurité (XSS), découpage en modules inc/* et js/admin/*, IDs résolus par slug, perf (caches, cron Gravatar, assets auto-hébergés), tests

This commit is contained in:
2026-06-10 21:30:25 +02:00
parent e6b73df516
commit 9280c3b9ce
44 changed files with 3209 additions and 2907 deletions

View File

@@ -0,0 +1,80 @@
/**
* Pages listes/édition de taxonomies (edit-tags.php, term.php) :
* info-bulles « FR // EN », filtre « Type de programme », mode visuel forcé
* sur les WYSIWYG Pods des pages term.
* Dépend de admin-base.js (window.ThalimAdmin) — enqueue conditionnel.
*/
(function($) {
'use strict';
var TA = window.ThalimAdmin;
var CONFIG = TA.CONFIG;
var safeRun = TA.safeRun;
// Inject a "Type de programme" filter select into the taxonomy search form.
// The form already has hidden taxonomy/post_type fields so the select value
// is submitted with them and picked up by pre_get_terms server-side.
function initProgrammeFilter() {
var form = document.querySelector('form.search-form');
if (!form) return;
var types = [
'Programme subventionné',
'Autre programme',
'Ancien programme'
];
// Read current filter value from the URL.
var params = new URLSearchParams(window.location.search);
var current = params.get('type_de_programme') || '';
var select = document.createElement('select');
select.name = 'type_de_programme';
select.id = 'filter-type-de-programme';
select.style.cssText = 'margin-right:6px;';
var blank = document.createElement('option');
blank.value = '';
blank.textContent = 'Tous les types';
select.appendChild(blank);
types.forEach(function(type) {
var opt = document.createElement('option');
opt.value = type;
opt.textContent = type;
if (type === current) opt.selected = true;
select.appendChild(opt);
});
// Insert before the first <p> (search-box) inside the form.
var searchBox = form.querySelector('p.search-box');
form.insertBefore(select, searchBox || null);
}
$(document).ready(function() {
setTimeout(function() {
safeRun('taxonomyPopovers', function() {
var isTranslateTaxonomy = CONFIG.translateTaxonomies.some(function(tax) {
return window.location.search.indexOf('taxonomy=' + tax) !== -1;
});
if (isTranslateTaxonomy) {
TA.initInfoPopovers('taxonomy');
}
});
safeRun('programmeFilter', function() {
if (window.location.search.indexOf('taxonomy=programme_de_recherche') !== -1) {
initProgrammeFilter();
}
});
}, 100);
// term.php / edit-tags.php : force visual mode on Pods WYSIWYG fields
$(window).on('load', function() {
document.querySelectorAll('.pods-dfv-container-wysiwyg textarea').forEach(function(ta) {
if (!ta.id) return;
TA.ensureVisualMode(ta.id);
});
});
});
})(jQuery);