Compare commits

...

21 Commits

Author SHA1 Message Date
Antoine M
af540c312e FEATURE refactoring presse components to handle datas with the new post type dedicated archives presses
All checks were successful
continuous-integration/drone/push Build is passing
2026-03-17 14:59:24 +01:00
e54304b2b1 UPDATE modify watch:js script in package.json to use TypeScript file and update esbuild version in package.json and pnpm-lock.yaml for improved build process 2026-03-16 10:18:02 +01:00
f45c1d0b40 FEATURE add get_authors_linked_to_posts function to retrieve authors associated with given posts via ACF field for enhanced content management 2026-03-16 10:17:47 +01:00
5ebdcf0831 REFACTOR add api.php inclusion in functions.php to enhance modularity and maintainability of the codebase 2026-03-16 10:17:37 +01:00
1a8cccd420 REFACTOR enhance press-ressources.css with new styles for archives-presse-card and list layout for improved visual consistency 2026-03-16 10:17:03 +01:00
a0164bcd85 REFACTOR add 'archives-presse' style to content-meta.css for consistent styling with other press components 2026-03-16 10:16:55 +01:00
1a82189831 REFACTOR update post-card.css to include 'block' display property for improved layout consistency 2026-03-16 10:16:48 +01:00
f1f66fd626 REFACTOR update post-grid.css to include 'types' select element in toolbar actions for improved filtering functionality 2026-03-16 10:16:39 +01:00
a6b5bd7e68 FEATURE Introducing component 2026-03-16 10:16:25 +01:00
8adca7da9b REFACTOR remove unnecessary blank line in analyses-etudes-grid.php for cleaner code 2026-03-16 10:15:59 +01:00
3cdd5bebbd REFACTOR remove unnecessary blank line in post-card.php for cleaner code 2026-03-16 10:15:49 +01:00
f90d43fd26 REFACTOR update single.php to replace post-toolbar with single-post-toolbar for clarity and consistency in component naming 2026-03-16 10:15:40 +01:00
0ec57f6278 FEATURE Introducing component 2026-03-16 10:15:14 +01:00
439029c830 REFACTOR post-grid.php to utilize the new post-grid-toolbar component, streamlining the code by removing redundant elements and enhancing maintainability. 2026-03-16 10:14:58 +01:00
239f2be885 FEATURE Introducing the toolbar component 2026-03-16 10:14:33 +01:00
162e0d06e0 REBUILDING 2026-03-16 10:13:50 +01:00
e2ce4f4201 FEATURE Introducing api main post query to integrate with archive filters 2026-03-16 10:13:35 +01:00
f49f7fd697 FEATURE Handling Javascript archive filters 2026-03-16 10:12:24 +01:00
dffeaa9a79 REFACTOR Renaming post toolbar into single post toolbar to avoid confusions with archive post toolbar 2026-03-16 10:11:20 +01:00
f8004e39e7 UPDATE change comment header in archive-expositions.php to reflect post grid type 2026-03-16 10:10:15 +01:00
145cc3c414 REFACTOR post grid with the generic post grid component 2026-03-16 10:10:00 +01:00
26 changed files with 3259 additions and 95 deletions

View File

@ -16,16 +16,18 @@
'url' => '#prochaines-publications',
)
)); ?>
<?php get_template_part('template-parts/components/archive/latest-parutions', null, array(
'post_amount' => 1,
'post_type' => 'analyses-etudes',
));
?>
<!-- #### ANALYSES ET ETUDES POST GRID #### -->
<?php get_template_part('template-parts/post-types/analyses-etudes/analyses-etudes-grid'); ?>
<!-- #### ARCHIVE POST GRID #### -->
<?php get_template_part('template-parts/components/archive/post-grid', null, array(
'current_post_type' => 'analyses-etudes',
'post_amount' => -1,
'grid_title' => 'Trouver une publication',
)); ?>
<!-- #### SOUTENIR #### -->

View File

