// // 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 .= '