Example #1
0
function wpi_most_download_widget()
{
    if (!wpi_user_func_exists('get_most_downloaded')) {
        return false;
    }
    global $wp_query;
    // asume downloads is located at download page
    if (get_option('download_page_url') != self_uri()) {
        return;
    }
    $limit = 5;
    wpi_widget_start('Most downloads', 'most-downloads');
    $htm = get_most_downloaded($limit, 0, false);
    t('ul', $htm, array('class' => 'select-odd'));
    wpi_widget_end();
}
Example #2
0
 function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', esc_attr($instance['title']));
     $type = esc_attr($instance['type']);
     $mode = esc_attr($instance['mode']);
     $limit = intval($instance['limit']);
     $chars = intval($instance['chars']);
     $cat_ids = explode(',', esc_attr($instance['cat_ids']));
     $link = intval($instance['link']);
     echo $before_widget . $before_title . $title . $after_title;
     echo '<ul>' . "\n";
     switch ($type) {
         case 'downloads_category':
             get_downloads_category($cat_ids, $limit, $chars);
             break;
         case 'recent_downloads':
             get_recent_downloads($limit, $chars);
             break;
         case 'most_downloaded':
             get_most_downloaded($limit, $chars);
             break;
     }
     echo '</ul>' . "\n";
     if ($link) {
         $download_template_download_page_link = stripslashes(get_option('download_template_download_page_link'));
         $download_template_download_page_link = str_replace('%DOWNLOAD_PAGE_URL%', get_option('download_page_url'), $download_template_download_page_link);
         echo $download_template_download_page_link;
     }
     echo $after_widget;
 }