mirror of
https://github.com/Frumph/comic-easel.git
synced 2026-07-21 00:35:30 -04:00
additional shortcode arguments for cast-page image=(0/1) and stats=(0/1)
This commit is contained in:
+38
-31
@@ -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 .= '<tr><td class="cast-image">';
|
||||
$cast_output .= '<div class="cast-pic character-'.$character->slug.'">';
|
||||
$cast_output .= '</div></td>';
|
||||
$cast_output .= '<tr>';
|
||||
if ($image) {
|
||||
$cast_output .= '<td class="cast-image">';
|
||||
$cast_output .= '<div class="cast-pic character-'.$character->slug.'">';
|
||||
$cast_output .= '</div></td>';
|
||||
}
|
||||
$cast_output .= '<td class="cast-info cast-info-'.$character->slug.'">';
|
||||
$cast_output .= '<h4 class="cast-name"><a href="'.get_term_link($character->slug, 'characters').'">'.$character->name.'</a></h4>';
|
||||
$cast_output .= '<p class="cast-description">';
|
||||
$cast_output .= $character->description;
|
||||
$cast_output .= '</p>';
|
||||
$cast_output .= '<p class="cast-character-stats">';
|
||||
$cast_output .= '<i>'.__('Comics:','comiceasel').'</i> <strong>'.$character->count.'</strong><br />';
|
||||
$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 .= '<i>'.__('Only Appearance:','comiceasel').'</i> <a href="'.get_permalink($first_seen_id).'">'.$first_seen_title.'</a><br />';
|
||||
} else {
|
||||
$cast_output .= '<i>'.__('Recent Appearance:','comiceasel').'</i> <a href="'.get_permalink($last_seen_id).'">'.$last_seen_title.'</a><br />';
|
||||
$cast_output .= '<i>'.__('First Appearance:','comiceasel').'</i> <a href="'.get_permalink($first_seen_id).'">'.$first_seen_title.'</a><br />';
|
||||
if ($stats) {
|
||||
$cast_output .= '<p class="cast-character-stats">';
|
||||
$cast_output .= '<i>'.__('Comics:','comiceasel').'</i> <strong>'.$character->count.'</strong><br />';
|
||||
$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 .= '<i>'.__('Only Appearance:','comiceasel').'</i> <a href="'.get_permalink($first_seen_id).'">'.$first_seen_title.'</a><br />';
|
||||
} else {
|
||||
$cast_output .= '<i>'.__('Recent Appearance:','comiceasel').'</i> <a href="'.get_permalink($last_seen_id).'">'.$last_seen_title.'</a><br />';
|
||||
$cast_output .= '<i>'.__('First Appearance:','comiceasel').'</i> <a href="'.get_permalink($first_seen_id).'">'.$first_seen_title.'</a><br />';
|
||||
}
|
||||
}
|
||||
$qposts = null;
|
||||
$cast_output .= '</p>';
|
||||
}
|
||||
$qposts = null;
|
||||
$cast_output .= '</p>';
|
||||
$cast_output .= '</td></tr>';
|
||||
}
|
||||
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 .= '<table class="cast-wrapper">'."\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 .= '</table>'."\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 .= '<table class="cast-wrapper">'."\r\n";
|
||||
$cast_output .= ceo_cast_display($single_character)."\r\n";
|
||||
$cast_output .= ceo_cast_display($single_character, $stats, $image)."\r\n";
|
||||
$cast_output .= '</table>'."\r\n";
|
||||
} else
|
||||
$cast_output .= __('Unknown Character: ', 'comiceasel').$character."<br />\r\n";
|
||||
|
||||
Reference in New Issue
Block a user