Esempio n. 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;
     }
 }
Esempio n. 2
0
 /**
  * Return a "cloud" of webcomic characters.
  * 
  * ### Arguments
  * 
  * - `string` **$id** - Value of the id attribute of the wrapping element.
  * - `mixed` **$class** - String or array of additional classes for the wrapping element.
  * - `integer` **$smallest** - The smallest font size to display links in.
  * - `integer` **$largest** - The largest font size to display links in.
  * - `string` **$unit** - The CSS unit to use for $smallest and $largest.
  * - `string` **$image** - Size of the character avatar to use for character links. Modified by the number of posts in a given character and the $smallest and $largest values.
  * - `string` **$before** - Content to display before the output.
  * - `string` **$after** - Content to display after the output.
  * - `string` **$sep** - Separator to use between links. An empty value generates an unordered list. Defaults to "\n".
  * - `string` **$collection** - The collection characters must belong to.
  * - `string` **$order** - How to order characters. Defaults to 'RAND'.
  * - `mixed` **$callback** - Callback function to use when building links.
  * - `boolean` **$show_count** - Whether to display the total number of webcomics featuring a character.
  * - `string` **$target** - The target url for characters, one of 'archive', 'first', 'last', or 'random'. Defaults to 'archive'.
  * - `integer` **$selected** - The ID of the current character.
  * 
  * <code class="php">
  * // render a cloud of webcomic characters
  * webcomic_character_cloud();
  * 
  * // render a list cloud of webcomic characters in collection 42 linked to the beginning of each character
  * webcomic_character_cloud( array( 'collection' => 'webcomic42', 'target' => 'first', 'sep' => '' ) );
  * 
  * // render a cloud of thumbnail-sized webcomic avatars
  * webcomic_character_cloud( array( 'image' => 'thumbnail' ) );
  * </code>
  * 
  * <code class="bbcode">
  * // render a cloud of webcomic characters
  * [webcomic_character_cloud]
  * 
  * // render a list cloud of webcomic characters in collection 42 linked to the beginning of each character
  * [webcomic_character_cloud collection="webcomic42" target="first" sep=""]
  * 
  * // render a cloud of thumbnail-sized webcomic avatars
  * [webcomic_character_cloud 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_term_cloud()
  */
 function webcomic_character_cloud($args = array())
 {
     $r = wp_parse_args($args, array('id' => '', 'class' => '', 'smallest' => 75, 'largest' => 150, 'unit' => '%', 'image' => '', 'before' => '', 'after' => '', 'sep' => "\n", 'collection' => '', 'order' => 'RAND', 'callback' => '', 'show_count' => false, '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_term_cloud($r);
     }
 }
Esempio n. 3
0
 /**
  * Handle webcomic_term_cloud 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_term_cloud()
  */
 public function webcomic_term_cloud($atts, $content, $name)
 {
     $r = shortcode_atts(array('id' => '', 'class' => '', 'smallest' => 75, 'largest' => 150, 'unit' => '%', 'image' => '', 'before' => '', 'after' => '', 'sep' => "\n", 'collection' => '', 'order' => 'RAND', 'callback' => '', 'show_count' => false, '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_term_cloud($r);
     }
 }