75 lines
2.2 KiB
PHP
75 lines
2.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Template part pour afficher une section d'artisans
|
|
*
|
|
* @param string $status - Le statut des artisans à afficher
|
|
* @param string $title - Le titre de la section
|
|
* @param int $current_user_id - L'ID de l'utilisateur courant
|
|
* @param array $additional_query - Paramètres de requête supplémentaires (optionnel)
|
|
*/
|
|
|
|
|
|
|
|
$status_class = $args['status_class'] ?? "";
|
|
$status = $args['status'] ?? null;
|
|
$title = $args['title'] ?? "";
|
|
$use_current_user = $args['use_current_user'] ?? false;
|
|
$current_user_id = $args['current_user_id'] ?? null;
|
|
$not_found_message = $args['not_found_message'] ?? "";
|
|
|
|
|
|
$queryArgsWithStatus = array(
|
|
'post_type' => 'artisans',
|
|
'posts_per_page' => -1,
|
|
'meta_query' => array(
|
|
array(
|
|
'key' => 'mdp_status',
|
|
'value' => $status,
|
|
'compare' => '='
|
|
)
|
|
)
|
|
);
|
|
$queryArgsActionRequired = array(
|
|
'post_type' => 'artisans',
|
|
'posts_per_page' => -1,
|
|
'meta_query' => array(
|
|
array(
|
|
'key' => 'required_action',
|
|
'value' => true,
|
|
'compare' => '='
|
|
)
|
|
)
|
|
);
|
|
|
|
$currentQueryArgs = $status ? $queryArgsWithStatus : $queryArgsActionRequired;
|
|
|
|
if ($use_current_user && $current_user_id) {
|
|
$currentQueryArgs['meta_value'] = $current_user_id;
|
|
$currentQueryArgs['meta_key'] = 'conseiller';
|
|
}
|
|
|
|
|
|
|
|
$artisans = new WP_Query($currentQueryArgs);
|
|
|
|
?>
|
|
|
|
<div class="group-artisans group-artisans--<?php echo $status_class ?>">
|
|
<h3 class="group-artisans__title"><?php echo $title ?> <span class="group-artisans__post-count">(<?php echo $artisans->found_posts ?>)</span></h3>
|
|
<ul class="group-artisans__list">
|
|
<?php if ($artisans->found_posts === 0) : ?>
|
|
<p class="group-artisans__no-results"><?php echo $not_found_message ?></p>
|
|
<?php else : ?>
|
|
<?php foreach ($artisans->posts as $artisan) : ?>
|
|
<?php $mdp_status = get_field('mdp_status', $artisan->ID); ?>
|
|
<li class="group-artisans__list__item">
|
|
<a href="<?php echo get_edit_post_link($artisan->ID) ?>"><?php echo $artisan->post_title ?></a>
|
|
<?php if ($mdp_status) : ?>
|
|
<span class="status-state status-state--<?php echo $mdp_status['value'] ?>"><?php echo $mdp_status['label'] ?></span>
|
|
<?php endif; ?>
|
|
</li>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</ul>
|
|
</div>
|