示例#1
0
 /**
  * Render the widget.
  * 
  * @param array $args General widget arguments.
  * @param array $instance Specific instance arguments.
  * @uses WebcomicTag::webcomic_list_collections()
  * @uses WebcomicTag::webcomic_collection_cloud()
  * @uses WebcomicTag::webcomic_dropdown_collections()
  */
 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['orderby'] = 'name';
     $a['show_option_none'] = __('Select Collection', 'webcomic');
     if (!empty($object->query_var) and preg_match('/^webcomic\\d+$/', $object->query_var)) {
         $a['selected'] = $object->query_var;
     }
     if ('list' === $format) {
         $output = WebcomicTag::webcomic_list_collections($a);
     } elseif ('dropdown' === $format) {
         $output = WebcomicTag::webcomic_dropdown_collections($a);
     } else {
         $output = WebcomicTag::webcomic_collection_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 "cloud" of webcomic collections.
  * 
  * ### 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 collection poster to use for collection links. Modified by the number of posts in a given term 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` **$orderby** - What to sort the collections by. May be one of 'name', 'slug', 'count', or 'updated'. Defaults to collection ID.
  * - `string` **$order** - How to order collections. Defaults to 'RAND'.
  * - `mixed` **$callback** - Callback function to use when building links.
  * - `boolean` **$show_count** - Whether to display the total number of webcomics in a collection.
  * - `string` **$target** - The target url for collections, one of 'archive', 'first', 'last', or 'random'. Defaults to 'archive'.
  * - `integer` **$selected** - The ID of the current collection.
  * 
  * <code class="php">
  * // render a cloud of webcomic collections
  * webcomic_collection_cloud();
  * 
  * // render a list cloud of webcomic collections linked to the beginning of each character
  * webcomic_collection_cloud( array( 'target' => 'first', 'sep' => '' ) );
  * 
  * // render a cloud of thumbnail-sized webcomic collections
  * webcomic_collection_cloud( array( 'image' => 'thumbnail' ) );
  * </code>
  * 
  * <code class="bbcode">
  * // render a cloud of webcomic collections
  * [webcomic_collection_cloud]
  * 
  * // render a list cloud of webcomic collections linked to the beginning of each character
  * [webcomic_collection_cloud target="first" sep=""]
  * 
  * // render a cloud of thumbnail-sized webcomic collections
  * [webcomic_collection_cloud image="thumbnail"]
  * </code>
  * 
  * @package Webcomic
  * @param array $args Array of arguments. See function description for detailed information.
  * @uses WebcomicTag::webcomic_collection_cloud()
  */
 function webcomic_collection_cloud($args = array())
 {
     $r = wp_parse_args($args, array('id' => '', 'class' => '', 'smallest' => 75, 'largest' => 150, 'unit' => '%', 'image' => '', 'before' => '', 'after' => '', 'sep' => "\n", 'orderby' => '', 'order' => 'RAND', 'callback' => '', 'show_count' => false, 'target' => 'archive', 'selected' => 0));
     echo WebcomicTag::webcomic_collection_cloud($r);
 }
示例#3
0
 /**
  * Handle webcomic_collection_cloud shortcode.
  * 
  * @param array $atts Shortcode attributes.
  * @return string
  * @uses WebcomicTag::webcomic_collection_cloud()
  */
 public function webcomic_collection_cloud($atts)
 {
     $r = shortcode_atts(array('id' => '', 'class' => '', 'smallest' => 75, 'largest' => 150, 'unit' => '%', 'image' => '', 'before' => '', 'after' => '', 'sep' => "\n", 'orderby' => '', 'order' => 'RAND', 'callback' => '', 'show_count' => false, 'target' => 'archive', 'selected' => 0), $atts);
     return WebcomicTag::webcomic_collection_cloud($r);
 }