From b7ca9316adfdc389d5cedd3ed9d69897cc945ca2 Mon Sep 17 00:00:00 2001 From: Frumph Date: Sat, 30 Mar 2013 16:59:59 -0700 Subject: [PATCH] Adjustments to the navigation to work on home page with first comic (hopefully) --- comiceasel.php | 6 ++++-- functions/displaycomic.php | 1 - functions/library.php | 1 + functions/navigation.php | 5 +---- functions/redirects.php | 1 + options/general.php | 11 ++++++++++- readme.txt | 6 +++++- widgets/navigation.php | 20 ++++++++++---------- 8 files changed, 32 insertions(+), 19 deletions(-) diff --git a/comiceasel.php b/comiceasel.php index 83c46ef..06a0ff5 100644 --- a/comiceasel.php +++ b/comiceasel.php @@ -3,7 +3,7 @@ Plugin Name: Comic Easel Plugin URI: http://comiceasel.com Description: Comic Easel allows you to incorporate a WebComic using the WordPress Media Library functionality with Navigation into almost all WordPress themes. With just a few modifications of adding injection do_action locations into a theme, you can have the theme of your choice display and manage a webcomic. -Version: 1.1 +Version: 1.2 Author: Philip M. Hofer (Frumph) Author URI: http://frumph.net/ @@ -300,7 +300,8 @@ function ceo_load_options($reset = false) { 'include_comics_in_blog_archive' => false, 'disable_related_comics' => false, 'custom_post_type_slug_name' => 'comic', - 'display_first_comic_on_home_page' => false + 'display_first_comic_on_home_page' => false, + 'disable_style_sheet' => false ) as $field => $value) { $ceo_config[$field] = $value; } @@ -321,6 +322,7 @@ function ceo_pluginfo($whichinfo = null) { ceo_chapters_activate(); $ceo_options['db_version'] = '1.1'; $ceo_options['display_first_comic_on_home_page'] = false; + $ceo_options['disable_style_sheet'] = false; update_option('comiceasel-config', $ceo_options); } if (!isset($ceo_options['custom_post_type_slug_name']) || empty($ceo_options['custom_post_type_slug_name'])) $ceo_options['custom_post_type_slug_name'] == 'comic'; diff --git a/functions/displaycomic.php b/functions/displaycomic.php index cd6d0e3..2e58fdf 100644 --- a/functions/displaycomic.php +++ b/functions/displaycomic.php @@ -90,7 +90,6 @@ function ceo_display_comic_area() { $wp_query->in_the_loop = true; $comicFrontpage = new WP_Query(); $comicFrontpage->query($comic_args); while ($comicFrontpage->have_posts()) : $comicFrontpage->the_post(); ceo_display_comic_wrapper(); - break; endwhile; ceo_UnProtect(); } diff --git a/functions/library.php b/functions/library.php index 4bc26d2..4d4d91d 100644 --- a/functions/library.php +++ b/functions/library.php @@ -4,6 +4,7 @@ */ function ceo_get_sidebar($location = '') { + global $post; if (!empty($location)) do_action($location.'-top'); if (file_exists(get_stylesheet_directory().'/sidebar-'.$location.'.php')) { get_sidebar($location); diff --git a/functions/navigation.php b/functions/navigation.php index d79c4e2..c3ce7d4 100644 --- a/functions/navigation.php +++ b/functions/navigation.php @@ -22,7 +22,6 @@ function ceo_get_first_comic_in_chapter_permalink() { } function ceo_get_last_comic($in_chapter = false) { - global $post; $current_chapter = get_the_terms( $post->ID, 'chapters'); $current_chapter_id = 0; if (is_array($current_chapter) && $in_chapter) { @@ -129,7 +128,6 @@ function ceo_get_terminal_post_of_chapter($chapterID = 0, $first = true) { */ function ceo_get_adjacent_comic($previous = true, $in_same_chapter = false, $taxonomy = 'comic') { global $post, $wpdb; - if ( empty( $post ) ) return null; $current_post_date = $post->post_date; @@ -154,7 +152,7 @@ function ceo_get_adjacent_comic($previous = true, $in_same_chapter = false, $tax $sort = apply_filters( "get_{$adjacent}_{$taxonomy}_sort", "ORDER BY p.post_date $order LIMIT 1" ); $query = "SELECT p.* FROM $wpdb->posts AS p $join $where $sort"; - $query_key = "adjacent_{$taxonomy}_" . md5($query); + $query_key = "adjacent_{$taxonomy}_{$post->ID}_{$previous}_{$in_same_chapter}"; // . md5($query); $result = wp_cache_get($query_key, 'counts'); if ( false !== $result ) return $result; @@ -162,7 +160,6 @@ function ceo_get_adjacent_comic($previous = true, $in_same_chapter = false, $tax $result = $wpdb->get_row("SELECT p.* FROM $wpdb->posts AS p $join $where $sort"); if ( null === $result ) $result = ''; - wp_cache_set($query_key, $result, 'counts'); return $result; } diff --git a/functions/redirects.php b/functions/redirects.php index bc5c37a..01bf55c 100644 --- a/functions/redirects.php +++ b/functions/redirects.php @@ -8,6 +8,7 @@ if ( isset( $_GET['random'] ) ) //to use simply create a URL link to "/?latestcomic" function ceo_latest_comic_jump() { + $chapter = 0; if (isset($_GET['latest'])) $chapter = (int)esc_attr($_GET['latest']); if (!empty($chapter)) { $this_chapter = get_term_by('term_id', $chapter, 'chapters'); diff --git a/options/general.php b/options/general.php index 4dc5e7e..f0bd146 100644 --- a/options/general.php +++ b/options/general.php @@ -70,7 +70,16 @@ - + + + + + /> + + + + +
diff --git a/readme.txt b/readme.txt index 24a7e41..8c6612d 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: frumph Tags: comiceasel, easel, webcomic, comic, webcomic Requires at least: 3.2 Tested up to: 3.5 -Stable tag: 1.1 +Stable tag: 1.2 Donate link: http://frumph.net License: GPLv3 or later License URI: http://www.gnu.org/licenses/gpl-3.0.html @@ -125,6 +125,10 @@ The comic navigation widget is only seen if you have the comic sidebar's enabled == Changelog == += 1.2 = +Attempt at a navigation fix for the widget for front page ASC/DESC changes +Also fixed (hopefully) the name change after saving the widget + = 1.1 = Added option to allow making the first comic appear on the home page the comic's blog post now will search for content-comic.php in the theme/child themes directory and use that if it exists diff --git a/widgets/navigation.php b/widgets/navigation.php index 0e2ded8..f779f0a 100644 --- a/widgets/navigation.php +++ b/widgets/navigation.php @@ -162,22 +162,22 @@ class ceo_comic_navigation_widget extends WP_Widget { } function widget($args, $instance) { - global $wp_query, $post; + global $post; if (is_home() || is_front_page()) { - ceo_Protect(); + $order = (ceo_pluginfo('display_first_comic_on_home_page')) ? 'asc' : 'desc'; $comic_args = array( 'showposts' => 1, 'posts_per_page' => 1, - 'post_type' => 'comic' + 'post_type' => 'comic', + 'order' => $order ); - $posts = get_posts($comic_args); - foreach ($posts as $post) { + $wp_query->in_the_loop = true; $comicFrontpage = new WP_Query(); $comicFrontpage->query($comic_args); + while ($comicFrontpage->have_posts()) : $comicFrontpage->the_post(); $this->display_comic_nav_wrapper($args, $instance); - } - ceo_UnProtect(); - } else { + endwhile; + } else { $this->display_comic_nav_wrapper($args, $instance); - } + } } function update($new_instance, $old_instance) { @@ -267,7 +267,7 @@ class ceo_comic_navigation_widget extends WP_Widget {
/> -
+

/>