diff --git a/functions/shortcodes.php b/functions/shortcodes.php index 1e1c188..394bd10 100644 --- a/functions/shortcodes.php +++ b/functions/shortcodes.php @@ -5,43 +5,48 @@ add_shortcode('cast-page', 'ceo_cast_page'); add_shortcode('comic-archive', 'ceo_comic_archive_multi'); add_shortcode('transcript', 'ceo_display_transcript'); -function ceo_cast_display($character) { +function ceo_cast_display($character, $stats, $image) { $cast_output = ''; if ($character) { - $cast_output .= ''; - $cast_output .= '
'; - $cast_output .= '
'; + $cast_output .= ''; + if ($image) { + $cast_output .= ''; + $cast_output .= '
'; + $cast_output .= '
'; + } $cast_output .= ''; $cast_output .= '

'.$character->name.'

'; $cast_output .= '

'; $cast_output .= $character->description; $cast_output .= '

'; - $cast_output .= '

'; - $cast_output .= ''.__('Comics:','comiceasel').' '.$character->count.'
'; - $args = array( - 'post_type' => 'comic', - 'orderby' => 'post_date', - 'order' => 'ASC', - 'post_status' => 'publish', - 'characters' => $character->slug, - ); - $qposts = get_posts( $args ); - if (!empty($qposts)) { - $first_seen_object = reset($qposts); - $first_seen_title = $first_seen_object->post_title; - $first_seen_id = $first_seen_object->ID; - $last_seen_object = end($qposts); - $last_seen_title = $last_seen_object->post_title; - $last_seen_id = $last_seen_object->ID; - if ($first_seen_id == $last_seen_id) { - $cast_output .= ''.__('Only Appearance:','comiceasel').' '.$first_seen_title.'
'; - } else { - $cast_output .= ''.__('Recent Appearance:','comiceasel').' '.$last_seen_title.'
'; - $cast_output .= ''.__('First Appearance:','comiceasel').' '.$first_seen_title.'
'; + if ($stats) { + $cast_output .= '

'; + $cast_output .= ''.__('Comics:','comiceasel').' '.$character->count.'
'; + $args = array( + 'post_type' => 'comic', + 'orderby' => 'post_date', + 'order' => 'ASC', + 'post_status' => 'publish', + 'characters' => $character->slug, + ); + $qposts = get_posts( $args ); + if (!empty($qposts)) { + $first_seen_object = reset($qposts); + $first_seen_title = $first_seen_object->post_title; + $first_seen_id = $first_seen_object->ID; + $last_seen_object = end($qposts); + $last_seen_title = $last_seen_object->post_title; + $last_seen_id = $last_seen_object->ID; + if ($first_seen_id == $last_seen_id) { + $cast_output .= ''.__('Only Appearance:','comiceasel').' '.$first_seen_title.'
'; + } else { + $cast_output .= ''.__('Recent Appearance:','comiceasel').' '.$last_seen_title.'
'; + $cast_output .= ''.__('First Appearance:','comiceasel').' '.$first_seen_title.'
'; + } } + $qposts = null; + $cast_output .= '

'; } - $qposts = null; - $cast_output .= '

'; $cast_output .= ''; } return $cast_output; @@ -51,7 +56,9 @@ function ceo_cast_page( $atts, $content = '' ) { extract( shortcode_atts( array( 'character' => '', 'limit' => '', - 'order' => 'desc' + 'order' => 'desc', + 'stats' => 1, + 'image' => 1 ), $atts ) ); $cast_output = ''; if (empty($character)) { @@ -62,7 +69,7 @@ function ceo_cast_page( $atts, $content = '' ) { if (is_array($characters)) { $cast_output .= ''."\r\n"; foreach ($characters as $character) { - $cast_output .= ceo_cast_display($character)."\r\n"; + $cast_output .= ceo_cast_display($character, $stats, $image)."\r\n"; } $cast_output .= '
'."\r\n"; } else { @@ -72,7 +79,7 @@ function ceo_cast_page( $atts, $content = '' ) { $single_character = get_term_by('slug', $character, 'characters'); if (!empty($single_character)) { $cast_output .= ''."\r\n"; - $cast_output .= ceo_cast_display($single_character)."\r\n"; + $cast_output .= ceo_cast_display($single_character, $stats, $image)."\r\n"; $cast_output .= '
'."\r\n"; } else $cast_output .= __('Unknown Character: ', 'comiceasel').$character."
\r\n";