Esempio n. 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;
     }
 }
Esempio n. 2
0
 /**
  * Render a `<select>` element for webcomic collections.
  * 
  * ### Arguments
  * 
  * - `string` **$select_name** - Value for the name attribute of the `<select>` element.
  * - `string` **$id** - Value of the id attribute of the `<select>` element.
  * - `mixed` **$class** - String or array of additional classes for the `<select>` element.
  * - `string` **$show_option_all** - String to display for an "all" `<option>` (value="0").
  * - `string` **$show_option_none** - String to display for a "none" `<option>` (value="-1").
  * - `boolean` **$hide_empty** - Whether to hide collections with no readable posts. Defaults to true.
  * - `boolean` **$hide_if_empty** - Whether to display the `<select>` even if it contains no `<option>'s`.
  * - `string` **$collection** - Limits output to a single collection. Useful in combination with $webcomics.
  * - `string` **$orderby** - What to sort the collections by. May be one of 'name', 'slug', 'count', or 'updated'. Defaults to collection ID.
  * - `string` **$callback** - Custom callback function for generating `<option>'s`. Callback functions should accept three arguments: the collection configuration array, the function arguments array, and the posts array (if any).
  * - `boolean` **$webcomics** - Whether to display a dropdown of webcomic posts grouped by collection. The 'hide_empty' argument is ignored when $webcomics is true.
  * - `boolean` **$show_count** - Whether to display the total number of published webcomics in a collection.
  * - `string` **$target** - The target url for collections, one of 'archive', 'first', 'last', or 'random'. Defaults to 'archive'.
  * - `string` **$selected** - The ID of the selected collection or webcomic.
  * 
  * <code class="php">
  * // render a dropdown of all webcomic collections with at least one post
  * webcomic_dropdown_collections();
  * 
  * // render a dropdown of all webcomic collections linked to the beginning of each collection with a default option
  * webcomic_dropdown_collections( array( 'hide_empty' => false, 'target' => 'first', 'show_option_all' => '- Collections -' ) );
  * 
  * // render a dropdown of published webcomics grouped by collection only for collection 42
  * webcomic_dropdown_collections( array( 'collection' => 'webcomic42', 'webcomics' => true ) );
  * </code>
  * 
  * <code class="bbcode">
  * // render a dropdown of all webcomic collections with at least one post
  * [webcomic_dropdown_collections]
  * 
  * // render a dropdown of all webcomic collections linked to the beginning of each collection with a default option
  * [webcomic_dropdown_collections hide_empty="false" target="first" show_option_all="- Collections -"]
  * 
  * // render a dropdown of published webcomics grouped by collection only for collection 42
  * [webcomic_dropdown_collections collection="webcomic42" webcomics="true"]
  * </code>
  * 
  * @package Webcomic
  * @param array $args Array of arguments. See function description for detailed information.
  * @uses WebcomicTag::webcomic_dropdown_collections()
  */
 function webcomic_dropdown_collections($args = array())
 {
     $r = wp_parse_args($args, array('select_name' => 'webcomic_collections', 'id' => '', 'class' => '', 'show_option_all' => '', 'show_option_none' => '', 'hide_empty' => true, 'hide_if_empty' => true, 'collection' => '', 'orderby' => '', 'callback' => '', 'webcomics' => false, 'show_count' => false, 'target' => 'archive', 'selected' => ''));
     echo WebcomicTag::webcomic_dropdown_collections($r);
 }
Esempio n. 3
0
 /**
  * Handle webcomic_dropdown_collections shortcode.
  * 
  * @param array $atts Shortcode attributes.
  * @return string
  * @uses WebcomicTag::webcomic_dropdown_terms()
  */
 public function webcomic_dropdown_collections($atts)
 {
     $r = shortcode_atts(array('select_name' => 'webcomic_collections', 'id' => '', 'class' => '', 'show_option_all' => '', 'show_option_none' => '', 'hide_empty' => true, 'hide_if_empty' => true, 'collection' => '', 'orderby' => '', 'callback' => '', 'webcomics' => false, 'show_count' => false, 'target' => 'archive', 'selected' => ''), $atts);
     return WebcomicTag::webcomic_dropdown_collections($r);
 }