FEATURE refactoring member-card to handle a redirect to author parameter for best reusability in dynamiques
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
8ef34620b7
commit
b00eb3123e
|
|
@ -1,29 +1,70 @@
|
|||
<?php
|
||||
$member_id = $args['member_id'];
|
||||
|
||||
$redirect_to_author_page = $args['redirect_to_author_page'] ?? false;
|
||||
$placeholder_thumbnail_counter = 0;
|
||||
switch_to_blog(1);
|
||||
$member_full_name = get_the_title($member_id);
|
||||
$member_thumbnail = get_field('profile_thumbnail', $member_id);
|
||||
$member_description = get_field('description', $member_id);
|
||||
$member_email = get_field('email', $member_id);
|
||||
|
||||
$tumbnailPosition = get_field('profile_thumbnail_position', $member_id) ?? '50%';
|
||||
|
||||
$is_synced_member = get_field('sync_carhop_member', $member_id);
|
||||
$carhop_member_id = get_field('carhop_member', $member_id);
|
||||
|
||||
$member_permalink = get_the_permalink($member_id);
|
||||
$card_permalink = $member_permalink;
|
||||
|
||||
|
||||
if ($redirect_to_author_page) {
|
||||
restore_current_blog();
|
||||
$corresponding_author_id = get_posts(array(
|
||||
'post_type' => 'auteurs',
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'key' => 'carhop_member',
|
||||
'value' => $member_id,
|
||||
'compare' => 'LIKE',
|
||||
),
|
||||
),
|
||||
'posts_per_page' => 1,
|
||||
));
|
||||
|
||||
$card_permalink = isset($corresponding_author_id[0]->ID) ? get_the_permalink($corresponding_author_id[0]->ID) : '#';
|
||||
write_log($card_permalink);
|
||||
restore_current_blog();
|
||||
}
|
||||
|
||||
if ($is_synced_member && isset($carhop_member_id)) {
|
||||
|
||||
$member_description = get_field('description', $carhop_member_id);
|
||||
$member_thumbnail = get_field('profile_thumbnail', $carhop_member_id);
|
||||
$member_email = get_field('email', $carhop_member_id);
|
||||
$comity = get_field('comity', $carhop_member_id);
|
||||
$profile_thumbnail_position = get_field('profile_thumbnail_position', $carhop_member_id);
|
||||
}
|
||||
|
||||
|
||||
$is_director = $member_id === 476 ? true : false;
|
||||
|
||||
?>
|
||||
<li class="comity-type__item member-card">
|
||||
<div class="member-card__profile-picture">
|
||||
<?php if ($member_thumbnail) : ?>
|
||||
<a href="<?php echo get_the_permalink($member_id); ?>">
|
||||
<a href="<?php echo $card_permalink; ?>">
|
||||
<img style="object-position: 50% <?php echo $tumbnailPosition; ?>%;" src="<?php echo $member_thumbnail['url']; ?>" alt="<?php echo $member_thumbnail['alt']; ?>">
|
||||
</a>
|
||||
<?php else : ?>
|
||||
<a href="<?php echo get_the_permalink($member_id); ?>">
|
||||
<a href="<?php echo $card_permalink; ?>">
|
||||
<div class="member-card__profile-picture-placeholder member-card__profile-picture-placeholder--<?php echo $placeholder_thumbnail_counter % 3 + 1; ?>n">
|
||||
</div>
|
||||
</a>
|
||||
|
||||
<?php $placeholder_thumbnail_counter++; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<h4 class="member-card__name">
|
||||
<a href="<?php echo get_the_permalink($member_id); ?>"> <?php echo $member_full_name ?></a>
|
||||
<a href="<?php echo $card_permalink; ?>"> <?php echo $member_full_name ?></a>
|
||||
</h4>
|
||||
|
||||
<div class="member-card__bio"><?php echo $member_description; ?></p>
|
||||
|
|
@ -38,4 +79,8 @@ $tumbnailPosition = get_field('profile_thumbnail_position', $member_id) ?? '50%'
|
|||
Envoyer un email
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<?php restore_current_blog();
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user