add comic space insertion type

This commit is contained in:
John Bintz 2009-07-15 21:34:34 -04:00
parent baed6838a6
commit 82b01186ee
12 changed files with 68 additions and 29 deletions

View File

@ -2,7 +2,7 @@
class ComicPressAddonCore extends ComicPressAddon { class ComicPressAddonCore extends ComicPressAddon {
function init($comicpress) { function init($comicpress) {
add_action('admin_init', array(&$this, 'setup_admin_interface')); add_action('admin_menu', array(&$this, 'setup_admin_interface'));
add_filter('attachment_fields_to_edit', array(&$this, 'setup_comic_metadata_buttons'), 10, 2); add_filter('attachment_fields_to_edit', array(&$this, 'setup_comic_metadata_buttons'), 10, 2);
add_action('show_comic', array(&$this, 'show_comic'), 1, 1); add_action('show_comic', array(&$this, 'show_comic'), 1, 1);
add_action('show_archive', array(&$this, 'show_archive'), 1, 1); add_action('show_archive', array(&$this, 'show_archive'), 1, 1);
@ -54,8 +54,18 @@ class ComicPressAddonCore extends ComicPressAddon {
global $post; global $post;
$post_to_use = (is_null($override_post)) ? $this->comicpress->get_last_comic() : $post; $post_to_use = (is_null($override_post)) ? $this->comicpress->get_last_comic() : $post;
$comic_post = new ComicPressComicPost($post_to_use, &$this->comicpress); switch ($this->comicpress->comicpress_options['comic_space']) {
$comic_post->{$method}(); case "comic_only":
$comic_post = new ComicPressComicPost($post_to_use, &$this->comicpress);
$comic_post->{$method}();
break;
case "post_content":
$t = $post;
$post = $post_to_use;
include_partial('index-blog-post');
$post = $t;
break;
}
} }
function show_comic($override_post = null) { function show_comic($override_post = null) {
@ -323,6 +333,9 @@ class ComicPressAddonCore extends ComicPressAddon {
case 'blogpost_count': case 'blogpost_count':
$this->comicpress->comicpress_options[$option] = (int)$_POST['cp'][$option]; $this->comicpress->comicpress_options[$option] = (int)$_POST['cp'][$option];
break; break;
case 'comic_space':
$this->comicpress->comicpress_options[$option] = $_POST['cp'][$option];
break;
} }
} }
} }

View File

@ -63,6 +63,17 @@
<p><em>(categories can be modified on the Posts -> Categories page)</em></p> <p><em>(categories can be modified on the Posts -> Categories page)</em></p>
</td> </td>
</tr> </tr>
<tr>
<th scope="row">Insert into comic space:</th>
<td>
<?php foreach (array(
"comic_only" => __("The comic only, with post content below", 'comicpress'),
"post_content" => __("The post content", 'comicpress')
) as $value => $label) { ?>
<label><input type="radio" name="cp[comic_space]" value="<?php echo $value ?>" <?php echo ($this->comicpress->comicpress_options['comic_space'] == $value) ? 'checked="checked"' : "" ?> /> <?php echo $label ?></label><br />
<?php } ?>
</td>
</tr>
<tr> <tr>
<td>&nbsp;</td> <td>&nbsp;</td>
<td><input type="submit" value="<?php _e("Submit Changes", 'comicpress') ?>" /></td> <td><input type="submit" value="<?php _e("Submit Changes", 'comicpress') ?>" /></td>

View File

@ -2,7 +2,7 @@
<div id="content" class="archive"> <div id="content" class="archive">
<?php if (have_posts()) { <?php if (have_posts()) {
include(get_template_directory() . '/partials/archive-header.inc'); include_partial('archive-header');
// why can't wordpress allow for post date asc sorting out of the box... // why can't wordpress allow for post date asc sorting out of the box...
@ -11,15 +11,15 @@
the_post(); the_post();
if (in_comic_category()) { if (in_comic_category()) {
include(get_template_directory() . '/partials/archive-comic-post.inc'); include_partial('archive-comic-post');
} else { } else {
include(get_template_directory() . '/partials/archive-blog-post.inc'); include_partial('archive-blog-post');
} }
} }
include(get_template_directory() . '/partials/archive-page-nav.inc'); include_partial('archive-page-nav');
} else { } else {
include(get_template_directory() . '/partials/archive-not-found.inc'); include_partial('archive-not-found');
} ?> } ?>
</div> </div>

View File

