/** * Start element output. * * @param string $output Walker output string. * @param object $term Current term being handled by the walker. * @param integer $depth Depth the walker is currently at. * @param array $args Arguments passed to the walker. * @uses WebcomicTag::get_relative_webcomic_link() * @filter string webcomic_term_list_title Filters the term titles used by `webcomic_list_storylines` and `webcomic_list_characters`. * @filter string webcomic_term_image Filters the term images used by `webcomic_list_storylines` and `webcomic_list_characters`. * @filter string webcomic_term_description Filters the term titles used by `webcomic_dropdown_transcript_languages`. * @filter string term_list_webcomic_title Fitlers the webcomic titles used by `webcomic_list_storylines` and `webcomic_list_characters`. */ public function start_el(&$output, $term, $depth = 0, $args = array(), $current = 0) { global $post; $temp_post = $post; extract($args, $args['hierarchical'] ? EXTR_SKIP : EXTR_OVERWRITE); $term_title = apply_filters('webcomic_term_list_title', esc_attr($term->name), $term); $feed_image = filter_var($feed, FILTER_VALIDATE_URL); $feed_link = $feed ? '<a href="' . get_term_feed_link($term->term_id, $term->taxonomy, $feed_type) . '" class="webcomic-term-feed">' . ($feed_image ? '<img src="' . $feed . '" alt="' . sprintf(__('Feed for %s', 'webcomic'), $term->name) . '">' : $feed) . '</a>' : ''; if ($webcomics) { $the_posts = new WP_Query(array('posts_per_page' => -1, 'post_type' => str_replace(array('_storyline', '_character'), '', $term->taxonomy), 'order' => $webcomic_order, 'orderby' => $webcomic_orderby, 'tax_query' => array(array('taxonomy' => $term->taxonomy, 'field' => 'id', 'include_children' => false, 'terms' => $term->term_id)))); $output .= '<li class="webcomic-term ' . $term->taxonomy . ' webcomic-term-' . $term->term_id . ($selected === $term->term_id ? ' current' : '') . '"><a href="' . ('archive' === $target ? get_term_link($term, $term->taxonomy) : WebcomicTag::get_relative_webcomic_link($target, $term->term_id, false, $term->taxonomy, preg_replace('/_(storyline|character)$/', '', $term->taxonomy))) . '" class="webcomic-term-link"><div class="webcomic-term-name">' . $term_title . ($show_count ? " ({$term->count})" : '') . '</div>' . (($show_image and $term->webcomic_image) ? '<div class="webcomic-term-image">' . apply_filters('webcomic_term_image', wp_get_attachment_image($term->webcomic_image, $show_image), $show_image, $term) . '</div>' : '') . '</a>' . (($show_description and $term->description) ? '<div class="webcomic-term-description">' . apply_filters('webcomic_term_description', $term->description, $term) . '</div>' : '') . $feed_link; if ($the_posts->have_posts()) { $output .= '<' . ($ordered ? 'ol' : 'ul') . ' class="webcomics">'; $i = 0; while ($the_posts->have_posts()) { $the_posts->the_post(); $i++; $output .= '<li' . ($selected === get_the_ID() ? ' class="current"' : '') . '><a href="' . apply_filters('the_permalink', get_permalink()) . '">' . ($webcomic_image ? WebcomicTag::the_webcomic($webcomic_image, 'self') : apply_filters('term_list_webcomic_title', the_title('', '', false), get_post(), $i)) . '</a></li>'; } $output .= $ordered ? '</ol>' : '</ul>'; } } else { $output .= '<li class="webcomic-term ' . $term->taxonomy . ' webcomic-term-' . $term->term_id . ($selected === $term->term_id ? ' current' : '') . '"><a href="' . ('archive' === $target ? get_term_link($term, $term->taxonomy) : WebcomicTag::get_relative_webcomic_link($target, $term->term_id, false, $term->taxonomy, preg_replace('/_(storyline|character)$/', '', $term->taxonomy))) . '" class="webcomic-term-link"><div class="webcomic-term-name">' . $term_title . ($show_count ? " ({$term->count})" : '') . '</div>' . (($show_image and $term->webcomic_image) ? '<div class="webcomic-term-image">' . apply_filters('webcomic_term_image', wp_get_attachment_image($term->webcomic_image, $show_image), $show_image, $term) . '</div>' : '') . '</a>' . (($show_description and $term->description) ? '<div class="webcomic-term-description">' . apply_filters('webcomic_term_description', $term->description, $term) . '</div>' : '') . $feed_link; } $post = $temp_post; }
/** * Handle parameterized webcomic URL's. * * @uses WebcomicTag::get_relative_webcomic_term_link() * @uses WebcomicTag::get_relative_webcomic_link() * @hook init */ public function webcomic_redirect() { $link = ''; if (isset($_GET['first_webcomic']) or isset($_GET['last_webcomic']) or isset($_GET['random_webcomic'])) { if (isset($_GET['first_webcomic'])) { $relative = 'first'; } elseif (isset($_GET['last_webcomic'])) { $relative = 'last'; } else { $relative = 'random'; } $in_same_term = empty($_GET['in_same_term']) ? false : maybe_unserialize(stripslashes(urldecode($_GET['in_same_term']))); $excluded_terms = empty($_GET['excluded_terms']) ? false : maybe_unserialize(stripslashes(urldecode($_GET['excluded_terms']))); $taxonomy = empty($_GET['taxonomy']) ? false : maybe_unserialize(stripslashes(urldecode($_GET['taxonomy']))); $collection = empty($_GET["{$relative}_webcomic"]) ? array_rand(self::$config['collections']) : $_GET["{$relative}_webcomic"]; $link = WebcomicTag::get_relative_webcomic_link($relative, $in_same_term, $excluded_terms, $taxonomy, $collection); } elseif (isset($_GET['first_webcomic_term']) or isset($_GET['last_webcomic_term']) or isset($_GET['random_webcomic_term'])) { $target = empty($_GET['target']) ? 'archive' : $_GET['target']; if (isset($_GET['first_webcomic_term'])) { $relative = 'first'; } elseif (isset($_GET['last_webcomic_term'])) { $relative = 'last'; } else { $relative = 'random'; } if (empty($_GET["{$relative}_webcomic_term"])) { $taxonomy = array_rand(self::$config['collections']) . '_' . array_rand(array('storyline' => true, 'character' => true)); } else { $taxonomy = $_GET["{$relative}_webcomic_term"]; } $args = empty($_GET['args']) ? false : maybe_unserialize(stripslashes(urldecode($_GET['args']))); $link = WebcomicTag::get_relative_webcomic_term_link($target, $relative, $taxonomy, $args); } if ($link) { wp_redirect($link); die; } }