Compare commits
No commits in common. "b6bbcf33d55ac9519a693425059f7ae4fe747eda" and "fc0fb25f605e67c65f822ded3694aa7ea28ff46f" have entirely different histories.
b6bbcf33d5
...
fc0fb25f60
|
|
@ -11,13 +11,11 @@ function metiers_patrimoine_artisans_post_updater($post_id)
|
||||||
$name = get_field("name", $post_id);
|
$name = get_field("name", $post_id);
|
||||||
$address = get_field("adresse", $post_id);
|
$address = get_field("adresse", $post_id);
|
||||||
|
|
||||||
// ###### Update post title if name is set ######
|
|
||||||
if (get_post_type() == 'artisans' && $name) {
|
if (get_post_type() == 'artisans' && $name) {
|
||||||
$my_post['post_title'] = "";
|
$my_post['post_title'] = "";
|
||||||
$my_post['post_title'] = $name;
|
$my_post['post_title'] = $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ###### Update custom "state" post Meta (used in search) ######
|
|
||||||
if ($address && isset($address['country'])) {
|
if ($address && isset($address['country'])) {
|
||||||
$stateGenericName = getGenericStateNameFromAcfStateName($address['state']) ?? "";
|
$stateGenericName = getGenericStateNameFromAcfStateName($address['state']) ?? "";
|
||||||
update_post_meta($post_id, 'state', $stateGenericName);
|
update_post_meta($post_id, 'state', $stateGenericName);
|
||||||
|
|
@ -27,55 +25,6 @@ function metiers_patrimoine_artisans_post_updater($post_id)
|
||||||
}
|
}
|
||||||
add_action('acf/save_post', 'metiers_patrimoine_artisans_post_updater', 20);
|
add_action('acf/save_post', 'metiers_patrimoine_artisans_post_updater', 20);
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------
|
|
||||||
AUTO CHECK PARENT TAXONOMIES WHEN CHILDREN ARE CHOSEN
|
|
||||||
---------------------------------------------------------*/
|
|
||||||
function metiers_patrimoine_artisans_post_taxonomies_updater($post_id)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (!$post_id || get_post_type() !== 'artisans') return;
|
|
||||||
|
|
||||||
$metiersTerms = get_the_terms($post_id, 'metiers');
|
|
||||||
$elementsBatimentsTerms = get_the_terms($post_id, 'elementsbatiments');
|
|
||||||
|
|
||||||
// ###### METIERS — ADD PARENT TAXONOMIES IF NOT ALREADY ADDED ######
|
|
||||||
if ($metiersTerms) {
|
|
||||||
$existingMetiersTermIds = array_column($metiersTerms, 'term_id');
|
|
||||||
|
|
||||||
// Parcours chaque terme et ajoute son parent si absent
|
|
||||||
foreach ($metiersTerms as $term) {
|
|
||||||
if ($term->parent && !in_array($term->parent, $existingMetiersTermIds)) {
|
|
||||||
$parentTerm = get_term($term->parent, 'metiers');
|
|
||||||
if ($parentTerm && !is_wp_error($parentTerm)) {
|
|
||||||
wp_add_object_terms($post_id, $parentTerm->term_id, 'metiers'); // Update les posts terms directement
|
|
||||||
$existingMetiersTermIds[] = $parentTerm->term_id; // Ajoute l'ID du parent à une liste pour éviter de pusher plusieurs fois le parent
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ###### ELEMENTS BATIMENTS — ADD PARENT TAXONOMIES IF NOT ALREADY ADDED ######
|
|
||||||
if ($elementsBatimentsTerms) {
|
|
||||||
$existingElementsBatimentsTermIds = array_column($elementsBatimentsTerms, 'term_id');
|
|
||||||
|
|
||||||
foreach ($elementsBatimentsTerms as $term) {
|
|
||||||
if ($term->parent && !in_array($term->parent, $existingElementsBatimentsTermIds)) {
|
|
||||||
$parentTerm = get_term($term->parent, 'elementsbatiments');
|
|
||||||
if ($parentTerm && !is_wp_error($parentTerm)) {
|
|
||||||
wp_add_object_terms($post_id, $parentTerm->term_id, 'elementsbatiments'); // Update les posts terms directement
|
|
||||||
$existingElementsBatimentsTermIds[] = $parentTerm->term_id; // Ajoute l'ID du parent à une liste pour éviter de pusher plusieurs fois le parent
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
add_action('acf/save_post', 'metiers_patrimoine_artisans_post_taxonomies_updater', 20);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* -----------------------------------------------
|
/* -----------------------------------------------
|
||||||
AUTOMATIZE POST STATUS DEPENDING ON MDP STATUS
|
AUTOMATIZE POST STATUS DEPENDING ON MDP STATUS
|
||||||
--------------------------------------------------*/
|
--------------------------------------------------*/
|
||||||
|
|
|
||||||
|
|
@ -1,66 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function get_the_parent_terms($taxonomy, $postID = null)
|
|
||||||
{
|
|
||||||
if (!$postID || !$taxonomy || !taxonomy_exists($taxonomy)) return null;
|
|
||||||
|
|
||||||
$terms = get_the_terms($postID, $taxonomy);
|
|
||||||
if (!$terms || empty($terms)) return [];
|
|
||||||
|
|
||||||
$parentTerms = array_filter($terms, function ($term) {
|
|
||||||
return $term->parent == 0;
|
|
||||||
});
|
|
||||||
return $parentTerms;
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_the_children_terms($taxonomy, $postID)
|
|
||||||
{
|
|
||||||
if (!$postID || !$taxonomy || !taxonomy_exists($taxonomy)) return null;
|
|
||||||
|
|
||||||
$terms = get_the_terms($postID, $taxonomy);
|
|
||||||
if (!$terms || empty($terms)) return [];
|
|
||||||
|
|
||||||
$childrenTerms = array_filter($terms, function ($term) {
|
|
||||||
return $term->parent !== 0;
|
|
||||||
});
|
|
||||||
return $childrenTerms;
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_children_terms_from_specific_parent($taxonomy, $postID, $parentTerm)
|
|
||||||
{
|
|
||||||
if (!$postID || !$taxonomy || !taxonomy_exists($taxonomy)) return null;
|
|
||||||
|
|
||||||
$childrenTerms = get_the_children_terms($taxonomy, $postID);
|
|
||||||
$filteredChildrenTerms = array_filter($childrenTerms, function ($term) use ($parentTerm) {
|
|
||||||
return $term->parent === $parentTerm->term_id;
|
|
||||||
});
|
|
||||||
return $filteredChildrenTerms;
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_the_terms_organised_by_parent($taxonomy, $postID = null)
|
|
||||||
{
|
|
||||||
if (!$postID) return;
|
|
||||||
|
|
||||||
$terms = get_the_terms($postID, $taxonomy);
|
|
||||||
|
|
||||||
$sortedTermsByParent = [];
|
|
||||||
if (!$terms) return $sortedTermsByParent;
|
|
||||||
|
|
||||||
$parentTerms = get_the_parent_terms($taxonomy, $postID);
|
|
||||||
|
|
||||||
foreach ($parentTerms as $parentTerm) {
|
|
||||||
$sortedTermsByParent[] = $parentTerm;
|
|
||||||
|
|
||||||
$childrenTerms = get_children_terms_from_specific_parent($taxonomy, $postID, $parentTerm);
|
|
||||||
|
|
||||||
foreach ($childrenTerms as $childTerm) {
|
|
||||||
$sortedTermsByParent[] = $childTerm;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $sortedTermsByParent;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getAllBatimentsTermsByParents()
|
function getAllBatimentsTermsByParents()
|
||||||
{
|
{
|
||||||
// Récupérer tous les termes de la taxonomie 'elementsbatiments' avec une hiérarchie
|
// Récupérer tous les termes de la taxonomie 'elementsbatiments' avec une hiérarchie
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,5 @@
|
||||||
@apply flex flex-wrap gap-2 mt-4;
|
@apply flex flex-wrap gap-2 mt-4;
|
||||||
.taxonomy-tag {
|
.taxonomy-tag {
|
||||||
@apply bg-patrimoine-sante-securite-light text-patrimoine-sante-securite rounded-lg text-sm px-3 py-1;
|
@apply bg-patrimoine-sante-securite-light text-patrimoine-sante-securite rounded-lg text-sm px-3 py-1;
|
||||||
|
|
||||||
&.taxonomy-tag--parent {
|
|
||||||
@apply bg-patrimoine-sante-securite font-semibold text-white;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ $pageIcon = get_field('page_icon', get_queried_object_id()) ?? null;
|
||||||
|
|
||||||
|
|
||||||
<li><a href="<?php echo $frontPageUrl ?>"><?php echo $frontPageTitle ?></a></li>
|
<li><a href="<?php echo $frontPageUrl ?>"><?php echo $frontPageTitle ?></a></li>
|
||||||
|
|
||||||
<li><a href="<?php echo $searchPageUrl ?>"><?php echo $searchPageTitle ?></a></li>
|
<li><a href="<?php echo $searchPageUrl ?>"><?php echo $searchPageTitle ?></a></li>
|
||||||
|
|
||||||
<?php if ($currentPage) : ?>
|
<?php if ($currentPage) : ?>
|
||||||
|
|
@ -172,6 +173,7 @@ $pageIcon = get_field('page_icon', get_queried_object_id()) ?? null;
|
||||||
</div>
|
</div>
|
||||||
<p class="chantier__description"><?php echo $chantier_description ?></p>
|
<p class="chantier__description"><?php echo $chantier_description ?></p>
|
||||||
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
// Rendre Un bloc acf/lightbox-gallery avec les photos du chantier
|
// Rendre Un bloc acf/lightbox-gallery avec les photos du chantier
|
||||||
$block_content = '<!-- wp:acf/lightbox-gallery {"data":{"gallery":' . json_encode($pictures) . '}} /-->';
|
$block_content = '<!-- wp:acf/lightbox-gallery {"data":{"gallery":' . json_encode($pictures) . '}} /-->';
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,6 @@
|
||||||
?>
|
?>
|
||||||
<div class='no-results'>
|
<div class='no-results'>
|
||||||
<img class='no-results__cover' src="<?php echo get_stylesheet_directory_uri() . "/resources/img/illustrations/Homegrade_resultats-filtres-cactus.svg" ?>" alt='' />
|
<img class='no-results__cover' src="<?php echo get_stylesheet_directory_uri() . "/resources/img/illustrations/Homegrade_resultats-filtres-cactus.svg" ?>" alt='' />
|
||||||
<h3><?php echo __("Aucun artisan correspondant actuellement", "metiers-patrimoine-theme") ?> </h3>
|
<h3><?php echo __("Aucun résultat trouvé", "metiers-patrimoine-theme") ?> </h3>
|
||||||
<p> <?php echo __("Sélectionnez un ou plusieurs <span class='highlighted-purple'>métiers</span> ou <span class='highlighted-purple'>critères</span> pour lancer votre recherche", "metiers-patrimoine-theme") ?></p>
|
<p> <?php echo __("Essayez d'ajouter un <span class='highlighted-purple'>filtre supplémentaire</span> pour trouver plus de résultats", "metiers-patrimoine-theme") ?></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -8,8 +8,7 @@ $post_permalink = get_the_permalink($postID);
|
||||||
$company_members = get_field('company_members', $postID);
|
$company_members = get_field('company_members', $postID);
|
||||||
$currentTaxonomy = $args['current_taxonomy'];
|
$currentTaxonomy = $args['current_taxonomy'];
|
||||||
|
|
||||||
// $taxonomyTerms = $currentTaxonomy === "elementsbatiments" ? get_the_terms($postID, 'elementsbatiments') : get_the_terms($postID, 'metiers');
|
$taxonomyTerms = $currentTaxonomy === "elementsbatiments" ? get_the_terms($postID, 'elementsbatiments') : get_the_terms($postID, 'metiers');
|
||||||
$taxonomySortedTerms = $currentTaxonomy === "elementsbatiments" ? get_the_terms_organised_by_parent('elementsbatiments', $postID) : get_the_terms_organised_by_parent('metiers', $postID);
|
|
||||||
|
|
||||||
|
|
||||||
$phoneNumber = get_field('phone_number', $postID);
|
$phoneNumber = get_field('phone_number', $postID);
|
||||||
|
|
@ -35,14 +34,14 @@ $cover_image = get_field('artisan_cover', $postID);
|
||||||
<?php if ($company_members): ?>
|
<?php if ($company_members): ?>
|
||||||
<p class="card-artisans__team-members">
|
<p class="card-artisans__team-members">
|
||||||
<?php foreach ($company_members as $key => $member) : ?>
|
<?php foreach ($company_members as $key => $member) : ?>
|
||||||
<span><?php echo $member['first_name'] . ' ' . $member['last_name'] . ' ' . ($key == count($company_members) - 1 ? '' : ', ') ?></span>
|
<span><?php echo $member['first_name'] . ' ' . $member['last_name']; ?></span>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</p>
|
</p>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if ($taxonomySortedTerms): ?>
|
<?php if ($taxonomyTerms): ?>
|
||||||
<div class="card-artisans__taxonomy-tags taxonomy-tags">
|
<div class="card-artisans__taxonomy-tags">
|
||||||
<?php foreach ($taxonomySortedTerms as $key => $term) : ?>
|
<?php foreach ($taxonomyTerms as $key => $term) : ?>
|
||||||
<span class="taxonomy-tag taxonomy-tag--<?php echo $term->parent === 0 ? 'parent' : 'child'; ?>"><?php echo $term->name; ?></span>
|
<span class="taxonomy-tag"><?php echo $term->name; ?></span>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ $cover_image = get_field('artisan_cover', $postID);
|
||||||
<?php if ($company_members): ?>
|
<?php if ($company_members): ?>
|
||||||
<p class="card-artisans__team-members">
|
<p class="card-artisans__team-members">
|
||||||
<?php foreach ($company_members as $key => $member) : ?>
|
<?php foreach ($company_members as $key => $member) : ?>
|
||||||
<span><?php echo $member['first_name'] . ' ' . $member['last_name'] . ' ' . ($key == count($company_members) - 1 ? '' : ', ') ?></span>
|
<span><?php echo $member['first_name'] . ' ' . $member['last_name']; ?></span>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</p>
|
</p>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,10 @@
|
||||||
@apply font-bold !my-0;
|
@apply font-bold !my-0;
|
||||||
}
|
}
|
||||||
&__taxonomy-tags {
|
&__taxonomy-tags {
|
||||||
@apply mt-2 mb-4;
|
@apply flex flex-wrap gap-2 mt-4;
|
||||||
|
.taxonomy-tag {
|
||||||
|
@apply bg-patrimoine-sante-securite-light text-patrimoine-sante-securite rounded-lg text-sm px-3 py-1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
&__contact-details-title {
|
&__contact-details-title {
|
||||||
@apply uppercase !font-medium text-neutral-400 !mb-3 !text-sm;
|
@apply uppercase !font-medium text-neutral-400 !mb-3 !text-sm;
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@ $post_permalink = get_the_permalink($postID);
|
||||||
$company_members = get_field('company_members', $postID);
|
$company_members = get_field('company_members', $postID);
|
||||||
|
|
||||||
$elementsBatimentsTerms = get_the_terms($postID, 'elementsbatiments');
|
$elementsBatimentsTerms = get_the_terms($postID, 'elementsbatiments');
|
||||||
// $metiersTerms = get_the_terms($postID, 'metiers');
|
$metiersTerms = get_the_terms($postID, 'metiers');
|
||||||
$metiersTerms = get_the_terms_organised_by_parent('metiers', $postID); // From utilities.php
|
|
||||||
|
|
||||||
$hasEmptyTaxos = (empty($elementsBatimentsTerms) && empty($metiersTerms)) ? 'card-taxonomies--empty' : '';
|
$hasEmptyTaxos = (empty($elementsBatimentsTerms) && empty($metiersTerms)) ? 'card-taxonomies--empty' : '';
|
||||||
?>
|
?>
|
||||||
|
|
@ -35,7 +35,7 @@ $hasEmptyTaxos = (empty($elementsBatimentsTerms) && empty($metiersTerms)) ? 'car
|
||||||
</div>
|
</div>
|
||||||
<div class="taxonomy-tags card-taxonomies__taxonomy-tags">
|
<div class="taxonomy-tags card-taxonomies__taxonomy-tags">
|
||||||
<?php foreach ($metiersTerms as $key => $term) : ?>
|
<?php foreach ($metiersTerms as $key => $term) : ?>
|
||||||
<span class="taxonomy-tag taxonomy-tag--<?php echo $term->parent === 0 ? 'parent' : 'child'; ?>"><?php echo $term->name; ?></span>
|
<span class="taxonomy-tag"><?php echo $term->name; ?></span>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user