@ -11,7 +11,8 @@ class ComicPress {
'archive_dimensions' => '125x', 'archive_dimensions' => '125x',
'mini_dimensions' => '100x', 'mini_dimensions' => '100x',
'category_order' => false, 'category_order' => false,
'blogpost_count' => 10 'blogpost_count' => 10,
'comic_space' => 'comic_only'
); );
var $additional_stylesheets = array(); var $additional_stylesheets = array();

View File

@ -50,6 +50,18 @@ function __comicpress_init() {
} }
} }
function include_partial($partials = '') {
if (!is_array($partials)) {
$partials = func_get_args();
}
foreach ($partials as $partial) {
if (($result = include(get_template_directory() . '/partials/' . $partial . '.inc')) === true) {
return;
}
}
}
function in_comic_category() { function in_comic_category() {
global $post, $comicpress; global $post, $comicpress;

View File

@ -7,16 +7,12 @@
$post = $nav_comics['last']; $post = $nav_comics['last'];
?> ?>
<?php if (!is_paged()) { ?> <?php if (!is_paged()) { include_partial('index-display-comic'); } ?>
<div id="comic-head"></div>
<div id="comic"><?php do_action('show_comic', null); ?></div>
<div id="comic-foot"></div>
<?php } ?>
<div id="content" class="narrowcolumn"> <div id="content" class="narrowcolumn">
<?php if (!is_paged()) { include(get_template_directory() . '/partials/index-comic-post.inc'); } ?> <?php if (!is_paged() && ($comicpress->comicpress_options['comic_space'] == "comic_only")) { include_partial('index-comic-post'); } ?>
<div id="blogheader"><!-- This area can be used for a heading above your main page blog posts --></div> <?php include_partial('index-blog-header'); ?>
<?php <?php
$wp_query = new WP_Query(); $wp_query = new WP_Query();
@ -31,10 +27,10 @@
while ($wp_query->have_posts()) { while ($wp_query->have_posts()) {
$wp_query->the_post(); $wp_query->the_post();
include(get_template_directory() . '/partials/index-blog-post.inc'); include_partial('index-blog-post');
} }
include(get_template_directory() . '/partials/index-blog-post.inc'); include_partial('index-blog-post');
?> ?>
</div> </div>

View File

@ -0,0 +1 @@
<div id="blogheader"></div>

View File

@ -0,0 +1,3 @@
<div id="comic-head"></div>
<div id="comic"><?php do_action('show_comic', null); ?></div>
<div id="comic-foot"></div>

View File

@ -0,0 +1,3 @@
<div id="comic-head"></div>
<div id="comic"><?php do_action('show_comic'); ?></div>
<div id="comic-foot"></div>

View File

@ -2,7 +2,7 @@
<div id="content" class="archive"> <div id="content" class="archive">
<?php <?php
include(get_template_directory() . '/partials/search-results-count.inc'); include_partial('search-results-count');
if (have_posts()) { if (have_posts()) {
query_posts($query_string . '&order=asc'); query_posts($query_string . '&order=asc');
@ -11,15 +11,15 @@
the_post(); the_post();
if (in_comic_category()) { if (in_comic_category()) {
include(get_template_directory() . '/partials/archive-comic-post.inc'); include_partial('search-comic-post', 'archive-comic-post');
} else { } else {
include(get_template_directory() . '/partials/archive-blog-post.inc'); include_partial('search-blog-post', 'archive-blog-post');
} }
} }
include(get_template_directory() . '/partials/archive-page-nav.inc'); include_partial('search-page-nav', 'archive-page-nav');
} else { } else {
include(get_template_directory() . '/partials/search-not-found.inc'); include_partial('search-not-found');
} }
?> ?>
</div> </div>

View File

@ -5,11 +5,7 @@
if (have_posts()) { if (have_posts()) {
the_post(); the_post();
if (in_comic_category()) { ?> if (in_comic_category()) { include_partial('single-display-comic') }
<div id="comic-head"></div>
<div id="comic"><?php do_action('show_comic'); ?></div>
<div id="comic-foot"></div>
<?php }
} }
rewind_posts(); rewind_posts();
@ -21,7 +17,9 @@
if (have_posts()) { if (have_posts()) {
while (have_posts()) { the_post(); while (have_posts()) { the_post();
if (in_comic_category()) { if (in_comic_category()) {
include(get_template_directory() . '/partials/single-comic-post.inc'); if ($comicpress->comicpress_options['comic_space'] == "comic_only")) {
include(get_template_directory() . '/partials/single-comic-post.inc');
}
} else { } else {
include(get_template_directory() . '/partials/single-blog-post.inc'); include(get_template_directory() . '/partials/single-blog-post.inc');
} }

View File

@ -0,0 +1 @@
this is my override blog header!