function comicpress_create_comic_category_tree() { $categories_by_id = comicpress_get_comic_category_objects_by_id(); foreach (array_keys($categories_by_id) as $category_id) { $category_tree[] = $categories_by_id[$category_id]->parent . '/' . $category_id; } do { $all_ok = true; for ($i = 0; $i < count($category_tree); ++$i) { $current_parts = explode("/", $category_tree[$i]); if (reset($current_parts) != 0) { $all_ok = false; for ($j = 0; $j < count($category_tree); ++$j) { $j_parts = explode("/", $category_tree[$j]); if (end($j_parts) == reset($current_parts)) { $category_tree[$i] = implode("/", array_merge($j_parts, array_slice($current_parts, 1))); break; } } } } } while (!$all_ok); return $category_tree; }
} ?> <div class="post-content"> <div class="post-info"> <div class="post-text"> <h2 class="page-title"><?php the_title(); ?> </h2> </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); }
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(); }