@ -17,7 +17,7 @@ $current_post_type = get_post_type();
?>
<!-- #### ANALYSES ET ETUDES POST GRID #### -->
<!-- #### ARCHIVE POST GRID #### -->
<?php get_template_part('template-parts/components/archive/post-grid', null, array(
'current_post_type' => 'expositions',
'post_amount' => -1,

View File

@ -14,16 +14,16 @@ body {
#wp-submit {
--tw-border-opacity: 1;
border-color: rgb(19 111 99 / var(--tw-border-opacity));
border-color: rgb(19 111 99 / var(--tw-border-opacity, 1));
--tw-bg-opacity: 1;
background-color: rgb(19 111 99 / var(--tw-bg-opacity));
background-color: rgb(19 111 99 / var(--tw-bg-opacity, 1));
}
#nav a,
#backtoblog a {
/* color: var(--red) !important; */
--tw-text-opacity: 1;
color: rgb(19 111 99 / var(--tw-text-opacity));
color: rgb(19 111 99 / var(--tw-text-opacity, 1));
}
#loginform {
@ -32,6 +32,6 @@ body {
.wp-pwd span {
--tw-text-opacity: 1;
color: rgb(19 111 99 / var(--tw-text-opacity));
color: rgb(19 111 99 / var(--tw-text-opacity, 1));
/* color: var(--red) !important; */
}

View File

@ -10,6 +10,7 @@ require_once(__DIR__ . '/includes/utilities.php');
require_once(__DIR__ . '/includes/nawalker_fction.php');
require_once(__DIR__ . '/includes/options-social-networks.php');
require_once(__DIR__ . '/includes/options-presse.php');
require_once(__DIR__ . '/includes/api.php');
require_once(__DIR__ . '/includes/forms.php');
require_once(__DIR__ . '/includes/rapport-activites.php');
require_once(__DIR__ . '/includes/equipe.php');

121
includes/api.php Normal file
View File

@ -0,0 +1,121 @@
<?php
add_action('rest_api_init', function () {
/* ----------------
BUILDING ROUTES
-----------------*/
// ################ FILTER ARTICLES ################
register_rest_route('carhop-datas/v1/build', '/posts', array(
'methods' => 'GET',
'callback' => 'build_posts',
'permission_callback' => '__return_true',
));
});
// ################ FILTER POSTS ################
function build_posts($request)
{
$post_type = esc_html($request->get_param('post_type'));
$etiquette = esc_html($request->get_param('etiquette'));
$auteur = esc_html($request->get_param('auteur'));
$sort_by = esc_html($request->get_param('sort_by'));
$recherche = esc_html($request->get_param('recherche'));
// Construire les arguments de la query WordPress
$args = array(
'post_type' => $post_type,
'posts_per_page' => -1,
);
write_log("##########params");
write_log(array(
'post_type' => $post_type,
'etiquette' => $etiquette,
'auteur' => $auteur,
'sort_by' => $sort_by,
'recherche' => $recherche,
));
// Gestion du tri
switch ($sort_by) {
case 'date_desc':
$args['orderby'] = 'date';
$args['order'] = 'DESC';
break;
case 'date_asc':
$args['orderby'] = 'date';
$args['order'] = 'ASC';
break;
case 'title_asc':
$args['orderby'] = 'title';
$args['order'] = 'ASC';
break;
default:
$args['orderby'] = 'date';
$args['order'] = 'DESC';
}
// Filtre par étiquette (taxonomie)
if (!empty($etiquette) && $etiquette != '1') {
$args['tax_query'] = array(
array(
'taxonomy' => 'etiquettes',
'field' => 'slug',
'terms' => $etiquette,
),
);
}
// Filtre par auteur
if (!empty($auteur) && $auteur != '1') {
$args['meta_query'] = array(
array(
'key' => 'authors', // Ajustez selon votre structure
'value' => $auteur,
'compare' => 'LIKE'
)
);
}
// Recherche par mot-clé
if (!empty($recherche)) {
$args['s'] = $recherche;
}
$posts_query = new WP_Query($args);
write_log($posts_query->posts);
ob_start();
if ($posts_query->have_posts()) :
while ($posts_query->have_posts()) : $posts_query->the_post();
get_template_part('template-parts/components/cards/post-card', null, array(
'ID' => get_the_ID(),
));
endwhile;
else :
echo '<p>Aucun article trouvé.</p>';
endif;
wp_reset_postdata();
$html_template = ob_get_clean();
$response_data = array(
'html_template' => $html_template,
'post_count' => $posts_query->found_posts,
'query_args' => $args, // Pour debug
);
$response = new WP_REST_Response($response_data);
$response->set_status(200);
return $response;
}

View File

@ -361,3 +361,42 @@ function get_carhop_members_by_comity()
restore_current_blog();
return $members_organised_by_comity;
}
/**
* Retourne les auteurs (posts du CPT "auteurs") réellement liés
* aux posts donnés via le champ ACF "authors".
*
* @param array $post_ids Liste d'IDs de posts
* @param string $acf_field_name Nom du champ ACF (par défaut "authors")
* @return array|WP_Post[] Liste de posts "auteurs"
*/
function get_authors_linked_to_posts(array $post_ids)
{
if (empty($post_ids)) {
return array();
}
$author_ids = array();
foreach ($post_ids as $post_id) {
$post_authors = get_field('authors', $post_id);
if (empty($post_authors)) continue;
foreach ($post_authors as $author) {
$author_id = is_object($author) ? $author->ID : (int) $author;
if ($author_id) {
$author_ids[$author_id] = $author_id; // set pour éviter les doublons
}
}
}
if (empty($author_ids)) {
return array();
}
return get_posts(array(
'post_type' => 'auteurs',
'post__in' => array_values($author_ids),
'posts_per_page' => -1,
'orderby' => 'title',
'order' => 'ASC',
));
}

View File

@ -26,7 +26,7 @@
"watch:css-editor": "cross-env NODE_ENV=development tailwindcss -i ./resources/css/editor-style.css -o ./css/editor-style.css --postcss --watch",
"watch:css-admin": "cross-env NODE_ENV=development tailwindcss -i ./resources/css/admin-style.css -o ./css/admin-style.css --postcss --watch",
"watch:css-login": "cross-env NODE_ENV=development tailwindcss -i ./resources/css/login-style.css -o ./css/login-style.css --postcss --watch",
"watch:js": "cross-env NODE_ENV=development ./node_modules/.bin/esbuild ./resources/js/app.js --bundle --outfile=./js/app.js --watch",
"watch:js": "cross-env NODE_ENV=development ./node_modules/.bin/esbuild ./resources/js/app.ts --bundle --outfile=./js/app.js --watch",
"production": "cross-env NODE_ENV=production concurrently \"npm run production:css-app\" \"npm run production:css-editor\" \"npm run production:css-admin\" \"npm run production:css-login\" \"npm run production:js\"",
"dev": "cross-env NODE_ENV=development concurrently \"npm run dev:css-app\" \"npm run dev:css-admin\" \"npm run dev:css-editor\" \"npm run dev:css-login\" \"npm run dev:js\"",
"watch": "cross-env NODE_ENV=development concurrently \"npm run watch:css-app\" \"npm run watch:css-editor\" \"npm run watch:css-admin\" \"npm run watch:css-login\" \"npm run watch:js\"",
@ -39,7 +39,7 @@
"browser-sync": "^2.26.14",
"concurrently": "^6.2.1",
"cross-env": "^6.0.3",
"esbuild": "^0.12.24",
"esbuild": "^0.24.0",
"postcss": "^8.4.4",
"postcss-import": "^14.0.0",
"postcss-nested-ancestors": "^2.0.0",

2502
pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load Diff

View File

@ -153,18 +153,6 @@
}
}
.presse-reviews {
@apply mt-12;
.wp-block-carhop-blocks-content-box {
@apply !w-full !m-0;
.content-box__innerblocks {
@apply p-0;
> * {
@apply w-full max-w-none;
}
}
}
}
.ressources-grid-content-wrapper {
&[data-active-tab='communiques'] {
.ressources-graphiques,
@ -185,3 +173,99 @@
}
}
}
.presse-reviews {
@apply mt-12;
.wp-block-carhop-blocks-content-box {
@apply !w-full !m-0;
.content-box__innerblocks {
@apply p-0;
> * {
@apply w-full max-w-none;
}
}
}
&__inner {
@apply grid gap-8;
grid-template-columns: 250px 3fr;
}
aside {
ul.presse-reviews__years-list {
@apply sticky top-0;
li.presse-reviews__year {
@apply list-none border border-primary border-solid p-6 text-4xl fjalla;
}
li.presse-reviews__year + li.presse-reviews__year {
@apply mt-4;
}
}
}
&__archives-list {
@apply grid grid-cols-1 gap-8;
.archives-year-title-wrapper {
@apply relative mb-6;
&:after {
@apply content-[''] block w-full bg-primary absolute;
top: 50%;
height: 1px;
}
h3 {
@apply bg-white w-fit mx-auto px-8 relative z-10 text-lg nunito !font-bold tracking-wide;
}
}
}
&__archives-decade {
.post-card + .post-card {
@apply mt-8;
}
}
&__title {
@apply my-12;
}
ul.archives-decade-used-types {
@apply flex items-center gap-10;
li.archives-decade-used-type {
@apply text-primary flex items-center gap-2;
&::before {
@apply content-[''] block w-8 h-8 bg-no-repeat bg-center bg-contain bg-red-300;
}
&--audio::before {
background-image: url('../resources/img/icons/carhop-source-audio.svg');
}
&--video::before {
background-image: url('../resources/img/icons/carhop-source-video.svg');
}
&--photo::before {
background-image: url('../resources/img/icons/carhop-source-photo.svg');
}
&--article::before {
background-image: url('../resources/img/icons/carhop-source-ecrits.svg');
}
}
}
}
/*
.archives-presse-card {
@apply block bg-red-500;
&__inner {
@apply flex items-start justify-between gap-8;
}
.cta--download {
@apply shrink-0 py-0;
}
h3 {
@apply mb-6 text-2xl;
}
@apply border border-primary border-solid bg-white p-8;
.archives-presse-card__file-infos {
@apply flex items-center gap-2 text-primary;
}
.archives-presse-card__file-type {
@apply uppercase;
}
} */

