__CLASS__, 'description' => __( 'Display a thumbnail of a comic, by chapter, newest, first or random, clickable to go to the comic.', 'comic-easel' ), ) // Args
);
}
function widget($args, $instance) {
global $post, $wp_query;
extract($args, EXTR_SKIP);
ceo_protect();
$current_permalink = '';
if (!is_404() && !empty($post)) $current_permalink = get_permalink($post->ID);
$current_post_id = '';
$chaptinfo = '';
$dateset = '';
if (!isset($instance['showdate'])) $instance['showdate'] = false;
if (!empty($post)) $current_post_id = $post->ID;
$comic_query = array(
'post_type' => 'comic',
'showposts' => $instance['thumbcount'],
'month' => ($instance['inhistory']) ? get_the_date('m') : '',
'day' => ($instance['inhistory']) ? get_the_date('d') : '',
'chapters' => ($instance['thumbchapt'] && ($instance['thumbchapt'] !== 'All') ) ? $instance['thumbchapt'] : '',
'order' => ($instance['first']) ? 'ASC' : 'DESC',
'orderby' => ($instance['inhistory'] || $instance['random']) ? 'rand' : '',
'exclude' => (($instance['inhistory'] || $instance['random']) && $instance['same']) ? $current_post_id : ''
);
$thumbnail_size = (isset($instance['thumbnail_size'])) ? $instance['thumbnail_size'] : 'thumbnail';
// var_dump($comic_query);
$thumbnail_query = new WP_Query($comic_query);
$archive_image = null;
if ($thumbnail_query->have_posts()) {
echo $before_widget;
$title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
if ( !empty( $title ) ) { echo $before_title . $title . $after_title; };
while ($thumbnail_query->have_posts()) : $thumbnail_query->the_post();
$the_permalink = get_permalink($post->ID);
if (!isset($instance['same'])) $instance['same'] = false;
if (!($instance['same'] && ($the_permalink == $current_permalink))) {
echo '
';
if ($instance['centering']) echo "\r\n
\r\n";
if (isset($instance['secondary']) && $instance['secondary'] && class_exists('MultiPostThumbnails')) {
$secondary_image = MultiPostThumbnails::get_the_post_thumbnail(get_post_type(), 'secondary-image', $post->ID, 'secondary-image');
if (!empty($secondary_image)) {
echo ''.$secondary_image.''."\r\n";
} else {
if ( has_post_thumbnail($post->ID) ) {
echo ''.get_the_post_thumbnail($post->ID, $thumbnail_size).''."\r\n";
} else {
echo esc_html__('No Thumbnail Found.','comic-easel');
}
}
} else {
if ( has_post_thumbnail($post->ID) ) {
echo ''.get_the_post_thumbnail($post->ID, $thumbnail_size).''."\r\n";
} else {
echo esc_html__('No Thumbnail Found.','comic-easel');
}
}
if ($instance['linktitle']) { echo ''; }
if ($instance['showdate']) { echo ''.get_the_date(get_option('date_format')).'
'; }
if ($instance['centering']) echo "\r\n\r\n";
echo "
\r\n";
}
endwhile;
echo $after_widget;
}
ceo_unprotect();
}
function update($new_instance, $old_instance) {
$instance = $old_instance;
$instance['title'] = wp_strip_all_tags($new_instance['title']);
$instance['thumbnail_size'] = wp_strip_all_tags($new_instance['thumbnail_size']);
$instance['thumbchapt'] = wp_strip_all_tags($new_instance['thumbchapt']);
$instance['thumbcount'] = (int)wp_strip_all_tags($new_instance['thumbcount']);
$instance['first'] = (bool)( $new_instance['first'] == 1 ? true : false );
$instance['random'] = (bool)( $new_instance['random'] == 1 ? true : false );
$instance['linktitle'] = (bool)($new_instance['linktitle'] == 1 ? true : false );
$instance['centering'] = (bool)($new_instance['centering'] == 1 ? true : false );
$instance['showdate'] = (bool)($new_instance['showdate'] == 1 ? true : false );
$instance['secondary'] = (bool)($new_instance['secondary'] == 1 ? true : false );
$instance['same'] = (bool)($new_instance['same'] == 1 ? true : false );
$instance['inhistory'] = (bool)($new_instance['inhistory'] == 1 ? true : false );
return $instance;
}
function form($instance) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'thumbchapt' => '', 'first' => false, 'random' => false, 'thumbcount' => 1, 'linktitle' => false, 'centering' => false, 'showdate' => false, 'secondary' => false, 'same' => false, 'inhistory' => false, 'thumbnail_size' => 'thumbnail' ) );
$title = wp_strip_all_tags($instance['title']);
$thumbnail_size = (isset($instance['thumbnail_size'])) ? $instance['thumbnail_size'] : 'thumbnail';
$thumbchapt = $instance['thumbchapt'];
$first = $instance['first'];
$random = $instance['random'];
$thumbcount = $instance['thumbcount'];
$linktitle = $instance['linktitle'];
$centering = $instance['centering'];
$showdate = $instance['showdate'];
$secondary = $instance['secondary'];
$same = $instance['same'];
$inhistory = $instance['inhistory'];
?>
All';
foreach ($allterms as $term) {
$chaptselected = '';
if ($thumbchapt == $term->slug) $chaptselected = 'selected';
$chapter_options .= '';
}
?>