a bunch of work on storyline support
This commit is contained in:
parent
f2cdb8d7df
commit
4815766fe4
@ -413,7 +413,7 @@ class ComicPressAddonCore extends ComicPressAddon {
|
|||||||
$this->comicpress->comicpress_options[$option] = (int)$_POST['cp'][$option];
|
$this->comicpress->comicpress_options[$option] = (int)$_POST['cp'][$option];
|
||||||
break;
|
break;
|
||||||
case 'comic_space':
|
case 'comic_space':
|
||||||
case 'category_page_usage':
|
case 'category_usage':
|
||||||
case 'layout';
|
case 'layout';
|
||||||
$this->comicpress->comicpress_options[$option] = $_POST['cp'][$option];
|
$this->comicpress->comicpress_options[$option] = $_POST['cp'][$option];
|
||||||
break;
|
break;
|
||||||
|
@ -73,7 +73,7 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Insert into comic space:</th>
|
<th scope="row"><?php _e('Insert into comic space:', 'comicpress') ?></th>
|
||||||
<td>
|
<td>
|
||||||
<?php foreach (array(
|
<?php foreach (array(
|
||||||
"comic_only" => __("The comic only, with post content below", 'comicpress'),
|
"comic_only" => __("The comic only, with post content below", 'comicpress'),
|
||||||
@ -84,13 +84,13 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Use comic category pages as:</th>
|
<th scope="row"><?php _e('Use subcategories of the Master Comic Category as:', 'comicpress') ?></th>
|
||||||
<td>
|
<td>
|
||||||
<?php foreach (array(
|
<?php foreach (array(
|
||||||
"archive_list" => __("The normal way, as a list of posts in that category", 'comicpress'),
|
"storyline" => __("Storyline indicators for a single comic", 'comicpress'),
|
||||||
"comic_frontpage" => __("As the front page to the comics in that category", 'comicpress')
|
"multicomic" => __("Multicomic indicators, with direct descendents being separate comics", 'comicpress')
|
||||||
) as $value => $label) { ?>
|
) as $value => $label) { ?>
|
||||||
<label><input type="radio" name="cp[category_page_usage]" value="<?php echo $value ?>" <?php echo ($this->comicpress->comicpress_options['category_page_usage'] == $value) ? 'checked="checked"' : "" ?> /> <?php echo $label ?></label><br />
|
<label><input type="radio" name="cp[category_usage]" value="<?php echo $value ?>" <?php echo ($this->comicpress->comicpress_options['category_usage'] == $value) ? 'checked="checked"' : "" ?> /> <?php echo $label ?></label><br />
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -13,7 +13,7 @@ class ComicPress {
|
|||||||
'category_order' => false,
|
'category_order' => false,
|
||||||
'blogpost_count' => 10,
|
'blogpost_count' => 10,
|
||||||
'comic_space' => 'comic_only',
|
'comic_space' => 'comic_only',
|
||||||
'category_page_usage' => 'archive_list',
|
'category_usage' => 'storyline',
|
||||||
'layout' => 'classic.inc',
|
'layout' => 'classic.inc',
|
||||||
'helpers' => array()
|
'helpers' => array()
|
||||||
);
|
);
|
||||||
@ -70,6 +70,14 @@ class ComicPress {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function needs_storyline_nav() {
|
||||||
|
return (count($this->category_tree) > 1) && ($this->comicpress_options['category_usage'] == "storyline");
|
||||||
|
}
|
||||||
|
|
||||||
|
function is_multicomic() {
|
||||||
|
return $this->comicpress_options['category_usage'] == "multicomic";
|
||||||
|
}
|
||||||
|
|
||||||
function wp_head() {
|
function wp_head() {
|
||||||
foreach ($this->additional_stylesheets as $uri) { ?>
|
foreach ($this->additional_stylesheets as $uri) { ?>
|
||||||
<link rel="stylesheet" href="<?php echo get_template_directory_uri() . $uri ?>" type="text/css" />
|
<link rel="stylesheet" href="<?php echo get_template_directory_uri() . $uri ?>" type="text/css" />
|
||||||
@ -463,6 +471,24 @@ class ComicPress {
|
|||||||
|
|
||||||
return $prev_next_categories;
|
return $prev_next_categories;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_sorted_post_categories($override_post = null) {
|
||||||
|
global $post;
|
||||||
|
$post_to_use = (!empty($override_post)) ? $override_post : $post;
|
||||||
|
|
||||||
|
$categories = wp_get_post_categories($post_to_use->ID);
|
||||||
|
|
||||||
|
$sorted_categories = array();
|
||||||
|
|
||||||
|
foreach ($this->category_tree as $node) {
|
||||||
|
$category_id = end(explode("/", $node));
|
||||||
|
if (in_array($category_id, $categories)) {
|
||||||
|
$sorted_categories[] = $category_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $sorted_categories;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
@ -64,7 +64,7 @@ function comicpress_init() {
|
|||||||
global $post, $comicpress;
|
global $post, $comicpress;
|
||||||
|
|
||||||
if (!empty($post)) {
|
if (!empty($post)) {
|
||||||
if (in_comic_category()) {
|
if (in_comic_category() && $comicpress->is_multicomic()) {
|
||||||
$category_ids = wp_get_post_categories($post->ID);
|
$category_ids = wp_get_post_categories($post->ID);
|
||||||
if (is_array($category_ids)) {
|
if (is_array($category_ids)) {
|
||||||
foreach ($category_ids as $id) {
|
foreach ($category_ids as $id) {
|
||||||
|
@ -1,26 +1,17 @@
|
|||||||
<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('nav.inc') ?>
|
||||||
<div class="comicdate">
|
<div class="comicdate"><?php the_date('F jS, Y') ?></div>
|
||||||
<?php the_date('F jS, Y') ?>
|
<br class="clear" />
|
||||||
</div>
|
|
||||||
<div class="clear"></div>
|
|
||||||
<?php if (get_option('comicpress-enable-storyline-support') == 1) { ?>
|
|
||||||
<ul class="storyline-cats"><li class="storyline-root"><?php the_category(' » </li><li>', multiple) ?></li></ul>
|
|
||||||
<?php } ?>
|
|
||||||
<h2>
|
<h2>
|
||||||
<a href="<?php get_permalink($last_comic_post->ID) ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'comicpress'), get_the_title()) ?>"><?php the_title() ?></a>
|
<a href="<?php get_permalink($last_comic_post->ID) ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'comicpress'), get_the_title()) ?>"><?php the_title() ?></a>
|
||||||
</h2>
|
</h2>
|
||||||
<div class="entry">
|
<div class="entry"><?php the_content('↓ Read the rest of this entry...') ?></div>
|
||||||
<?php the_content('↓ Read the rest of this entry...') ?>
|
|
||||||
</div>
|
|
||||||
<?php the_transcript('styled') ?>
|
<?php the_transcript('styled') ?>
|
||||||
<div class="tags">
|
<div class="tags"><?php the_tags('└ Tags: ', ', ', ''); edit_post_link('Edit Post', ' [ ', ' ] ') ?></div>
|
||||||
<?php the_tags('└ Tags: ', ', ', ''); edit_post_link('Edit Post', ' [ ', ' ] ') ?>
|
|
||||||
</div>
|
|
||||||
<div class="comment-link">
|
<div class="comment-link">
|
||||||
<?php if ('open' == $post->comment_status) { comments_popup_link('“Comment”', '“1 Comment”', '“% Comments”'); } ?>
|
<?php if ('open' == $post->comment_status) { comments_popup_link('“Comment”', '“1 Comment”', '“% Comments”'); } ?>
|
||||||
</div>
|
</div>
|
||||||
<br class="clear-margins" />
|
<br class="clear" />
|
||||||
</div>
|
</div>
|
||||||
<div class="post-comic-foot"></div>
|
<div class="post-comic-foot"></div>
|
@ -1,26 +1,53 @@
|
|||||||
<div class="nav">
|
<?php
|
||||||
<?php if ($nav_comics['show_first']) { ?>
|
$nav_fields = array(
|
||||||
<div class="nav-first">
|
'first' => '‹‹ ' . __('First', 'comicpress'),
|
||||||
<a href="<?php echo get_permalink($nav_comics['first']->ID) ?>"
|
'previous' => '‹ ' . __('Previous', 'comicpress'),
|
||||||
title="<?php _e('Go to the first comic', 'comicpress') ?>">‹‹ <?php _e('First', 'comicpress') ?></a>
|
'next' => __('Next', 'comicpress') . ' ›',
|
||||||
</div>
|
'last' => __('Last', 'comicpress') . ' ››'
|
||||||
<?php } ?>
|
);
|
||||||
<?php if ($nav_comics['show_previous']) { ?>
|
|
||||||
<div class="nav-previous">
|
if ($comicpress->needs_storyline_nav()) {
|
||||||
<a href="<?php echo get_permalink($nav_comics['previous']->ID) ?>"
|
$nav_fields = array_merge(
|
||||||
title="<?php _e('Go to the previous comic', 'comicpress') ?>">‹ <?php _e('Previous', 'comicpress') ?></a>
|
array('prior' => '‹‹ ' . __('Prior Storyline', 'comicpress')),
|
||||||
</div>
|
$nav_fields,
|
||||||
<?php } ?>
|
array('upcoming' => __('Upcoming Storyline', 'comicpress') . ' ››')
|
||||||
<?php if ($nav_comics['show_next']) { ?>
|
);
|
||||||
<div class="nav-first">
|
|
||||||
<a href="<?php echo get_permalink($nav_comics['next']->ID) ?>"
|
foreach ($comicpress->get_sorted_post_categories() as $category_id) {
|
||||||
title="<?php _e('Go to the next comic', 'comicpress') ?>"><?php _e('Next', 'comicpress') ?> ›</a>
|
$prev_next_categories = $comicpress->get_previous_next_categories($category_id);
|
||||||
</div>
|
|
||||||
<?php } ?>
|
foreach ($prev_next_categories as $master_id => $cat_list) {
|
||||||
<?php if ($nav_comics['show_last']) { ?>
|
foreach ($cat_list as $which => $id) {
|
||||||
<div class="nav-previous">
|
switch ($which) {
|
||||||
<a href="<?php echo get_permalink($nav_comics['last']->ID) ?>"
|
case "previous":
|
||||||
title="<?php _e('Go to the last comic', 'comicpress') ?>"><?php _e('Last', 'comicpress') ?> ››</a>
|
$terminal_post = $comicpress->get_last_comic($id);
|
||||||
</div>
|
$which_field = "prior";
|
||||||
<?php } ?>
|
break;
|
||||||
</div>
|
case "next":
|
||||||
|
$terminal_post = $comicpress->get_first_comic($id);
|
||||||
|
$which_field = "upcoming";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_object($terminal_post)) {
|
||||||
|
$nav_comics[$which_field] = $terminal_post;
|
||||||
|
$nav_comics["show_${which_field}"] =true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($terminal_post) == 2) { break; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
<div class="nav">
|
||||||
|
<?php foreach ($nav_fields as $field => $link_text) { ?>
|
||||||
|
<?php if ($nav_comics['show_' . $field]) { ?>
|
||||||
|
<div class="nav-<?php echo $field ?>">
|
||||||
|
<a href="<?php echo (is_object($nav_comics[$field])) ? get_permalink($nav_comics[$field]->ID) : $nav_comics[$field] ?>"
|
||||||
|
title="<?php sprintf(__('Go to the %s comic', 'comicpress'), $field) ?>"><?php echo $link_text ?></a>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
<?php } ?>
|
||||||
|
</div>
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
global $comicpress, $nav_comics;
|
global $comicpress, $nav_comics;
|
||||||
|
|
||||||
comicpress_get_header();
|
comicpress_init();
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
@ -276,6 +276,37 @@ FILE
|
|||||||
|
|
||||||
$this->assertEquals($expected_results, $cp->get_layout_choices());
|
$this->assertEquals($expected_results, $cp->get_layout_choices());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function providerTestGetSortedPostCategories() {
|
||||||
|
return array(
|
||||||
|
array(
|
||||||
|
array(1),
|
||||||
|
array('0/1'),
|
||||||
|
array(1)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array(2, 1),
|
||||||
|
array('0/1', '0/1/2'),
|
||||||
|
array(1, 2)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array(2, 1),
|
||||||
|
array('0/1', '0/1/3', '0/1/2'),
|
||||||
|
array(1, 2)
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider providerTestGetSortedPostCategories
|
||||||
|
*/
|
||||||
|
function testGetSortedPostCategories($post_categories, $category_tree, $expected_sort_order) {
|
||||||
|
$this->cp->category_tree = $category_tree;
|
||||||
|
|
||||||
|
wp_set_post_categories(1, $post_categories);
|
||||||
|
|
||||||
|
$this->assertEquals($expected_sort_order, $this->cp->get_sorted_post_categories((object)array('ID' => 1)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Reference in New Issue
Block a user