// // Note that it's quite possible to slurp up the wrong file if your expressions are too broad. $comic_filename_filters = array(); $comic_filename_filters['default'] = "{date}*.*"; require_once(dirname(__FILE__) . '/options.php'); // load all of the comic & non-comic category information add_action('init', '__comicpress_init'); function __comicpress_init() { global $comicpress; foreach (glob(dirname(__FILE__) . '/classes/*.inc') as $file) { if (is_file($file)) { require_once($file); } } $comicpress = new ComicPress(); $comicpress->init(); if (is_dir($addons_dir = (dirname(__FILE__) . '/addons'))) { $entries = glob($addons_dir . '/*'); if (is_array($entries)) { foreach ($entries as $entry) { if (is_dir($entry)) { $classname = basename($entry); if (file_exists($entry . "/${classname}.inc")) { require_once($entry . "/${classname}.inc"); $classname = "ComicPressAddon${classname}"; if (class_exists($classname)) { $addon = new $classname(); $addon->init(&$comicpress); if (is_admin()) { add_action('admin_notices', array(&$addon, 'display_messages')); if (is_array($_POST['cp'])) { if (isset($_POST['cp']['_nonce'])) { if (wp_verify_nonce($_POST['cp']['_nonce'], 'comicpress')) { $addon->handle_update(); } } } } } } } } } } //get_all_comic_categories(); } function the_comic_img_tag($url, $type, $additional_parameters = array()) { global $comicpress; echo $comicpress->get_comic_img_tag($url, $type, $additional_parameters); } /** * Get the hyperlink to the first comic post in the database. * @return string The hyperlink to the first comic post, or false. */ function get_first_comic_permalink() { global $comicpress; $terminal = $comicpress->get_first_comic(); return !empty($terminal) ? get_permalink($terminal->ID) : false; } /** * Get the hyperlink to the last comic post in the database. * @return string The hyperlink to the first comic post, or false. */ function get_last_comic_permalink() { global $comicpress; $terminal = $comicpress->get_last_comic(); return !empty($terminal) ? get_permalink($terminal->ID) : false; } /** * Get the link to the previous comic from the current one. */ function previous_comic_link($format, $link) { global $non_comic_categories; previous_post_link($format, $link, false, $non_comic_categories); } /** * Get the link to the next comic from the current one. */ function next_comic_link($format, $link) { global $non_comic_categories; next_post_link($format, $link, false, $non_comic_categories); } /** * Get the adjacent comic from the current one. * @param int $category The category to use. * @param boolean $next True if the next chronological comic should be retrieved. * @return array The WordPress post object for the comic post. */ function get_adjacent_comic($category, $next = false) { } /** * Find a comic file in the filesystem. * @param string $folder The folder name to search. * @param string $override_post A WP Post object to use in place of global $post. * @param string $filter The $comic_filename_filters to use. * @return string The relative path to the comic file, or false if not found. */ function get_comic_path($folder = 'comic', $override_post = null, $filter = 'default') { global $post, $comic_filename_filters, $comic_folder, $archive_comic_folder, $rss_comic_folder, $comic_pathfinding_errors; if (isset($comic_filename_filters[$filter])) { $filter_to_use = $comic_filename_filters[$filter]; } else { $filter_to_use = '{date}*.*'; } switch ($folder) { case "rss": $folder_to_use = $rss_comic_folder; break; case "archive": $folder_to_use = $archive_comic_folder; break; case "comic": default: $folder_to_use = $comic_folder; break; } $post_to_use = (is_object($override_post)) ? $override_post : $post; $post_date = mysql2date(CP_DATE_FORMAT, $post_to_use->post_date); $filter_with_date = str_replace('{date}', $post_date, $filter_to_use); if (count($results = glob("${folder_to_use}/${filter_with_date}")) > 0) { return reset($results); } $comic_pathfinding_errors[] = sprintf(__("Unable to find the file in the %s folder that matched the pattern %s. Check your WordPress and ComicPress settings.", 'comicpress'), $folder, $filter_with_date); return false; } /** * Find a comic file in the filesystem and return an absolute URL to that file. * @param string $folder The folder name to search. * @param string $override_post A WP Post object to use in place of global $post. * @param string $filter The $comic_filename_filters to use. * @return string The absolute URL to the comic file, or false if not found. */ function get_comic_url($folder = 'comic', $override_post = null, $filter = 'default') { if (($result = get_comic_path($folder, $override_post, $filter)) !== false) { return get_option('home') . '/' . $result; } return false; } // ComicPress Template Functions function the_comic($filter = 'default') { echo get_comic_url('comic', null, $filter); } //The following is deprecated... function comic_display($filter = 'default') { echo get_comic_url('comic', null, $filter); } function the_comic_archive($filter = 'default') { echo get_comic_url('archive', null, $filter); } //The following is deprecated... function comic_archive($filter = 'default') { echo get_comic_url('archive', null, $filter); } function the_comic_rss($filter = 'default') { echo get_comic_url('rss', null, $filter); } //The following is deprecated... function comic_rss($filter = 'default') { echo get_comic_url('rss', null, $filter); } /** * Display the list of Storyline categories. */ function comicpress_list_storyline_categories($args = "") { global $category_tree; $defaults = array( 'style' => 'list', 'title_li' => __('Storyline') ); $r = wp_parse_args($args, $defaults); extract($r); $categories_by_id = get_all_category_objects_by_id(); $output = ''; if ($style == "list") { $output .= '
  • '; } if ($title_li && ($style == "list")) { $output .= $title_li; } if ($style == "list") { $output .= "
  • ", $current_depth); } if ($style == "list") { $output .= ""; } echo $output; } /** * Display text when image (comic) is hovered * Text is taken from a custom field named "hovertext" */ function the_hovertext() { echo get_the_hovertext(); } function get_the_hovertext() { $hovertext = get_post_meta(get_the_ID(), "hovertext", true ); return (empty($hovertext)) ? get_the_title() : $hovertext; } /** * Display the comic transcript * Transcript must be entered into a custom field named "transcript" * @param string $displaymode, "raw" (straight from the field), "br" (includes html line breaks), "styled" (fully css styled with JavaScript expander) */ function the_transcript($displaymode = 'raw') { $transcript = get_post_meta( get_the_ID(), "transcript", true ); switch ($displaymode) { case "raw": echo $transcript; break; case "br": echo nl2br($transcript); break; case "styled": if (!empty($transcript)) { ?>
    ↓ Transcript


    <?php the_title() ?>

    query('showposts=1&orderby=rand&cat='.get_all_comic_categories_as_cat_string()); while ($randomComicQuery->have_posts()) : $randomComicQuery->the_post(); $random_comic_id = get_the_ID(); endwhile; wp_redirect( get_permalink( $random_comic_id ) ); exit; } if ( isset( $_GET['randomcomic'] ) ) add_action( 'template_redirect', 'random_comic' ); // Register Sidebar and Define Widgets if ( function_exists('register_sidebar') ) register_sidebar(); function widget_comicpress_calendar() { ?>
  • Latest Comics

  • ? Random Comic

  • postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id "; } return $join; } add_filter('posts_join', 'szub_search_custom_join'); function szub_search_custom_where($where) { global $wp_query, $wp_version, $wpdb; if( !empty($wp_query->query_vars['s']) && szub_is_search_key() ) { $search = $wp_query->query_vars['s']; $key = $_GET['key']; $status = ($wp_version >= 2.1) ? 'post_type = \'post\' AND post_status = \'publish\'' : 'post_status = \'publish\''; $where = " AND $wpdb->postmeta.meta_key = '$key' AND $wpdb->postmeta.meta_value LIKE '%$search%' AND $status "; } return $where; } add_filter('posts_where', 'szub_search_custom_where'); function szub_search_custom_template($template) { if( is_search() && szub_is_search_key() && file_exists(TEMPLATEPATH . '/search-transcript.php') ) $template = TEMPLATEPATH . '/search-transcript.php'; if( !$template ) $template = get_query_template('search'); return $template; } add_filter('search_template', 'szub_search_custom_template'); function szub_is_search_key($key='') { if( isset($_GET['key']) ) { if( !empty($_GET['key']) || (!empty($key) && ($key = $_GET['key'])) ) return true; } return false; } ?>