move randomcomic stuff into core
This commit is contained in:
parent
83e1175f2a
commit
45d9c45b23
@ -9,9 +9,27 @@ class ComicPressAddonCore extends ComicPressAddon {
|
|||||||
add_action('show_rss', array(&$this, 'show_rss'), 1, 1);
|
add_action('show_rss', array(&$this, 'show_rss'), 1, 1);
|
||||||
add_filter('the_content', array(&$this, 'insert_comic_feed'));
|
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;
|
$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() { ?>
|
function comic_feed() { ?>
|
||||||
<p><a href="<?php the_permalink() ?>"><?php do_action('show_rss') ?></a></p><?php
|
<p><a href="<?php the_permalink() ?>"><?php do_action('show_rss') ?></a></p><?php
|
||||||
}
|
}
|
||||||
|
@ -136,20 +136,6 @@ function the_transcript($displaymode = 'raw') {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//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
|
// Register Sidebar and Define Widgets
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user