function ceo_display_comic_area() { global $wp_query, $post; if (is_single()) { ceo_display_comic_wrapper(); } else { if ((is_home() || is_front_page()) && !is_paged() && !ceo_pluginfo('disable_comic_on_home_page')) { ceo_protect(); $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) ? $chapter_on_home->slug : ''; $order = ceo_pluginfo('display_first_comic_on_home_page') ? 'asc' : 'desc'; $comic_args = array('showposts' => 1, 'posts_per_page' => 1, 'post_type' => 'comic', 'order' => $order, 'chapters' => $chapter_on_home); $comicFrontpage = new WP_Query(); $comicFrontpage->query($comic_args); while ($comicFrontpage->have_posts()) { $comicFrontpage->the_post(); ceo_display_comic_wrapper(); } ceo_unprotect(); } elseif (is_archive() && (isset($wp_query->query_vars['taxonomy']) && isset($wp_query->query_vars['chapters'])) && $wp_query->query_vars['taxonomy'] == 'chapters' && ceo_pluginfo('enable_chapter_landing') && !is_paged()) { ceo_protect(); $order = ceo_pluginfo('enable_chapter_landing_first') ? 'asc' : 'desc'; $comic_args = array('showposts' => 1, 'posts_per_page' => 1, 'post_type' => 'comic', 'order' => $order, 'chapters' => $wp_query->query_vars['chapters']); $comicFrontpage = new WP_Query(); $comicFrontpage->query($comic_args); while ($comicFrontpage->have_posts()) { $comicFrontpage->the_post(); ceo_display_comic_wrapper(); } ceo_unprotect(); } } }
function widget($args, $instance) { global $post; extract($args, EXTR_SKIP); echo $before_widget; ceo_protect(); $title = empty($instance['title']) ? __('Latest Comics', 'comiceasel') : apply_filters('widget_title', $instance['title']); if (!empty($title)) { echo $before_title . $title . $after_title; } $args = array('showposts' => (int) $instance['count'], 'post_type' => 'comic'); $latestcomics = get_posts($args); ?> <ul> <?php foreach ($latestcomics as $post) { ?> <li><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></li> <?php } ?> </ul> <?php echo $after_widget; ceo_unprotect(); }
function widget($args, $instance) { extract($args, EXTR_SKIP); echo $before_widget; ceo_protect(); $title = empty($instance['title']) ? __('Scheduled Comics', 'comiceasel') : apply_filters('widget_title', $instance['title']); if (!empty($title)) { echo $before_title . $title . $after_title; } $args = array('post_status' => 'future', 'showposts' => -1, 'post_type' => 'comic'); $scheduled_posts = get_posts($args); if (empty($scheduled_posts)) { echo '<ul><li>' . __('None', 'comiceasel') . '</li></ul>'; } else { ?> <ul> <?php foreach ($scheduled_posts as $post) { ?> <li><span class="scheduled-post-date"><?php echo date('m/d/Y', strtotime($post->post_date)); ?> </span> <span class="scheduled-post-title"><?php echo $post->post_title; ?> </span></li> <?php } ?> </ul> <?php } echo $after_widget; ceo_unprotect(); }
function ceo_list_jump_to_comic($exclude = '', $return = false) { global $post; ceo_protect(); $output = ''; $terms = wp_get_object_terms($post->ID, 'chapters'); if (!empty($terms)) { $term = reset($terms); // only one chapter $output = '<form method="get" class="comic-list-dropdown-form">'; $output .= '<select onchange="document.location.href=this.options[this.selectedIndex].value;">'; $level = 0; $output .= '<option class="level-select" value="">' . __('Jump To', 'comiceasel') . '</option>'; $post_args = array('showposts' => -1, 'post_type' => 'comic', 'order' => 'ASC', 'post_status' => 'publish', 'chapters' => $term->slug); $qposts = get_posts($post_args); foreach ($qposts as $qpost) { $permalink = get_permalink($qpost->ID); if (!empty($permalink)) { $output .= '<option class="level-0" value="' . esc_url($permalink) . '">' . $qpost->post_title . '</option>'; } } $output .= '</select>'; $output .= '<noscript>'; $output .= '<div><input type="submit" value="View" /></div>'; $output .= '</noscript>'; $output .= '</form>'; if ($return) { return $output; } else { echo $output; } } ceo_unprotect(); }
function widget($args, $instance) { global $post, $wp_query; if (!is_home() && $instance['onlyhome']) { return; } if (is_page() || is_archive() || is_search() || is_404()) { return; } extract($args, EXTR_SKIP); ceo_protect(); if ((is_home() || is_front_page()) && !is_paged() && !ceo_pluginfo('disable_comic_on_home_page')) { $order = ceo_pluginfo('display_first_comic_on_home_page') ? 'asc' : 'desc'; $args = array('showposts' => 1, 'posts_per_page' => 1, 'order' => $order, 'post_type' => 'comic'); $posts = get_posts($args); foreach ($posts as $post) { setup_postdata($post); if (!($instance['hidecontent'] && empty($post->post_content))) { echo $before_widget; $temp_query = $wp_query->is_single; $wp_query->is_single = true; $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']); ceo_display_comic_small_blog_post($instance); $wp_query->is_single = $temp_query; echo $after_widget; } } } elseif ($post->post_type == 'comic') { setup_postdata($post); if (!($instance['hidecontent'] && empty($post->post_content)) && $post->post_type == 'comic') { echo $before_widget; $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']); if (!empty($title)) { echo "<div class=\"comic-post-widget-header\">" . $title . "</div>\r\n"; } ceo_display_comic_small_blog_post($instance); echo $after_widget; } } ceo_unprotect(); }
function ceo_comic_archive_jump_to_chapter($hide = true, $exclude = '', $showcount = false, $jumptoarchive = false, $echo = true, $render_as_list = false) { ceo_protect(); $output = ''; if ($render_as_list) { global $post; $the_terms = get_the_terms($post->ID, 'chapters'); // echo "<pre>the terms ";print_r($the_terms); echo "</pre>"; $args = array('walker' => new ceo_walker_taxonomy_list(), 'orderby' => 'menu_order', 'order' => 'ASC', 'show_count' => $showcount, 'hide_empty' => $hide, 'exclude' => $exclude, 'echo' => false, 'hierarchical' => 1, 'taxonomy' => 'chapters', 'current_category' => $the_terms, 'title_li' => null, 'jumptoarchive' => $jumptoarchive, 'render_as_list' => $render_as_list); $output .= '<ul class="chapter-select">'; $output .= wp_list_categories($args); $output .= '</ul>'; } else { $args = array('walker' => new ceo_walker_taxonomy_dropdown(), 'show_option_all' => __('Select', 'comiceasel') . ' ' . ucwords(ceo_pluginfo('chapter_type_slug_name')), 'option_none_value' => '-1', 'orderby' => 'menu_order', 'order' => 'ASC', 'name' => ceo_pluginfo('chapter_type_slug_name'), 'show_count' => $showcount, 'hide_empty' => $hide, 'exclude' => $exclude, 'echo' => false, 'hierarchical' => 1, 'taxonomy' => 'chapters', 'hide_if_empty' => $hide, 'value_field' => 'slug', 'jumptoarchive' => $jumptoarchive, 'render_as_list' => $render_as_list); $output .= '<form id="chapter-select" class="chapter-select" method="get">' . "\r\n"; $select = wp_dropdown_categories($args); $replace = '<select$1 onchange="document.location.href=this.options[this.selectedIndex].value;">'; $output .= preg_replace('#<select([^>]*)>#', $replace, $select); $output .= "\t<noscript>\r\n"; $output .= "\t\t<input type=\"submit\" value=\"View\" />\r\n"; $output .= "\t</noscript>\r\n"; $output .= "</form>\r\n"; } ceo_unprotect(); if ($echo) { echo $output; } else { return $output; } }
function ceo_random_comic_shortcode($atts, $content = '') { extract(shortcode_atts(array('character' => '', 'size' => 'thumbnail', 'slug' => '', 'chapter' => '', 'orderby' => 'rand', 'month' => '', 'day' => '', 'year' => ''), $atts)); global $post; $args = array('name' => $slug, 'orderby' => $orderby, 'showposts' => 1, 'post_type' => 'comic', 'chapters' => $chapter, 'characters' => $character, 'exclude' => $post->ID, 'year' => $year, 'month' => $month, 'day' => $day); ceo_protect(); $thumbnail_query = new WP_Query($args); $output = ''; $archive_image = ''; if ($thumbnail_query->have_posts()) { while ($thumbnail_query->have_posts()) { $thumbnail_query->the_post(); $the_permalink = get_permalink($post->ID); $output = '<div class="rand-comic-wrap rand-comic-' . $post->ID . '">'; if (has_post_thumbnail($post->ID)) { $output .= "<a href=\"" . $the_permalink . "\" rel=\"bookmark\" title=\"" . get_the_title() . "\">" . get_the_post_thumbnail($post->ID, $size) . "</a>\r\n"; } else { $output .= "No Thumbnail Found."; } $output .= "</div>\r\n"; } } ceo_unprotect(); return $output; }
function widget($args, $instance) { global $post, $wp_query; extract($args, EXTR_SKIP); echo $before_widget; ceo_protect(); if (!empty($instance)) { extract($instance); } ?> <div id="wp-calendar-head"></div> <div id="wp-calendar-wrap"> <?php if (!empty($thumbnail)) { ?> <div class="wp-calendar-download"> <?php if (!empty($link)) { ?> <a href="<?php echo esc_attr($link); ?> "><img src="<?php echo esc_attr($thumbnail); ?> " class="wp-calendar-thumb" alt="" /></a> <?php } else { ?> <img src="<?php echo esc_attr($thumbnail); ?> " class="wp-calendar-thumb" alt="" /> <?php } ?> <div class="wp-calendar-download-links"> <?php if (!empty($small) || !empty($medium) || !empty($large)) { ?> <?php _e('DOWNLOAD', 'comiceasel'); ?> <?php foreach (array('small' => array(__('Download Small', 'comiceasel'), __('S', 'comiceasel')), 'medium' => array(__('Download Medium', 'comiceasel'), __('M', 'comiceasel')), 'large' => array(__('Download Large', 'comiceasel'), __('L', 'comiceasel'))) as $field => $text) { if (!empty(${$field})) { ?> <a href="<?php echo esc_attr(${$field}); ?> " title="<?php echo esc_attr($text[0]); ?> "><?php echo esc_html($text[1]); ?> </a><?php } } } ?> </div> </div> <?php } ?> <?php ceo_get_calendar(true, true, 'comic'); ?> </div> <div id="wp-calendar-foot"></div> <?php echo $after_widget; ceo_unprotect(); }
function ceo_comic_archive_jump_to_chapter($unhide = false, $exclude = '', $showcount = false, $jumptoarchive = true, $return = false) { ceo_protect(); $args = array('pad_counts' => 1, 'orderby' => 'menu_order', 'order' => 'ASC', 'hide_empty' => $unhide, 'exclude' => $exclude, 'parent' => 0); $parent_chapters = get_terms('chapters', $args); $output = '<form method="get" class="comic-archive-dropdown-form">'; $output .= '<select onchange="document.location.href=this.options[this.selectedIndex].value;">'; $level = 0; $output .= '<option class="level-select" value="">' . __('Select', 'comiceasel') . ' ' . ucwords(ceo_pluginfo('chapter_type_slug_name')) . '</option>'; if (!is_null($parent_chapters)) { foreach ($parent_chapters as $parent_chapter) { $thecount = $showcount ? ' (' . $parent_chapter->count . ')' : ''; if ($parent_chapter->count) { $permalink = ''; if (!$jumptoarchive) { $parent_args = array('numberposts' => 1, 'post_type' => 'comic', 'order' => 'ASC', 'post_status' => 'publish', 'chapters' => $parent_chapter->slug); $qposts = get_posts($parent_args); if (is_array($qposts) && !is_wp_error($qposts) && !empty($qposts)) { $qposts = reset($qposts); $permalink = get_permalink($qposts->ID); } } else { $permalink = get_term_link($parent_chapter->slug, 'chapters'); } if (!empty($permalink)) { $output .= '<option class="level-0" value="' . esc_url($permalink) . '">' . $parent_chapter->name . $thecount . '</option>'; } } elseif (!$unhide) { $output .= '<option class="level-0" value="" disabled>' . $parent_chapter->name . '</option>'; } $child_chapters = get_term_children($parent_chapter->term_id, 'chapters'); $args = array('pad_counts' => 1, 'orderby' => 'menu_order', 'order' => 'ASC', 'hide_empty' => $unhide, 'child_of' => $parent_chapter->term_id, 'exclude' => array($exclude)); $child_chapters = get_terms('chapters', $args); foreach ($child_chapters as $child) { $child_term = get_term_by('id', $child->term_id, 'chapters'); $thecount = 0; $thecount = $showcount ? '(' . $child_term->count . ')' : ''; if ($child_term->count) { $child_args = array('numberposts' => 1, 'post_type' => 'comic', 'order' => 'ASC', 'post_status' => 'publish', 'chapters' => $child_term->slug); if (!$jumptoarchive) { $qcposts = get_posts($child_args); if (is_array($qcposts)) { $qcposts = reset($qcposts); $permalink = get_permalink($qcposts->ID); } } else { $permalink = get_term_link($child_term->slug, 'chapters'); } if (!empty($permalink)) { $output .= '<option class="level-1" value="' . esc_url($permalink) . '"> ' . $child_term->name . ' ' . $thecount . '</option>'; } } } } } $output .= '</select>'; $output .= '<noscript>'; $output .= '<div><input type="submit" value="View" /></div>'; $output .= '</noscript>'; $output .= '</form>'; if ($return) { return $output; } else { echo $output; } ceo_unprotect(); }
function widget($args, $instance) { global $post; ceo_protect(); if (is_home() || is_front_page()) { $order = ceo_pluginfo('display_first_comic_on_home_page') ? 'asc' : 'desc'; $comic_args = array('showposts' => 1, 'posts_per_page' => 1, 'post_type' => 'comic', 'order' => $order); apply_filters('ceo_comic_navigation_widget_home_query_args_array', $comic_args); $comicFrontpage = new WP_Query(); $comicFrontpage->query($comic_args); while ($comicFrontpage->have_posts()) { $comicFrontpage->the_post(); $this->display_comic_nav_wrapper($args, $instance); } } else { $this->display_comic_nav_wrapper($args, $instance); } ceo_unprotect(); }
function widget($args, $instance) { global $post; extract($args, EXTR_SKIP); ceo_protect(); if (is_single() && $post->post_type == 'comic' || is_home() || is_front_page()) { if ((is_home() || is_front_page()) && (is_paged() || ceo_pluginfo('disable_comic_on_home_page') || is_page())) { return; } // This section allows the plugin to work in any sidebar even on home, except (paged) files if ((is_home() || is_front_page()) && !is_paged() && !ceo_pluginfo('disable_comic_on_home_page')) { $order = ceo_pluginfo('display_first_comic_on_home_page') ? 'asc' : 'desc'; $args = array('showposts' => 1, 'posts_per_page' => 1, 'order' => $order, 'post_type' => 'comic'); $posts = get_posts($args); $post = reset($posts); } $post_characters = get_the_terms($post->ID, 'characters'); if (!empty($post_characters)) { echo $before_widget; $title = apply_filters('widget_title', $instance['title']); if ($title) { echo $before_title . $title . $after_title; } ?> <div class="castrefwidget-wrapper"><?php foreach ($post_characters as $mychar) { $out[] = '<span class="castrefwidget-line casthover-hovercard-hook"><a href="' . get_term_link($mychar->slug, 'characters') . '"><div class="castrefwidget-block character-' . $mychar->slug . '"></div></a>' . ceo_insert_character_hovercard($mychar->slug) . '</span>'; } echo join('', $out); ?> </div><?php echo $after_widget; } ceo_unprotect(); } }
function widget($args, $instance) { global $post, $wp_query; extract($args, EXTR_SKIP); ceo_protect(); $current_permalink = ''; if (!is_404()) { $current_permalink = get_permalink($post->ID); } $current_post_id = ''; $chaptinfo = ''; $dateset = ''; if ($instance['inhistory']) { $day = get_the_date('d'); $month = get_the_date('m'); $dateset = '&month=' . $month . '&day=' . $day; $instance['random'] = true; /* set random to true even if false */ } if ($instance['thumbchapt'] !== 'All') { $chaptinfo = '&chapters=' . $instance['thumbchapt']; } if ($instance['first']) { $order = 'ASC'; } else { $order = 'DESC'; } $comic_query = 'showposts=' . $instance['thumbcount'] . '&order=' . $order . '&post_type=comic' . $chaptinfo . $dateset; if ($instance['random']) { $comic_query .= '&orderby=rand'; } if (!empty($post) && $instance['random']) { $current_post_id = $post->ID; $comic_query .= '&exclude=' . $current_post_id; } $thumbnail_size = isset($instance['thumbnail_size']) ? $instance['thumbnail_size'] : 'thumbnail'; $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 '<div class="comic-thumb-wrap comic-thumb-' . $post->ID . '">'; if ($instance['centering']) { echo "\r\n<center>\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 "<a href=\"" . $the_permalink . "\" rel=\"bookmark\" title=\"Permanent Link to " . get_the_title() . "\">" . $secondary_image . "</a>\r\n"; } else { if (has_post_thumbnail($post->ID)) { echo "<a href=\"" . $the_permalink . "\" rel=\"bookmark\" title=\"Permanent Link to " . get_the_title() . "\">" . get_the_post_thumbnail($post->ID, $thumbnail_size) . "</a>\r\n"; } else { echo "No Thumbnail Found."; } } } else { if (has_post_thumbnail($post->ID)) { echo "<a href=\"" . $the_permalink . "\" rel=\"bookmark\" title=\"Permanent Link to " . get_the_title() . "\">" . get_the_post_thumbnail($post->ID, $thumbnail_size) . "</a>\r\n"; } else { echo "No Thumbnail Found."; } } if ($instance['linktitle']) { echo '<div class="comic-thumb-title"><a href="' . $the_permalink . '" rel="bookmark" title="Permanent Link to ' . get_the_title() . '">' . get_the_title() . '</a></div><div class="clear"></div>'; } if ($instance['centering']) { echo "\r\n</center>\r\n"; } echo "</div>\r\n"; } } echo $after_widget; } ceo_unprotect(); }
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 '<div class="comic-thumb-wrap comic-thumb-' . $post->ID . '">'; if ($instance['centering']) { echo "\r\n<center>\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 '<a href="' . $the_permalink . '" rel="bookmark" title="' . __('Permanent Link to', 'comiceasel') . ' ' . get_the_title() . '">' . $secondary_image . '</a>' . "\r\n"; } else { if (has_post_thumbnail($post->ID)) { echo '<a href="' . $the_permalink . '" rel="bookmark" title="' . __('Permanent Link to', 'comiceasel') . ' ' . get_the_title() . '">' . get_the_post_thumbnail($post->ID, $thumbnail_size) . '</a>' . "\r\n"; } else { echo __('No Thumbnail Found.', 'comiceasel'); } } } else { if (has_post_thumbnail($post->ID)) { echo '<a href="' . $the_permalink . '" rel="bookmark" title="' . __('Permanent Link to', 'comiceasel') . ' ' . get_the_title() . '">' . get_the_post_thumbnail($post->ID, $thumbnail_size) . '</a>' . "\r\n"; } else { echo __('No Thumbnail Found.', 'comiceasel'); } } if ($instance['linktitle']) { echo '<div class="comic-thumb-title"><a href="' . $the_permalink . '" rel="bookmark" title="' . __('Permanent Link to', 'comiceasel') . ' ' . get_the_title() . '">' . get_the_title() . '</a></div><div class="clear"></div>'; } if ($instance['showdate']) { echo '<div class="comic-thumb-date">' . get_the_date(get_option('date_format')) . '</div>'; } if ($instance['centering']) { echo "\r\n</center>\r\n"; } echo "</div>\r\n"; } } echo $after_widget; } ceo_unprotect(); }