move randomcomic stuff into core

This commit is contained in:
John Bintz 2009-07-13 04:30:01 -04:00
parent 83e1175f2a
commit 45d9c45b23
2 changed files with 18 additions and 14 deletions

View File

@ -9,9 +9,27 @@ class ComicPressAddonCore extends ComicPressAddon {
add_action('show_rss', array(&$this, 'show_rss'), 1, 1);
add_filter('the_content', array(&$this, 'insert_comic_feed'));
if (isset($_GET['randomcomic'])) {
add_action('template_redirect', array(&$this, 'go_to_random_comic'));
}
$this->comicpress = $comicpress;
}
//Generate a random comic page - to use simply create a URL link to "/?randomcomic"
function go_to_random_comic() {
$random_comic_query = new WP_Query();
$random_comic_query->query('showposts=1&orderby=rand&cat=' . $this->comicpress->get_all_comic_categories_as_cat_string());
while ($random_comic_query->have_posts()) {
$random_comic_query->the_post();
$random_comic_id = get_the_ID();
break;
}
if (!empty($random_comic_id)) {
wp_redirect(get_permalink( $random_comic_id ));
}
}
function comic_feed() { ?>
<p><a href="<?php the_permalink() ?>"><?php do_action('show_rss') ?></a></p><?php
}

View File

@ -137,20 +137,6 @@ function the_transcript($displaymode = 'raw') {
}
}
//Generate a random comic page - to use simply create a URL link to "/?randomcomic"
function random_comic() {
$randomComicQuery = new WP_Query(); $randomComicQuery->query('showposts=1&orderby=rand&cat='.get_all_comic_categories_as_cat_string());
while ($randomComicQuery->have_posts()) : $randomComicQuery->the_post();
$random_comic_id = get_the_ID();
endwhile;
wp_redirect( get_permalink( $random_comic_id ) );
exit;
}
if ( isset( $_GET['randomcomic'] ) )
add_action( 'template_redirect', 'random_comic' );
// Register Sidebar and Define Widgets
if ( function_exists('register_sidebar') )