Skip to content

Instantly share code, notes, and snippets.

@jmabbas
Created June 26, 2024 09:48
Show Gist options
  • Save jmabbas/3804e34b486079bd0a924740040b55ff to your computer and use it in GitHub Desktop.
Save jmabbas/3804e34b486079bd0a924740040b55ff to your computer and use it in GitHub Desktop.
MAS video - Person know credits count update
function masvideos_template_single_person_credits() {
global $person;
$movie_cast = $person->get_movie_cast() ? $person->get_movie_cast() : array();
$movie_crew = $person->get_movie_crew() ? $person->get_movie_crew() : array();
$tv_show_cast = $person->get_tv_show_cast() ? $person->get_tv_show_cast() : array();
$tv_show_crew = $person->get_tv_show_crew() ? $person->get_tv_show_crew() : array();
$credits = array_unique( array_merge ( $movie_cast, $movie_crew, $tv_show_cast, $tv_show_crew ) );
$posts_status = [];
$published_count = 0;
foreach ($credits as $post_id) {
$status = get_post_status($post_id);
if ($status === 'publish') {
$posts_status[$post_id] = 'published';
$published_count++;
} elseif ($status === false) {
$posts_status[$post_id] = 'does not exist';
} else {
$posts_status[$post_id] = 'not published';
}
}
if( count( $credits ) > 0 ) :
$title = apply_filters( 'masvideos_template_single_person_credits_title_text', __( 'Known Credits', 'masvideos' ) );
?>
<div class="single-person__credits">
<h4 class="single-person__sidebar-title credits-title"><?php echo esc_html( $title ); ?></h4>
<?php echo $published_count; ?>
</div>
<?php
endif;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment