Compare commits
5 Commits
715b542826
...
7f57f70593
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f57f70593 | ||
|
|
6f4a9ad9f8 | ||
|
|
10e5b13d3d | ||
|
|
7c630c82c0 | ||
|
|
ec2ca4fe66 |
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
require_once(__DIR__ . '/includes/errorlog.php');
|
||||
require_once(__DIR__ . '/includes/init.php');
|
||||
require_once(__DIR__ . '/includes/admin.php');
|
||||
require_once(__DIR__ . '/includes/post_types.php');
|
||||
require_once(__DIR__ . '/includes/logos.php');
|
||||
require_once(__DIR__ . '/includes/article-columns.php');
|
||||
|
|
@ -12,20 +13,3 @@ require_once(__DIR__ . '/includes/article.php');
|
|||
require_once(__DIR__ . '/includes/api.php');
|
||||
require_once(__DIR__ . '/includes/renderPostsDatas.php');
|
||||
require_once(__DIR__ . '/includes/utilities.php');
|
||||
|
||||
// Support SVG - Solution de secours
|
||||
add_filter('upload_mimes', function ($mimes) {
|
||||
$mimes['svg'] = 'image/svg+xml';
|
||||
$mimes['svgz'] = 'image/svg+xml';
|
||||
return $mimes;
|
||||
}, 999);
|
||||
|
||||
// Forcer la reconnaissance des fichiers SVG
|
||||
add_filter('wp_check_filetype_and_ext', function ($data, $file, $filename, $mimes) {
|
||||
if (strtolower(pathinfo($filename, PATHINFO_EXTENSION)) === 'svg') {
|
||||
$data['ext'] = 'svg';
|
||||
$data['type'] = 'image/svg+xml';
|
||||
$data['proper_filename'] = $filename;
|
||||
}
|
||||
return $data;
|
||||
}, 10, 4);
|
||||
|
|
|
|||
|
|
@ -70,8 +70,7 @@ function customize_submenu_classnames($classes, $args, $depth)
|
|||
// $classes[] = 'sub-menu';
|
||||
// $classes[] = 'test';
|
||||
// }
|
||||
// write_log($classes);
|
||||
// write_log($classes);
|
||||
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,219 +1,191 @@
|
|||
<?php
|
||||
|
||||
function getRevueAuthors($revueID)
|
||||
{
|
||||
$revueRelatedArticles = new WP_Query(array(
|
||||
'post_type' => 'articles',
|
||||
'posts_per_page' => -1,
|
||||
'post_status' => 'publish',
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'key' => 'related_revue',
|
||||
'value' => $revueID,
|
||||
'compare' => '=',
|
||||
),
|
||||
),
|
||||
));
|
||||
$authors = array();
|
||||
|
||||
foreach ($revueRelatedArticles->posts as $article) {
|
||||
$currentArticleAuthors = get_field('authors', $article->ID);
|
||||
|
||||
if (empty($currentArticleAuthors) || !is_array($currentArticleAuthors)) continue;
|
||||
|
||||
foreach ($currentArticleAuthors as $authorID) {
|
||||
$authors[] = $authorID;
|
||||
}
|
||||
}
|
||||
return array_unique($authors);
|
||||
}
|
||||
|
||||
function get_revue_terms($revueID, $taxonomy)
|
||||
{
|
||||
$revueRelatedArticles = new WP_Query(array(
|
||||
'post_type' => 'articles',
|
||||
'posts_per_page' => -1,
|
||||
'post_status' => 'publish',
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'key' => 'related_revue',
|
||||
'value' => $revueID,
|
||||
'compare' => '=',
|
||||
),
|
||||
),
|
||||
));
|
||||
$terms = array();
|
||||
|
||||
foreach ($revueRelatedArticles->posts as $article) {
|
||||
$currentArticleTerms = get_the_terms($article->ID, $taxonomy);
|
||||
|
||||
if (empty($currentArticleTerms) || !is_array($currentArticleTerms)) continue;
|
||||
|
||||
foreach ($currentArticleTerms as $term) {
|
||||
$terms[] = $term->term_id;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (array_unique($terms) as $term) {
|
||||
$termObject = get_term($term, $taxonomy);
|
||||
$uniquesTermsArray[] = $termObject;
|
||||
}
|
||||
|
||||
return $uniquesTermsArray;
|
||||
}
|
||||
|
||||
|
||||
function count_user_articles($userID, $postType)
|
||||
{
|
||||
$args = array(
|
||||
'post_type' => $postType,
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'key' => 'authors',
|
||||
'value' => '"' . $userID . '"',
|
||||
'compare' => 'LIKE',
|
||||
),
|
||||
),
|
||||
);
|
||||
$query = new WP_Query($args);
|
||||
return $query->found_posts;
|
||||
}
|
||||
|
||||
|
||||
function build_sommaire_from_content($postID)
|
||||
{
|
||||
$blocks = parse_blocks(get_the_content($postID));
|
||||
$titleBlocks = array_filter(
|
||||
$blocks,
|
||||
function ($block) {
|
||||
// Vérifier si c'est un bloc heading
|
||||
if ($block['blockName'] !== 'core/heading') {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Extraire le niveau depuis le HTML si les attributs sont vides
|
||||
if (empty($block['attrs']['level'])) {
|
||||
// Chercher seulement h2 dans le HTML
|
||||
if (preg_match('/<h2[^>]*>/i', $block['innerHTML'], $matches)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Utiliser le niveau des attributs s'il existe
|
||||
return $block['attrs']['level'] === 2;
|
||||
}
|
||||
);
|
||||
|
||||
$outputIndex = [];
|
||||
|
||||
foreach ($titleBlocks as $block) {
|
||||
$title = strip_tags($block['innerHTML']);
|
||||
|
||||
// Extraire le niveau depuis le HTML ou les attributs
|
||||
$level = $block['attrs']['level'] ?? null;
|
||||
if (!$level && preg_match('/<h2[^>]*>/i', $block['innerHTML'], $matches)) {
|
||||
$level = 2;
|
||||
}
|
||||
|
||||
if ($level !== 2) continue;
|
||||
|
||||
$anchor = $block['attrs']['idName'] ?? sanitize_title($title);
|
||||
|
||||
// Ajouter un préfixe si l'ancre commence par un chiffre
|
||||
if (!empty($anchor) && preg_match('/^[0-9]/', $anchor)) {
|
||||
$anchor = 'anchor-' . $anchor;
|
||||
}
|
||||
|
||||
|
||||
$outputIndex[] = [
|
||||
'title' => $title,
|
||||
'anchor' => $anchor,
|
||||
'level' => $level,
|
||||
];
|
||||
}
|
||||
|
||||
return $outputIndex;
|
||||
}
|
||||
|
||||
|
||||
function build_footnotes_index_from_content($content)
|
||||
{
|
||||
if (empty($content)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$footnotes = [];
|
||||
$dom = new DOMDocument();
|
||||
// On supprime les erreurs de parsing pour le HTML5
|
||||
@$dom->loadHTML(mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8'), LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
|
||||
|
||||
$links = $dom->getElementsByTagName('a');
|
||||
foreach ($links as $key => $link) {
|
||||
if ($link->hasAttribute('class') && strpos($link->getAttribute('class'), 'footnote-reference') !== false) {
|
||||
$footnote_content = $link->getAttribute('footnote-content');
|
||||
if (!empty($footnote_content)) {
|
||||
$footnotes[] = array(
|
||||
'key' => $key + 1,
|
||||
'anchorID' => $key + 1,
|
||||
'content' => $footnote_content
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $footnotes;
|
||||
}
|
||||
|
||||
add_filter('the_content', 'apply_footnotes_urls_to_content', 10);
|
||||
|
||||
function apply_footnotes_urls_to_content($content)
|
||||
{
|
||||
$post_type = get_post_type();
|
||||
|
||||
if ($post_type !== 'articles' && !is_admin()) return $content;
|
||||
|
||||
|
||||
$footnotes = build_footnotes_index_from_content($content);
|
||||
$dom = new DOMDocument();
|
||||
@$dom->loadHTML(mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8'), LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
|
||||
|
||||
$links = $dom->getElementsByTagName('a');
|
||||
|
||||
foreach ($links as $key => $link) {
|
||||
|
||||
if ($link->hasAttribute('class') && strpos($link->getAttribute('class'), 'footnote-reference') !== false) {
|
||||
$link->setAttribute('id', 'footnote-' . ($key + 1));
|
||||
}
|
||||
}
|
||||
|
||||
return $dom->saveHTML();
|
||||
}
|
||||
|
||||
// Endpoint AJAX pour sanitize_title
|
||||
add_action('wp_ajax_sanitize_title_ajax', 'sanitize_title_ajax_handler');
|
||||
add_action('wp_ajax_nopriv_sanitize_title_ajax', 'sanitize_title_ajax_handler');
|
||||
|
||||
function sanitize_title_ajax_handler()
|
||||
{
|
||||
// Vérifier le nonce pour la sécurité
|
||||
if (!wp_verify_nonce($_POST['nonce'], 'sanitize_title_nonce')) {
|
||||
wp_die('Erreur de sécurité');
|
||||
}
|
||||
|
||||
$title = sanitize_text_field($_POST['title']);
|
||||
$sanitized_title = sanitize_title($title);
|
||||
|
||||
wp_send_json_success(array('sanitized_title' => $sanitized_title));
|
||||
}
|
||||
|
||||
// Ajouter le script et les variables localisées
|
||||
add_action('wp_enqueue_scripts', 'add_sanitize_title_script');
|
||||
|
||||
function add_sanitize_title_script()
|
||||
{
|
||||
wp_localize_script('jquery', 'sanitize_title_ajax', array(
|
||||
'ajax_url' => admin_url('admin-ajax.php'),
|
||||
'nonce' => wp_create_nonce('sanitize_title_nonce')
|
||||
));
|
||||
}
|
||||
<?php
|
||||
|
||||
function getRevueAuthors($revueID)
|
||||
{
|
||||
$revueRelatedArticles = new WP_Query(array(
|
||||
'post_type' => 'articles',
|
||||
'posts_per_page' => -1,
|
||||
'post_status' => 'publish',
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'key' => 'related_revue',
|
||||
'value' => $revueID,
|
||||
'compare' => '=',
|
||||
),
|
||||
),
|
||||
));
|
||||
$authors = array();
|
||||
|
||||
foreach ($revueRelatedArticles->posts as $article) {
|
||||
$currentArticleAuthors = get_field('authors', $article->ID);
|
||||
|
||||
if (empty($currentArticleAuthors) || !is_array($currentArticleAuthors)) continue;
|
||||
|
||||
foreach ($currentArticleAuthors as $authorID) {
|
||||
$authors[] = $authorID;
|
||||
}
|
||||
}
|
||||
return array_unique($authors);
|
||||
}
|
||||
|
||||
function get_revue_terms($revueID, $taxonomy)
|
||||
{
|
||||
$revueRelatedArticles = new WP_Query(array(
|
||||
'post_type' => 'articles',
|
||||
'posts_per_page' => -1,
|
||||
'post_status' => 'publish',
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'key' => 'related_revue',
|
||||
'value' => $revueID,
|
||||
'compare' => '=',
|
||||
),
|
||||
),
|
||||
));
|
||||
$terms = array();
|
||||
|
||||
foreach ($revueRelatedArticles->posts as $article) {
|
||||
$currentArticleTerms = get_the_terms($article->ID, $taxonomy);
|
||||
|
||||
if (empty($currentArticleTerms) || !is_array($currentArticleTerms)) continue;
|
||||
|
||||
foreach ($currentArticleTerms as $term) {
|
||||
$terms[] = $term->term_id;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (array_unique($terms) as $term) {
|
||||
$termObject = get_term($term, $taxonomy);
|
||||
$uniquesTermsArray[] = $termObject;
|
||||
}
|
||||
|
||||
return $uniquesTermsArray;
|
||||
}
|
||||
|
||||
|
||||
function count_user_articles($userID, $postType)
|
||||
{
|
||||
$args = array(
|
||||
'post_type' => $postType,
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'key' => 'authors',
|
||||
'value' => '"' . $userID . '"',
|
||||
'compare' => 'LIKE',
|
||||
),
|
||||
),
|
||||
);
|
||||
$query = new WP_Query($args);
|
||||
return $query->found_posts;
|
||||
}
|
||||
|
||||
|
||||
function build_sommaire_from_content($postID)
|
||||
{
|
||||
$blocks = parse_blocks(get_the_content($postID));
|
||||
$titleBlocks = array_filter(
|
||||
$blocks,
|
||||
function ($block) {
|
||||
// Vérifier si c'est un bloc heading
|
||||
if ($block['blockName'] !== 'core/heading') {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Extraire le niveau depuis le HTML si les attributs sont vides
|
||||
if (empty($block['attrs']['level'])) {
|
||||
// Chercher seulement h2 dans le HTML
|
||||
if (preg_match('/<h2[^>]*>/i', $block['innerHTML'], $matches)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Utiliser le niveau des attributs s'il existe
|
||||
return $block['attrs']['level'] === 2;
|
||||
}
|
||||
);
|
||||
|
||||
$outputIndex = [];
|
||||
|
||||
foreach ($titleBlocks as $block) {
|
||||
$title = strip_tags($block['innerHTML']);
|
||||
|
||||
// Extraire le niveau depuis le HTML ou les attributs
|
||||
$level = $block['attrs']['level'] ?? null;
|
||||
if (!$level && preg_match('/<h2[^>]*>/i', $block['innerHTML'], $matches)) {
|
||||
$level = 2;
|
||||
}
|
||||
|
||||
if ($level !== 2) continue;
|
||||
|
||||
$anchor = $block['attrs']['idName'] ?? sanitize_title($title);
|
||||
|
||||
// Ajouter un préfixe si l'ancre commence par un chiffre
|
||||
if (!empty($anchor) && preg_match('/^[0-9]/', $anchor)) {
|
||||
$anchor = 'anchor-' . $anchor;
|
||||
}
|
||||
|
||||
|
||||
$outputIndex[] = [
|
||||
'title' => $title,
|
||||
'anchor' => $anchor,
|
||||
'level' => $level,
|
||||
];
|
||||
}
|
||||
|
||||
return $outputIndex;
|
||||
}
|
||||
|
||||
|
||||
function build_footnotes_index_from_content($content)
|
||||
{
|
||||
if (empty($content)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$footnotes = [];
|
||||
$dom = new DOMDocument();
|
||||
// On supprime les erreurs de parsing pour le HTML5
|
||||
@$dom->loadHTML(mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8'), LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
|
||||
|
||||
$links = $dom->getElementsByTagName('a');
|
||||
foreach ($links as $key => $link) {
|
||||
if ($link->hasAttribute('class') && strpos($link->getAttribute('class'), 'footnote-reference') !== false) {
|
||||
$footnote_content = $link->getAttribute('footnote-content');
|
||||
if (!empty($footnote_content)) {
|
||||
$footnotes[] = array(
|
||||
'key' => $key + 1,
|
||||
'anchorID' => $key + 1,
|
||||
'content' => $footnote_content
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $footnotes;
|
||||
}
|
||||
|
||||
add_filter('the_content', 'apply_footnotes_urls_to_content', 10);
|
||||
|
||||
function apply_footnotes_urls_to_content($content)
|
||||
{
|
||||
$post_type = get_post_type();
|
||||
|
||||
if ($post_type !== 'articles' && !is_admin()) return $content;
|
||||
|
||||
|
||||
$footnotes = build_footnotes_index_from_content($content);
|
||||
$dom = new DOMDocument();
|
||||
@$dom->loadHTML(mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8'), LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
|
||||
|
||||
$links = $dom->getElementsByTagName('a');
|
||||
|
||||
foreach ($links as $key => $link) {
|
||||
|
||||
if ($link->hasAttribute('class') && strpos($link->getAttribute('class'), 'footnote-reference') !== false) {
|
||||
$link->setAttribute('id', 'footnote-' . ($key + 1));
|
||||
}
|
||||
}
|
||||
|
||||
return $dom->saveHTML();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
.wp-block-pullquote {
|
||||
@apply text-carhop-purple-500 py-6 fjalla font-bold text-2xl 2xl:text-4xl my-6 border-primary pl-4 border-t border-b;
|
||||
@apply text-carhop-green-700 py-6 fjalla font-bold text-2xl 2xl:text-4xl my-6 border-primary pl-4 border-t border-b;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ module.exports = {
|
|||
950: '#062d2a',
|
||||
},
|
||||
'carhop-orange': {
|
||||
50: '#fff8eb',
|
||||
50: getBaseColor('carhop-orange-light'),
|
||||
100: '#ffebc6',
|
||||
200: '#ffd588',
|
||||
300: '#ffba4a',
|
||||
|
|
@ -66,7 +66,7 @@ module.exports = {
|
|||
950: '#033249',
|
||||
},
|
||||
'carhop-red': {
|
||||
50: '#fcf3f8',
|
||||
50: getBaseColor('carhop-red-light'),
|
||||
100: '#fbe8f2',
|
||||
200: '#f8d2e6',
|
||||
300: '#f4add0',
|
||||
|
|
@ -79,7 +79,7 @@ module.exports = {
|
|||
950: '#4c0b21',
|
||||
},
|
||||
'carhop-purple': {
|
||||
50: '#f8f5ff',
|
||||
50: getBaseColor('carhop-purple-light'),
|
||||
100: '#efe8ff',
|
||||
200: '#e2d4ff',
|
||||
300: getBaseColor('carhop-purple'), // Base Color
|
||||
|
|
|
|||
15
theme.json
15
theme.json
|
|
@ -39,16 +39,31 @@
|
|||
"slug": "carhop-orange",
|
||||
"color": "#ffa630"
|
||||
},
|
||||
{
|
||||
"name": "Carhop Orange Light",
|
||||
"slug": "carhop-orange-light",
|
||||
"color": "#fff8eb"
|
||||
},
|
||||
{
|
||||
"name": "Carhop Red",
|
||||
"slug": "carhop-red",
|
||||
"color": "#ae2154"
|
||||
},
|
||||
{
|
||||
"name": "Carhop Red Light",
|
||||
"slug": "carhop-red-light",
|
||||
"color": "#fcf3f8"
|
||||
},
|
||||
{
|
||||
"name": "Carhop Purple",
|
||||
"slug": "carhop-purple",
|
||||
"color": "#d6c3ff"
|
||||
},
|
||||
{
|
||||
"name": "Carhop Purple Light",
|
||||
"slug": "carhop-purple-light",
|
||||
"color": "#f8f5ff"
|
||||
},
|
||||
{
|
||||
"name": "Carhop Gray",
|
||||
"slug": "carhop-gray",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user