/**
  * Generate the content of the widget.
  *
  * @param	array	args		The array of form elements
  * @param	array	instance	The current instance of the widget
  */
 public function widget_content($args, $instance)
 {
     extract($args, EXTR_SKIP);
     extract($instance);
     $count = (array) wp_count_posts('movie');
     $count = array('movies' => $count['publish'], 'imported' => $count['import-draft'], 'queued' => $count['import-queued'], 'draft' => $count['draft'], 'total' => 0);
     $count['total'] = array_sum($count);
     $count['collections'] = wp_count_terms('collection');
     $count['genres'] = wp_count_terms('genre');
     $count['actors'] = wp_count_terms('actor');
     $count = array_map('intval', $count);
     extract($count);
     $links = array();
     $links['%total%'] = sprintf('<a href="%s">%s</a>', get_post_type_archive_link('movie'), sprintf(_n('<strong>1</strong> movie', '<strong>%d</strong> movies', $movies, 'wpmovielibrary'), $movies));
     $links['%collections%'] = WPMOLY_Utils::get_taxonomy_permalink('collection', sprintf(_n('<strong>1</strong> collection', '<strong>%d</strong> collections', $collections, 'wpmovielibrary'), $collections));
     $links['%genres%'] = WPMOLY_Utils::get_taxonomy_permalink('genre', sprintf(_n('<strong>1</strong> genre', '<strong>%d</strong> genres', $genres, 'wpmovielibrary'), $genres));
     $links['%actors%'] = WPMOLY_Utils::get_taxonomy_permalink('actor', sprintf(_n('<strong>1</strong> actor', '<strong>%d</strong> actors', $actors, 'wpmovielibrary'), $actors));
     $title = $before_title . apply_filters('widget_title', $title) . $after_title;
     $description = esc_attr($description);
     $format = wpautop(wp_kses($format, array('ul', 'ol', 'li', 'p', 'span', 'em', 'i', 'p', 'strong', 'b', 'br')));
     $content = str_replace(array_keys($links), array_values($links), $format);
     $style = 'wpmoly-widget wpmoly-statistics';
     $attributes = array('content' => $content, 'description' => $description, 'style' => $style);
     $html = WPMovieLibrary::render_template('statistics-widget/statistics.php', $attributes, $require = 'always');
     return $before_widget . $title . $html . $after_widget;
 }
 /**
  * Generate the content of the widget.
  * 
  * @since    1.2
  *
  * @param    array    $args The array of form elements
  * @param    array    $instance The current instance of the widget
  * 
  * @return   string   The Widget Content
  */
 public function widget_content($args, $instance)
 {
     if (!in_array($instance['taxonomy'], array('collection', 'genre', 'actor'))) {
         return false;
     }
     $defaults = array('title' => __('Movie Taxonomies', 'wpmovielibrary'), 'description' => '', 'taxonomy' => '', 'list' => 0, 'count' => 0, 'orderby' => 'count', 'order' => 'DESC', 'css' => 0, 'limit' => WPMOLY_MAX_TAXONOMY_LIST);
     $args = wp_parse_args($args, $defaults);
     extract($args, EXTR_SKIP);
     extract($instance);
     $title = apply_filters('widget_title', $title);
     $archive = wpmoly_o("rewrite-{$taxonomy}");
     if ('ASC' != $order) {
         $order = 'DESC';
     }
     if ('name' != $orderby) {
         $orderby = 'count';
     }
     $args = array("order={$order}", "orderby={$orderby}");
     if (0 < $limit) {
         $args[] = "number={$limit}";
     }
     $args = implode('&', $args);
     $taxonomies = get_terms(array($taxonomy), $args);
     if ($taxonomies && !is_wp_error($taxonomies)) {
         $items = array();
         $this->widget_css .= " {$taxonomy} list";
         if ($css) {
             $this->widget_css .= ' custom';
         }
         foreach ($taxonomies as $term) {
             $items[] = array('attr_title' => sprintf(__('Permalink for &laquo; %s &raquo;', 'wpmovielibrary'), $term->name), 'link' => get_term_link(sanitize_term($term, $taxonomy), $taxonomy), 'title' => esc_attr($term->name . ($count ? sprintf('&nbsp;(%d)', $term->count) : '')));
         }
         if ($limit) {
             $url = WPMOLY_Utils::get_taxonomy_permalink($archive, $value = false);
             if ('' != $url) {
                 $items[] = array('attr_title' => $this->taxonomies[$taxonomy]['view_all'], 'link' => $url, 'title' => __('View the complete list', 'wpmovielibrary'));
             }
         }
         $items = apply_filters('wpmoly_widget_collection_list', $items, $list, $css);
         $attributes = array('items' => $items, 'description' => $description, 'default_option' => $this->taxonomies[$taxonomy]['default'], 'style' => $this->widget_css);
         if ($list) {
             $html = WPMovieLibrary::render_template('taxonomies-widget/taxonomies-dropdown-list.php', $attributes, $require = 'always');
         } else {
             $html = WPMovieLibrary::render_template('taxonomies-widget/taxonomies-list.php', $attributes, $require = 'always');
         }
     } else {
         $html = WPMovieLibrary::render_template('empty.php', array('message' => $this->taxonomies[$taxonomy]['empty']), $require = 'always');
     }
     return $before_widget . $before_title . $title . $after_title . $html . $after_widget;
 }