function get_downloads_category($cat_id = 0, $limit = 10, $chars = 0, $display = true) { global $wpdb, $user_ID; if (is_array($cat_id)) { $category_sql = "file_category IN (" . join(',', $cat_id) . ')'; } else { $category_sql = "file_category = {$cat_id}"; } $output = ''; $files = $wpdb->get_results("SELECT * FROM {$wpdb->downloads} WHERE {$category_sql} AND file_permission != -2 ORDER BY file_date DESC LIMIT {$limit}"); if ($files) { $current_user = wp_get_current_user(); $file_extensions_images = file_extension_images(); $download_categories = get_option('download_categories'); $template_download_most_temp = get_option('download_template_most'); foreach ($files as $file) { $file_permission = intval($file->file_permission); $template_download_most = $template_download_most_temp; if ($file_permission > 0 && intval($current_user->wp_user_level) >= $file_permission && intval($user_ID) > 0 || $file_permission == 0 && intval($user_ID) > 0 || $file_permission == -1) { $template_download_most = stripslashes($template_download_most[0]); } else { $template_download_most = stripslashes($template_download_most[1]); } if ($chars > 0) { $file_name = snippet_text(stripslashes($file->file_name), $chars); } else { $file_name = stripslashes($file->file_name); } $template_download_most = str_replace("%FILE_ID%", $file->file_id, $template_download_most); $template_download_most = str_replace("%FILE%", stripslashes($file->file), $template_download_most); $template_download_most = str_replace("%FILE_NAME%", $file_name, $template_download_most); $template_download_most = str_replace("%FILE_EXT%", file_extension(stripslashes($file->file)), $template_download_most); $template_download_most = str_replace("%FILE_ICON%", file_extension_image(stripslashes($file->file), $file_extensions_images), $template_download_most); $template_download_most = str_replace("%FILE_DESCRIPTION%", stripslashes($file->file_des), $template_download_most); $template_download_most = str_replace("%FILE_SIZE%", format_filesize($file->file_size), $template_download_most); $template_download_most = str_replace("%FILE_SIZE_DEC%", format_filesize_dec($file->file_size), $template_download_most); $template_download_most = str_replace("%FILE_CATEGORY_ID%", intval($file->file_category), $template_download_most); $template_download_most = str_replace("%FILE_CATEGORY_NAME%", stripslashes($download_categories[intval($file->file_category)]), $template_download_most); $template_download_most = str_replace("%FILE_DATE%", mysql2date(get_option('date_format'), gmdate('Y-m-d H:i:s', $file->file_date)), $template_download_most); $template_download_most = str_replace("%FILE_TIME%", mysql2date(get_option('time_format'), gmdate('Y-m-d H:i:s', $file->file_date)), $template_download_most); $template_download_most = str_replace("%FILE_UPDATED_DATE%", mysql2date(get_option('date_format'), gmdate('Y-m-d H:i:s', $file->file_updated_date)), $template_download_most); $template_download_most = str_replace("%FILE_UPDATED_TIME%", mysql2date(get_option('time_format'), gmdate('Y-m-d H:i:s', $file->file_updated_date)), $template_download_most); $template_download_most = str_replace("%FILE_HITS%", number_format_i18n($file->file_hits), $template_download_most); $template_download_most = str_replace("%FILE_DOWNLOAD_URL%", download_file_url($file->file_id, $file->file), $template_download_most); $output .= $template_download_most; } } else { $output = '<li>' . __('N/A', 'wp-downloadmanager') . '</li>' . "\n"; } if ($display) { echo $output; } else { return $output; } }
<?php do_action('rss2_head'); ?> <?php if ($files) { ?> <?php foreach ($files as $file) { ?> <item> <title><?php echo stripslashes($file->file_name); ?> </title> <link><?php echo download_file_url($file->file_id, $file->file); ?> </link> <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', gmdate('Y-m-d H:i:s', $file->file_date), false); ?> </pubDate> <category><![CDATA[<?php echo stripslashes($download_categories[intval($file->file_category)]); ?> ]]></category> <guid isPermaLink="false"><?php echo get_option('home') . '/?dl_id=' . $file->file_id; ?> </guid> <description><![CDATA[<?php