/** * 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; } }
/** * Return a list of webcomic collections. * * ### 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` **$hide_empty** - Whether to hide collections with no readable posts. Defaults to true. * - `boolean` **$ordered** - Use `<ol>` instead of `<ul>`. * - `string` **$collection** - Limits output to a single collection. Useful in combination with $webcomics. * - `string` **$order** - How to order collections, one of 'ASC' (default) or 'DESC'. * - `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 list items. Callback functions should accept three arguments: the collection configuration array, the function arguments array, and the posts array (if any). * - `string` **$feed** - Text or image URL to use for a collection feed link. * - `string` **$feed_type** - The type of feed to link to. * - `boolean` **$webcomics** - Whether to display a list of webcomic posts grouped by collection. 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 collection. * - `boolean` **$show_description** - Whether to display collection descriptions. * - `boolean` **$show_image** - Size of the collection image to use for collection links. * - `string` **$target** - The target url for collections, one of 'archive', 'first', 'last', or 'random'. Defaults to 'archive'. * - `integer` **$selected** - The ID of the selected collection or webcomic. * * <code class="php"> * // render a list of all webcomic collections with at least one post * webcomic_list_collections(); * * // render an ordered list of all webcomic collections linked to the beginning of each collection * webcomic_list_collections( array( 'hide_empty' => false, 'target' => 'first', 'ordered' => true ) ); * * // render a list of published webcomic thumbnails grouped by collection only for collection 42 with collection descriptions * webcomic_list_collections( array( 'collection' => 'webcomic42', 'show_description' => true, 'webcomics' => true, 'webcomic_image' => 'thumbnail' ) ); * </code> * * <code class="bbcode"> * // render a list of all webcomic collections with at least one post * [webcomic_list_collections] * * // render an ordered list of all webcomic collections linked to the beginning of each collection * [webcomic_list_collections hide_empty="false" target="first" ordered="true"] * * // render a list of published webcomic thumbnails grouped by collection only for collection 42 with collection descriptions * [webcomic_list_collections 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_collections() */ function webcomic_list_collections($args = array()) { $r = wp_parse_args($args, array('id' => '', 'class' => '', 'before' => '', 'after' => '', 'hide_empty' => true, 'ordered' => '', 'collection' => '', 'order' => 'ASC', 'orderby' => '', 'callback' => false, 'feed' => '', 'feed_type' => 'rss2', 'webcomics' => false, 'webcomic_order' => 'ASC', 'webcomic_orderby' => 'date', 'webcomic_image' => '', 'show_count' => false, 'show_description' => false, 'show_image' => '', 'target' => 'archive', 'selected' => 0)); echo WebcomicTag::webcomic_list_collections($r); }
/** * Handle webcomic_list_collections shortcode. * * @param array $atts Shortcode attributes. * @return string * @uses WebcomicTag::webcomic_list_collections() */ public function webcomic_list_collections($atts) { $r = shortcode_atts(array('id' => '', 'class' => '', 'before' => '', 'after' => '', 'hide_empty' => true, 'ordered' => '', 'collection' => '', 'order' => 'ASC', 'orderby' => '', 'callback' => false, 'feed' => '', 'feed_type' => 'rss2', 'webcomics' => false, 'webcomic_order' => 'ASC', 'webcomic_orderby' => 'date', 'webcomic_image' => '', 'show_count' => false, 'show_description' => false, 'show_image' => '', 'target' => 'archive', 'selected' => 0), $atts); return WebcomicTag::webcomic_list_collections($r); }