Ejemplo n.º 1
0
function wmp_get_popular($args = array())
{
    // This function is just for backwards compatibility
    return wp_most_popular_get_popular($args);
}
Ejemplo n.º 2
0
 public function widget($args, $instance)
 {
     // Find default args
     extract($args);
     // Get our posts
     $defaults = $this->default_options($instance);
     $options['limit'] = (int) $defaults['number'];
     $options['range'] = $defaults['timeline'];
     if ($defaults['post_type'] != 'all') {
         $options['post_type'] = $defaults['post_type'];
     }
     $posts = wp_most_popular_get_popular($options);
     $thumbnail_size = preg_match("/\\d{1,}x\\d{1,}/", $defaults['thumbnail_size']) === 1 ? explode('x', $defaults['thumbnail_size']) : $defaults['thumbnail_size'];
     // Display the widget
     echo $before_widget;
     if ($defaults['title']) {
         echo $before_title . $defaults['title'] . $after_title;
     }
     echo apply_filters('wp_most_popular_list_before', '<ul class="wp-most-popular">');
     global $post;
     foreach ($posts as $post) {
         do_action('wp_most_popular_list_item', $post, $defaults);
     }
     echo apply_filters('wp_most_popular_list_after', '</ul>');
     echo $after_widget;
     // Reset post data
     wp_reset_postdata();
 }