2009-06-13 11:58:02 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// load all of the comic & non-comic category information
|
2009-07-04 16:08:02 +00:00
|
|
|
add_action('init', '__comicpress_init');
|
|
|
|
|
|
|
|
function __comicpress_init() {
|
2009-07-16 01:55:28 +00:00
|
|
|
global $comicpress, $wp_query;
|
2009-07-08 23:54:56 +00:00
|
|
|
|
2009-07-13 02:41:36 +00:00
|
|
|
if (current_user_can('edit_files')) {
|
|
|
|
wp_cache_flush();
|
|
|
|
}
|
|
|
|
|
2009-07-08 23:51:02 +00:00
|
|
|
foreach (glob(dirname(__FILE__) . '/classes/*.inc') as $file) {
|
|
|
|
if (is_file($file)) { require_once($file); }
|
|
|
|
}
|
|
|
|
|
|
|
|
$comicpress = new ComicPress();
|
|
|
|
$comicpress->init();
|
2009-07-13 02:51:15 +00:00
|
|
|
$addons = array();
|
2009-07-08 23:51:02 +00:00
|
|
|
|
|
|
|
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)) {
|
2009-07-13 02:51:15 +00:00
|
|
|
$addons[] = new $classname();
|
|
|
|
end($addons)->init(&$comicpress);
|
2009-08-04 01:28:59 +00:00
|
|
|
if (current_user_can('edit_posts')) {
|
2009-07-14 01:21:53 +00:00
|
|
|
if (is_array($_REQUEST['cp'])) {
|
|
|
|
if (isset($_REQUEST['cp']['_nonce'])) {
|
|
|
|
if (wp_verify_nonce($_REQUEST['cp']['_nonce'], 'comicpress')) {
|
2009-07-13 02:51:15 +00:00
|
|
|
if (method_exists(end($addons), 'handle_update')) {
|
|
|
|
end($addons)->handle_update();
|
2009-07-13 02:31:14 +00:00
|
|
|
}
|
2009-07-09 00:07:52 +00:00
|
|
|
}
|
2009-07-08 23:51:02 +00:00
|
|
|
}
|
|
|
|
}
|
2009-08-04 01:28:59 +00:00
|
|
|
if (is_admin()) {
|
|
|
|
add_action('admin_notices', array(end($addons), 'display_messages'));
|
|
|
|
} else {
|
|
|
|
add_action('wp_head', array(end($addons), 'display_messages'));
|
|
|
|
}
|
2009-07-08 23:51:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-07-23 22:25:02 +00:00
|
|
|
|
|
|
|
$layouts = $comicpress->get_layout_choices();
|
|
|
|
if (isset($layouts[$comicpress->comicpress_options['layout']])) {
|
|
|
|
if (isset($layouts[$comicpress->comicpress_options['layout']]['Sidebars'])) {
|
|
|
|
foreach (explode(",", $layouts[$comicpress->comicpress_options['layout']]['Sidebars']) as $sidebar) {
|
|
|
|
$sidebar = trim($sidebar);
|
|
|
|
register_sidebar($sidebar);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-07-07 02:45:17 +00:00
|
|
|
}
|
|
|
|
|
2009-07-20 01:29:43 +00:00
|
|
|
function comicpress_init() {
|
2009-07-16 01:55:28 +00:00
|
|
|
global $post, $comicpress;
|
|
|
|
|
|
|
|
if (!empty($post)) {
|
2009-07-30 00:07:56 +00:00
|
|
|
if (in_comic_category() && $comicpress->is_multicomic() && !is_index()) {
|
|
|
|
$comicpress->setup_multicomic_partial_paths($post->ID);
|
2009-07-16 01:55:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$comicpress->partial_paths[] = get_template_directory() . '/partials';
|
2009-07-20 01:29:43 +00:00
|
|
|
}
|
2009-07-16 01:55:28 +00:00
|
|
|
|
2009-07-20 01:29:43 +00:00
|
|
|
function comicpress_get_header() {
|
2009-07-16 01:55:28 +00:00
|
|
|
get_header();
|
|
|
|
}
|
|
|
|
|
2009-07-16 01:34:34 +00:00
|
|
|
function include_partial($partials = '') {
|
2009-07-23 22:25:02 +00:00
|
|
|
global $comicpress, $post, $nav_comics;
|
2009-07-19 23:08:27 +00:00
|
|
|
|
2009-07-16 01:34:34 +00:00
|
|
|
if (!is_array($partials)) {
|
|
|
|
$partials = func_get_args();
|
|
|
|
}
|
2009-07-19 23:20:13 +00:00
|
|
|
|
2009-07-19 23:08:27 +00:00
|
|
|
$target = $comicpress->get_partial_path($partials);
|
|
|
|
|
2009-07-28 02:09:20 +00:00
|
|
|
if ($target !== false) {
|
|
|
|
ob_start();
|
|
|
|
include($target);
|
|
|
|
echo apply_filters("comicpress_partial", ob_get_clean(), $target);
|
|
|
|
}
|
2009-07-16 01:34:34 +00:00
|
|
|
}
|
|
|
|
|
2009-07-12 23:31:47 +00:00
|
|
|
function in_comic_category() {
|
|
|
|
global $post, $comicpress;
|
2009-07-09 04:57:00 +00:00
|
|
|
|
2009-07-12 23:31:47 +00:00
|
|
|
return $comicpress->in_comic_category($post->ID);
|
2009-06-13 11:58:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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 .= '<li class="categories storyline">'; }
|
|
|
|
if ($title_li && ($style == "list")) { $output .= $title_li; }
|
|
|
|
if ($style == "list") { $output .= "<ul>"; }
|
|
|
|
$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("<li><ul>", ($target_depth - $current_depth));
|
|
|
|
}
|
|
|
|
if ($target_depth < $current_depth) {
|
|
|
|
$output .= str_repeat("</ul></li>", ($current_depth - $target_depth));
|
|
|
|
}
|
|
|
|
$output .= '<li><a href="' . get_category_link($category_id) . '">';
|
|
|
|
$output .= $categories_by_id[$category_id]->cat_name;
|
|
|
|
$output .= "</a></li>";
|
|
|
|
$current_depth = $target_depth;
|
|
|
|
}
|
|
|
|
if ($current_depth > 0) {
|
|
|
|
$output .= str_repeat("</ul></li>", $current_depth);
|
|
|
|
}
|
|
|
|
if ($style == "list") { $output .= "</ul></li>"; }
|
|
|
|
echo $output;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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)) { ?>
|
|
|
|
<script type='text/javascript'>
|
|
|
|
<!--
|
|
|
|
function toggle_expander(id) {
|
|
|
|
var e = document.getElementById(id);
|
|
|
|
if(e.style.height == 'auto')
|
|
|
|
e.style.height = '1px';
|
|
|
|
else
|
|
|
|
e.style.height = 'auto';
|
|
|
|
}
|
|
|
|
//-->
|
|
|
|
</script>
|
|
|
|
<div class="transcript-border"><div id="transcript"><a href="javascript:toggle_expander('transcript-content');" class="transcript-title">↓ Transcript</a><div id="transcript-content"><?php echo nl2br($transcript); ?><br /><br /></div></div></div>
|
|
|
|
<script type='text/javascript'>
|
|
|
|
<!--
|
|
|
|
document.getElementById('transcript-content').style.height = '1px';
|
|
|
|
//-->
|
|
|
|
</script><?php
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Register Sidebar and Define Widgets
|
|
|
|
|
|
|
|
function widget_comicpress_latest_comics() { ?>
|
|
|
|
<li>
|
|
|
|
<h2>Latest Comics</h2>
|
|
|
|
<ul>
|
|
|
|
<?php global $post;
|
|
|
|
$latestcomics = get_posts('numberposts=5&category='.get_all_comic_categories_as_cat_string());
|
|
|
|
foreach($latestcomics as $post) : ?>
|
|
|
|
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
|
|
|
|
<?php endforeach; ?>
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
<?php } if ( function_exists('register_sidebar_widget') )
|
|
|
|
register_sidebar_widget(__('Latest Comics'), 'widget_comicpress_latest_comics');
|
|
|
|
|
|
|
|
function widget_comicpress_random_comic() { ?>
|
|
|
|
<li>
|
|
|
|
<h2><a href="?randomcomic"><span class="random-comic-icon">?</span> Random Comic</a></h2>
|
|
|
|
</li>
|
|
|
|
<?php } if ( function_exists('register_sidebar_widget') )
|
|
|
|
register_sidebar_widget(__('Random Comic'), 'widget_comicpress_random_comic');
|
|
|
|
|
|
|
|
function widget_comicpress_archive_dropdown() { ?>
|
|
|
|
<li class="archive-dropdown-wrap">
|
|
|
|
<select name="archive-dropdown" class="archive-dropdown" onChange='document.location.href=this.options[this.selectedIndex].value;'>
|
|
|
|
<option value=""><?php echo attribute_escape(__('Archives...')); ?></option>
|
|
|
|
<?php wp_get_archives('type=monthly&format=option&show_post_count=1'); ?> </select>
|
|
|
|
</li>
|
|
|
|
<?php } if ( function_exists('register_sidebar_widget') )
|
|
|
|
register_sidebar_widget(__('Archive Dropdown'), 'widget_comicpress_archive_dropdown');
|
|
|
|
|
2009-07-04 16:08:02 +00:00
|
|
|
?>
|