View File

@ -15,6 +15,7 @@
@apply rounded-full bg-carhop-orange-400;
}
&--archives-presse:before ,
&--communique-presse:before {
@apply rounded-full bg-white border-2 border-primary;
}

View File

@ -1,5 +1,5 @@
.post-card {
@apply bg-white border border-primary p-6;
@apply bg-white border border-primary p-6 block;
transition: transform 0.3s ease-out;
&:hover {
transform: translateY(-4px);
@ -84,3 +84,30 @@
}
}
}
.post-card--archives-presse {
&::after {
@apply !content-none;
}
.media-type-list {
.media-type {
@apply flex items-center gap-2 w-fit;
&::before {
@apply content-[''] block w-8 h-8 bg-no-repeat bg-center bg-contain bg-red-300;
}
&--audio::before {
background-image: url('../resources/img/icons/carhop-source-audio.svg');
}
&--video::before {
background-image: url('../resources/img/icons/carhop-source-video.svg');
}
&--photo::before {
background-image: url('../resources/img/icons/carhop-source-photo.svg');
}
&--article::before {
background-image: url('../resources/img/icons/carhop-source-ecrits.svg');
}
}
}
}

View File

@ -109,6 +109,7 @@
body:has(.search-by button[data-filter='thematique'][aria-selected='true']) {
.post-grid__toolbar-actions {
select[name='auteurs'],
select[name='types'],
.search-bar {
@apply hidden;
}
@ -118,6 +119,7 @@ body:has(.search-by button[data-filter='thematique'][aria-selected='true']) {
body:has(.search-by button[data-filter='auteur'][aria-selected='true']) {
.post-grid__toolbar-actions {
select[name='etiquettes'],
select[name='types'],
.search-bar {
@apply hidden;
}
@ -127,6 +129,7 @@ body:has(.search-by button[data-filter='auteur'][aria-selected='true']) {
body:has(.search-by button[data-filter='occurence'][aria-selected='true']) {
.post-grid__toolbar-actions {
select[name='etiquettes'],
select[name='types'],
select[name='auteurs'] {
@apply hidden;
}

View File

@ -0,0 +1,14 @@
<svg width="35" height="35" viewBox="0 0 35 35" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="35" height="35" fill="#136F63"/>
<g clip-path="url(#clip0_3635_16495)">
<path d="M7.58008 12.272H11.0646L19.0193 7.97668V27.0408L11.3081 23.0515H7.58008V12.272Z" stroke="white" stroke-width="2"/>
<path d="M10.873 12.2721V23.0516" stroke="white" stroke-width="2"/>
<path d="M27.4199 10.1302V25.1874" stroke="white" stroke-width="2"/>
<path d="M23.2402 14.8257V20.492" stroke="white" stroke-width="2"/>
</g>
<defs>
<clipPath id="clip0_3635_16495">
<rect width="21" height="21" fill="white" transform="translate(7 7)"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 653 B

View File

@ -0,0 +1,16 @@
<svg width="35" height="35" viewBox="0 0 35 35" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="35" height="35" fill="#136F63"/>
<g clip-path="url(#clip0_3635_16500)">
<path d="M12.2363 11.4052H24.1386H27.3785V30.3677H12.2363V11.4052Z" stroke="white" stroke-width="2"/>
<path d="M12.2362 25.8595H7.62207V5.63232H23.7778V11.4052" stroke="white" stroke-width="2"/>
<path d="M24.8103 19.1255H14.9229" stroke="white" stroke-width="2"/>
<path d="M24.8103 26.4601H14.9229" stroke="white" stroke-width="2"/>
<path d="M22.0555 15.4581H14.9229" stroke="white" stroke-width="2"/>
<path d="M22.0555 22.7927H14.9229" stroke="white" stroke-width="2"/>
</g>
<defs>
<clipPath id="clip0_3635_16500">
<rect width="21" height="26" fill="white" transform="translate(7 5)"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 795 B

View File

@ -0,0 +1,13 @@
<svg width="35" height="35" viewBox="0 0 35 35" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="35" height="35" fill="#136F63"/>
<g clip-path="url(#clip0_3635_16485)">
<path d="M28.2386 6.79419H6.76074V29.2058H28.2386V6.79419Z" stroke="white" stroke-width="2"/>
<path d="M19.5779 15.7683C20.9061 15.7683 21.9829 14.6448 21.9829 13.2587C21.9829 11.8727 20.9061 10.7491 19.5779 10.7491C18.2496 10.7491 17.1729 11.8727 17.1729 13.2587C17.1729 14.6448 18.2496 15.7683 19.5779 15.7683Z" stroke="white" stroke-width="2"/>
<path d="M6.76074 29.2058L14.6913 20.9305L18.3292 24.7267L28.2386 14.3785" stroke="white" stroke-width="2"/>
</g>
<defs>
<clipPath id="clip0_3635_16485">
<rect width="23" height="24" fill="white" transform="translate(6 6)"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 781 B

View File

@ -0,0 +1,12 @@
<svg width="35" height="35" viewBox="0 0 35 35" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="35" height="35" fill="#136F63"/>
<g clip-path="url(#clip0_3635_16490)">
<path d="M28.2386 5.79419H6.76074V28.2058H28.2386V5.79419Z" stroke="white" stroke-width="2"/>
<path d="M14.8519 12.9894L21.5646 17L14.7529 21.0106L14.8519 12.9894Z" stroke="white" stroke-width="2"/>
</g>
<defs>
<clipPath id="clip0_3635_16490">
<rect width="23" height="24" fill="white" transform="translate(6 5)"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 523 B

View File

@ -5,6 +5,7 @@ import handleInsidePageScrolling from './page-scrolling';
import alternatePictures from './alternate-pictures';
import { searchBarInit } from './search-bar';
import singlesInit from './singles/singles';
import archivesInit from './archives/archives';
window.addEventListener('load', function () {
menuInit();
@ -14,4 +15,5 @@ window.addEventListener('load', function () {
alternatePictures();
searchBarInit();
singlesInit();
archivesInit();
});

View File

@ -0,0 +1,140 @@
//post-grid__toolbar-actions
export default function archivesInit() {
const isArchivePage = document.querySelector('body.archive');
if (!isArchivePage) return;
const toolbar = document.querySelector('.post-grid__toolbar');
if (!toolbar) return;
const postGridToolbarActions = toolbar.querySelector('.post-grid__toolbar-actions');
const currentPostType = postGridToolbarActions?.getAttribute('data-post-type') as string;
const etiquettesSelect = toolbar.querySelector('select[name="etiquettes"]') as HTMLSelectElement;
const auteursSelect = toolbar.querySelector('select[name="auteurs"]') as HTMLSelectElement;
const sortBySelect = toolbar.querySelector('select[name="sort_by"]') as HTMLSelectElement;
const rechercheInput = toolbar.querySelector('.search-bar input') as HTMLInputElement;
console.log('currentPostType', currentPostType);
console.log('etiquettesSelect', etiquettesSelect);
console.log('auteursSelect', auteursSelect);
console.log('sortBySelect', sortBySelect);
console.log('rechercheInput', rechercheInput);
// Évite les courses: annule les requêtes précédentes et ignore les réponses obsolètes
let currentAbortController: AbortController | null = null;
let lastRequestId = 0;
// Debounce simple pour la recherche
function debounce<T extends (...args: any[]) => void>(fn: T, waitMs: number) {
let timeoutId: number | undefined;
return (...args: Parameters<T>) => {
if (timeoutId) window.clearTimeout(timeoutId);
timeoutId = window.setTimeout(() => fn(...args), waitMs);
};
}
async function hydratePosts() {
const etiquetteValue = etiquettesSelect?.value ?? '';
const auteurValue = auteursSelect?.value ?? '';
const sortByValue = sortBySelect?.value ?? '';
const rechercheValue = rechercheInput?.value ?? '';
const postTypeValue = currentPostType ?? '';
const params = new URLSearchParams({
etiquette: etiquetteValue,
auteur: auteurValue,
sort_by: sortByValue,
recherche: rechercheValue,
post_type: postTypeValue,
});
console.log(params.toString());
const url = `/wp-json/carhop-datas/v1/build/posts?${params.toString()}`;
// Annule la précédente et prépare un nouvel identifiant
if (currentAbortController) currentAbortController.abort();
currentAbortController = new AbortController();
const requestId = ++lastRequestId;
try {
const response = await fetch(url, { signal: currentAbortController.signal });
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const data = await response.json();
console.log('data', data);
// Ignore si une requête plus récente a été envoyée
if (requestId !== lastRequestId) return;
const articlesContainer = document.querySelector('.post-grid__list');
if (!articlesContainer) return;
articlesContainer.innerHTML = data.html_template;
updatePostCount(data.post_count);
} catch (error) {
if ((error as any)?.name === 'AbortError') return;
console.error('Erreur lors de la récupération des articles:', error);
}
}
const hydratePostsDebounced = debounce(hydratePosts, 150);
function resetCurrentFilters() {
if (!etiquettesSelect || !auteursSelect || !rechercheInput) return;
etiquettesSelect.value = '';
auteursSelect.value = '';
rechercheInput.value = '';
}
function setFilterByActivebutton(button: HTMLButtonElement) {
const filterByButtons = document.querySelectorAll('.search-by button');
if (!filterByButtons) return;
filterByButtons.forEach((button) => {
button.setAttribute('aria-selected', 'false');
});
button.setAttribute('aria-selected', 'true');
}
function handleFilterPostsBy() {
const filterByButtons = document.querySelectorAll('.search-by button');
if (!filterByButtons) return;
filterByButtons.forEach((button) => {
button.addEventListener('click', (e) => {
e.preventDefault();
setFilterByActivebutton(button as HTMLButtonElement);
resetCurrentFilters();
hydratePosts(); // immédiat sur action explicite
});
});
}
auteursSelect.addEventListener('change', (e) => {
hydratePosts();
});
etiquettesSelect.addEventListener('change', (e) => {
hydratePosts();
});
sortBySelect.addEventListener('change', (e) => {
hydratePosts(); // immédiat pour le tri
});
rechercheInput.addEventListener('input', (e) => {
hydratePostsDebounced(); // debounce pour la saisie rapide
});
handleFilterPostsBy();
postGridToolbarActions.addEventListener('click', (e) => {
e.preventDefault();
});
}

View File

@ -13,7 +13,7 @@ $postType = get_post_type();
<?php while (have_posts()) : the_post(); ?>
<?php get_template_part('template-parts/components/posts/post-header'); ?>
<?php get_template_part('template-parts/components/posts/post-toolbar'); ?>
<?php get_template_part('template-parts/components/posts/single-post-toolbar'); ?>
<div class="content-wrapper" data-active-tab="post">
<aside class="sidebar">
@ -21,8 +21,6 @@ $postType = get_post_type();
</aside>
<div class="content-area">
<?php get_template_part('template-parts/components/posts/post-content', null, array(
'ID' => get_the_ID()
)); ?>

View File

@ -0,0 +1,74 @@
<?php
$current_post_type = $args['current_post_type'] ?? get_post_type();
$posts_query = $args['posts_query'] ?? null;
$post_count = $posts_query->post_count;
$current_post_type_obj = get_post_type_object($current_post_type);
$post_ids = wp_list_pluck($posts_query->posts, 'ID');
$types = get_terms(array(
'taxonomy' => 'type',
'hide_empty' => true,
));
$authors = get_authors_linked_to_posts($post_ids);
$tags = get_terms(array(
'taxonomy' => 'etiquettes',
'hide_empty' => true,
'object_ids' => $post_ids,
));
?>
<div class="post-grid__toolbar">
<div class="search-by">
<p class="search-by__label">Filtrer par</p>
<div class="search-by__buttons">
<button data-filter="thematique" aria-selected="true">Thématique</button>
<button data-filter="auteur" aria-selected="false">Auteur</button>
<button data-filter="occurence" aria-selected="false">Mot clé</button>
</div>
</div>
<div class="post-grid__toolbar-actions" data-post-type="<?php echo $current_post_type; ?>">
<div class="search-bar">
<input type="text" placeholder="<?php _e('Rechercher par mot-clé', 'dynamiques'); ?>">
</div>
<select name="etiquettes">
<option value=""><?php _e('Tous les tags', 'dynamiques'); ?></option>
<?php foreach ($tags as $tag) : ?>
<option value="<?php echo $tag->slug; ?>"><?php echo $tag->name; ?></option>
<?php endforeach; ?>
</select>
<select name="auteurs">
<option value=""><?php _e('Tous·tes les auteur·e·s', 'dynamiques'); ?></option>
<?php foreach ($authors as $author) : ?>
<option value="<?php echo $author->ID; ?>"><?php echo $author->post_title; ?></option>
<?php endforeach; ?>
</select>
</div>
<h2 class="post-count">
<span class="post-count__count">
<?php echo $post_count; ?>
</span>
<?php if ($post_amount > 1) : ?>
<span class="post-count__text">
<?php echo $current_post_type_obj->labels->name; ?>
</span>
<?php else : ?>
<span class="post-count__text">
<?php echo $current_post_type_obj->labels->singular_name; ?>
</span>
<?php endif; ?>
</h2>
<select name="sort_by">
<option value="date_desc" selected><?php _e('Numéros récents en premier', 'dynamiques'); ?></option>
<option value="date_asc"><?php _e('Numéros anciens en premier', 'dynamiques'); ?></option>
<option value="title_asc"><?php _e('Par ordre alphabétique', 'dynamiques'); ?></option>
</select>
</div>

View File

@ -1,83 +1,23 @@
<?php
$post_amount = $args['post_amount'] ?? -1;
$grid_title = $args['grid_title'] ?? 'Trouver une publication';
$current_post_type = $args['current_post_type'] ?? get_post_type();
$current_post_type_obj = get_post_type_object($current_post_type);
$posts_query = new WP_Query(array(
'post_type' => $current_post_type,
'posts_per_page' => $post_amount
));
$post_count = $posts_query->post_count;
$types = get_terms(array(
'taxonomy' => 'type',
'hide_empty' => true,
));
// write_log($current_post_type_obj);
?>
<section class="post-grid content-section">
<h2 class="find-publication__title title-small"><?php echo $grid_title; ?></h2>
<div class="content-section__inner">
<div class="post-grid__toolbar">
<div class="search-by">
<p class="search-by__label">Filtrer par</p>
<div class="search-by__buttons" data-filter="thematique">
<button data-filter="thematique" aria-selected="true">Thématique</button>
<button data-filter="occurence" aria-selected="false">Mot clé</button>
</div>
</div>
<div class="post-grid__toolbar-actions" data-post-type="revues">
<div class="search-bar">
<input type="text" placeholder="<?php _e('Rechercher par mot-clé', 'dynamiques'); ?>">
</div>
<select name="types">
<option value=""><?php _e('Tous les types', 'carhop'); ?></option>
<?php foreach ($types as $type) : ?>
<option value="<?php echo $type->slug; ?>" <?php selected($type_slug, $type->slug); ?>>
<?php echo $type->name; ?>
</option>
<?php endforeach; ?>
</select>
<select name="auteurs">
<option value=""><?php _e('Tous·tes les auteur·e·s', 'dynamiques'); ?></option>
<?php foreach ($authors as $author) : ?>
<option value="<?php echo $author->ID; ?>"><?php echo $author->post_title; ?></option>
<?php endforeach; ?>
</select>
</div>
<h2 class="post-count">
<span class="post-count__count">
<?php echo $post_count; ?>
</span>
<?php if ($post_amount > 1) : ?>
<span class="post-count__text">
<?php echo $current_post_type_obj->labels->name; ?>
</span>
<?php else : ?>
<span class="post-count__text">
<?php echo $current_post_type_obj->labels->singular_name; ?>
</span>
<?php endif; ?>
</h2>
<select name="sort_by">
<option value="date_desc" selected><?php _e('Numéros récents en premier', 'dynamiques'); ?></option>
<option value="date_asc"><?php _e('Numéros anciens en premier', 'dynamiques'); ?></option>
<option value="title_asc"><?php _e('Par ordre alphabétique', 'dynamiques'); ?></option>
</select>
</div>
<?php get_template_part('template-parts/components/archive/post-grid-toolbar', null, array(
'posts_query' => $posts_query,
'current_post_type' => $current_post_type,
)); ?>
<ul class="post-grid__list">
<?php if (isset($posts_query) && $posts_query->have_posts()) : ?>
@ -87,5 +27,6 @@ $types = get_terms(array(
)); ?>
<?php endwhile; ?>
<?php endif; ?>
</ul>
</div>
</section>

View File

@ -0,0 +1,97 @@
<?php
$ID = $args['ID'] ?? null;
$current_post_type = 'archives-presse';
$title = get_the_title($ID);
$showExcerpt = $args['show_excerpt'] ?? false;
$excerpt = get_the_excerpt($ID);
$link = get_field('source_url', $ID) ?? "#";
$has_post_thumbnail = has_post_thumbnail($ID);
$thumbnail_url = get_the_post_thumbnail_url($ID) ?? null;
$year = get_field('year', $ID);
$authors = get_field('authors', $ID);
$editors = get_field('editors', $ID);
$numerotation = get_post_meta($ID, 'post_numerotation', true);
$tags = get_the_terms($ID, 'etiquettes');
$media_types = get_field('media_type', $ID);
$media_types_list = array(
'audio' => 'Audio',
'video' => 'Vidéo',
'photo' => 'Photo',
'image' => 'Image',
'article' => 'Article',
);
?>
<a class="post-card post-card--archives-presse <?php $has_post_thumbnail ? 'post-card--has-thumbnail' : ''; ?> card" href="<?php echo $link; ?> " target="_blank">
<?php if ($has_post_thumbnail) : ?>
<div class="post-card__thumbnail">
<img src="<?php echo $thumbnail_url; ?>" alt="<?php echo $title; ?>">
</div>
<?php endif; ?>
<div class="card__inner">
<?php get_template_part('template-parts/components/content-meta', null, array(
'current_post_type' => $current_post_type,
'current_post_id' => $ID
)); ?>
<div class="card__content">
<h3 class="card__title"><?php echo $title; ?></h3>
<?php if ($showExcerpt) : ?>
<div class="card__excerpt"><?php echo $excerpt; ?></div>
<?php endif; ?>
</div>
<div class="card__details">
<div class="post-card__details-text">
<time datetime="<?php echo $year; ?>" class="card__details-date date"><?php echo $year; ?></time>
<?php if ($authors) : ?>
<ul class="post-card__authors">
<?php foreach ($authors as $author) : ?>
<li class="author"><?php echo $author->post_title; ?></li>
<?php endforeach; ?>
<?php foreach ($editors as $editor) : ?>
<li class="editor"><?php echo $editor->post_title; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
<?php if ($current_post_type === 'outils-pedagogiques' && has_post_thumbnail($ID)) : ?>
<div class="card__thumbnail">
<?php the_post_thumbnail('medium'); ?>
</div>
<?php endif; ?>
<?php if ($tags) : ?>
<ul class="tag-list">
<?php foreach ($tags as $tag) : ?>
<li class="tag-list__tag"><?php echo $tag->name; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<?php if ($media_types) : ?>
<ul class="media-type-list">
<?php foreach ($media_types as $media_type) : ?>
<?php
$amount = $media_type['amount'];
$media_type = $media_type['acf_fc_layout'];
write_log($media_type);
if (!$amount || !$media_type) continue;
?>
<li class="media-type media-type--<?php echo esc_attr($media_type); ?>"><?php echo $amount . ' ' . ($media_types_list[$media_type] ?? $media_type) . ($amount > 1 ? 's' : ''); ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
</div>
</a>

View File

@ -18,7 +18,6 @@ $editors = get_field('editors', $ID);
$numerotation = get_post_meta($ID, 'post_numerotation', true);
$tags = get_the_terms($ID, 'etiquettes');
?>
<a class="post-card post-card--<?php echo $current_post_type . ' ' . ($has_post_thumbnail ? 'post-card--has-thumbnail' : ''); ?> card" href="<?php echo $link; ?> ">

View File

@ -47,4 +47,6 @@ $pdf_url = isset($pdf_version) && !empty($pdf_version['url']) ? $pdf_version['ur
</div>
</div>
</div>
</div>

View File

@ -16,7 +16,6 @@ $types = get_terms(array(
?>
<section class="post-grid content-section">
<h2 class="find-publication__title title-small">Trouver une publication</h2>
<div class="content-section__inner">

View File

@ -0,0 +1,77 @@
<?php
$archives_presse = get_posts(array(
'post_type' => 'archives-presse',
'posts_per_page' => -1,
'meta_key' => 'year',
'orderby' => 'meta_value_num',
'order' => 'ASC',
));
$archives_presse_by_decade = [];
$used_media_types_by_decade = [];
foreach ($archives_presse as $archive) {
$year = (int) get_field('year', $archive->ID);
$media_types = get_field('media_type', $archive->ID);
if (!$year) continue;
$decade = floor($year / 10) * 10;
$archives_presse_by_decade[$decade][] = $archive;
if (isset($media_types) && is_array($media_types)) {
foreach ($media_types as $media_type) {
if (!isset($used_media_types_by_decade[$decade])) {
$used_media_types_by_decade[$decade] = [];
}
if (!in_array($media_type['acf_fc_layout'], $used_media_types_by_decade[$decade])) {
$used_media_types_by_decade[$decade][] = $media_type['acf_fc_layout'];
}
}
}
}
$media_types_list = array(
'audio' => 'Audios',
'video' => 'Vidéos',
'photo' => 'Photo',
'image' => 'Images',
'article' => 'Articles',
);
?>
<div class="presse-reviews">
<h2 class="presse-reviews__title">Ce que dit la presse de nous</h2>
<div class="presse-reviews__inner">
<aside>
<ul class="presse-reviews__years-list">
<?php foreach ($archives_presse_by_decade as $decade => $archives) : ?>
<li class="presse-reviews__year">
<a href="#archives-presse-year-<?php echo $decade; ?>"><?php echo $decade; ?></a>
</li>
<?php endforeach; ?>
</ul>
</aside>
<div class="presse-reviews__archives-list">
<?php foreach ($archives_presse_by_decade as $decade => $archives) : ?>
<div class="presse-reviews__archives-decade">
<div id="archives-presse-year-<?php echo $decade; ?>" class="archives-year-title-wrapper">
<h3><?php echo $decade; ?></h3>
</div>
<ul class="archives-decade-used-types">
<?php foreach ($used_media_types_by_decade[$decade] as $media_type) : ?>
<li class="archives-decade-used-type archives-decade-used-type--<?php echo $media_type; ?>">
<?php echo $media_types_list[$media_type] ?? $media_type; ?>
</li>
<?php endforeach; ?>
</ul>
<?php foreach ($archives as $archive) : ?>
<?php get_template_part('template-parts/components/cards/archive-presse-card', '', array('ID' => $archive->ID)); ?>
<?php endforeach; ?>
</div>
<?php endforeach; ?>
</div>
</div>
</div>