Newsletter : ouvrages en année seule + filets pleins sous les titres
- Catégorie ouvrages (15) : la date n'affiche plus que l'année (format Y), comme l'affichage des cartes côté front. format_raw_date() accepte un paramètre de format, sans changement pour les autres catégories. - Titres de section : remplacement du dégradé (linear-gradient, non supporté par Outlook et certains clients mail) par un filet de couleur unie via le pattern table + bgcolor déjà utilisé pour la barre d'accent. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -200,7 +200,7 @@ body { margin: 0 !important; padding: 0 !important; }
|
|||||||
<tr>
|
<tr>
|
||||||
<td style="padding:0 40px 24px 40px;">
|
<td style="padding:0 40px 24px 40px;">
|
||||||
|
|
||||||
<!-- Section heading with gradient underline -->
|
<!-- Section heading with solid colour rule -->
|
||||||
<table role="presentation" border="0" cellpadding="0" cellspacing="0" width="100%">
|
<table role="presentation" border="0" cellpadding="0" cellspacing="0" width="100%">
|
||||||
<tr>
|
<tr>
|
||||||
<td style="padding-top:28px;padding-bottom:0;">
|
<td style="padding-top:28px;padding-bottom:0;">
|
||||||
@@ -211,7 +211,13 @@ body { margin: 0 !important; padding: 0 !important; }
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="padding-top:6px;padding-bottom:16px;">
|
<td style="padding-top:6px;padding-bottom:16px;">
|
||||||
<div style="height:3px;border-radius:2px;background:linear-gradient(to top, <?php echo esc_attr($block['color']); ?>, transparent);"></div>
|
<!-- Filet plein (pas de dégradé : non supporté par certains clients) -->
|
||||||
|
<table role="presentation" border="0" cellpadding="0" cellspacing="0" width="100%">
|
||||||
|
<tr>
|
||||||
|
<td height="3" bgcolor="<?php echo esc_attr($block['color']); ?>"
|
||||||
|
style="height:3px;line-height:3px;font-size:0;background-color:<?php echo esc_attr($block['color']); ?>;"> </td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -536,11 +542,14 @@ body { margin: 0 !important; padding: 0 !important; }
|
|||||||
private function format_date_for_category(int $post_id, int $cat_id): string {
|
private function format_date_for_category(int $post_id, int $cat_id): string {
|
||||||
$window = Thalim_NL_Post_Query::get_window_type($cat_id);
|
$window = Thalim_NL_Post_Query::get_window_type($cat_id);
|
||||||
|
|
||||||
|
// Ouvrages : année seule, comme l'affichage des cartes côté front.
|
||||||
|
$date_format = ($cat_id === THALIM_NL_CAT_OUVRAGES) ? 'Y' : 'j F Y';
|
||||||
|
|
||||||
if ($window === 'debut_minus35_to_fin') {
|
if ($window === 'debut_minus35_to_fin') {
|
||||||
$raw_debut = get_post_meta($post_id, 'date_de_debut', true) ?: '';
|
$raw_debut = get_post_meta($post_id, 'date_de_debut', true) ?: '';
|
||||||
$raw_fin = get_post_meta($post_id, 'date_de_fin', true) ?: '';
|
$raw_fin = get_post_meta($post_id, 'date_de_fin', true) ?: '';
|
||||||
$debut_str = $this->format_raw_date($raw_debut);
|
$debut_str = $this->format_raw_date($raw_debut, $date_format);
|
||||||
$fin_str = $this->format_raw_date($raw_fin);
|
$fin_str = $this->format_raw_date($raw_fin, $date_format);
|
||||||
if ($debut_str && $fin_str && $debut_str !== $fin_str) {
|
if ($debut_str && $fin_str && $debut_str !== $fin_str) {
|
||||||
return $debut_str . '–' . $fin_str;
|
return $debut_str . '–' . $fin_str;
|
||||||
}
|
}
|
||||||
@@ -549,18 +558,18 @@ body { margin: 0 !important; padding: 0 !important; }
|
|||||||
|
|
||||||
$raw_dt = get_post_meta($post_id, 'datetime', true) ?: '';
|
$raw_dt = get_post_meta($post_id, 'datetime', true) ?: '';
|
||||||
if ($raw_dt && !str_starts_with($raw_dt, '0000-00-00')) {
|
if ($raw_dt && !str_starts_with($raw_dt, '0000-00-00')) {
|
||||||
return $this->format_raw_date($raw_dt);
|
return $this->format_raw_date($raw_dt, $date_format);
|
||||||
}
|
}
|
||||||
$post = get_post($post_id);
|
$post = get_post($post_id);
|
||||||
return $post ? $this->format_raw_date($post->post_date) : '';
|
return $post ? $this->format_raw_date($post->post_date, $date_format) : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
private function format_raw_date(string $raw): string {
|
private function format_raw_date(string $raw, string $format = 'j F Y'): string {
|
||||||
if (!$raw || str_starts_with($raw, '0000-00-00')) {
|
if (!$raw || str_starts_with($raw, '0000-00-00')) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
$ts = strtotime($raw);
|
$ts = strtotime($raw);
|
||||||
return $ts ? date_i18n('j F Y', $ts) : '';
|
return $ts ? date_i18n($format, $ts) : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Rich-text processor (intro / conclusion) ──────────────────────────────
|
// ── Rich-text processor (intro / conclusion) ──────────────────────────────
|
||||||
|
|||||||
Reference in New Issue
Block a user