function comicpress_latest_comic_jump() { if (isset($_GET['latestcomic'])) { $chapter = (int) $_GET['latestcomic']; } if (!empty($chapter)) { wp_redirect(get_permalink(comicpress_get_terminal_post_in_category($chapter, false))); } else { wp_redirect(get_permalink(comicpress_get_terminal_post_in_category(comicpress_all_comic_categories_string(), false))); } exit; }
<?php /* Template Name: Comic Year Archive */ get_header(); Protect(); if (isset($_GET['archive_year'])) { $archive_year = (int) $_GET['archive_year']; } else { if (comicpress_themeinfo('archive_start_latest_year')) { $latest_comic = comicpress_get_terminal_post_in_category(comicpress_all_comic_categories_string(), false); } else { $latest_comic = comicpress_get_terminal_post_in_category(comicpress_all_comic_categories_string(), true); } $archive_year = get_post_time('Y', false, $latest_comic, true); } if (empty($archive_year)) { $archive_year = date('Y'); } $is_comic = false; while (have_posts()) { the_post(); ?> <div <?php post_class(); ?> > <?php comicpress_display_post_thumbnail($is_comic);
</div> </div> <ul id="storyline" class="level-0"> <?php if (comicpress_themeinfo('enable-storyline-support') == 1) { if (($result = comicpress_themeinfo('storyline-category-order')) !== false) { $categories_by_id = comicpress_get_comic_category_objects_by_id(); $current_depth = 0; $storyline_root = " class=\"storyline-root\""; foreach (explode(",", $result) as $node) { $parts = explode("/", $node); $target_depth = count($parts) - 2; $category_id = end($parts); $category = $categories_by_id[$category_id]; $description = $category->description; $first_comic_in_category = comicpress_get_terminal_post_in_category($category_id); $first_comic_permalink = get_permalink($first_comic_in_category->ID); $archive_image = get_comic_url('mini', $first_comic_in_category); $post_title = $first_comic_in_category->post_title; if (!empty($archive_image) && is_array($archive_image)) { $archive_image = reset($archive_image); } if ($target_depth < $current_depth) { echo str_repeat("</ul></li>", $current_depth - $target_depth); } if ($target_depth > $current_depth) { for ($i = $current_depth; $i < $target_depth; ++$i) { $next_i = $i + 1; echo "<li><ul class=\"level-{$next_i}\">"; } }
function comicpress_get_terminal_post_of_chapter_permalink($first = true) { global $post; $category = get_the_category($post->ID); $term_post = comicpress_get_terminal_post_in_category($category[0]->cat_ID, $first, false); if (is_object($term_post)) { if (isset($term_post->ID)) { return get_permalink($term_post->ID); } } return false; }
function widget($args, $instance) { global $wp_query, $post; Protect(); $this_permalink = get_permalink(); $temp_query = $wp_query->is_single; $wp_query->is_single = true; if ($instance['previous']) { $prev_comic = comicpress_get_previous_comic_permalink(false); } if ($instance['prev_in'] && comicpress_themeinfo('enable-storyline-support') == 1) { $prev_in_chapter = comicpress_get_previous_comic_permalink(true); } if ($instance['next']) { $next_comic = comicpress_get_next_comic_permalink(false); } if ($instance['next_in'] && comicpress_themeinfo('enable-storyline-support') == 1) { $next_in_chapter = comicpress_get_next_comic_permalink(true); } $wp_query->is_single = $temp_query; $temp_query = null; if ($instance['first']) { $first_comic = comicpress_get_first_comic_permalink(); } if ($instance['last']) { $last_comic = comicpress_get_last_comic_permalink(); } if ($instance['first_in'] && comicpress_themeinfo('enable-storyline-support') == 1) { $first_in_chapter = comicpress_get_terminal_post_of_chapter_permalink(true); } if ($instance['last_in'] && comicpress_themeinfo('enable-storyline-support') == 1) { $last_in_chapter = comicpress_get_terminal_post_of_chapter_permalink(false); } if ($instance['story_prev'] && comicpress_themeinfo('enable-storyline-support') == 1) { $prev_story = comicpress_get_previous_storyline_start_permalink(); } if ($instance['story_next'] && comicpress_themeinfo('enable-storyline-support') == 1) { $next_story = comicpress_get_next_storyline_start_permalink(); } $latest_comic = get_permalink(comicpress_get_terminal_post_in_category(comicpress_all_comic_categories_string(), false)); UnProtect(); ?> <div class="comic_navi_wrapper"> <table class="comic_navi"> <tr> <td class="comic_navi_left"> <?php if ($instance['first']) { if (!empty($first_comic) && $first_comic != $this_permalink) { ?> <a href="<?php echo $first_comic; ?> " class="navi navi-first" title="<?php echo $instance['first_title']; ?> "><?php echo $instance['first_title']; ?> </a> <?php } else { ?> <span class="navi navi-first navi-void"><?php echo $instance['first_title']; ?> </span> <?php } } if ($instance['first_in'] && comicpress_themeinfo('enable-storyline-support') == 1) { if (!empty($first_in_chapter) && $first_in_chapter != $this_permalink) { ?> <a href="<?php echo $first_in_chapter; ?> " class="navi navi-firstinchap" title="<?php echo $instance['first_in_title']; ?> "><?php echo $instance['first_in_title']; ?> </a> <?php } else { ?> <span class="navi navi-firstinchap navi-void"><?php echo $instance['first_in_title']; ?> </span> <?php } } if ($instance['story_prev'] && comicpress_themeinfo('enable-storyline-support') == 1) { if (!empty($prev_story)) { ?> <a href="<?php echo $prev_story; ?> " class="navi navi-prevchap" title="<?php echo $instance['story_prev_title']; ?> "><?php echo $instance['story_prev_title']; ?> </a> <?php } else { ?> <span class="navi navi-prevchap navi-void"><?php echo $instance['story_prev_title']; ?> </span> <?php } } if ($instance['prev_in'] && comicpress_themeinfo('enable-storyline-support') == 1) { if (!empty($prev_in_chapter)) { ?> <a href="<?php echo $prev_in_chapter; ?> " class="navi navi-prev-in" title="<?php echo $instance['prev_in_title']; ?> "><?php echo $instance['prev_in_title']; ?> </a> <?php } else { ?> <span class="navi navi-prev-in navi-void"><?php echo $instance['prev_in_title']; ?> </span> <?php } } if ($instance['previous']) { if (!empty($prev_comic)) { ?> <a href="<?php echo $prev_comic; ?> " class="navi navi-prev" title="<?php echo $instance['previous_title']; ?> "><?php echo $instance['previous_title']; ?> </a> <?php } else { ?> <span class="navi navi-prev navi-void"><?php echo $instance['previous_title']; ?> </span> <?php } } ?> </td> <td class="comic_navi_center"> <?php if ($instance['archives'] && !empty($instance['archive_path'])) { ?> <a href="<?php echo $instance['archive_path']; ?> " class="navi navi-archives navi-archive" title="<?php echo $instance['archives_title']; ?> "><?php echo $instance['archives_title']; ?> </a> <?php } if ($instance['random']) { ?> <a href="<?php echo home_url(); ?> /?randomcomic&nocache=1" class="navi navi-random" title="<?php echo $instance['random_title']; ?> "><?php echo $instance['random_title']; ?> </a> <?php } if ($instance['comictitle']) { ?> <span class="navi-comictitle"><a href="<?php the_permalink(); ?> ">"<?php the_title(); ?> "</a></span> <?php } if ($instance['comments']) { ?> <a href="<?php the_permalink(); ?> #comment" class="navi navi-comments" title="<?php echo $instance['comments_title']; ?> "><span class="navi-comments-count"><?php comments_number('0', '1', '%'); ?> </span><?php echo $instance['comments_title']; ?> </a> <?php } if (comicpress_themeinfo('enable_buy_print') && $instance['buyprint']) { if (strpos(comicpress_themeinfo('buy_print_url'), '?') !== false) { $bpsep = '&'; } else { $bpsep = '?'; } ?> <a href="<?php echo comicpress_themeinfo('buy_print_url'); echo $bpsep; ?> comic=<?php echo $post->ID; ?> " class="navi navi-buyprint" title="<?php echo $instance['buyprint_title']; ?> "><?php echo $instance['buyprint_title']; ?> </a> <?php } if ($instance['sharethis']) { $url = get_permalink($post->ID); $title = $post->post_title; $title = str_replace(' ', '%20', $title); $rss = get_bloginfo('rss2_url'); $blogname = urlencode(get_bloginfo('name') . " " . get_bloginfo('description')); // Grab the excerpt, if there is no excerpt, create one $excerpt = urlencode(strip_tags(strip_shortcodes($post->post_excerpt))); if ($excerpt == "") { $excerpt = urlencode(substr(strip_tags(strip_shortcodes($post->post_content)), 0, 250)); } // Clean the excerpt for use with links $excerpt = str_replace('+', '%20', $excerpt); ?> <script type="text/javascript"> function sharethis() { var sharewin = document.getElementById('navi-share-box'); if ( sharewin.style.display == 'block' ) { sharewin.style.display = 'none'; } else { sharewin.style.display = 'block'; } } </script> <a href="javascript:sharethis()" class="navi" id="navi-share" title="<?php echo $instance['sharethis_title']; ?> "><?php echo $instance['sharethis_title']; ?> </a> <?php } if ($instance['subscribe']) { ?> <a href="<?php bloginfo('rss2_url'); ?> " class="navi navi-subscribe" title="<?php echo $instance['subscribe_title']; ?> "><?php echo $instance['subscribe_title']; ?> </a> <?php } ?> </td> <td class="comic_navi_right"> <?php if ($instance['next']) { if (!empty($next_comic)) { ?> <a href="<?php echo $next_comic; ?> " class="navi navi-next" title="<?php echo $instance['next_title']; ?> "><?php echo $instance['next_title']; ?> </a> <?php } else { ?> <span class="navi navi-next navi-void"><?php echo $instance['next_title']; ?> </span> <?php } } if ($instance['next_in'] && comicpress_themeinfo('enable-storyline-support') == 1) { if (!empty($next_in_chapter)) { ?> <a href="<?php echo $next_in_chapter; ?> " class="navi navi-next-in" title="<?php echo $instance['next_in_title']; ?> "><?php echo $instance['next_in_title']; ?> </a> <?php } else { ?> <span class="navi navi-next-in navi-void"><?php echo $instance['next_in_title']; ?> </span> <?php } } if ($instance['story_next'] && comicpress_themeinfo('enable-storyline-support') == 1) { if (!empty($next_story) && !is_home()) { ?> <a href="<?php echo $next_story; ?> " class="navi navi-nextchap" title="<?php echo $instance['story_next_title']; ?> "><?php echo $instance['story_next_title']; ?> </a> <?php } else { ?> <span class="navi navi-nextchap navi-void"><?php echo $instance['story_next_title']; ?> </span> <?php } } if ($instance['last_in'] && comicpress_themeinfo('enable-storyline-support') == 1) { if (!empty($last_in_chapter) && $last_in_chapter != $this_permalink) { ?> <a href="<?php echo $last_in_chapter; ?> " class="navi navi-lastinchap" title="<?php echo $instance['last_in_title']; ?> "><?php echo $instance['last_in_title']; ?> </a> <?php } else { ?> <span class="navi navi-lastinchap navi-void"><?php echo $instance['last_in_title']; ?> </span> <?php } } if ($instance['last']) { if (!empty($last_comic) && $last_comic != $this_permalink) { if (isset($instance['lastgohome']) && $instance['lastgohome']) { ?> <a href="/" class="navi navi-last" title="<?php echo $instance['last_title']; ?> "><?php echo $instance['last_title']; ?> </a> <?php } else { ?> <a href="<?php echo $last_comic; ?> " class="navi navi-last" title="<?php echo $instance['last_title']; ?> "><?php echo $instance['last_title']; ?> </a> <?php } ?> <?php } else { ?> <span class="navi navi-last navi-void"><?php echo $instance['last_title']; ?> </span> <?php } } ?> </td> </tr> </table> <?php if ($instance['sharethis']) { ?> <div id="navi-share-box"> <a href="http://reddit.com/submit?url=<?php echo $url; ?> &title=<?php echo comicpress_clean_url($title); ?> " title="Reddit">Reddit</a> <a href="http://digg.com/submit?phase=2&url=<?php echo $url; ?> &title=<?php echo $title; ?> " title="Digg">Digg</a> <a href="http://www.facebook.com/share.php?u=<?php echo $url; ?> " title="Facebook">Facebook</a> <a href="http://www.myspace.com/Modules/PostTo/Pages/?l=3&u=<?php echo $url; ?> &t=<?php echo $title; ?> &c=" title="MySpace">MySpace</a> <a href="http://del.icio.us/post?url=<?php echo $url; ?> " title="Delicious">Delicious</a> <a href="http://www.stumbleupon.com/submit?url=<?php echo $url; ?> &title=<?php echo $title; ?> " title="Stumbleupon">Stumbleupon</a> <a href="http://buzz.yahoo.com/submit/?submitUrl=<?php echo $url; ?> &submitHeadline=<?php echo $title; ?> " title="Buzz Up!">Buzz Up!</a> <a href="http://www.mixx.com/submit?page_url=<?php echo $url; ?> " title="Mixx">Mixx</a> <a href="http://www.technorati.com/faves?add=<?php echo $url; ?> " title="Technorati">Technorati</a> <a href="http://www.google.com/bookmarks/mark?op=edit&bkmk=<?php echo $url; ?> &title=<?php echo $title; ?> " title="Google Bookmarks">Google Bookmarks</a> <a href="http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&u=<?php echo $url; ?> &t=<?php echo $title; ?> " title="Yahoo Bookmarks">Yahoo Bookmarks</a> <a href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=<?php echo $url; ?> &t=<?php echo $title; ?> " title="Yahoo MyWeb">Yahoo MyWeb</a> <a href="https://favorites.live.com/quickadd.aspx?marklet=1&mkt=en-us&url=<?php echo $url; ?> &title=<?php echo $title; ?> " title="Windows Live">Windows Live</a> <a href="http://www.propeller.com/submit/?U=<?php echo $url; ?> &T=<?php echo $title; ?> " title="Propeller">Propeller</a> <a href="http://friendfeed.com/share?url=<?php echo $url; ?> &title=<?php echo $title; ?> " title="FriendFeed">FriendFeed</a> <a href="http://www.newsvine.com/_tools/seed&save?popoff=0&u=<?php echo $url; ?> &h=<?php echo $title; ?> " title="Newsvine">Newsvine</a> <a href="http://www.xanga.com/private/editorx.aspx?t=<?php echo $title; ?> &u=<?php echo $url; ?> &s=" title="Xanga">Xanga</a> <a href="http://www.linkedin.com/shareArticle?mini=true&url=<?php echo $url; ?> &title=<?php echo $title; ?> &summary=<?php echo $excerpt; ?> &source=" title="LinkedIn">LinkedIn</a> <a href="http://blinklist.com/index.php?Action=Blink/addblink.php&Url=<?php echo $url; ?> &Title=<?php echo $title; ?> " title="Blinklist">Blinklist</a> <a href="http://twitter.com/intent/tweet?original_referer=<?php echo $url; ?> &source=tweetbutton&text=<?php echo $title; ?> &url=<?php echo $url; ?> " title="Twitter">Twitter</a> </div> <?php } ?> </div> <?php // } }
function widget($args, $instance) { global $wp_query, $post; Protect(); 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; } ?> <div class="archive-dropdown-wrap"> <select name="archive-dropdown" class="archive-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'> <option value=""><?php echo esc_attr(__('Archives...', 'comicpress')); ?> </option> <?php switch ($instance['mode']) { case "monthly": wp_get_archives('type=monthly&format=option&show_post_count=-1'); break; case "yearly": wp_get_archives('type=yearly&format=option&show_post_count=-1'); break; case "allposts": wp_get_archives('type=postbypost&format=option&show_post_count=-1'); break; case "blogposts": $comicArchive = new WP_Query(); $comicArchive->query('showposts=-1&cat=-' . comicpress_exclude_comic_categories()); while ($comicArchive->have_posts()) { $comicArchive->the_post(); ?> <option value="<?php echo get_permalink($post->ID); ?> "><?php the_title(); ?> </option> <?php } break; case "comicposts": $comicArchive = new WP_Query(); $comicArchive->query('showposts=-1&cat=' . comicpress_all_comic_categories_string()); while ($comicArchive->have_posts()) { $comicArchive->the_post(); ?> <option value="<?php echo get_permalink($post->ID); ?> "><?php the_title(); ?> </option> <?php } break; case "currentcat": $currentcat = get_the_category($post->ID); $currentcat = $currentcat[0]->cat_ID; $comicArchive = new WP_Query(); $comicArchive->query('showposts=-1&cat=' . $currentcat); while ($comicArchive->have_posts()) { $comicArchive->the_post(); ?> <option value="<?php echo get_permalink($post->ID); ?> "><?php the_title(); ?> </option> <?php } break; case "allcats": $args = array('hide_empty' => 1, 'orderby' => 'group'); $categories = get_categories($args); foreach ($categories as $cat) { if ($cat->category_count > 0) { $option = '<option value="' . get_category_link($cat->term_id) . '">'; $option .= $cat->cat_name; $option .= ' (' . $cat->category_count . ')'; $option .= '</option>'; echo $option; } } break; case "blogcats": $args = array('hide_empty' => 1, 'orderby' => 'group', 'order' => 'ASC', 'exclude' => comicpress_all_comic_categories_string()); $categories = get_categories($args); foreach ($categories as $cat) { if ($cat->category_count > 0) { $option = '<option value="' . get_category_link($cat->term_id) . '">'; $option .= $cat->cat_name; $option .= ' (' . $cat->category_count . ')'; $option .= '</option>'; echo $option; } } break; case "storylines": if (($result = comicpress_themeinfo('storyline-category-order')) !== false) { $comicpress_storyline_dropdown_archive = wp_cache_get('comicpress', 'archivedropdown'); if (empty($comicpress_storyline_dropdown_archive)) { $categories_by_id = comicpress_get_comic_category_objects_by_id(); $current_depth = 0; $comicpress_storyline_dropdown_archive = ''; foreach (explode(",", $result) as $node) { $parts = explode("/", $node); $target_depth = count($parts) - 1; $category_id = end($parts); $category = $categories_by_id[$category_id]; $description = $category->description; $first_comic_in_category = comicpress_get_terminal_post_in_category($category_id); $first_comic_permalink = get_permalink($first_comic_in_category->ID); $padding = str_repeat(" ", $target_depth - 1); $option = '<option value="' . get_category_link($category_id) . '">'; $option .= $padding . $category->name; if ($category->count > 0) { $option .= ' (' . $category->count . ')'; } $option .= '</option>' . "\r\n"; $comicpress_storyline_dropdown_archive .= $option; $current_depth = $target_depth; } wp_cache_set('comicpress', $comicpress_storyline_dropdown_archive, 'archivedropdown', 7200); } echo $comicpress_storyline_dropdown_archive; } break; case "comiccats": default: $args = array('hierarchical ' => 1, 'orderby' => 'group', 'include' => comicpress_all_comic_categories_string()); $categories = get_categories($args); foreach ($categories as $cat) { if ($cat->category_count > 0) { $option = '<option value="' . get_category_link($cat->term_id) . '">'; $option .= $cat->cat_name; $option .= ' (' . $cat->category_count . ')'; $option .= '</option>'; echo $option; } } break; } ?> </select> </div> <?php echo $after_widget; UnProtect(); }