switching dahsboard-widget to a new folder template
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
8c9e8b6a8b
commit
97fc8b7aaa
|
|
@ -14,73 +14,7 @@ function custom_dashboard_widget()
|
|||
|
||||
function custom_dashboard_widget_display()
|
||||
{
|
||||
$current_user = wp_get_current_user();
|
||||
$user_name = $current_user->user_login;
|
||||
|
||||
|
||||
|
||||
$args = array(
|
||||
'post_type' => 'artisans',
|
||||
'meta_key' => 'conseiller',
|
||||
'meta_value' => $current_user->ID,
|
||||
'posts_per_page' => -1
|
||||
);
|
||||
|
||||
$user_attached_artisans = new WP_Query($args);
|
||||
|
||||
|
||||
|
||||
$required_actions_artisans = new WP_Query(
|
||||
array(
|
||||
'post_type' => 'artisans',
|
||||
'meta_key' => 'conseiller',
|
||||
'meta_value' => $current_user->ID,
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'key' => 'required_action',
|
||||
'value' => true,
|
||||
'compare' => '='
|
||||
)
|
||||
),
|
||||
'posts_per_page' => -1
|
||||
)
|
||||
);
|
||||
|
||||
?>
|
||||
<h3>Bonjour <?php echo $user_name ?> !</h3>
|
||||
<div class="total-attached">
|
||||
<p> Artisans associés : <?php echo count($user_attached_artisans->posts) ?></p>
|
||||
</div>
|
||||
<div class="required-actions">
|
||||
<?php
|
||||
$total = count($required_actions_artisans->posts);
|
||||
?>
|
||||
<?php if ($total == 0) : ?>
|
||||
<p>Aucun artisan en attente d'action</p>
|
||||
"count"><?php echo $total ?></span> action requise </h4>
|
||||
<?php else : ?>
|
||||
<h4>Actions requises<span class="count">(<?php echo $total ?>)</span></h4>
|
||||
<?php endif; ?>
|
||||
|
||||
<ul>
|
||||
<?php foreach ($required_actions_artisans->posts as $index => $artisan) : ?>
|
||||
<?php if ($index >= 4) break; ?>
|
||||
|
||||
<?php $mdp_status = get_field('mdp_status', $artisan->ID);
|
||||
write_log($mdp_status);
|
||||
?>
|
||||
<li>
|
||||
<a href="<?php echo get_edit_post_link($artisan->ID) ?>">
|
||||
<?php echo $artisan->post_title ?>
|
||||
</a>
|
||||
<span class="status-state status-state--<?php echo $mdp_status['value'] ?>"><?php echo $mdp_status['label'] ?></span>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<a class="cta cta--button" href="<?php echo home_url('/wp-admin/admin.php?page=mdp-dashboard') ?>">Pannel de gestion</a>
|
||||
<?php
|
||||
get_template_part('template-parts/admin/personnal-widget');
|
||||
}
|
||||
|
||||
// Ajouter le widget au tableau de bord
|
||||
|
|
|
|||
65
template-parts/admin/personnal-widget.php
Normal file
65
template-parts/admin/personnal-widget.php
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
$current_user = wp_get_current_user();
|
||||
$user_name = $current_user->user_login;
|
||||
|
||||
$args = array(
|
||||
'post_type' => 'artisans',
|
||||
'meta_key' => 'conseiller',
|
||||
'meta_value' => $current_user->ID,
|
||||
'posts_per_page' => -1
|
||||
);
|
||||
|
||||
$user_attached_artisans = new WP_Query($args);
|
||||
|
||||
$required_actions_artisans = new WP_Query(
|
||||
array(
|
||||
'post_type' => 'artisans',
|
||||
'meta_key' => 'conseiller',
|
||||
'meta_value' => $current_user->ID,
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'key' => 'required_action',
|
||||
'value' => true,
|
||||
'compare' => '='
|
||||
)
|
||||
),
|
||||
'posts_per_page' => -1
|
||||
)
|
||||
);
|
||||
|
||||
$posts_to_show = 5;
|
||||
|
||||
?>
|
||||
<h3>Bonjour <?php echo $user_name ?> !</h3>
|
||||
<div class="total-attached">
|
||||
<p> Artisans associés : <?php echo count($user_attached_artisans->posts) ?></p>
|
||||
</div>
|
||||
<div class="required-actions">
|
||||
<?php
|
||||
$total = count($required_actions_artisans->posts);
|
||||
?>
|
||||
<?php if ($total == 0) : ?>
|
||||
<p>Aucun artisan en attente d'action</p>
|
||||
<?php else : ?>
|
||||
<h4>Actions requises<span class="count">(<?php echo $total ?>)</span></h4>
|
||||
<?php endif; ?>
|
||||
|
||||
<ul>
|
||||
<?php foreach ($required_actions_artisans->posts as $index => $artisan) : ?>
|
||||
<?php if ($index >= $posts_to_show ) break; ?>
|
||||
<?php $mdp_status = get_field('mdp_status', $artisan->ID); ?>
|
||||
<li>
|
||||
<a href="<?php echo get_edit_post_link($artisan->ID) ?>">
|
||||
<?php echo $artisan->post_title ?>
|
||||
</a>
|
||||
<span class="status-state status-state--<?php echo $mdp_status['value'] ?>"><?php echo $mdp_status['label'] ?></span>
|
||||
</li>
|
||||
<?php if ($index === $posts_to_show - 1) : ?>
|
||||
<p>et <?php echo $total - $posts_to_show ?> artisan(s) de plus ...</p>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<a class="cta cta--button" href="<?php echo home_url('/wp-admin/admin.php?page=gestion-artisans') ?>">Pannel de gestion</a>
|
||||
<?php
|
||||
Loading…
Reference in New Issue
Block a user