comicpress-core/functions.php

95 lines
2.5 KiB
PHP
Raw Normal View History

2009-08-07 19:50:06 +00:00
<?php
// load all of the comic & non-comic category information
add_action('init', '__comicpress_init');
function __comicpress_init() {
global $comicpress, $wp_query;
if (current_user_can('edit_files')) {
wp_cache_flush();
}
2009-11-04 02:45:56 +00:00
$classes_search = array(
'/classes/',
'/classes/backends/'
);
foreach ($classes_search as $path) {
foreach (glob(dirname(__FILE__) . $path . '*.inc') as $file) {
if (is_file($file)) {
require_once($file);
}
2009-11-04 02:45:56 +00:00
}
2009-08-07 19:50:06 +00:00
}
2009-11-01 18:15:59 +00:00
$comicpress = ComicPress::get_instance();
2009-08-07 19:50:06 +00:00
$comicpress->init();
$comicpress_admin = new ComicPressAdmin();
$comicpress_admin->init();
$comicpress_admin->handle_update();
$comicpress_filters = new ComicPressFilters();
$comicpress_filters->init();
2009-08-07 19:50:06 +00:00
}
2009-11-07 22:18:11 +00:00
function F($name, $path, $override_post = null) {
global $post;
$comic_post = new ComicPressComicPost(is_null($override_post) ? $post : $override_post);
return ComicPress::get_instance()->find_file($name, $path, $comic_post->find_parents());
}
2009-11-07 22:40:16 +00:00
function FinishComicPress() {
$content = ob_get_clean();
include(F('application.php', ''));
}
2009-08-07 19:50:06 +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;
}
2009-11-07 22:40:16 +00:00
ob_start();
?>