function widget($args, $instance)
 {
     global $post;
     extract($args, EXTR_SKIP);
     echo $before_widget;
     $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
     if (!empty($title)) {
         echo $before_title . $title . $after_title;
     }
     if ((is_home() || is_front_page()) && !is_paged() && !ceo_pluginfo('disable_comic_on_home_page')) {
         $chapter_on_home = '';
         $chapter_on_home = get_term_by('id', ceo_pluginfo('chapter_on_home'), 'chapters');
         $chapter_on_home = !is_wp_error($chapter_on_home) && !empty($chapter_on_home) ? '&chapters=' . $chapter_on_home->slug : '';
         $order = ceo_pluginfo('display_first_comic_on_home_page') ? 'asc' : 'desc';
         $query_args = 'post_type=comic&showposts=1&order=' . $order . $chapter_on_home;
         apply_filters('ceo_display_comic_mininav_home_query', $query_args);
         $comicFrontpage = new WP_Query();
         $comicFrontpage->query($query_args);
         while ($comicFrontpage->have_posts()) {
             $comicFrontpage->the_post();
             ceo_list_jump_to_comic($instance['exclude'], false);
         }
     } elseif (!empty($post)) {
         ceo_list_jump_to_comic($instance['exclude'], false);
     }
     echo $after_widget;
 }
Example #2
0
function ceo_display_comic_navigation()
{
    global $post, $wp_query;
    if (ceo_pluginfo('navigate_only_chapters')) {
        $first_comic = ceo_get_first_comic_in_chapter_permalink();
        $last_comic = ceo_get_last_comic_in_chapter_permalink();
        $next_comic = ceo_get_next_comic_in_chapter_permalink();
        $prev_comic = ceo_get_previous_comic_in_chapter_permalink();
    } else {
        $first_comic = ceo_get_first_comic_permalink();
        $last_comic = ceo_get_last_comic_permalink();
        $next_comic = ceo_get_next_comic_permalink();
        $prev_comic = ceo_get_previous_comic_permalink();
    }
    $first_text = __('‹‹ First', 'comiceasel');
    $last_text = __('Last ››', 'comiceasel');
    $next_text = __('Next ›', 'comiceasel');
    $prev_text = __('‹ Prev', 'comiceasel');
    ?>
	<table id="comic-nav-wrapper">
		<tr class="comic-nav-container">
			<td class="comic-nav"><?php 
    if (get_permalink() != $first_comic) {
        ?>
<a href="<?php 
        echo $first_comic;
        ?>
" class="comic-nav-base comic-nav-first<?php 
        if (get_permalink() == $first_comic) {
            ?>
 comic-nav-inactive<?php 
        }
        ?>
"><?php 
        echo $first_text;
        ?>
</a><?php 
    } else {
        echo '<span class="comic-nav-base comic-nav-first comic-nav-void">' . $first_text . '</span>';
    }
    ?>
</td>
			<td class="comic-nav"><?php 
    if ($prev_comic) {
        ?>
<a href="<?php 
        echo $prev_comic;
        ?>
" class="comic-nav-base comic-nav-previous<?php 
        if (!$prev_comic) {
            ?>
 comic-nav-inactive<?php 
        }
        ?>
"><?php 
        echo $prev_text;
        ?>
</a><?php 
    } else {
        echo '<span class="comic-nav-base comic-nav-previous comic-nav-void ">' . $prev_text . '</span>';
    }
    ?>
</td>
<?php 
    if (ceo_pluginfo('enable_buy_comic') && !wp_is_mobile()) {
        if (strpos(ceo_pluginfo('buy_comic_url'), '?') !== false) {
            $bpsep = '&';
        } else {
            $bpsep = '?';
        }
        ?>
		<td class="comic-nav"><a href="<?php 
        echo ceo_pluginfo('buy_comic_url') . $bpsep . 'id=' . $post->ID;
        ?>
" class="comic-nav-base comic-nav-buycomic" title="Buy Comic"><?php 
        _e('Buy!', 'comiceasel');
        ?>
</a></td>
<?php 
    }
    if (ceo_pluginfo('enable_comment_nav') && !wp_is_mobile()) {
        $commentscount = get_comments_number();
        ?>
			<td class="comic-nav"><a href="<?php 
        comments_link();
        ?>
" class="comic-nav-comments" title="<?php 
        the_title();
        ?>
"><span class="comic-nav-comment-count"><?php 
        echo sprintf(_n('Comment(%d)', 'Comments(%d)', $commentscount, 'comiceasel'), $commentscount);
        ?>
</span></a></td>
<?php 
    }
    if (ceo_pluginfo('enable_random_nav') && !wp_is_mobile()) {
        $stay = '';
        if (ceo_pluginfo('enable_chapter_only_random')) {
            $chapter = get_the_terms($post->ID, 'chapters');
            if (!empty($chapter) && !is_wp_error($chapter)) {
                $stay = '&stay=' . reset($chapter)->term_id;
            }
        }
        ?>
			<td class="comic-nav"><a href="<?php 
        bloginfo('url');
        ?>
?random&nocache=1<?php 
        echo $stay;
        ?>
" class="comic-nav-random" title="Random Comic"><?php 
        _e('Random', 'comiceasel');
        ?>
</a></td>
<?php 
    }
    ?>
	<td class="comic-nav"><?php 
    if ($next_comic) {
        ?>
<a href="<?php 
        echo $next_comic;
        ?>
" class="comic-nav-base comic-nav-next<?php 
        if (!$next_comic) {
            ?>
 comic-nav-inactive<?php 
        }
        ?>
"><?php 
        echo $next_text;
        ?>
</a><?php 
    } else {
        echo '<span class="comic-nav-base comic-nav-next comic-nav-void ">' . $next_text . '</span>';
    }
    ?>
</td>
	<td class="comic-nav"><?php 
    if (get_permalink() != $last_comic) {
        ?>
<a href="<?php 
        echo $last_comic;
        ?>
" class="comic-nav-base comic-nav-last<?php 
        if (get_permalink() == $last_comic) {
            ?>
 comic-nav-inactive<?php 
        }
        ?>
"><?php 
        echo $last_text;
        ?>
</a><?php 
    } else {
        echo '<span class="comic-nav-base comic-nav-last comic-nav-void ">' . $last_text . '</span>';
    }
    ?>
</td>
<?php 
    if (ceo_pluginfo('enable_chapter_nav')) {
        ?>
				
			<td class="comic-nav comic-nav-jumpto"><?php 
        ceo_comic_archive_jump_to_chapter(true, '', false, ceo_pluginfo('default_nav_bar_chapter_goes_to_archive'));
        ?>
</td>
<?php 
    }
    if (ceo_pluginfo('enable_comic_nav')) {
        ?>
				
			<td class="comic-nav comic-nav-jumptocomic"><?php 
        ceo_list_jump_to_comic();
        ?>
</td>
<?php 
    }
    ?>
		</tr>
<?php 
    if (ceo_pluginfo('enable_embed_nav') && !wp_is_mobile()) {
        ?>
		<tr>
			<td class="comic-nav" colspan="15">
				<?php 
        $post_image_id = get_post_thumbnail_id($post->ID);
        $thumbnail = wp_get_attachment_image_src($post_image_id, 'full', false);
        if (is_array($thumbnail)) {
            $thumbnail = reset($thumbnail);
            echo $thumbnail;
        }
        ?>
			</td>
		</tr>
<?php 
    }
    ?>
 
	</table>
	<?php 
}