Changeset 1460530
- Timestamp:
- 07/26/2016 12:08:21 AM (10 years ago)
- Location:
- dwnldr/trunk
- Files:
-
- 2 edited
-
dwnldr.php (modified) (5 diffs)
-
readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dwnldr/trunk/dwnldr.php
r1460223 r1460530 9 9 Description: Lightweight download manager - link to your attachment page: your URLs are hidden & your downloads are logged. Simples! 10 10 Author: Ian Young 11 Version: 1.0 211 Version: 1.03 12 12 Author URI: http://findshorty.com/ 13 13 */ … … 21 21 public function __construct() { 22 22 add_action('template_redirect', array($this, 'check_attachment')); 23 add_action('manage_media_custom_column', array($this,'display_dwnldr_column'), 10, 2 ); 23 24 add_action('admin_init', array($this, 'add_list_download_log_metabox')); 24 25 add_action('admin_init', array($this, 'load_textdomain') ); 26 add_filter('manage_media_columns', array($this,'add_dwnldr_column') ); 25 27 } 26 28 27 29 public function load_textdomain() { 28 30 load_plugin_textdomain( 'dwnldr', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); 31 } 32 33 public function add_dwnldr_column($cols) { 34 $cols["dwnlds"] = "Downloads"; 35 return $cols; 36 } 37 38 public function display_dwnldr_column($col, $id) { 39 if('dwnlds'==$col) { 40 global $post; 41 $mime = get_post_mime_type( $post->ID ); 42 $extarr = explode('/',$mime); 43 $ext = array_pop($extarr); 44 $extensions = apply_filters('dwnldr_extensions', $this->dwnldr_extensions); 45 if(in_array($ext, $extensions)) { 46 $logs = get_post_meta($id, '_download_log', false); 47 echo '<a href="'.admin_url('post.php?post='.$id.'&action=edit#dwnldr_logs').'">'.count($logs).'</a>'; 48 } 49 } 29 50 } 30 51 … … 37 58 $logs = get_post_meta($post->ID,'_download_log',false); 38 59 $latestlogs = array_slice(array_reverse($logs),0,20); 60 // do we have any custom items? 61 $checklog = $latestlogs[0]; 62 $has_custom = count(array_keys($checklog))>4; 39 63 if(!empty($latestlogs)) { 40 64 ?> 41 <table class="widefat " cellspacing="0">65 <table class="widefat dwnldr_logs" cellspacing="0"> 42 66 <thead> 43 67 <tr> 44 <th colspan=" 4"><strong><?php _e('Total downloads','dwnldr'); ?></strong> => <?php echo number_format(count($logs),0); ?></th>68 <th colspan="<?php echo $has_custom ? 5 : 4; ?>"><strong><?php _e('Total downloads','dwnldr'); ?></strong> => <?php echo number_format(count($logs),0); ?></th> 45 69 </tr> 46 70 <tr> … … 49 73 <th scope="col" class="manage-column"><?php _e('IP','dwnldr'); ?></th> 50 74 <th scope="col" class="manage-column"><?php _e('Browser','dwnldr'); ?></th> 75 <?php 76 if($has_custom): 77 ?> 78 <th scope="col" class="manage-column"><?php _e('Custom','dwnldr'); ?></th> 79 <?php 80 endif; 81 ?> 51 82 </tr> 52 83 </thead> … … 65 96 <td><?php echo $log['ip']; ?></td> 66 97 <td><span title="<?php echo htmlentities($log['browser_info']); ?>"><?php echo htmlentities(substr($log['browser_info'], 0, 64).'…'); ?></span></td> 98 <?php 99 if($has_custom): 100 unset($log['time'],$log['user'],$log['ip'],$log['browser_info']); 101 ?> 102 <td><?php 103 foreach($log as $key => $val): 104 echo '<strong>'.$key.'</strong> => '.$val.'<br />'; 105 endforeach; 106 ?></td> 107 <?php 108 endif; 109 ?> 67 110 </tr> 68 111 <?php -
dwnldr/trunk/readme.txt
r1460223 r1460530 18 18 dwnldr will log who's downloaded it and when, and force the download without exposing your download's URL. 19 19 20 You can find your logs on the attachment page in the dashboard. If you're viewing your media library as a grid, make sure you click the "View attachment page" link from within the dialog.21 22 20 == Installation == 23 21 … … 30 28 == Frequently Asked Questions == 31 29 32 To change the file extensions that you want to allow people to download (instead of serving up the attachment page for that file), add the following to your theme's functions.php file. 30 **Where are the logs?** 31 32 You can find your logs on the "edit post" page in the dashboard. 33 If you're viewing your media library as a grid, make sure you click the "Edit more details" link from within the dialog. 34 If your media library is in list format, you'll see a Downloads column showing you the total downloads for that item. 35 Clicking the download count, or the edit link, will take you to the edit post page, and the logs are towards the bottom. 36 37 **Can I change the file extensions people can download?** 38 39 Yes - to change the file extensions that you want to allow people to download (instead of serving up the attachment page for that file), add the following to your theme's functions.php file. 33 40 34 41 add_filter('dwnldr_extensions', 'my_dwnldr_extensions'); … … 36 43 return array('.pdf','.jpg','.jpeg', etc...); 37 44 } 45 46 **Can I add to the log?** 38 47 39 48 You can also change, or add to, the data you want to log when a person downloads a file with the following. … … 50 59 == Changelog == 51 60 61 = 1.03 = 62 63 Added custom logs to download log table 64 Added "Downloads" count column to media library table 65 52 66 = 1.02 = 53 67
Note: See TracChangeset
for help on using the changeset viewer.