Compare commits
2 Commits
0eb39603a9
...
0ebaf0d0bf
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ebaf0d0bf | ||
|
|
f12528f780 |
|
|
@ -331,17 +331,6 @@ function generate_og_meta_tags()
|
||||||
} elseif (is_single() || is_page()) {
|
} elseif (is_single() || is_page()) {
|
||||||
$og_title = get_the_title();
|
$og_title = get_the_title();
|
||||||
$og_description = get_the_excerpt();
|
$og_description = get_the_excerpt();
|
||||||
|
|
||||||
// Pour les articles, améliorer la description avec les métadonnées
|
|
||||||
if (empty($og_description) && get_post_type() === 'articles') {
|
|
||||||
// Essayer d'utiliser le champ de référence de citation si disponible
|
|
||||||
$cite_reference = get_field('cite_reference');
|
|
||||||
if (!empty($cite_reference)) {
|
|
||||||
$og_description = strip_tags($cite_reference);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fallback vers le contenu si toujours vide
|
|
||||||
if (empty($og_description)) {
|
if (empty($og_description)) {
|
||||||
$og_description = wp_trim_words(strip_tags(get_the_content()), 30);
|
$og_description = wp_trim_words(strip_tags(get_the_content()), 30);
|
||||||
}
|
}
|
||||||
|
|
@ -364,29 +353,8 @@ function generate_og_meta_tags()
|
||||||
$og_description = str_replace(array("\r", "\n", "\t"), ' ', $og_description);
|
$og_description = str_replace(array("\r", "\n", "\t"), ' ', $og_description);
|
||||||
$og_description = wp_trim_words($og_description, 30);
|
$og_description = wp_trim_words($og_description, 30);
|
||||||
|
|
||||||
// Image
|
// Image Open Graph fixe
|
||||||
$og_image = '';
|
$og_image = get_template_directory_uri() . '/resources/img/og/dynamiques-og.png';
|
||||||
if (is_single() || is_page()) {
|
|
||||||
if (has_post_thumbnail()) {
|
|
||||||
$og_image = get_the_post_thumbnail_url(null, 'large');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Image par défaut si aucune image n'est trouvée
|
|
||||||
if (empty($og_image)) {
|
|
||||||
// Essayer d'utiliser le logo personnalisé du site
|
|
||||||
$custom_logo = wp_get_attachment_image_src(get_theme_mod('custom_logo'), 'large');
|
|
||||||
if ($custom_logo) {
|
|
||||||
$og_image = $custom_logo[0];
|
|
||||||
} else {
|
|
||||||
// Utiliser l'icône du site
|
|
||||||
$og_image = get_site_icon_url(512);
|
|
||||||
// Si pas d'icône de site, utiliser une image par défaut du thème
|
|
||||||
if (empty($og_image)) {
|
|
||||||
$og_image = get_template_directory_uri() . '/resources/img/covers/carhop-articles-page-cover.svg';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Type de contenu
|
// Type de contenu
|
||||||
$og_type = is_single() ? 'article' : 'website';
|
$og_type = is_single() ? 'article' : 'website';
|
||||||
|
|
@ -396,30 +364,8 @@ function generate_og_meta_tags()
|
||||||
|
|
||||||
// Auteur (pour les articles)
|
// Auteur (pour les articles)
|
||||||
$og_author = '';
|
$og_author = '';
|
||||||
$article_authors = array();
|
|
||||||
if (is_single()) {
|
if (is_single()) {
|
||||||
$post_type = get_post_type();
|
$og_author = get_the_author_meta('display_name');
|
||||||
if ($post_type === 'articles') {
|
|
||||||
// Pour les articles, utiliser le champ ACF 'authors'
|
|
||||||
$authors = get_field('authors');
|
|
||||||
if ($authors && is_array($authors)) {
|
|
||||||
foreach ($authors as $author) {
|
|
||||||
$first_name = get_field('first_name', $author->ID) ?: '';
|
|
||||||
$last_name = get_field('last_name', $author->ID) ?: '';
|
|
||||||
$author_name = trim($first_name . ' ' . $last_name);
|
|
||||||
if (empty($author_name)) {
|
|
||||||
$author_name = $author->post_title;
|
|
||||||
}
|
|
||||||
$article_authors[] = $author_name;
|
|
||||||
}
|
|
||||||
$og_author = implode(', ', $article_authors);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fallback vers l'auteur WordPress standard
|
|
||||||
if (empty($og_author)) {
|
|
||||||
$og_author = get_the_author_meta('display_name');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Date de publication (pour les articles)
|
// Date de publication (pour les articles)
|
||||||
|
|
@ -457,22 +403,6 @@ function generate_og_meta_tags()
|
||||||
$meta_tags[] = '<meta property="article:modified_time" content="' . esc_attr($modified_time) . '" />';
|
$meta_tags[] = '<meta property="article:modified_time" content="' . esc_attr($modified_time) . '" />';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ajouter les tags/sections pour les articles
|
|
||||||
if (is_single() && get_post_type() === 'articles') {
|
|
||||||
$article_tags = get_the_tags();
|
|
||||||
if ($article_tags) {
|
|
||||||
foreach ($article_tags as $tag) {
|
|
||||||
$meta_tags[] = '<meta property="article:tag" content="' . esc_attr($tag->name) . '" />';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ajouter la section/revue si disponible
|
|
||||||
$related_revue = get_field('related_revue');
|
|
||||||
if ($related_revue) {
|
|
||||||
$meta_tags[] = '<meta property="article:section" content="' . esc_attr($related_revue->post_title) . '" />';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Twitter Cards
|
// Twitter Cards
|
||||||
$meta_tags[] = '<meta name="twitter:card" content="summary_large_image" />';
|
$meta_tags[] = '<meta name="twitter:card" content="summary_large_image" />';
|
||||||
$meta_tags[] = '<meta name="twitter:title" content="' . esc_attr($og_title) . '" />';
|
$meta_tags[] = '<meta name="twitter:title" content="' . esc_attr($og_title) . '" />';
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.post-details {
|
.post-details {
|
||||||
@apply flex flex-wrap justify-between gap-28 mt-12;
|
@apply flex flex-wrap justify-between gap-28 gap-y-8 mt-12;
|
||||||
grid-template-columns: 1fr 1fr;
|
grid-template-columns: 1fr 1fr;
|
||||||
|
|
||||||
&__label {
|
&__label {
|
||||||
|
|
@ -75,8 +75,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.socials-buttons {
|
.socials-buttons {
|
||||||
@apply flex flex-wrap gap-4 h-fit;
|
@apply flex flex-wrap justify-end gap-4 h-fit;
|
||||||
|
min-width: 470px;
|
||||||
&__button {
|
&__button {
|
||||||
@apply bg-white text-carhop-green-700 px-4 lg:px-6 md:px-8 !py-3 lg:!py-4 font-normal rounded-full w-max flex items-center gap-2;
|
@apply bg-white text-carhop-green-700 px-4 lg:px-6 md:px-8 !py-3 lg:!py-4 font-normal rounded-full w-max flex items-center gap-2;
|
||||||
transition: transform 0.3s ease-in-out;
|
transition: transform 0.3s ease-in-out;
|
||||||
|
|
@ -90,6 +90,62 @@
|
||||||
img {
|
img {
|
||||||
@apply w-7 h-7 filter-primary;
|
@apply w-7 h-7 filter-primary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&--like {
|
||||||
|
transition: all 0.3s ease-in-out;
|
||||||
|
|
||||||
|
.button-action-text {
|
||||||
|
max-width: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.likes-count {
|
||||||
|
max-width: 200px;
|
||||||
|
overflow: hidden;
|
||||||
|
/* transition: max-width 0.3s ease-in-out; */
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
&[data-likes-count='0'] {
|
||||||
|
.button-action-text {
|
||||||
|
max-width: 200px;
|
||||||
|
}
|
||||||
|
.likes-count {
|
||||||
|
max-width: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
.button-action-text {
|
||||||
|
max-width: 200px;
|
||||||
|
transition: max-width 0.3s ease-in-out;
|
||||||
|
}
|
||||||
|
.likes-count {
|
||||||
|
max-width: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.is-disabled {
|
||||||
|
@apply opacity-100 cursor-not-allowed hover:opacity-80;
|
||||||
|
|
||||||
|
.likes-count {
|
||||||
|
@apply block;
|
||||||
|
}
|
||||||
|
.button-action-text {
|
||||||
|
@apply max-w-0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.is-disabled:hover {
|
||||||
|
.button-action-text {
|
||||||
|
@apply max-w-[200px];
|
||||||
|
}
|
||||||
|
.likes-count {
|
||||||
|
@apply max-w-0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
BIN
resources/img/og/dynamiques-og.png
Normal file
BIN
resources/img/og/dynamiques-og.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 79 KiB |
Loading…
Reference in New Issue
Block a user