Merge branch 'master' of git@github.com:johnbintz/comicpress-theme-core
This commit is contained in:
commit
3543e14aea
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class ComicPressAddonBookmarkWidget extends ComicPressAddon {
|
class ComicPressAddonBookmarkWidget extends ComicPressAddon {
|
||||||
|
var $name = "Bookmark Widget";
|
||||||
|
|
||||||
function init($comicpress) {
|
function init($comicpress) {
|
||||||
wp_register_sidebar_widget('comic-bookmark', __('Comic Bookmark', 'comicpress'), array(&$this, 'render_widget'), array('description' => __('Let your readers save their place via a cookie.', 'comicpress')));
|
wp_register_sidebar_widget('comic-bookmark', __('Comic Bookmark', 'comicpress'), array(&$this, 'render_widget'), array('description' => __('Let your readers save their place via a cookie.', 'comicpress')));
|
||||||
|
|
||||||
@ -8,31 +10,25 @@ class ComicPressAddonBookmarkWidget extends ComicPressAddon {
|
|||||||
|
|
||||||
add_action('wp_head', array(&$this, 'wp_head'));
|
add_action('wp_head', array(&$this, 'wp_head'));
|
||||||
$this->comicpress->additional_javascripts[] = '/js/bookmark.js';
|
$this->comicpress->additional_javascripts[] = '/js/bookmark.js';
|
||||||
|
|
||||||
|
wp_enqueue_script('prototype');
|
||||||
|
wp_enqueue_script('cookiejar', get_template_directory_uri() . '/js/cookiejar.js', array('prototype'));
|
||||||
|
wp_enqueue_script('bookmark', get_template_directory_uri() . '/js/bookmark.js', array('prototype', 'cookiejar'));
|
||||||
}
|
}
|
||||||
|
|
||||||
function wp_head() {
|
function wp_head() { ?>
|
||||||
$last_comic = $this->comicpress->get_last_comic(); ?>
|
<script type="text/javascript">
|
||||||
<script type="text/javascript">
|
var image_root = '<?php bloginfo('template_directory'); ?>/images/';
|
||||||
var imgTag = '<?php bloginfo('template_directory'); ?>/images/1.gif'; //add tag image.
|
var permalink = '<?php the_permalink() ?>';
|
||||||
var imgClearOff = '<?php bloginfo('template_directory'); ?>/images/3a.gif'; //no comic tagged, clear not possible
|
</script>
|
||||||
var imgGotoOff = '<?php bloginfo('template_directory'); ?>/images/2a.gif'; //no comic tagged, goto not possible
|
<?php }
|
||||||
var imgClearOn = '<?php bloginfo('template_directory'); ?>/images/3.gif'; //clear a tag, shows when comic previously tagged
|
|
||||||
var imgGotoOn = '<?php bloginfo('template_directory'); ?>/images/2.gif'; //shows when a comic is tagged
|
|
||||||
var imgInfo = '<?php bloginfo('template_directory'); ?>/images/4.gif'; //img that displays the help
|
|
||||||
var comicDir = '/'; //alter this if you run multiple comics in different directories on your site.
|
|
||||||
|
|
||||||
var comicPermalink = '<?php echo get_permalink($last_comic->ID) ?>';
|
|
||||||
|
|
||||||
var isHome = <?php echo is_home() ? "true" : "false" ?>;
|
|
||||||
var isSingle = <?php echo (is_single() && $this->comicpress->in_comic_category()) ? "true" : "false" ?>;
|
|
||||||
</script>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
function render_widget() {
|
function render_widget() {
|
||||||
?>
|
?>
|
||||||
<div class="comic-bookmark">
|
<div id="comic-bookmark-holder">
|
||||||
<script type="text/javascript">writeBookmarkWidget()</script>
|
<a href="#" class="tag-page"><img src="<?php bloginfo('template_directory'); ?>/images/1.gif" /></a>
|
||||||
|
<a href="#" class="goto-tag"><img /></a>
|
||||||
|
<a href="#" class="clear-tag"><img /></a>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class ComicPressAddonCore extends ComicPressAddon {
|
class ComicPressAddonCore extends ComicPressAddon {
|
||||||
|
var $is_addon_manager = true;
|
||||||
|
var $cannot_be_disabled = true;
|
||||||
|
var $name = "ComicPress Core";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the addon.
|
* Initialize the addon.
|
||||||
* @param ComicPress $comicpress The master ComicPress object.
|
* @param ComicPress $comicpress The master ComicPress object.
|
||||||
@ -504,7 +508,9 @@ class ComicPressAddonCore extends ComicPressAddon {
|
|||||||
* Update ComicPress options.
|
* Update ComicPress options.
|
||||||
*/
|
*/
|
||||||
function handle_update_comicpress_options() {
|
function handle_update_comicpress_options() {
|
||||||
$this->comicpress->comicpress_options['helpers'] = array();
|
foreach (array('helpers', 'options') as $type) {
|
||||||
|
$this->comicpress->comicpress_options[$type] = array();
|
||||||
|
}
|
||||||
foreach ($this->comicpress->comicpress_options as $option => $value) {
|
foreach ($this->comicpress->comicpress_options as $option => $value) {
|
||||||
if (isset($_POST['cp'][$option])) {
|
if (isset($_POST['cp'][$option])) {
|
||||||
switch ($option) {
|
switch ($option) {
|
||||||
@ -550,8 +556,9 @@ class ComicPressAddonCore extends ComicPressAddon {
|
|||||||
$this->comicpress->comicpress_options[$option] = $_POST['cp'][$option];
|
$this->comicpress->comicpress_options[$option] = $_POST['cp'][$option];
|
||||||
break;
|
break;
|
||||||
case 'helpers':
|
case 'helpers':
|
||||||
foreach ($_POST['cp'][$option] as $helper => $set) {
|
case 'addons':
|
||||||
$this->comicpress->comicpress_options['helpers'][$helper] = true;
|
foreach ($_POST['cp'][$option] as $type => $set) {
|
||||||
|
$this->comicpress->comicpress_options[$option][$type] = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -575,7 +582,7 @@ class ComicPressAddonCore extends ComicPressAddon {
|
|||||||
function handle_update_override_partial($info) {
|
function handle_update_override_partial($info) {
|
||||||
switch ($info['action']) {
|
switch ($info['action']) {
|
||||||
case __('Update partial', 'comicpress'):
|
case __('Update partial', 'comicpress'):
|
||||||
$this->comicpress->comicpress_options['override_partials'][$info['partial']] = $info['code'];
|
$this->comicpress->comicpress_options['override_partials'][$info['partial']] = stripslashes($info['code']);
|
||||||
break;
|
break;
|
||||||
case __('Delete override partial', 'comicpress'):
|
case __('Delete override partial', 'comicpress'):
|
||||||
unset($this->comicpress->comicpress_options['override_partials'][$info['partial']]);
|
unset($this->comicpress->comicpress_options['override_partials'][$info['partial']]);
|
||||||
@ -643,4 +650,4 @@ class ComicPressAddonCore extends ComicPressAddon {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
<?php }
|
<?php }
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<p><em>(categories can be modified on the Posts -> Categories page)</em></p>
|
<p><em><?php _e('(categories can be modified on the Posts -> Categories page)', 'comicpress') ?></em></p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@ -98,20 +98,51 @@
|
|||||||
<h3><?php _e('Admin Options', 'comicpress') ?></h3>
|
<h3><?php _e('Admin Options', 'comicpress') ?></h3>
|
||||||
<table class="widefat fixed">
|
<table class="widefat fixed">
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">
|
<th scope="row"><?php _e('Enable editing helpers', 'comicpress') ?></th>
|
||||||
Enable editing helpers
|
|
||||||
</th>
|
|
||||||
<td>
|
<td>
|
||||||
<?php
|
<?php
|
||||||
foreach (array(
|
foreach (array(
|
||||||
"show_partials_info" => __('Show partials info', 'comicpress'),
|
"show_partials_info" => __('Show partials info', 'comicpress'),
|
||||||
"show_inline_comic_ordering" => __('Show inline comic ordering', 'comicpress')
|
"show_inline_comic_ordering" => __('Show inline comic ordering', 'comicpress')
|
||||||
) as $key => $label) { ?>
|
) as $key => $label) { ?>
|
||||||
<label><input type="checkbox" name="cp[helpers][<?php echo $key ?>]" value="yes" <?php echo (($this->comicpress->comicpress_options['helpers'][$key] === true) ? 'checked="checked"' : '') ?> /> <?php echo $label ?></label><br />
|
<label>
|
||||||
|
<input type="checkbox"
|
||||||
|
name="cp[helpers][<?php echo $key ?>]"
|
||||||
|
value="yes"
|
||||||
|
<?php echo (($this->comicpress->comicpress_options['helpers'][$key] === true) ? 'checked="checked"' : '') ?> />
|
||||||
|
<?php echo $label ?>
|
||||||
|
</label>
|
||||||
|
<br />
|
||||||
<?php }
|
<?php }
|
||||||
?>
|
?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<?php if (is_array($this->all_addons)) { ?>
|
||||||
|
<tr>
|
||||||
|
<th scope="row"><?php _e('Enable addons', 'comicpress') ?></th>
|
||||||
|
<td>
|
||||||
|
<?php
|
||||||
|
foreach ($this->all_addons as $addon) {
|
||||||
|
if (!empty($addon->name)) {
|
||||||
|
$enabled = ($addon->is_addon_manager !== true);
|
||||||
|
$checked = $enabled && $this->comicpress->comicpress_options['addons'][$addon->name];
|
||||||
|
?>
|
||||||
|
|
||||||
|
<label>
|
||||||
|
<input type="checkbox"
|
||||||
|
name="cp[addons][<?php echo $addon->name ?>]"
|
||||||
|
value="yes"
|
||||||
|
<?php echo !$enabled ? 'disabled="disabled"' : '' ?>
|
||||||
|
<?php echo $checked ? 'checked="checked"' : '' ?> />
|
||||||
|
<?php echo $addon->name ?>
|
||||||
|
</label><br />
|
||||||
|
<?php }
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php } ?>
|
||||||
</table>
|
</table>
|
||||||
<input type="submit" value="<?php _e("Submit Changes", 'comicpress') ?>" /> </form>
|
<input class="button" type="submit" value="<?php _e('Submit Changes', 'comicpress') ?>" />
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
class ComicPressAddonSearchTranscripts extends ComicPressAddon {
|
class ComicPressAddonSearchTranscripts extends ComicPressAddon {
|
||||||
var $custom_template_default = 'search-transcript.php';
|
var $custom_template_default = 'search-transcript.php';
|
||||||
|
var $name = "Search Transcripts";
|
||||||
|
|
||||||
function init($comicpress) {
|
function init($comicpress) {
|
||||||
add_filter('posts_join', array(&$this, 'search_custom_join'));
|
add_filter('posts_join', array(&$this, 'search_custom_join'));
|
||||||
|
@ -16,7 +16,8 @@ class ComicPress {
|
|||||||
'category_usage' => 'storyline',
|
'category_usage' => 'storyline',
|
||||||
'layout' => 'classic.inc',
|
'layout' => 'classic.inc',
|
||||||
'helpers' => array(),
|
'helpers' => array(),
|
||||||
'override_partials' => array()
|
'override_partials' => array(),
|
||||||
|
'addons' => array()
|
||||||
);
|
);
|
||||||
|
|
||||||
var $additional_stylesheets = array();
|
var $additional_stylesheets = array();
|
||||||
|
@ -170,10 +170,16 @@ class ComicPressComicPost {
|
|||||||
usort($remaining_posts_to_sort[$type], array(&$this, 'sort_remaining_comic_images'));
|
usort($remaining_posts_to_sort[$type], array(&$this, 'sort_remaining_comic_images'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = array_merge($comic_image_ordering, $remaining_posts_to_sort);
|
foreach ($remaining_posts_to_sort as $type => $posts) {
|
||||||
|
if (is_array($comic_image_ordering[$type])) {
|
||||||
|
$comic_image_ordering[$type] = array_merge($comic_image_ordering[$type], $posts);
|
||||||
|
} else {
|
||||||
|
$comic_image_ordering[$type] = $posts;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
update_post_meta($this->post->ID, 'comic_ordering', $this->build_comic_ordering_string($result));
|
update_post_meta($this->post->ID, 'comic_ordering', $this->build_comic_ordering_string($comic_image_ordering));
|
||||||
return $result;
|
return $comic_image_ordering;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
465
functions.php
465
functions.php
@ -1,236 +1,239 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// load all of the comic & non-comic category information
|
// load all of the comic & non-comic category information
|
||||||
add_action('init', '__comicpress_init');
|
add_action('init', '__comicpress_init');
|
||||||
|
|
||||||
function __comicpress_init() {
|
function __comicpress_init() {
|
||||||
global $comicpress, $wp_query;
|
global $comicpress, $wp_query;
|
||||||
|
|
||||||
if (current_user_can('edit_files')) {
|
if (current_user_can('edit_files')) {
|
||||||
wp_cache_flush();
|
wp_cache_flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (glob(dirname(__FILE__) . '/classes/*.inc') as $file) {
|
foreach (glob(dirname(__FILE__) . '/classes/*.inc') as $file) {
|
||||||
if (is_file($file)) { require_once($file); }
|
if (is_file($file)) { require_once($file); }
|
||||||
}
|
}
|
||||||
|
|
||||||
$comicpress = new ComicPress();
|
$comicpress = new ComicPress();
|
||||||
$comicpress->init();
|
$comicpress->init();
|
||||||
$addons = array();
|
$addons = array();
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
if (get_magic_quotes_gpc()) {
|
if (
|
||||||
$_POST = stripslashes_deep($_POST);
|
$comicpress->comicpress_options['addons'][$addon->name] ||
|
||||||
$_GET = stripslashes_deep($_GET);
|
$addon->is_addon_manager
|
||||||
$_REQUEST = stripslashes_deep($_REQUEST);
|
) {
|
||||||
}
|
$addon->init(&$comicpress);
|
||||||
|
if (current_user_can('edit_posts')) {
|
||||||
if (is_dir($addons_dir = (dirname(__FILE__) . '/addons'))) {
|
if (is_array($_REQUEST['cp'])) {
|
||||||
$entries = glob($addons_dir . '/*');
|
if (isset($_REQUEST['cp']['_nonce'])) {
|
||||||
if (is_array($entries)) {
|
if (wp_verify_nonce($_REQUEST['cp']['_nonce'], 'comicpress')) {
|
||||||
foreach ($entries as $entry) {
|
if (method_exists($addon, 'handle_update')) {
|
||||||
if (is_dir($entry)) {
|
$addon->handle_update();
|
||||||
$classname = basename($entry);
|
$comicpress->load();
|
||||||
if (file_exists($entry . "/${classname}.inc")) {
|
}
|
||||||
require_once($entry . "/${classname}.inc");
|
}
|
||||||
$classname = "ComicPressAddon${classname}";
|
}
|
||||||
if (class_exists($classname)) {
|
}
|
||||||
$addon =& new $classname();
|
if (is_admin()) {
|
||||||
|
add_action('admin_notices', array(&$addon, 'display_messages'));
|
||||||
$addon->init(&$comicpress);
|
} else {
|
||||||
if (current_user_can('edit_posts')) {
|
add_action('wp_head', array(&$addon, 'display_messages'));
|
||||||
if (is_array($_REQUEST['cp'])) {
|
}
|
||||||
if (isset($_REQUEST['cp']['_nonce'])) {
|
|
||||||
if (wp_verify_nonce($_REQUEST['cp']['_nonce'], 'comicpress')) {
|
|
||||||
if (method_exists($addon, 'handle_update')) {
|
|
||||||
$addon->handle_update();
|
|
||||||
$comicpress->load();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (is_admin()) {
|
}
|
||||||
add_action('admin_notices', array(&$addon, 'display_messages'));
|
$addons[] = $addon;
|
||||||
} else {
|
}
|
||||||
add_action('wp_head', array(&$addon, 'display_messages'));
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$addons[] = $addon;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$layouts = $comicpress->get_layout_choices();
|
foreach ($addons as $addon) {
|
||||||
if (isset($layouts[$comicpress->comicpress_options['layout']])) {
|
if ($addon->is_addon_manager) { $addon->all_addons =& $addons; break; }
|
||||||
if (isset($layouts[$comicpress->comicpress_options['layout']]['Sidebars'])) {
|
}
|
||||||
foreach (explode(",", $layouts[$comicpress->comicpress_options['layout']]['Sidebars']) as $sidebar) {
|
|
||||||
$sidebar = trim($sidebar);
|
$layouts = $comicpress->get_layout_choices();
|
||||||
register_sidebar($sidebar);
|
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);
|
||||||
|
}
|
||||||
function comicpress_init() {
|
}
|
||||||
global $post, $comicpress;
|
}
|
||||||
|
}
|
||||||
if (!empty($post)) {
|
|
||||||
if (in_comic_category() && $comicpress->is_multicomic() && !is_index()) {
|
function comicpress_init() {
|
||||||
$comicpress->setup_multicomic_partial_paths($post->ID);
|
global $post, $comicpress;
|
||||||
}
|
|
||||||
}
|
if (!empty($post)) {
|
||||||
|
if (in_comic_category() && $comicpress->is_multicomic() && !is_index()) {
|
||||||
$comicpress->partial_paths[] = get_template_directory() . '/partials';
|
$comicpress->setup_multicomic_partial_paths($post->ID);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
function comicpress_get_header() {
|
|
||||||
get_header();
|
$comicpress->partial_paths[] = get_template_directory() . '/partials';
|
||||||
}
|
}
|
||||||
|
|
||||||
function include_partial($partials = '') {
|
function comicpress_get_header() {
|
||||||
global $comicpress, $post, $nav_comics;
|
get_header();
|
||||||
|
}
|
||||||
if (!is_array($partials)) { $partials = func_get_args(); }
|
|
||||||
|
function include_partial($partials = '') {
|
||||||
$content = $target = null;
|
global $comicpress, $post, $nav_comics;
|
||||||
|
|
||||||
if (($result = $comicpress->get_options_partial($partials)) !== false) {
|
if (!is_array($partials)) { $partials = func_get_args(); }
|
||||||
list($target, $code) = $result;
|
|
||||||
ob_start(); eval('?>' . $code . '<?'); $content = ob_get_clean();
|
$content = $target = null;
|
||||||
} else {
|
|
||||||
$target = $comicpress->get_partial_path($partials);
|
if (($result = $comicpress->get_options_partial($partials)) !== false) {
|
||||||
|
list($target, $code) = $result;
|
||||||
if ($target !== false) {
|
ob_start(); eval(' ?>' . $code . '<?php '); $content = ob_get_clean();
|
||||||
ob_start(); include($target); $content = ob_get_clean();
|
} else {
|
||||||
}
|
$target = $comicpress->get_partial_path($partials);
|
||||||
|
|
||||||
$target = str_replace(".inc", "", $target);
|
if ($target !== false) {
|
||||||
}
|
ob_start(); include($target); $content = ob_get_clean();
|
||||||
|
}
|
||||||
if (!empty($target) && !empty($content)) {
|
|
||||||
echo apply_filters("comicpress_partial", $content, $target);
|
$target = str_replace(".inc", "", $target);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
if (!empty($target) && !empty($content)) {
|
||||||
function in_comic_category() {
|
echo apply_filters("comicpress_partial", $content, $target);
|
||||||
global $post, $comicpress;
|
}
|
||||||
|
}
|
||||||
return $comicpress->in_comic_category($post->ID);
|
|
||||||
}
|
function in_comic_category() {
|
||||||
|
global $post, $comicpress;
|
||||||
/**
|
|
||||||
* Display the list of Storyline categories.
|
return $comicpress->in_comic_category($post->ID);
|
||||||
*/
|
}
|
||||||
function comicpress_list_storyline_categories($args = "") {
|
|
||||||
global $category_tree;
|
/**
|
||||||
|
* Display the list of Storyline categories.
|
||||||
$defaults = array(
|
*/
|
||||||
'style' => 'list', 'title_li' => __('Storyline')
|
function comicpress_list_storyline_categories($args = "") {
|
||||||
);
|
global $category_tree;
|
||||||
|
|
||||||
$r = wp_parse_args($args, $defaults);
|
$defaults = array(
|
||||||
|
'style' => 'list', 'title_li' => __('Storyline')
|
||||||
extract($r);
|
);
|
||||||
|
|
||||||
$categories_by_id = get_all_category_objects_by_id();
|
$r = wp_parse_args($args, $defaults);
|
||||||
|
|
||||||
$output = '';
|
extract($r);
|
||||||
if ($style == "list") { $output .= '<li class="categories storyline">'; }
|
|
||||||
if ($title_li && ($style == "list")) { $output .= $title_li; }
|
$categories_by_id = get_all_category_objects_by_id();
|
||||||
if ($style == "list") { $output .= "<ul>"; }
|
|
||||||
$current_depth = 0;
|
$output = '';
|
||||||
foreach ($category_tree as $node) {
|
if ($style == "list") { $output .= '<li class="categories storyline">'; }
|
||||||
$parts = explode("/", $node);
|
if ($title_li && ($style == "list")) { $output .= $title_li; }
|
||||||
$category_id = end($parts);
|
if ($style == "list") { $output .= "<ul>"; }
|
||||||
$target_depth = count($parts) - 2;
|
$current_depth = 0;
|
||||||
if ($target_depth > $current_depth) {
|
foreach ($category_tree as $node) {
|
||||||
$output .= str_repeat("<li><ul>", ($target_depth - $current_depth));
|
$parts = explode("/", $node);
|
||||||
}
|
$category_id = end($parts);
|
||||||
if ($target_depth < $current_depth) {
|
$target_depth = count($parts) - 2;
|
||||||
$output .= str_repeat("</ul></li>", ($current_depth - $target_depth));
|
if ($target_depth > $current_depth) {
|
||||||
}
|
$output .= str_repeat("<li><ul>", ($target_depth - $current_depth));
|
||||||
$output .= '<li><a href="' . get_category_link($category_id) . '">';
|
}
|
||||||
$output .= $categories_by_id[$category_id]->cat_name;
|
if ($target_depth < $current_depth) {
|
||||||
$output .= "</a></li>";
|
$output .= str_repeat("</ul></li>", ($current_depth - $target_depth));
|
||||||
$current_depth = $target_depth;
|
}
|
||||||
}
|
$output .= '<li><a href="' . get_category_link($category_id) . '">';
|
||||||
if ($current_depth > 0) {
|
$output .= $categories_by_id[$category_id]->cat_name;
|
||||||
$output .= str_repeat("</ul></li>", $current_depth);
|
$output .= "</a></li>";
|
||||||
}
|
$current_depth = $target_depth;
|
||||||
if ($style == "list") { $output .= "</ul></li>"; }
|
}
|
||||||
echo $output;
|
if ($current_depth > 0) {
|
||||||
}
|
$output .= str_repeat("</ul></li>", $current_depth);
|
||||||
|
}
|
||||||
/**
|
if ($style == "list") { $output .= "</ul></li>"; }
|
||||||
* Display the comic transcript
|
echo $output;
|
||||||
* 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') {
|
* Display the comic transcript
|
||||||
$transcript = get_post_meta( get_the_ID(), "transcript", true );
|
* Transcript must be entered into a custom field named "transcript"
|
||||||
switch ($displaymode) {
|
* @param string $displaymode, "raw" (straight from the field), "br" (includes html line breaks), "styled" (fully css styled with JavaScript expander)
|
||||||
case "raw":
|
*/
|
||||||
echo $transcript;
|
function the_transcript($displaymode = 'raw') {
|
||||||
break;
|
$transcript = get_post_meta( get_the_ID(), "transcript", true );
|
||||||
case "br":
|
switch ($displaymode) {
|
||||||
echo nl2br($transcript);
|
case "raw":
|
||||||
break;
|
echo $transcript;
|
||||||
case "styled":
|
break;
|
||||||
if (!empty($transcript)) { ?>
|
case "br":
|
||||||
<script type='text/javascript'>
|
echo nl2br($transcript);
|
||||||
<!--
|
break;
|
||||||
function toggle_expander(id) {
|
case "styled":
|
||||||
var e = document.getElementById(id);
|
if (!empty($transcript)) { ?>
|
||||||
if(e.style.height == 'auto')
|
<script type='text/javascript'>
|
||||||
e.style.height = '1px';
|
<!--
|
||||||
else
|
function toggle_expander(id) {
|
||||||
e.style.height = 'auto';
|
var e = document.getElementById(id);
|
||||||
}
|
if(e.style.height == 'auto')
|
||||||
//-->
|
e.style.height = '1px';
|
||||||
</script>
|
else
|
||||||
<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>
|
e.style.height = 'auto';
|
||||||
<script type='text/javascript'>
|
}
|
||||||
<!--
|
//-->
|
||||||
document.getElementById('transcript-content').style.height = '1px';
|
</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><?php
|
<script type='text/javascript'>
|
||||||
}
|
<!--
|
||||||
break;
|
document.getElementById('transcript-content').style.height = '1px';
|
||||||
}
|
//-->
|
||||||
}
|
</script><?php
|
||||||
|
}
|
||||||
// Register Sidebar and Define Widgets
|
break;
|
||||||
|
}
|
||||||
function widget_comicpress_latest_comics() { ?>
|
}
|
||||||
<li>
|
|
||||||
<h2>Latest Comics</h2>
|
// Register Sidebar and Define Widgets
|
||||||
<ul>
|
|
||||||
<?php global $post;
|
function widget_comicpress_latest_comics() { ?>
|
||||||
$latestcomics = get_posts('numberposts=5&category='.get_all_comic_categories_as_cat_string());
|
<li>
|
||||||
foreach($latestcomics as $post) : ?>
|
<h2>Latest Comics</h2>
|
||||||
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
|
<ul>
|
||||||
<?php endforeach; ?>
|
<?php global $post;
|
||||||
</ul>
|
$latestcomics = get_posts('numberposts=5&category='.get_all_comic_categories_as_cat_string());
|
||||||
</li>
|
foreach($latestcomics as $post) : ?>
|
||||||
<?php } if ( function_exists('register_sidebar_widget') )
|
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
|
||||||
register_sidebar_widget(__('Latest Comics'), 'widget_comicpress_latest_comics');
|
<?php endforeach; ?>
|
||||||
|
</ul>
|
||||||
function widget_comicpress_random_comic() { ?>
|
</li>
|
||||||
<li>
|
<?php } if ( function_exists('register_sidebar_widget') )
|
||||||
<h2><a href="?randomcomic"><span class="random-comic-icon">?</span> Random Comic</a></h2>
|
register_sidebar_widget(__('Latest Comics'), 'widget_comicpress_latest_comics');
|
||||||
</li>
|
|
||||||
<?php } if ( function_exists('register_sidebar_widget') )
|
function widget_comicpress_random_comic() { ?>
|
||||||
register_sidebar_widget(__('Random Comic'), 'widget_comicpress_random_comic');
|
<li>
|
||||||
|
<h2><a href="?randomcomic"><span class="random-comic-icon">?</span> Random Comic</a></h2>
|
||||||
function widget_comicpress_archive_dropdown() { ?>
|
</li>
|
||||||
<li class="archive-dropdown-wrap">
|
<?php } if ( function_exists('register_sidebar_widget') )
|
||||||
<select name="archive-dropdown" class="archive-dropdown" onChange='document.location.href=this.options[this.selectedIndex].value;'>
|
register_sidebar_widget(__('Random Comic'), 'widget_comicpress_random_comic');
|
||||||
<option value=""><?php echo attribute_escape(__('Archives...')); ?></option>
|
|
||||||
<?php wp_get_archives('type=monthly&format=option&show_post_count=1'); ?> </select>
|
function widget_comicpress_archive_dropdown() { ?>
|
||||||
</li>
|
<li class="archive-dropdown-wrap">
|
||||||
<?php } if ( function_exists('register_sidebar_widget') )
|
<select name="archive-dropdown" class="archive-dropdown" onChange='document.location.href=this.options[this.selectedIndex].value;'>
|
||||||
register_sidebar_widget(__('Archive Dropdown'), 'widget_comicpress_archive_dropdown');
|
<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');
|
||||||
|
|
||||||
|
?>
|
||||||
|
139
js/bookmark.js
139
js/bookmark.js
@ -1,81 +1,70 @@
|
|||||||
var cl = 31;
|
var button_images = {
|
||||||
|
'clear-tag': {
|
||||||
/* Below are our functions for this little script */
|
'off': '3a.gif', 'on': '3.gif'
|
||||||
|
},
|
||||||
function bmhome() {
|
'goto-tag': {
|
||||||
if(document.getElementById) {
|
'off': '2a.gif', 'on': '2.gif'
|
||||||
document.getElementById('gtc').src = imgGotoOn;
|
|
||||||
document.getElementById('rmc').src = imgClearOn;
|
|
||||||
}
|
}
|
||||||
createCookie("bm", comicPermalink, cl);
|
};
|
||||||
}
|
|
||||||
|
|
||||||
function bm() {
|
var BookmarkInfo = Class.create({
|
||||||
if(document.getElementById) {
|
'default': {
|
||||||
document.getElementById('gtc').src = imgGotoOn;
|
'permalink': false
|
||||||
document.getElementById('rmc').src = imgClearOn;
|
},
|
||||||
}
|
'initialize': function() {
|
||||||
createCookie("bm", window.location, cl);
|
this.jar = new CookieJar({
|
||||||
}
|
'expires': 60 * 60 * 24 * 31,
|
||||||
|
'path': '/'
|
||||||
|
});
|
||||||
|
},
|
||||||
|
'read': function() {
|
||||||
|
var bookmark_info = this.jar.get('bookmark-info');
|
||||||
|
|
||||||
function bmc() {
|
if ((typeof(bookmark_info) != 'object') || (bookmark_info == null)) {
|
||||||
if(document.getElementById) {
|
bookmark_info = this.default;
|
||||||
document.getElementById('gtc').src = imgGotoOff;
|
}
|
||||||
document.getElementById('rmc').src = imgClearOff;
|
|
||||||
|
return bookmark_info;
|
||||||
|
},
|
||||||
|
'write': function(bookmark_info) {
|
||||||
|
this.jar.put('bookmark-info', bookmark_info);
|
||||||
|
if (this.onWrite) { this.onWrite(bookmark_info); }
|
||||||
}
|
}
|
||||||
createCookie("bm","",-1);
|
});
|
||||||
}
|
|
||||||
|
Event.observe(window, 'load', function() {
|
||||||
|
var bookmark_info = new BookmarkInfo();
|
||||||
|
var info = bookmark_info.read();
|
||||||
|
|
||||||
function gto() {
|
var hrefs = {};
|
||||||
var g = readCookie('bm');
|
$$('#comic-bookmark-holder a').each(function(a) {
|
||||||
if(g) {
|
var name = $w(a.className).shift();
|
||||||
window.location = g;
|
hrefs[name] = a;
|
||||||
}
|
});
|
||||||
}
|
|
||||||
|
var set_goto_tag = function(i) {
|
||||||
|
hrefs['goto-tag'].href = (i.permalink ? i.permalink : "#");
|
||||||
|
[ 'goto-tag','clear-tag' ].each(function(which) {
|
||||||
|
hrefs[which].select('img')[0].src = image_root + button_images[which][i.permalink ? "on" : "off"];
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
bookmark_info.onWrite = function(i) { set_goto_tag(i); }
|
||||||
|
set_goto_tag(info);
|
||||||
|
|
||||||
/* The follow functions have been borrowed from Peter-Paul Koch. Please find them here: http://www.quirksmode.org */
|
Event.observe(hrefs['tag-page'], 'click', function(e) {
|
||||||
|
Event.stop(e);
|
||||||
function createCookie(name,value,days) {
|
info.permalink = permalink;
|
||||||
if (days) {
|
bookmark_info.write(info);
|
||||||
var date = new Date();
|
});
|
||||||
date.setTime(date.getTime()+(days*24*60*60*1000));
|
|
||||||
var expires = "; expires="+date.toGMTString();
|
Event.observe(hrefs['clear-tag'], 'click', function(e) {
|
||||||
} else var expires = "";
|
Event.stop(e);
|
||||||
document.cookie = name+"="+value+expires+"; path="+comicDir;
|
info.permalink = false;
|
||||||
}
|
bookmark_info.write(info);
|
||||||
function readCookie(name) {
|
});
|
||||||
var nameEQ = name + "=";
|
|
||||||
var ca = document.cookie.split(';');
|
Event.observe(hrefs['goto-tag'], 'click', function(e) {
|
||||||
for(var i=0;i < ca.length;i++) {
|
if (hrefs['goto-tag'].href == "#") { Event.stop(e); }
|
||||||
var c = ca[i];
|
});
|
||||||
while (c.charAt(0)==' ') c = c.substring(1,c.length);
|
});
|
||||||
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
function writeBookmarkWidget() {
|
|
||||||
createCookie('t', 1);
|
|
||||||
var c = readCookie('t');
|
|
||||||
if (c && document.getElementById) {
|
|
||||||
var l = readCookie('bm');
|
|
||||||
var gt = imgGotoOff;
|
|
||||||
var ct = imgClearOff;
|
|
||||||
if (l) {
|
|
||||||
gt = imgGotoOn;
|
|
||||||
ct = imgClearOn;
|
|
||||||
}
|
|
||||||
document.write('<div id="bmh" style="width: 173px; margin: 15px 0 0 0; padding: 5px; position: absolute; color: #eee; font-size: 11px; background-color:#222; border: 1px solid #ccc; visibility: hidden;"><b>COMIC BOOKMARK</b><br />Click "Tag Page" to bookmark a comic page. When you return to the site, click "Goto Tag" to continue where you left off.</div>');
|
|
||||||
if (isHome) {
|
|
||||||
document.write('<a href="#" onClick="bmhome();return false;"><img src="'+imgTag+'" alt="Tag This Page" border="0"></a>');
|
|
||||||
document.write('<a href="#" onClick="gto();return false;"><img src="'+gt+'" alt="Goto Tag" border="0" id="gtc"></a>');
|
|
||||||
document.write('<a href="#" onClick="bmc();return false;"><img src="'+ct+'" alt="Clear Tag" border="0" id="rmc"></a>');
|
|
||||||
document.write('<a href="#" onMouseOver="document.getElementById(\'bmh\').style.visibility=\'visible\';" onMouseOut="document.getElementById(\'bmh\').style.visibility=\'hidden\';" onClick="return false;"><img src="'+imgInfo+'" alt="" border="0"></a>');
|
|
||||||
} else if (isSingle) {
|
|
||||||
document.write('<a href="#" onClick="bm();return false;"><img src="'+imgTag+'" alt="Tag This Page" border="0"></a>');
|
|
||||||
document.write('<a href="#" onClick="gto();return false;"><img src="'+gt+'" alt="Goto Tag" border="0" id="gtc"></a>');
|
|
||||||
document.write('<a href="#" onClick="bmc();return false;"><img src="'+ct+'" alt="Clear Tag" border="0" id="rmc"></a>');
|
|
||||||
document.write('<a href="#" onMouseOver="document.getElementById(\'bmh\').style.visibility=\'visible\';" onMouseOut="document.getElementById(\'bmh\').style.visibility=\'hidden\';" onClick="return false;"><img src="'+imgInfo+'" alt="" border="0"></a>');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
157
js/cookiejar.js
Normal file
157
js/cookiejar.js
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
/**
|
||||||
|
* Javascript code to store data as JSON strings in cookies.
|
||||||
|
* It uses prototype.js 1.5.1 (http://www.prototypejs.org)
|
||||||
|
*
|
||||||
|
* Author : Lalit Patel
|
||||||
|
* Website: http://www.lalit.org/lab/jsoncookies
|
||||||
|
* License: Apache Software License 2
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* Version: 0.5
|
||||||
|
* Updated: Jan 26, 2009
|
||||||
|
*
|
||||||
|
* Chnage Log:
|
||||||
|
* v 0.5
|
||||||
|
* - Changed License from CC to Apache 2
|
||||||
|
* v 0.4
|
||||||
|
* - Removed a extra comma in options (was breaking in IE and Opera). (Thanks Jason)
|
||||||
|
* - Removed the parameter name from the initialize function
|
||||||
|
* - Changed the way expires date was being calculated. (Thanks David)
|
||||||
|
* v 0.3
|
||||||
|
* - Removed dependancy on json.js (http://www.json.org/json.js)
|
||||||
|
* - empty() function only deletes the cookies set by CookieJar
|
||||||
|
*/
|
||||||
|
|
||||||
|
var CookieJar = Class.create();
|
||||||
|
|
||||||
|
CookieJar.prototype = {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Append before all cookie names to differntiate them.
|
||||||
|
*/
|
||||||
|
appendString: "__CJ_",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the cookie jar with the options.
|
||||||
|
*/
|
||||||
|
initialize: function(options) {
|
||||||
|
this.options = {
|
||||||
|
expires: 3600, // seconds (1 hr)
|
||||||
|
path: '', // cookie path
|
||||||
|
domain: '', // cookie domain
|
||||||
|
secure: '' // secure ?
|
||||||
|
};
|
||||||
|
Object.extend(this.options, options || {});
|
||||||
|
|
||||||
|
if (this.options.expires != '') {
|
||||||
|
var date = new Date();
|
||||||
|
date = new Date(date.getTime() + (this.options.expires * 1000));
|
||||||
|
this.options.expires = '; expires=' + date.toGMTString();
|
||||||
|
}
|
||||||
|
if (this.options.path != '') {
|
||||||
|
this.options.path = '; path=' + escape(this.options.path);
|
||||||
|
}
|
||||||
|
if (this.options.domain != '') {
|
||||||
|
this.options.domain = '; domain=' + escape(this.options.domain);
|
||||||
|
}
|
||||||
|
if (this.options.secure == 'secure') {
|
||||||
|
this.options.secure = '; secure';
|
||||||
|
} else {
|
||||||
|
this.options.secure = '';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a name values pair.
|
||||||
|
*/
|
||||||
|
put: function(name, value) {
|
||||||
|
name = this.appendString + name;
|
||||||
|
cookie = this.options;
|
||||||
|
var type = typeof value;
|
||||||
|
switch(type) {
|
||||||
|
case 'undefined':
|
||||||
|
case 'function' :
|
||||||
|
case 'unknown' : return false;
|
||||||
|
case 'boolean' :
|
||||||
|
case 'string' :
|
||||||
|
case 'number' : value = String(value.toString());
|
||||||
|
}
|
||||||
|
var cookie_str = name + "=" + escape(Object.toJSON(value));
|
||||||
|
try {
|
||||||
|
document.cookie = cookie_str + cookie.expires + cookie.path + cookie.domain + cookie.secure;
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a particular cookie (name value pair) form the Cookie Jar.
|
||||||
|
*/
|
||||||
|
remove: function(name) {
|
||||||
|
name = this.appendString + name;
|
||||||
|
cookie = this.options;
|
||||||
|
try {
|
||||||
|
var date = new Date();
|
||||||
|
date.setTime(date.getTime() - (3600 * 1000));
|
||||||
|
var expires = '; expires=' + date.toGMTString();
|
||||||
|
document.cookie = name + "=" + expires + cookie.path + cookie.domain + cookie.secure;
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a particular cookie by name;
|
||||||
|
*/
|
||||||
|
get: function(name) {
|
||||||
|
name = this.appendString + name;
|
||||||
|
var cookies = document.cookie.match(name + '=(.*?)(;|$)');
|
||||||
|
if (cookies) {
|
||||||
|
return (unescape(cookies[1])).evalJSON();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Empties the Cookie Jar. Deletes all the cookies.
|
||||||
|
*/
|
||||||
|
empty: function() {
|
||||||
|
keys = this.getKeys();
|
||||||
|
size = keys.size();
|
||||||
|
for(i=0; i<size; i++) {
|
||||||
|
this.remove(keys[i]);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all cookies as a single object
|
||||||
|
*/
|
||||||
|
getPack: function() {
|
||||||
|
pack = {};
|
||||||
|
keys = this.getKeys();
|
||||||
|
|
||||||
|
size = keys.size();
|
||||||
|
for(i=0; i<size; i++) {
|
||||||
|
pack[keys[i]] = this.get(keys[i]);
|
||||||
|
}
|
||||||
|
return pack;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all keys.
|
||||||
|
*/
|
||||||
|
getKeys: function() {
|
||||||
|
keys = $A();
|
||||||
|
keyRe= /[^=; ]+(?=\=)/g;
|
||||||
|
str = document.cookie;
|
||||||
|
CJRe = new RegExp("^" + this.appendString);
|
||||||
|
while((match = keyRe.exec(str)) != undefined) {
|
||||||
|
if (CJRe.test(match[0].strip())) {
|
||||||
|
keys.push(match[0].strip().gsub("^" + this.appendString,""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return keys;
|
||||||
|
}
|
||||||
|
};
|
@ -1,6 +1,6 @@
|
|||||||
<div class="post-comic-head"></div>
|
<div class="post-comic-head"></div>
|
||||||
<div class="post-comic">
|
<div class="post-comic">
|
||||||
<?php include('nav.inc') ?>
|
<?php include_partial('nav') ?>
|
||||||
<div class="comicdate"><?php the_date('F jS, Y') ?></div>
|
<div class="comicdate"><?php the_date('F jS, Y') ?></div>
|
||||||
<br class="clear" />
|
<br class="clear" />
|
||||||
<h2>
|
<h2>
|
||||||
@ -14,4 +14,4 @@
|
|||||||
</div>
|
</div>
|
||||||
<br class="clear" />
|
<br class="clear" />
|
||||||
</div>
|
</div>
|
||||||
<div class="post-comic-foot"></div>
|
<div class="post-comic-foot"></div>
|
||||||
|
@ -151,7 +151,7 @@ class ComicPressComicPostTest extends PHPUnit_Framework_TestCase {
|
|||||||
$p->expects($this->any())->method('get_comic_image_attachments')->will($this->returnValue($attachments));
|
$p->expects($this->any())->method('get_comic_image_attachments')->will($this->returnValue($attachments));
|
||||||
|
|
||||||
wp_insert_post((object)array('ID' => 1));
|
wp_insert_post((object)array('ID' => 1));
|
||||||
update_post_meta(1, 'comic_ordering', "comic:3,2");
|
update_post_meta(1, 'comic_ordering', "comic:3");
|
||||||
|
|
||||||
$p->post = (object)array('ID' => 1);
|
$p->post = (object)array('ID' => 1);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user