diff --git a/widgets/graphical-navigation.php b/widgets/graphical-navigation.php index 112893c..c96b1f8 100644 --- a/widgets/graphical-navigation.php +++ b/widgets/graphical-navigation.php @@ -6,7 +6,6 @@ Description: This widget places graphical navigation buttons on your comic. For Author: Philip M. Hofer (Frumph) & John Bintz Version: 1.2 Author URI: http://webcomicplanet.com/ - */ require_once(dirname(__FILE__) . '/../classes/ComicPressNavigation.inc'); @@ -17,11 +16,108 @@ class widget_comicpress_graphical_navigation extends WP_Widget { $this->WP_Widget('graphicalnavigation', __('Comic Navigation','comicpress'), $widget_ops); } - function comicpress_display_navigation_link($which, $current, $target, $title, $content = '') { + /** + * Initialize the widget class. + */ + function init() { + add_filter('comicpress_display_navigation_order', array(&$this, 'comicpress_display_navigation_order')); + add_filter('comicpress_display_navigation_link', array(&$this, 'comicpress_display_navigation_link'), 10, 5); + add_filter('comicpress_wrap_navigation_buttons', array(&$this, 'comicpress_wrap_navigation_buttons'), 10, 2); + + // these two need to be moved one level up + add_filter('comicpress_get_random_link_url', array(&$this, 'comicpress_get_random_link_url')); + add_filter('comicpress_get_buy_print_url', array(&$this, 'comicpress_get_buy_print_url')); + } + + /** + * Get the random link URL. + */ + function comicpress_get_random_link_url($url = '') { + return bloginfo('url') . '/?randomcomic'; + } + + /** + * Get the URL to buy a print. + * Handles hitting the global namespace for you. + */ + function comicpress_get_buy_print_url($url = '') { + global $buy_print_url; + return $buy_print_url; + } + + /** + * Render a button. + */ + function comicpress_display_navigation_link($which, $current, $target, $instance, $content = '') { + global $id; + + $ok = true; switch ($which) { - case 'first': - + case 'first': + case 'last': + $ok = $this->_will_display_nav_link($which, $current, $target); + break; + case 'previous': + case 'next': + case 'story_prev': + case 'story_next': + $ok = !empty($target); + break; + case 'archives': + $ok = !empty($instance['archive_path']); + break; } + + ob_start(); + switch ($which) { + case 'first': + case 'last': + case 'previous': + case 'next': + case 'story_prev': + case 'story_next': + if ($ok) { + ?>">ID; + ?> +
+
+
+ init($storyline); + $post_nav = $navigation->get_post_nav($post); $storyline_to_nav_mapping = array( - + 'story_prev' => 'storyline-previous', + 'story_next' => 'storyline-next' ); - $this_permalink = get_permalink(); + $nav_links = array(); + foreach (apply_filters('comicpress_display_navigation_order', array()) as $order) { + if ($instance[$order] == "on") { + $target_post_nav = (isset($storyline_to_nav_mapping[$order])) ? $storyline_to_nav_mapping[$order] : $order; - $temp_query = $wp_query->is_single; - $wp_query->is_single = true; - $prev_comic = get_previous_comic_permalink(); - $next_comic = get_next_comic_permalink(); - $wp_query->is_single = $temp_query; - $temp_query = null; + $target_post = null; + if (isset($post_nav[$target_post_nav])) { $target_post = $post_nav[$target_post_nav]; } - $first_comic = get_first_comic_permalink(); - $last_comic = get_last_comic_permalink(); + $nav_links[] = end(apply_filters('comicpress_display_navigation_link', $order, $post, $target_post, $instance, '')); + } + } - $prev_story = get_previous_storyline_start_permalink(); - $next_story = get_next_storyline_start_permalink(); - ?> - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - +