//
// 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')) {
if (method_exists($addon, 'handle_update')) {
$addon->handle_update();
}
}
}
}
}
}
}
}
}
}
}
}
function in_comic_category() {
global $post, $comicpress;
return $comicpress->in_comic_category($post->ID);
}
/**
* 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 = 0;
foreach ($category_tree as $node) {
$parts = explode("/", $node);
$category_id = end($parts);
$target_depth = count($parts) - 2;
if ($target_depth > $current_depth) {
$output .= str_repeat("", ($target_depth - $current_depth));
}
if ($target_depth < $current_depth) {
$output .= str_repeat(" ", ($current_depth - $target_depth));
}
$output .= '';
$output .= $categories_by_id[$category_id]->cat_name;
$output .= " ";
$current_depth = $target_depth;
}
if ($current_depth > 0) {
$output .= str_repeat(" ", $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)) { ?>
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