示例#1
0
 /**
  * Render the widget.
  * 
  * @param array $args General widget arguments.
  * @param array $instance Specific instance arguments.
  * @uses WebcomicTag::webcomic_list_terms()
  * @uses WebcomicTag::webcomic_term_cloud()
  * @uses WebcomicTag::webcomic_dropdown_terms()
  * @uses WebcomicTag::get_webcomic_collection()
  */
 public function widget($args, $instance)
 {
     extract($args);
     extract($instance);
     $a = array_merge($args, $instance);
     $object = get_queried_object();
     unset($a['name']);
     $a['target'] = empty($a['target']) ? 'archive' : $a['target'];
     $a['taxonomy'] = $collection ? "{$collection}_character" : WebcomicTag::get_webcomic_collection() . '_character';
     $a['show_option_none'] = __('Select Character', 'webcomic');
     if (!empty($object->taxonomy) and $a['taxonomy'] === $object->taxonomy) {
         $a['selected'] = $object->term_id;
     }
     if ('list' === $format) {
         $output = WebcomicTag::webcomic_list_terms($a);
     } elseif ('dropdown' === $format) {
         $output = WebcomicTag::webcomic_dropdown_terms($a);
     } else {
         $output = WebcomicTag::webcomic_term_cloud($a);
     }
     if ($output) {
         echo $before_widget, empty($title) ? '' : $before_title . $title . $after_title, $output, $after_widget;
     }
 }
示例#2
0
文件: tags.php 项目: ecerta/webcomic
 /**
  * Render a list of webcomic characters.
  * 
  * ### Arguments
  * 
  * - `string` **$id** - Value of the id attribute of the list element.
  * - `mixed` **$class** - String or array of additional classes for the list element.
  * - `string` **$before** - Content to display before the output.
  * - `string` **$after** - Content to display after the output.
  * - `boolean` **$ordered** - Use `<ol>` instead of `<ul>`.
  * - `string` **$collection** - The collection characters must belong to.
  * - `string` **$orderby** - What field to sort terms by. Defaults to 'name'.
  * - `object` **$walker** - Custom walker object. Defaults Walker_WebcomicTerm_List.
  * - `string` **$feed** - Text or image URL to use for a term feed link.
  * - `string` **$feed_type** - The type of feed to link to.
  * - `integer` **$depth** - How deep the walker should run. Defaults to 0 (all levels). A -1 depth will result in flat output.
  * - `boolean` **$webcomics** - Whether to display a list of webcomic posts grouped by term. The 'hide_empty' argument is ignored when $webcomics is true.
  * - `string` **$webcomic_order** - How to order webcomics, one of 'ASC' or 'DESC'. Defaults to 'ASC'.
  * - `string` **$webcomic_orderby** - What field to order webcomics by. Defaults to 'date'. See WP_Query for details.
  * - `string` **$webcomic_image** - Size of the webcomic image to use for webcomic links.
  * - `boolean` **$show_count** - Whether to display the total number of webcomics in a term.
  * - `boolean` **$show_description** - Whether to display term descriptions.
  * - `boolean` **$show_image** - Size of the term image to use for term links.
  * - `string` **$target** - The target url for terms, one of 'archive', 'first', 'last', or 'random'. Defaults to 'archive'.
  * - `integer` **$selected** - The ID of the selected term or webcomic.
  * 
  * <code class="php">
  * // render a list of characters with at least one webcomic in the current collection
  * webcomic_list_characters();
  * 
  * // render an ordered list of all characters in collection 42 linked to the beginning of each character
  * webcomic_list_characters( array( 'collection' => 'webcomic42', 'hide_empty' => false, 'target' => 'first', 'ordered' => true ) );
  * 
  * // render a list of published webcomic thumbnails grouped by character in collection 42 with character descriptions
  * webcomic_list_characters( array( 'collection' => 'webcomic42', 'show_description' => true, 'webcomics' => true, 'webcomic_image' => 'thumbnail' ) );
  * </code>
  * 
  * <code class="bbcode">
  * // render a list of characters with at least one webcomic in the current collection
  * [webcomic_list_characters]
  * 
  * // render an ordered list of all characters in collection 42 linked to the beginning of each character
  * [webcomic_list_characters collection="webcomic42" hide_empty="false" target="first" ordered="true"]
  * 
  * // render a list of published webcomic thumbnails grouped by character in collection 42 with character descriptions
  * [webcomic_list_characters collection="webcomic42" show_description="true" webcomics="true" webcomic_image="thumbnail"]
  * </code>
  * 
  * @package Webcomic
  * @param array $args Array of arguments. See function description for detailed information.
  * @uses WebcomicTag::get_webcomic_collection()
  * @uses WebcomicTag::webcomic_list_terms()
  */
 function webcomic_list_characters($args = array())
 {
     $r = wp_parse_args($args, array('id' => '', 'class' => '', 'before' => '', 'after' => '', 'sep' => '', 'ordered' => '', 'hierarchical' => true, 'collection' => '', 'orderby' => '', 'walker' => false, 'feed' => '', 'feed_type' => 'rss2', 'depth' => 0, 'webcomics' => false, 'webcomic_image' => '', 'show_count' => false, 'show_description' => false, 'show_image' => '', 'target' => 'archive', 'selected' => 0));
     $collection = $r['collection'] ? $r['collection'] : WebcomicTag::get_webcomic_collection();
     if (taxonomy_exists("{$collection}_character")) {
         $r['taxonomy'] = "{$collection}_character";
         echo WebcomicTag::webcomic_list_terms($r);
     }
 }
示例#3
0
 /**
  * Handle webcomic_list_terms shortcodes.
  * 
  * @param array $atts Shortcode attributes.
  * @param string $content Shortcode content.
  * @param string $name Shortcode name.
  * @return string
  * @uses WebcomicTag::get_webcomic_collection()
  * @uses WebcomicTag::webcomic_list_terms()
  */
 public function webcomic_list_terms($atts, $content, $name)
 {
     $r = shortcode_atts(array('id' => '', 'class' => '', 'before' => '', 'after' => '', 'sep' => '', 'ordered' => '', 'hierarchical' => true, 'collection' => '', 'orderby' => '', 'walker' => false, 'feed' => '', 'feed_type' => 'rss2', 'depth' => 0, 'webcomics' => false, 'webcomic_image' => '', 'show_count' => false, 'show_description' => false, 'show_image' => '', 'target' => 'archive', 'selected' => 0), $atts);
     $collection = $r['collection'] ? $r['collection'] : WebcomicTag::get_webcomic_collection();
     if (false !== strpos($name, 'storyline')) {
         $tax = 'storyline';
     } elseif (false !== strpos($name, 'character')) {
         $tax = 'character';
     } else {
         $tax = '';
     }
     if (taxonomy_exists("{$collection}_{$tax}")) {
         $r['taxonomy'] = "{$collection}_{$tax}";
         return WebcomicTag::webcomic_list_terms($r);
     }
 }