Introducing John Bintz's protect and restore functions, moved the #comic code from index & single into the layout-head so that it's uniformative code but made it call display_comic_area(); made it so that left and right sidebar's will know the comic code on index, etc. temporarily added the queries to the footer.php and re-enabled (orig) navigation for testing.

Signed-off-by: Philip M. Hofer (Frumph) <frumph_dragon@yahoo.com>
This commit is contained in:
Philip M. Hofer (Frumph) 2009-12-22 14:20:11 -08:00
parent 40295c662a
commit b0ad9bec80
9 changed files with 119 additions and 143 deletions

View File

@ -35,7 +35,7 @@
<span class="footer-pipe">|</span>
<a href="#outside" onclick="scrollup(); return false;"><?php _e('Back to Top &uarr;','comicpress'); ?></a>
</span>
<!-- <?php echo get_num_queries() ?> queries. <?php timer_stop(1) ?> seconds. -->
<br /><?php echo get_num_queries() ?> queries. <?php timer_stop(1) ?> seconds.
</p>
<?php } ?>
</div>

View File

@ -1,10 +1,19 @@
<?php
/**
* Display Comic
* Displays the comic.
*
*
*/
function display_comic_area() {
global $comicpress_options;
if (comicpress_check_child_file('partials/displaycomic') == false) { ?>
<div id="comic-wrap">
<div id="comic-head"><?php get_sidebar('over'); ?></div>
<div class="clear"></div>
<?php get_sidebar('comicleft'); ?>
<div id="comic"><?php display_comic(); ?></div>
<?php get_sidebar('comicright'); ?>
<div class="clear"></div>
<div id="comic-foot"><?php get_sidebar('under'); ?></div>
</div>
<?php }
}
function display_comic() {
global $post, $wp_query, $rascal_says, $comicpress_options, $comic_filename_filters;

View File

@ -6,8 +6,8 @@
*
*/
function display_comic_post() {
global $post, $wp_query, $authordata, $comicpress_options, $archive_comic_width;;
function display_comic_post($frontpage = 0) {
global $post, $wp_query, $authordata, $comicpress_options, $archive_comic_width;
$first_comic = get_first_comic_permalink();
$last_comic = get_last_comic_permalink();

41
functions/protect.php Normal file
View File

@ -0,0 +1,41 @@
<?php
/**
* Protect global $post and $wp_query.
* @param object $use_this_post If provided, after saving the current post, set up this post for template tag use.
*/
function Protect($use_this_post = null) {
global $post, $wp_query, $__post, $__wp_query;
$__post = $post;
$__wp_query = $wp_query;
if (!is_null($use_this_post)) {
$post = $use_this_post;
setup_postdata($post);
}
}
/**
* Temporarily restore the global $post variable and set it up for use.
*/
function Restore() {
global $post, $__post;
$post = $__post;
setup_postdata($post);
}
/**
* Restore global $post and $wp_query.
*/
function Unprotect() {
global $post, $wp_query, $__post, $__wp_query;
$post = $__post;
$wp_query = $__wp_query;
$__post = $__wp_query = null;
}
?>

View File

@ -1,68 +1,19 @@
<?php get_header(); ?>
<div id="content-wrapper-head"></div>
<div id="content-wrapper">
<?php include(get_template_directory() . '/layout-head.php'); ?>
<?php if (is_cp_theme_layout('gn,v3c')) get_sidebar('left'); ?>
<?php if (is_cp_theme_layout('gn,rgn')) { ?>
<div id="pagewrap-right">
<?php } ?>
<?php if (is_cp_theme_layout('v3cr')) { ?>
<div id="pagewrap-left">
<?php } ?>
<?php if (is_cp_theme_layout('v3c,v')) { ?>
<div id="content" class="narrowcolumn">
<div class="column">
<?php } ?>
<?php if (!(is_paged())) { ?>
<?php if (!$comicpress_options['disable_comic_frontpage']) { ?>
<?php $wp_query ->in_the_loop = true; $comicFrontpage = new WP_Query(); $comicFrontpage->query('showposts=1&cat='.get_all_comic_categories_as_cat_string());
while ($comicFrontpage->have_posts()) : $comicFrontpage->the_post() ?>
<?php if (comicpress_check_child_file('partials/displaycomic') == false) { ?>
<div id="comic-wrap">
<div id="comic-head"><?php get_sidebar('over'); ?></div>
<div class="clear"></div>
<?php get_sidebar('comicleft'); ?>
<div id="comic"><?php display_comic(); ?></div>
<?php get_sidebar('comicright'); ?>
<div class="clear"></div>
<div id="comic-foot"><?php get_sidebar('under'); ?></div>
</div>
<?php } ?>
<?php endwhile; ?>
<?php } ?>
<?php } ?>
<?php if (is_cp_theme_layout('3c,standard,3c2r')) { ?>
<div id="subcontent-wrapper-head"></div>
<div id="subcontent-wrapper">
<?php } ?>
<?php get_sidebar('overblog'); ?>
<?php if (is_cp_theme_layout('3c,rgn')) get_sidebar('left'); ?>
<?php if (is_cp_theme_layout('v3cr')) { ?>
<div id="subcontent-wrapper-head"></div>
<div id="subcontent-wrapper">
<?php } ?>
<?php if (!is_cp_theme_layout('v3c,v')) { ?>
<div id="content" class="narrowcolumn">
<div class="column">
<?php } ?>
<?php if (!$comicpress_options['disable_comic_frontpage'] && !$comicpress_options['disable_comic_blog_frontpage'] && !is_paged() ) { ?>
<?php while ($comicFrontpage->have_posts()) : $comicFrontpage->the_post();
<?php if (!$comicpress_options['disable_comic_frontpage'] && !$comicpress_options['disable_comic_blog_frontpage'] && !is_paged() ) {
Protect();
$comic_query = '&showposts=1&cat='.get_all_comic_categories_as_cat_string();
$posts = query_posts($comic_query);
$wp_query->is_archive = false;
if (have_posts()) {
while (have_posts()) : the_post();
display_comic_post();
$comicFrontPage->is_single = true;
comments_template();
endwhile; ?>
endwhile;
}
Restore();
UnProtect(); ?>
<?php } ?>
<?php if (function_exists('the_project_wonderful_ad')) { ?>
@ -81,6 +32,7 @@
<?php if (!$comicpress_options[disable_blog_frontpage]) {
global $blog_postcount;
Protect();
if (!$comicpress_options['split_column_in_two']) {
$blog_query = 'showposts='.$blog_postcount.'&cat="-'.exclude_comic_categories().'"&paged='.$paged;
@ -100,6 +52,8 @@
} else {
comicpress_dual_columns();
}
Restore();
UnProtect();
} ?>
<?php get_sidebar('underblog'); ?>

View File

@ -1,3 +1,4 @@
<?php global $comicpress_options; ?>
<?php if (comicpress_check_child_file('layout-head') == false) { ?>
<div id="content-wrapper-head"></div>
@ -13,6 +14,25 @@
<div id="pagewrap-left">
<?php } ?>
<?php
Protect();
if (!$comicpress_options['disable_comic_frontpage'] && is_home()) {
$comic_query = 'showposts=1&cat='.get_all_comic_categories_as_cat_string();
$posts = query_posts($comic_query);
if (have_posts()) {
while (have_posts()) : the_post();
$wp_query->is_single = true;
display_comic_area();
endwhile;
}
}
Restore();
UnProtect();
if (is_single() & in_comic_category()) {
display_comic_area();
}
?>
<?php if (is_cp_theme_layout('3c,standard,3c2r')) { ?>
<div id="subcontent-wrapper-head"></div>
<div id="subcontent-wrapper">

View File

@ -1,56 +1,8 @@
<?php get_header(); global $comicpress_options; ?>
<div id="content-wrapper-head"></div>
<div id="content-wrapper">
<?php get_header(); ?>
<?php include(get_template_directory() . '/layout-head.php'); ?>
<?php if (is_cp_theme_layout('gn,v3c')) get_sidebar('left'); ?>
<?php if (is_cp_theme_layout('gn,rgn')) { ?>
<div id="pagewrap-right">
<?php } ?>
<?php if (is_cp_theme_layout('v3cr')) { ?>
<div id="pagewrap-left">
<?php } ?>
<?php if (is_cp_theme_layout('v3c,v')) { ?>
<div id="content" class="narrowcolumn">
<div class="column">
<?php } ?>
<?php while (have_posts()) : the_post();
if (in_comic_category()) { ?>
<?php if (comicpress_check_child_file('partials/displaycomic') == false) { ?>
<div id="comic-wrap">
<div id="comic-head"><?php get_sidebar('over'); ?></div>
<div class="clear"></div>
<?php get_sidebar('comicleft'); ?>
<div id="comic"><?php display_comic(); ?></div>
<?php get_sidebar('comicright'); ?>
<div class="clear"></div>
<div id="comic-foot"><?php get_sidebar('under'); ?></div>
</div>
<?php } ?>
<?php } endwhile; ?>
<?php if (is_cp_theme_layout('3c,standard,3c2r')) { ?>
<div id="subcontent-wrapper-head"></div>
<div id="subcontent-wrapper">
<?php } ?>
<?php get_sidebar('overblog'); ?>
<?php if (is_cp_theme_layout('3c,rgn')) get_sidebar('left'); ?>
<?php if (is_cp_theme_layout('v3cr')) { ?>
<div id="subcontent-wrapper-head"></div>
<div id="subcontent-wrapper">
<?php } ?>
<?php if (!is_cp_theme_layout('v3c,v')) { ?>
<div id="content" class="narrowcolumn">
<div class="column">
<?php } ?>
<?php if (have_posts()) : while (have_posts()) : the_post();
<?php
if (have_posts()) : while (have_posts()) : the_post();
if (in_comic_category()) {
if (!$comicpress_options['disable_comic_blog_single']) {
display_comic_post();
@ -64,7 +16,8 @@
display_blog_post();
}
endwhile;
?>
?>
<?php if (function_exists('the_project_wonderful_ad')) { ?>
<div class="blogpwad">
<center>

View File

@ -20,14 +20,13 @@ class ComicPressComicBlogPostWidget extends WP_Widget {
function widget($args, $instance) {
global $post, $wp_query;
if (is_home() || is_single()) {
if ((is_home() || is_single()) && in_comic_category()) {
extract($args, EXTR_SKIP);
if (!empty($post->post_content)) {
echo $before_widget;
$title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
if ( !empty( $title ) ) { echo '<div class="heading">'.$title.'</div>'; }
display_comic_post();
echo $post->post_content;
echo $after_widget;
}
}

View File

@ -19,7 +19,7 @@ class widget_comicpress_graphical_navigation extends WP_Widget {
function widget($args, $instance) {
global $wp_query, $post;
if (is_home() || is_single()) {
// if (is_home() || is_single()) {
$this_permalink = get_permalink();
@ -113,7 +113,7 @@ class widget_comicpress_graphical_navigation extends WP_Widget {
</table>
</div>
<?php }
<?php // }
}
function update($new_instance, $old_instance) {
@ -273,13 +273,13 @@ class widget_comicpress_graphical_navigation extends WP_Widget {
<?php
}
}
// register_widget('widget_comicpress_graphical_navigation');
register_widget('widget_comicpress_graphical_navigation');
function widget_comicpress_graphical_navigation_init() {
new widget_comicpress_graphical_navigation();
}
// add_action('widgets_init', 'widget_comicpress_graphical_navigation_init');
add_action('widgets_init', 'widget_comicpress_graphical_navigation_init');
?>