Download Monitor - Version 1.6.0

Version Description

  • Plugin is now initiated at plugins_loaded.
  • Implemented auto loader.
  • Classes are no longer initiated at bottom of class file but whenever an object is needed.
  • Code standards corrections.
  • Introduced Template_Handler. Loading of template parts should be done through this class.
  • Removed $GLOBALS['dlm_logging'] global.
  • Removed $GLOBALS['DLM_Download_Handler'] global.
  • Removed internal use of $download_monitor global. # Moved all inline JavaScript to separate JavaScript files.
  • Moved all install related code to installer class.
  • Moved main plugin class to it's own file.
  • Deprecated 'dlm_create_log' function.
  • Redone extensions page.
  • Fixed a bug in shortcode download where orderby=download_count wasn't working.
  • Fixed a bug where downloads didn't work with default WP permalink structure.
  • Delete dlm_file_version_ids_ transient on save.
  • Added dlm_download_headers filter.
  • Added dlm_get_template_part filter.
Download this release

Release Info

Developer barrykooij
Plugin Icon 128x128 Download Monitor
Version 1.6.0
Comparing to
See all releases

Code changes from version 1.5.1 to 1.6.0

Files changed (73) hide show
  1. Gruntfile.js +0 -129
  2. assets/css/admin.css +1 -1
  3. assets/css/admin.less +597 -570
  4. assets/css/dashboard.css +1 -1
  5. assets/css/dashboard.less +47 -47
  6. assets/css/frontend.less +149 -135
  7. assets/css/menu.less +18 -18
  8. assets/images/cross.png +0 -0
  9. assets/images/download_count_head.png +0 -0
  10. assets/images/downloads-icon.gif +0 -0
  11. assets/images/featured_head.png +0 -0
  12. assets/images/folder-horizontal-open.png +0 -0
  13. assets/images/folder-horizontal.png +0 -0
  14. assets/images/media-button-download.gif +0 -0
  15. assets/images/member_head.png +0 -0
  16. assets/images/menu_icon.png +0 -0
  17. assets/images/on.png +0 -0
  18. assets/images/redirect_head.png +0 -0
  19. assets/js/edit-download.js +235 -0
  20. assets/js/edit-download.min.js +1 -0
  21. assets/js/edit-post.js +9 -0
  22. assets/js/edit-post.min.js +1 -0
  23. assets/js/extensions.js +37 -0
  24. assets/js/extensions.min.js +1 -0
  25. assets/js/jqueryFileTree/jqueryFileTree.min.js +0 -33
  26. assets/js/settings.js +18 -0
  27. assets/js/settings.min.js +1 -0
  28. download-monitor.php +55 -663
  29. includes/admin/class-dlm-addons.php +0 -59
  30. includes/admin/class-dlm-admin-cpt.php +140 -102
  31. includes/admin/class-dlm-admin-dashboard.php +63 -56
  32. includes/admin/class-dlm-admin-extensions.php +169 -0
  33. includes/admin/class-dlm-admin-media-browser.php +40 -35
  34. includes/admin/{class-dlm-admin-insert.php → class-dlm-admin-media-insert.php} +132 -121
  35. includes/admin/class-dlm-admin-scripts.php +106 -0
  36. includes/admin/class-dlm-admin-writepanels.php +93 -273
  37. includes/admin/class-dlm-admin.php +260 -235
  38. includes/admin/class-dlm-category-walker.php +12 -7
  39. includes/admin/class-dlm-logging-list-table.php +112 -92
  40. includes/admin/html-downloadable-file-version.php +63 -47
  41. includes/admin/uaparser/lib/json/jsonwrapper.php +4 -2
  42. includes/class-dlm-ajax-handler.php +73 -15
  43. includes/class-dlm-autoloader.php +61 -0
  44. includes/class-dlm-debug-logger.php +54 -0
  45. includes/class-dlm-download-handler.php +120 -83
  46. includes/class-dlm-download-version.php +25 -13
  47. includes/class-dlm-download.php +114 -89
  48. includes/class-dlm-file-manager.php +221 -0
  49. includes/class-dlm-installer.php +134 -0
  50. includes/class-dlm-logging.php +16 -22
  51. includes/class-dlm-post-type-manager.php +84 -0
  52. includes/class-dlm-shortcodes.php +109 -93
  53. includes/class-dlm-taxonomy-manager.php +85 -0
  54. includes/class-dlm-template-handler.php +67 -0
  55. includes/class-wp-dlm.php +426 -0
  56. includes/deprecated.php +37 -0
  57. includes/download-functions.php +2 -1
  58. includes/product/class-dlm-product-license.php +110 -0
  59. includes/product/class-dlm-product-manager.php +107 -0
  60. includes/product/class-dlm-product.php +346 -0
  61. includes/widgets/class-dlm-widget-downloads.php +97 -57
  62. includes/widgets/class-dlm-widget-manager.php +23 -0
  63. languages/download-monitor-de_DE.mo +0 -0
  64. languages/download-monitor-de_DE.po +169 -129
  65. package.json +0 -19
  66. readme.txt +40 -15
  67. templates/content-download-box.php +5 -2
  68. templates/content-download-button.php +4 -4
  69. templates/content-download-filename.php +7 -2
  70. templates/content-download-title.php +3 -1
  71. templates/content-download-version-list.php +12 -8
  72. templates/content-download.php +6 -2
  73. templates/pagination.php +16 -13
Gruntfile.js DELETED
@@ -1,129 +0,0 @@
1
- /* jshint node:true */
2
- module.exports = function( grunt ){
3
- 'use strict';
4
-
5
- grunt.initConfig({
6
- // setting folder templates
7
- dirs: {
8
- css: 'assets/css',
9
- images: 'assets/images',
10
- js: 'assets/js'
11
- },
12
-
13
- // Compile all .less files.
14
- less: {
15
- compile: {
16
- options: {
17
- // These paths are searched for @imports
18
- paths: ['<%= dirs.css %>/']
19
- },
20
- files: [{
21
- expand: true,
22
- cwd: '<%= dirs.css %>/',
23
- src: [
24
- '*.less',
25
- '!icons.less',
26
- '!mixins.less'
27
- ],
28
- dest: '<%= dirs.css %>/',
29
- ext: '.css'
30
- }]
31
- }
32
- },
33
-
34
- // Minify all .css files.
35
- cssmin: {
36
- minify: {
37
- expand: true,
38
- cwd: '<%= dirs.css %>/',
39
- src: ['*.css'],
40
- dest: '<%= dirs.css %>/',
41
- ext: '.css'
42
- }
43
- },
44
-
45
- // Minify .js files.
46
- uglify: {
47
- options: {
48
- preserveComments: 'some'
49
- },
50
- frontend: {
51
- files: [{
52
- expand: true,
53
- cwd: '<%= dirs.js %>',
54
- src: [
55
- '*.js',
56
- '!*.min.js'
57
- ],
58
- dest: '<%= dirs.js %>',
59
- ext: '.min.js'
60
- }]
61
- },
62
- },
63
-
64
- // Watch changes for assets
65
- watch: {
66
- less: {
67
- files: ['<%= dirs.css %>/*.less'],
68
- tasks: ['less', 'cssmin'],
69
- },
70
- js: {
71
- files: [
72
- '<%= dirs.js %>/*js',
73
- '!<%= dirs.js %>/*.min.js',
74
- ],
75
- tasks: ['uglify']
76
- }
77
- },
78
-
79
- shell: {
80
- options: {
81
- stdout: true,
82
- stderr: true
83
- },
84
- txpull: {
85
- command: [
86
- 'tx pull -a -f',
87
- ].join( '&&' )
88
- },
89
- generatemos: {
90
- command: [
91
- 'cd languages',
92
- 'for i in *.po; do msgfmt $i -o ${i%%.*}.mo; done'
93
- ].join( '&&' )
94
- },
95
- generatepot: {
96
- command: [
97
- 'makepot'
98
- ].join( '&&' )
99
- }
100
- },
101
-
102
- });
103
-
104
- // Load NPM tasks to be used here
105
- grunt.loadNpmTasks( 'grunt-shell' );
106
- grunt.loadNpmTasks( 'grunt-contrib-less' );
107
- grunt.loadNpmTasks( 'grunt-contrib-cssmin' );
108
- grunt.loadNpmTasks( 'grunt-contrib-uglify' );
109
- grunt.loadNpmTasks( 'grunt-contrib-watch' );
110
-
111
- // Register tasks
112
- grunt.registerTask( 'default', [
113
- 'less',
114
- 'cssmin',
115
- 'uglify'
116
- ]);
117
-
118
- // Just an alias for pot file generation
119
- grunt.registerTask( 'pot', [
120
- 'shell:generatepot'
121
- ]);
122
-
123
- grunt.registerTask( 'dev', [
124
- 'default',
125
- 'shell:txpull',
126
- 'shell:generatemos'
127
- ]);
128
-
129
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/css/admin.css CHANGED
@@ -1 +1 @@
1
- #dlm_logs td{padding:7px;vertical-align:middle}#dlm_logs .column-status{width:4em}#dlm_logs td.column-status{font-size:10px;vertical-align:middle;text-align:center}#dlm_logs td.column-status span{color:#fff;font-weight:400;-moz-border-radius:50%;-webkit-border-radius:50%;border-radius:50%;height:16px;line-height:16px;width:16px;display:inline-block}#dlm_logs td.column-status .failed{background-color:#df9d1d}#dlm_logs td.column-status .redirected{background-color:#74a721}#dlm_logs td.column-status .completed{background-color:#1c769b}#dlm_logs td.column-user_agent,#dlm_logs td.column-user_ip{font-family:monospace;font-weight:400}#dlm_logs span.description{font-weight:400}#dlm_logs .column-download,#dlm_logs .column-file,#dlm_logs .column-user,#dlm_logs .column-user_ua{width:16%!important}#dlm_logs .column-date,#dlm_logs .column-user_ip{width:6%!important}ul.download_monitor_file_browser{list-style:none outside;margin:0;border:1px solid #ddd;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;background:#f9f9f9;padding:5px;-moz-box-shadow:inset 0 0 0 1px #fff;-webkit-box-shadow:inset 0 0 0 1px #fff;box-shadow:inset 0 0 0 1px #fff}ul.download_monitor_file_browser li{padding:0;margin:0}ul.download_monitor_file_browser li a{color:#21759B;display:block;padding:4px 0 4px 4px;text-decoration:none}ul.download_monitor_file_browser li a:hover{background-color:#eaf2fa}ul.download_monitor_file_browser li a:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f123";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}ul.download_monitor_file_browser li a.folder:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f318";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}ul.download_monitor_file_browser li a.filetype-3g2:before,ul.download_monitor_file_browser li a.filetype-3gp:before,ul.download_monitor_file_browser li a.filetype-asf:before,ul.download_monitor_file_browser li a.filetype-asx:before,ul.download_monitor_file_browser li a.filetype-avi:before,ul.download_monitor_file_browser li a.filetype-mov:before,ul.download_monitor_file_browser li a.filetype-mp4:before,ul.download_monitor_file_browser li a.filetype-mpg:before,ul.download_monitor_file_browser li a.filetype-rm:before,ul.download_monitor_file_browser li a.filetype-srt:before,ul.download_monitor_file_browser li a.filetype-vob:before,ul.download_monitor_file_browser li a.filetype-wmv:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f126";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}ul.download_monitor_file_browser li a.filetype-aif:before,ul.download_monitor_file_browser li a.filetype-iff:before,ul.download_monitor_file_browser li a.filetype-m3u:before,ul.download_monitor_file_browser li a.filetype-m4a:before,ul.download_monitor_file_browser li a.filetype-mid:before,ul.download_monitor_file_browser li a.filetype-midi:before,ul.download_monitor_file_browser li a.filetype-mp3:before,ul.download_monitor_file_browser li a.filetype-mpa:before,ul.download_monitor_file_browser li a.filetype-ra:before,ul.download_monitor_file_browser li a.filetype-wav:before,ul.download_monitor_file_browser li a.filetype-wma:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f127";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}ul.download_monitor_file_browser li a.filetype-ai:before,ul.download_monitor_file_browser li a.filetype-bmp:before,ul.download_monitor_file_browser li a.filetype-dds:before,ul.download_monitor_file_browser li a.filetype-eps:before,ul.download_monitor_file_browser li a.filetype-gif:before,ul.download_monitor_file_browser li a.filetype-ico:before,ul.download_monitor_file_browser li a.filetype-jpeg:before,ul.download_monitor_file_browser li a.filetype-jpg:before,ul.download_monitor_file_browser li a.filetype-png:before,ul.download_monitor_file_browser li a.filetype-ps:before,ul.download_monitor_file_browser li a.filetype-psd:before,ul.download_monitor_file_browser li a.filetype-pspimage:before,ul.download_monitor_file_browser li a.filetype-svg:before,ul.download_monitor_file_browser li a.filetype-tga:before,ul.download_monitor_file_browser li a.filetype-thm:before,ul.download_monitor_file_browser li a.filetype-tif:before,ul.download_monitor_file_browser li a.filetype-yuv:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f128";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}ul.download_monitor_file_browser li.nofiles{color:#999;font-style:italic;padding:4px 0}ul.download_monitor_file_browser li ul{list-style:none outside;margin:0;padding:0 0 0 28px}ul.download_monitor_file_browser li ul.loading{background:url(../images/ajax-loader.gif) no-repeat 24px 0;height:32px}table.wp-list-table .column-thumb{width:44px;text-align:center;white-space:nowrap}table.wp-list-table .column-dlm_download_cat,table.wp-list-table .column-dlm_download_tag,table.wp-list-table .column-file{width:11%!important}table.wp-list-table .column-file,table.wp-list-table .column-title{width:17%!important}table.wp-list-table .column-download_id,table.wp-list-table .column-version{width:5em}table.wp-list-table th.column-download_count span:first-child,table.wp-list-table th.column-featured span:first-child,table.wp-list-table th.column-members_only span:first-child,table.wp-list-table th.column-redirect_only span:first-child,table.wp-list-table th.column-thumb span:first-child{float:none;display:inline-block;width:1em;height:1em;line-height:1em;padding:2px 0 0;overflow:hidden}table.wp-list-table th.column-download_count .sorting-indicator,table.wp-list-table th.column-featured .sorting-indicator,table.wp-list-table th.column-members_only .sorting-indicator,table.wp-list-table th.column-redirect_only .sorting-indicator,table.wp-list-table th.column-thumb .sorting-indicator{float:right}table.wp-list-table th.column-thumb{width:52px;text-align:center}table.wp-list-table th.column-thumb span:first-child:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f128";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}table.wp-list-table th.column-download_count{width:5em}table.wp-list-table th.column-download_count span:first-child:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f346";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}table.wp-list-table th.column-members_only{width:3.5em}table.wp-list-table th.column-members_only span:first-child:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f338";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}table.wp-list-table th.column-redirect_only{width:3.5em}table.wp-list-table th.column-redirect_only span:first-child:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f103";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}table.wp-list-table th.column-featured{width:3.5em}table.wp-list-table th.column-featured span:first-child:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f155";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}table.wp-list-table td.column-download_count,table.wp-list-table td.column-featured,table.wp-list-table td.column-members_only,table.wp-list-table td.column-redirect_only{text-align:left;padding-left:11px}table.wp-list-table td.column-download_count span.na,table.wp-list-table td.column-featured span.na,table.wp-list-table td.column-members_only span.na,table.wp-list-table td.column-redirect_only span.na{color:#999;width:1em;height:1em;line-height:1em;display:inline-block;overflow:hidden;vertical-align:middle}table.wp-list-table td.column-download_count span.na:before,table.wp-list-table td.column-featured span.na:before,table.wp-list-table td.column-members_only span.na:before,table.wp-list-table td.column-redirect_only span.na:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f460";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}table.wp-list-table td.column-download_count span.yes,table.wp-list-table td.column-featured span.yes,table.wp-list-table td.column-members_only span.yes,table.wp-list-table td.column-redirect_only span.yes{width:1em;height:1em;line-height:1em;display:inline-block;overflow:hidden;vertical-align:middle}table.wp-list-table td.column-download_count span.yes:before,table.wp-list-table td.column-featured span.yes:before,table.wp-list-table td.column-members_only span.yes:before,table.wp-list-table td.column-redirect_only span.yes:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f147";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}table.wp-list-table .column-thumb img{padding:2px;margin:0;border:1px solid #dfdfdf;vertical-align:middle;width:32px;height:32px}#download-monitor-file .inside{padding:0;margin:0}#download-monitor-file .dlm-metaboxes-wrapper .close_all,#download-monitor-file .dlm-metaboxes-wrapper .expand_all{float:right;margin-left:1em;line-height:22px;text-decoration:none}#download-monitor-file .dlm-metaboxes-wrapper .expand_all:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f168";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}#download-monitor-file .dlm-metaboxes-wrapper .close_all:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f460";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}#download-monitor-file .dlm-metaboxes-wrapper p.toolbar{margin:0!important;border-top:1px solid #fff;border-bottom:1px solid #DFDFDF;padding:7px 12px!important;overflow:hidden;zoom:1}#download-monitor-file .dlm-metaboxes-wrapper p.toolbar a.button{float:left;margin:0}#download-monitor-file .dlm-metaboxes-wrapper .fr,#download-monitor-file .dlm-metaboxes-wrapper button.add_attribute,#download-monitor-file .dlm-metaboxes-wrapper button.add_variable_attribute,#download-monitor-file .dlm-metaboxes-wrapper select.attribute_taxonomy{float:right;margin:0 0 0 6px}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metaboxes{padding:0 12px}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox-sortable-placeholder{border-color:#bbb;background-color:#f5f5f5;margin:9px 0;border-width:1px;border-style:dashed}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox{background:#ececec;border:1px solid #ececec;margin:9px 0!important}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox h3{margin:0!important;padding:6px!important;font-size:1em!important;overflow:hidden;zoom:1;cursor:move}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox h3 button{float:right}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox h3 strong{font-weight:400;line-height:24px}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox h3 select{font-family:sans-serif}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox h3 .handlediv{background-position:6px 5px!important;display:none;height:24px}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox:hover h3 .handlediv{display:block}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table{width:100%;position:relative;background:#fff;padding:3px}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table td{text-align:left;padding:6px;vertical-align:top;border:0;line-height:26px}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table td label{text-align:left;display:block;line-height:21px}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table td input{float:left;min-width:200px}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table td input,#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table td textarea{width:100%;margin:0;display:block;font-size:14px;padding:4px;color:#555}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table td textarea{height:7.5em}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table td select{width:100%}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table td input.short{width:200px}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table td input.checkbox{width:auto;min-width:inherit;vertical-align:middle;display:inline;float:none}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table td input.date-picker-field{width:50%;min-width:inherit;float:none;display:inline}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table td input.hour,#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table td input.minute{width:2em;min-width:inherit;float:none;display:inline}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table td.attribute_name{width:200px}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table .minus,#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table .plus{margin-top:6px}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table .fl{float:left}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table .fr{float:right}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox:first-child h3{background:#EAF2FA;background-image:linear-gradient(bottom,#dae6f2 0,#eaf2fa 100%);background-image:-o-linear-gradient(bottom,#dae6f2 0,#eaf2fa 100%);background-image:-moz-linear-gradient(bottom,#dae6f2 0,#eaf2fa 100%);background-image:-webkit-linear-gradient(bottom,#dae6f2 0,#eaf2fa 100%);background-image:-ms-linear-gradient(bottom,#dae6f2 0,#eaf2fa 100%);background-image:-webkit-gradient(linear,left bottom,left top,color-stop(0,#dae6f2),color-stop(1,#eaf2fa));border-color:#d3deea;color:#21759B}#download-monitor-file .dlm-metaboxes-wrapper .plus:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f132";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}#download-monitor-file .dlm-metaboxes-wrapper .minus:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f460";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}#download-monitor-file .dlm-metaboxes-wrapper .dlm_upload_file:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f317";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}#download-monitor-file .dlm-metaboxes-wrapper .dlm_browse_for_file:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f322";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}#download-monitor-options .inside{padding:0;margin:0}#download-monitor-options .form-field-checkbox label{display:inline;padding:0 0 4px}#download-monitor-options .form-field-checkbox input{display:inline-block;width:auto;vertical-align:middle}#download-monitor-options .form-field-checkbox .description{padding:4px 0 0;display:block}#download-monitor-options .access_permissions{margin:0!important;border-top:1px solid #fff;border-bottom:1px solid #DFDFDF;padding:7px 12px!important;overflow:hidden;zoom:1}#download-monitor-options .access_permissions h4{margin:0 0 .5em}#download-monitor-options .access_permissions ul{background:#fff;border:1px solid #dfdfdf;height:110px;overflow:auto;padding:.5em .9em;margin:0}#download-monitor-options p{margin:0!important;border-top:1px solid #fff;border-bottom:1px solid #DFDFDF;padding:7px 12px!important;overflow:hidden;zoom:1}#insert-download{padding:20px}#insert-download .error,#insert-download .updated{margin-left:0;margin-right:0}#insert-download h2{margin-top:0}#insert-download label{margin:0 0 .25em;display:block;font-size:1.1em}#insert-download span.description{display:block}#insert-download input.input{margin:0 0 .25em;display:block;width:100%;font-size:1.1em}#insert-download .add_link{float:right}#insert-download ul.page-numbers{overflow:hidden;zoom:1;margin:0 auto;padding:0;text-align:center}#insert-download ul.page-numbers li{display:inline-block;margin:0;list-style:none outside;line-height:1em}#insert-download ul.page-numbers li a,#insert-download ul.page-numbers li span{text-decoration:none;border:1px solid #ddd;-webkit-border-radius:4px;border-radius:4px;padding:8px;display:block}#insert-download ul.page-numbers li span{border-color:#eee}#insert-download legend{font-weight:700;display:block;margin:0 0 1em}#insert-download fieldset label{display:block;margin:0 0 .5em}.dlm_addons_wrap .items{overflow:hidden}.dlm_addons_wrap .items li{display:inline-block;margin:0 10px 10px 0!important;padding:0;vertical-align:top;width:250px;border:1px solid #ddd;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),inset 0 -1px 0 rgba(0,0,0,.1);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),inset 0 -1px 0 rgba(0,0,0,.1);overflow:hidden;position:relative}.dlm_addons_wrap .items li a{color:inherit;text-decoration:none}.dlm_addons_wrap .items li img{max-width:100%;height:auto;display:block;margin:0;background:#fff}.dlm_addons_wrap .items li h2{margin:0!important;padding:10px 20px!important;line-height:1;background:rgba(255,255,255,.8);color:#000;position:absolute;max-width:280px;top:20px;left:0;font-size:18px;text-shadow:none}.dlm_addons_wrap .items li .third_party{display:none}.dlm_addons_wrap .items li p{padding:20px!important;margin:0!important;border-top:1px solid #f1f1f1}.dlm_addons_wrap .items li .cost{display:none}
1
+ #dlm_logs td{padding:7px;vertical-align:middle}#dlm_logs .column-status{width:4em}#dlm_logs td.column-status{font-size:10px;vertical-align:middle;text-align:center}#dlm_logs td.column-status span{color:#fff;font-weight:400;-moz-border-radius:50%;-webkit-border-radius:50%;border-radius:50%;height:16px;line-height:16px;width:16px;display:inline-block}#dlm_logs td.column-status .failed{background-color:#df9d1d}#dlm_logs td.column-status .redirected{background-color:#74a721}#dlm_logs td.column-status .completed{background-color:#1c769b}#dlm_logs td.column-user_agent,#dlm_logs td.column-user_ip{font-family:monospace;font-weight:400}#dlm_logs span.description{font-weight:400}#dlm_logs .column-download,#dlm_logs .column-file,#dlm_logs .column-user,#dlm_logs .column-user_ua{width:16%!important}#dlm_logs .column-date,#dlm_logs .column-user_ip{width:6%!important}ul.download_monitor_file_browser{list-style:none outside;margin:0;border:1px solid #ddd;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;background:#f9f9f9;padding:5px;-moz-box-shadow:inset 0 0 0 1px #fff;-webkit-box-shadow:inset 0 0 0 1px #fff;box-shadow:inset 0 0 0 1px #fff}ul.download_monitor_file_browser li{padding:0;margin:0}ul.download_monitor_file_browser li a{color:#21759B;display:block;padding:4px 0 4px 4px;text-decoration:none}ul.download_monitor_file_browser li a:hover{background-color:#eaf2fa}ul.download_monitor_file_browser li a:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f123";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}ul.download_monitor_file_browser li a.folder:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f318";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}ul.download_monitor_file_browser li a.filetype-3g2:before,ul.download_monitor_file_browser li a.filetype-3gp:before,ul.download_monitor_file_browser li a.filetype-asf:before,ul.download_monitor_file_browser li a.filetype-asx:before,ul.download_monitor_file_browser li a.filetype-avi:before,ul.download_monitor_file_browser li a.filetype-mov:before,ul.download_monitor_file_browser li a.filetype-mp4:before,ul.download_monitor_file_browser li a.filetype-mpg:before,ul.download_monitor_file_browser li a.filetype-rm:before,ul.download_monitor_file_browser li a.filetype-srt:before,ul.download_monitor_file_browser li a.filetype-vob:before,ul.download_monitor_file_browser li a.filetype-wmv:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f126";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}ul.download_monitor_file_browser li a.filetype-aif:before,ul.download_monitor_file_browser li a.filetype-iff:before,ul.download_monitor_file_browser li a.filetype-m3u:before,ul.download_monitor_file_browser li a.filetype-m4a:before,ul.download_monitor_file_browser li a.filetype-mid:before,ul.download_monitor_file_browser li a.filetype-midi:before,ul.download_monitor_file_browser li a.filetype-mp3:before,ul.download_monitor_file_browser li a.filetype-mpa:before,ul.download_monitor_file_browser li a.filetype-ra:before,ul.download_monitor_file_browser li a.filetype-wav:before,ul.download_monitor_file_browser li a.filetype-wma:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f127";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}ul.download_monitor_file_browser li a.filetype-ai:before,ul.download_monitor_file_browser li a.filetype-bmp:before,ul.download_monitor_file_browser li a.filetype-dds:before,ul.download_monitor_file_browser li a.filetype-eps:before,ul.download_monitor_file_browser li a.filetype-gif:before,ul.download_monitor_file_browser li a.filetype-ico:before,ul.download_monitor_file_browser li a.filetype-jpeg:before,ul.download_monitor_file_browser li a.filetype-jpg:before,ul.download_monitor_file_browser li a.filetype-png:before,ul.download_monitor_file_browser li a.filetype-ps:before,ul.download_monitor_file_browser li a.filetype-psd:before,ul.download_monitor_file_browser li a.filetype-pspimage:before,ul.download_monitor_file_browser li a.filetype-svg:before,ul.download_monitor_file_browser li a.filetype-tga:before,ul.download_monitor_file_browser li a.filetype-thm:before,ul.download_monitor_file_browser li a.filetype-tif:before,ul.download_monitor_file_browser li a.filetype-yuv:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f128";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}ul.download_monitor_file_browser li.nofiles{color:#999;font-style:italic;padding:4px 0}ul.download_monitor_file_browser li ul{list-style:none outside;margin:0;padding:0 0 0 28px}ul.download_monitor_file_browser li ul.loading{background:url(../images/ajax-loader.gif) no-repeat 24px 0;height:32px}table.wp-list-table .column-thumb{width:44px;text-align:center;white-space:nowrap}table.wp-list-table .column-dlm_download_cat,table.wp-list-table .column-dlm_download_tag,table.wp-list-table .column-file{width:11%!important}table.wp-list-table .column-file,table.wp-list-table .column-title{width:17%!important}table.wp-list-table .column-download_id,table.wp-list-table .column-version{width:5em}table.wp-list-table th.column-download_count span:first-child,table.wp-list-table th.column-featured span:first-child,table.wp-list-table th.column-members_only span:first-child,table.wp-list-table th.column-redirect_only span:first-child,table.wp-list-table th.column-thumb span:first-child{float:none;display:inline-block;width:1em;height:1em;line-height:1em;padding:2px 0 0;overflow:hidden}table.wp-list-table th.column-download_count .sorting-indicator,table.wp-list-table th.column-featured .sorting-indicator,table.wp-list-table th.column-members_only .sorting-indicator,table.wp-list-table th.column-redirect_only .sorting-indicator,table.wp-list-table th.column-thumb .sorting-indicator{float:right}table.wp-list-table th.column-thumb{width:52px;text-align:center}table.wp-list-table th.column-thumb span:first-child:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f128";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}table.wp-list-table th.column-download_count{width:5em}table.wp-list-table th.column-download_count span:first-child:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f346";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}table.wp-list-table th.column-members_only{width:3.5em}table.wp-list-table th.column-members_only span:first-child:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f338";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}table.wp-list-table th.column-redirect_only{width:3.5em}table.wp-list-table th.column-redirect_only span:first-child:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f103";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}table.wp-list-table th.column-featured{width:3.5em}table.wp-list-table th.column-featured span:first-child:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f155";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}table.wp-list-table td.column-download_count,table.wp-list-table td.column-featured,table.wp-list-table td.column-members_only,table.wp-list-table td.column-redirect_only{text-align:left;padding-left:11px}table.wp-list-table td.column-download_count span.na,table.wp-list-table td.column-featured span.na,table.wp-list-table td.column-members_only span.na,table.wp-list-table td.column-redirect_only span.na{color:#999;width:1em;height:1em;line-height:1em;display:inline-block;overflow:hidden;vertical-align:middle}table.wp-list-table td.column-download_count span.na:before,table.wp-list-table td.column-featured span.na:before,table.wp-list-table td.column-members_only span.na:before,table.wp-list-table td.column-redirect_only span.na:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f460";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}table.wp-list-table td.column-download_count span.yes,table.wp-list-table td.column-featured span.yes,table.wp-list-table td.column-members_only span.yes,table.wp-list-table td.column-redirect_only span.yes{width:1em;height:1em;line-height:1em;display:inline-block;overflow:hidden;vertical-align:middle}table.wp-list-table td.column-download_count span.yes:before,table.wp-list-table td.column-featured span.yes:before,table.wp-list-table td.column-members_only span.yes:before,table.wp-list-table td.column-redirect_only span.yes:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f147";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}table.wp-list-table .column-thumb img{padding:2px;margin:0;border:1px solid #dfdfdf;vertical-align:middle;width:32px;height:32px}#download-monitor-file .inside{padding:0;margin:0}#download-monitor-file .dlm-metaboxes-wrapper .close_all,#download-monitor-file .dlm-metaboxes-wrapper .expand_all{float:right;margin-left:1em;line-height:22px;text-decoration:none}#download-monitor-file .dlm-metaboxes-wrapper .expand_all:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f168";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}#download-monitor-file .dlm-metaboxes-wrapper .close_all:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f460";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}#download-monitor-file .dlm-metaboxes-wrapper p.toolbar{margin:0!important;border-top:1px solid #fff;border-bottom:1px solid #DFDFDF;padding:7px 12px!important;overflow:hidden;zoom:1}#download-monitor-file .dlm-metaboxes-wrapper p.toolbar a.button{float:left;margin:0}#download-monitor-file .dlm-metaboxes-wrapper .fr,#download-monitor-file .dlm-metaboxes-wrapper button.add_attribute,#download-monitor-file .dlm-metaboxes-wrapper button.add_variable_attribute,#download-monitor-file .dlm-metaboxes-wrapper select.attribute_taxonomy{float:right;margin:0 0 0 6px}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metaboxes{padding:0 12px}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox-sortable-placeholder{border-color:#bbb;background-color:#f5f5f5;margin:9px 0;border-width:1px;border-style:dashed}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox{background:#ececec;border:1px solid #ececec;margin:9px 0!important}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox h3{margin:0!important;padding:6px!important;font-size:1em!important;overflow:hidden;zoom:1;cursor:move}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox h3 button{float:right}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox h3 strong{font-weight:400;line-height:24px}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox h3 select{font-family:sans-serif}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox h3 .handlediv{background-position:6px 5px!important;display:none;height:24px}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox:hover h3 .handlediv{display:block}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table{width:100%;position:relative;background:#fff;padding:3px}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table td{text-align:left;padding:6px;vertical-align:top;border:0;line-height:26px}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table td label{text-align:left;display:block;line-height:21px}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table td input{float:left;min-width:200px}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table td input,#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table td textarea{width:100%;margin:0;display:block;font-size:14px;padding:4px;color:#555}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table td textarea{height:7.5em}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table td select{width:100%}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table td input.short{width:200px}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table td input.checkbox{width:auto;min-width:inherit;vertical-align:middle;display:inline;float:none}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table td input.date-picker-field{width:50%;min-width:inherit;float:none;display:inline}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table td input.hour,#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table td input.minute{width:2em;min-width:inherit;float:none;display:inline}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table td.attribute_name{width:200px}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table .minus,#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table .plus{margin-top:6px}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table .fl{float:left}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox table .fr{float:right}#download-monitor-file .dlm-metaboxes-wrapper .dlm-metabox:first-child h3{background:#EAF2FA;background-image:linear-gradient(bottom,#dae6f2 0,#eaf2fa 100%);background-image:-o-linear-gradient(bottom,#dae6f2 0,#eaf2fa 100%);background-image:-moz-linear-gradient(bottom,#dae6f2 0,#eaf2fa 100%);background-image:-webkit-linear-gradient(bottom,#dae6f2 0,#eaf2fa 100%);background-image:-ms-linear-gradient(bottom,#dae6f2 0,#eaf2fa 100%);background-image:-webkit-gradient(linear,left bottom,left top,color-stop(0,#dae6f2),color-stop(1,#eaf2fa));border-color:#d3deea;color:#21759B}#download-monitor-file .dlm-metaboxes-wrapper .plus:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f132";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}#download-monitor-file .dlm-metaboxes-wrapper .minus:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f460";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}#download-monitor-file .dlm-metaboxes-wrapper .dlm_upload_file:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f317";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}#download-monitor-file .dlm-metaboxes-wrapper .dlm_browse_for_file:before{font-family:dashicons!important;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0 4px 0 0;content:"\f322";top:1px;left:-1px;font-size:1em;line-height:inherit;position:relative;vertical-align:top}#download-monitor-options .inside{padding:0;margin:0}#download-monitor-options .form-field-checkbox label{display:inline;padding:0 0 4px}#download-monitor-options .form-field-checkbox input{display:inline-block;width:auto;vertical-align:middle}#download-monitor-options .form-field-checkbox .description{padding:4px 0 0;display:block}#download-monitor-options .access_permissions{margin:0!important;border-top:1px solid #fff;border-bottom:1px solid #DFDFDF;padding:7px 12px!important;overflow:hidden;zoom:1}#download-monitor-options .access_permissions h4{margin:0 0 .5em}#download-monitor-options .access_permissions ul{background:#fff;border:1px solid #dfdfdf;height:110px;overflow:auto;padding:.5em .9em;margin:0}#download-monitor-options p{margin:0!important;border-top:1px solid #fff;border-bottom:1px solid #DFDFDF;padding:7px 12px!important;overflow:hidden;zoom:1}#insert-download{padding:20px}#insert-download .error,#insert-download .updated{margin-left:0;margin-right:0}#insert-download h2{margin-top:0}#insert-download label{margin:0 0 .25em;display:block;font-size:1.1em}#insert-download span.description{display:block}#insert-download input.input{margin:0 0 .25em;display:block;width:100%;font-size:1.1em}#insert-download .add_link{float:right}#insert-download ul.page-numbers{overflow:hidden;zoom:1;margin:0 auto;padding:0;text-align:center}#insert-download ul.page-numbers li{display:inline-block;margin:0;list-style:none outside;line-height:1em}#insert-download ul.page-numbers li a,#insert-download ul.page-numbers li span{text-decoration:none;border:1px solid #ddd;-webkit-border-radius:4px;border-radius:4px;padding:8px;display:block}#insert-download ul.page-numbers li span{border-color:#eee}#insert-download legend{font-weight:700;display:block;margin:0 0 1em}#insert-download fieldset label{display:block;margin:0 0 .5em}.dlm_extensions_wrap h2 a.dlm-reload-button{float:right}.dlm_extensions_wrap .dlm_extensions{padding:15px 0;overflow:hidden}.dlm_extensions_wrap .dlm_extensions div.dlm_extension{cursor:auto!important}.dlm_extensions_wrap .dlm_extensions div.dlm_extension a{color:#444;text-decoration:none}.dlm_extensions_wrap .dlm_extensions div.dlm_extension .dlm_extension_img_wrapper{width:100%;background:#419CCB;text-align:center}.dlm_extensions_wrap .dlm_extensions div.dlm_extension .dlm_extension_img_wrapper img{max-width:100%;margin:0 auto}.dlm_extensions_wrap .dlm_extensions div.dlm_extension h3{padding:0 20px}.dlm_extensions_wrap .dlm_extensions div.dlm_extension p.extension-desc{min-height:85px;padding:0 20px}.dlm_extensions_wrap .dlm_extensions div.dlm_extension .product_footer{padding:0 20px 15px}.dlm_extensions_wrap .dlm_extensions div.dlm_extension .product_footer .loop_price{font-weight:700}.dlm_extensions_wrap .dlm_extensions div.dlm_extension .product_footer .loop_price.sale{color:green}.dlm_extensions_wrap .dlm_extensions div.dlm_extension .product_footer .loop_price.sale strike{color:#444}.dlm_extensions_wrap .dlm_extensions div.dlm_extension .product_footer .loop_more{color:#459ac9;text-decoration:none;font-weight:700;float:right}.dlm_extensions_wrap .dlm_extensions div.dlm_extension .extension_license{padding:0 20px 20px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.dlm_extensions_wrap .dlm_extensions div.dlm_extension .extension_license p.license-status{padding:5px 0;margin:5px 0;background:red;font-weight:700;font-size:1.2em;color:#fff;text-align:center}.dlm_extensions_wrap .dlm_extensions div.dlm_extension .extension_license p.license-status.active{background:green}.dlm_extensions_wrap .dlm_extensions div.dlm_extension .extension_license input{width:100%;margin:7px 0;padding:7px}.dlm_extensions_wrap .dlm_extensions div.dlm_extension .extension_license a.button-primary{width:100%;margin:5px auto 0;color:#fff;text-align:center}
assets/css/admin.less CHANGED
@@ -1,609 +1,636 @@
1
  .iconbefore( @glyph: "\f333" ) {
2
- font-family: dashicons !important;
3
- speak: none;
4
- font-weight: normal;
5
- font-variant: normal;
6
- text-transform: none;
7
- -webkit-font-smoothing: antialiased;
8
- -moz-osx-font-smoothing: grayscale;
9
- margin: 0 4px 0 0;
10
- content: @glyph;
11
- top: 1px;
12
- left: -1px;
13
- font-size: 1em;
14
- line-height: inherit;
15
- position: relative;
16
- vertical-align: top;
17
  }
18
 
19
  /* Logs */
20
  #dlm_logs {
21
- td {
22
- padding: 7px 7px;
23
- vertical-align: middle;
24
- }
25
- .column-status {
26
- width: 4em;
27
- }
28
- td.column-status {
29
- font-size: 10px;
30
- vertical-align: middle;
31
- text-align: center;
32
- span {
33
- color: #fff;
34
- font-weight: normal;
35
- -moz-border-radius: 50%;
36
- -webkit-border-radius: 50%;
37
- border-radius: 50%;
38
- height: 16px;
39
- line-height: 16px;
40
- width: 16px;
41
- display: inline-block;
42
- }
43
- .failed {
44
- background-color: #df9d1d;
45
- }
46
- .redirected {
47
- background-color: #74a721;
48
- }
49
- .completed {
50
- background-color: #1c769b;
51
- }
52
- }
53
- td.column-user_ip, td.column-user_agent {
54
- font-family: monospace;
55
- font-weight: normal;
56
- }
57
- span.description {
58
- font-weight: normal;
59
- }
60
- .column-download, .column-file, .column-user, .column-user_ua {
61
- width: 16% !important;
62
- }
63
- .column-user_ip, .column-date {
64
- width: 6% !important;
65
- }
66
  }
67
 
68
  /* File lists */
69
  ul.download_monitor_file_browser {
70
- list-style: none outside;
71
- margin: 0;
72
- border: 1px solid #ddd;
73
- -moz-border-radius: 3px;
74
- -webkit-border-radius: 3px;
75
- border-radius: 3px;
76
- background: #f9f9f9;
77
- padding: 5px 5px;
78
- -moz-box-shadow: inset 0 0 0 1px #fff;
79
- -webkit-box-shadow: inset 0 0 0 1px #fff;
80
- box-shadow: inset 0 0 0 1px #fff;
81
 
82
- li {
83
- padding: 0;
84
- margin: 0;
85
- a {
86
- color: #21759B;
87
- display: block;
88
- padding: 4px 0 4px 4px;
89
- text-decoration: none;
90
 
91
- &:hover {
92
- background-color: #eaf2fa;
93
- }
94
- &:before {
95
- .iconbefore( "\f123" );
96
- }
97
- &.folder:before {
98
- .iconbefore( "\f318" );
99
- }
100
 
101
- // Videos
102
- &.filetype-mov, &.filetype-avi, &.filetype-3g2, &.filetype-3gp, &.filetype-asf, &.filetype-asx, &.filetype-mp4, &.filetype-mpg, &.filetype-rm, &.filetype-srt, &.filetype-vob, &.filetype-wmv {
103
- &:before {
104
- .iconbefore( "\f126" );
105
- }
106
- }
107
 
108
- // Audio
109
- &.filetype-mp3, &.filetype-aif, &.filetype-iff, &.filetype-m3u, &.filetype-m4a, &.filetype-mid, &.filetype-midi, &.filetype-mpa, &.filetype-ra, &.filetype-wav, &.filetype-wma {
110
- &:before {
111
- .iconbefore( "\f127" );
112
- }
113
- }
114
 
115
- // Images
116
- &.filetype-psd, &.filetype-ai, &.filetype-eps, &.filetype-ps, &.filetype-svg, &.filetype-bmp, &.filetype-dds, &.filetype-gif, &.filetype-jpg, &.filetype-jpeg, &.filetype-png, &.filetype-pspimage, &.filetype-tga, &.filetype-thm, &.filetype-tif, &.filetype-yuv, &.filetype-ico {
117
- &:before {
118
- .iconbefore( "\f128" );
119
- }
120
- }
121
- }
122
 
123
- &.nofiles {
124
- color: #999;
125
- font-style: italic;
126
- padding: 4px 0;
127
- }
128
 
129
- ul {
130
- list-style: none outside;
131
- margin: 0;
132
- padding: 0 0 0 28px;
133
 
134
- &.loading {
135
- background: url(../images/ajax-loader.gif) no-repeat 24px 0;
136
- height: 32px;
137
- }
138
- }
139
- }
140
  }
141
 
142
  /* Download list */
143
  table.wp-list-table {
144
- .column-thumb {
145
- width: 44px;
146
- text-align: center;
147
- white-space: nowrap
148
- }
149
- .column-dlm_download_cat, .column-dlm_download_tag, .column-file {
150
- width: 11% !important;
151
- }
152
- .column-title, .column-file {
153
- width: 17% !important;
154
- }
155
- .column-download_id, .column-version {
156
- width: 5em;
157
- }
158
- th.column-thumb, th.column-download_count, th.column-members_only, th.column-redirect_only, th.column-featured {
159
- span:first-child {
160
- float: none;
161
- display: inline-block;
162
- width: 1em;
163
- height: 1em;
164
- line-height: 1em;
165
- padding: 2px 0 0 0;
166
- overflow: hidden;
167
- }
168
- .sorting-indicator {
169
- float: right;
170
- }
171
- }
172
- th.column-thumb {
173
- width: 52px;
174
- text-align: center;
175
- span:first-child {
176
- &:before {
177
- .iconbefore( "\f128" );
178
- }
179
- }
180
- }
181
- th.column-download_count {
182
- width: 5em;
183
- span:first-child {
184
- &:before {
185
- .iconbefore( "\f346" );
186
- }
187
- }
188
- }
189
- th.column-members_only {
190
- width: 3.5em;
191
- span:first-child {
192
- &:before {
193
- .iconbefore( "\f338" );
194
- }
195
- }
196
- }
197
- th.column-redirect_only {
198
- width: 3.5em;
199
- span:first-child {
200
- &:before {
201
- .iconbefore( "\f103" );
202
- }
203
- }
204
- }
205
- th.column-featured {
206
- width: 3.5em;
207
- span:first-child {
208
- &:before {
209
- .iconbefore( "\f155" );
210
- }
211
- }
212
- }
213
- td.column-download_count, td.column-members_only, td.column-redirect_only, td.column-featured {
214
- text-align: left;
215
- padding-left: 11px;
216
- span.na {
217
- color: #999;
218
- width: 1em;
219
- height: 1em;
220
- line-height: 1em;
221
- display: inline-block;
222
- overflow: hidden;
223
- vertical-align: middle;
224
- &:before {
225
- .iconbefore( "\f460" );
226
- }
227
- }
228
- span.yes {
229
- width: 1em;
230
- height: 1em;
231
- line-height: 1em;
232
- display: inline-block;
233
- overflow: hidden;
234
- vertical-align: middle;
235
- &:before {
236
- .iconbefore( "\f147" );
237
- }
238
- }
239
- }
240
- .column-thumb img {
241
- padding: 2px;
242
- margin: 0;
243
- border: 1px solid #dfdfdf;
244
- vertical-align: middle;
245
- width: 32px;
246
- height: 32px;
247
- }
248
  }
249
 
250
  /* Meta boxes */
251
  #download-monitor-file {
252
- .inside {
253
- padding: 0;
254
- margin: 0;
255
- }
256
- .dlm-metaboxes-wrapper {
257
- .expand_all, .close_all {
258
- float: right;
259
- margin-left: 1em;
260
- line-height: 22px;
261
- text-decoration: none;
262
- }
263
- .expand_all {
264
- &:before {
265
- .iconbefore( "\f168" );
266
- }
267
- }
268
- .close_all {
269
- &:before {
270
- .iconbefore( "\f460" );
271
- }
272
- }
273
- p.toolbar {
274
- margin: 0 !important;
275
- border-top: 1px solid white;
276
- border-bottom: 1px solid #DFDFDF;
277
- padding: 7px 12px !important;
278
- overflow: hidden;
279
- zoom: 1;
280
 
281
- a.button {
282
- float: left;
283
- margin: 0;
284
- }
285
- }
286
- select.attribute_taxonomy, button.add_attribute, button.add_variable_attribute, .fr {
287
- float: right;
288
- margin: 0 0 0 6px;
289
- }
290
- .dlm-metaboxes {
291
- padding: 0 12px 0;
292
- }
293
- .dlm-metabox-sortable-placeholder {
294
- border-color:#bbb;
295
- background-color:#f5f5f5;
296
- margin: 9px 0;
297
- border-width:1px;
298
- border-style:dashed;
299
- }
300
- .dlm-metabox {
301
- background: #ececec;
302
- border: 1px solid #ececec;
303
- margin: 9px 0 !important;
304
- h3 {
305
- margin: 0 !important;
306
- padding: 6px !important;
307
- font-size: 1em !important;
308
- overflow: hidden;
309
- zoom: 1;
310
- cursor: move;
311
- button {
312
- float: right;
313
- }
314
- strong {
315
- font-weight: normal;
316
- line-height: 24px;
317
- }
318
- select {
319
- font-family: sans-serif;
320
- }
321
- .handlediv {
322
- background-position: 6px 5px !important;
323
- display: none;
324
- height: 24px;
325
- }
326
- }
327
- &:hover h3 .handlediv {
328
- display: block;
329
- }
330
- table {
331
- width: 100%;
332
- position: relative;
333
- background: #fff;
334
- padding: 3px;
335
- td {
336
- text-align: left;
337
- padding: 6px 6px;
338
- vertical-align: top;
339
- border: 0;
340
- line-height: 26px;
341
- label {
342
- text-align: left;
343
- display: block;
344
- line-height: 21px;
345
- }
346
- input {
347
- float: left;
348
- min-width: 200px;
349
- }
350
- input, textarea {
351
- width: 100%;
352
- margin: 0;
353
- display: block;
354
- font-size: 14px;
355
- padding: 4px;
356
- color: #555;
357
- }
358
- textarea {
359
- height: 7.5em;
360
- }
361
- select {
362
- width: 100%;
363
- }
364
- input.short {
365
- width: 200px;
366
- }
367
- input.checkbox {
368
- width: auto;
369
- min-width: inherit;
370
- vertical-align: middle;
371
- display: inline;
372
- float: none;
373
- }
374
- input.date-picker-field {
375
- width: 50%;
376
- min-width: inherit;
377
- float: none;
378
- display: inline;
379
- }
380
- input.minute, input.hour {
381
- width: 2em;
382
- min-width: inherit;
383
- float: none;
384
- display: inline;
385
- }
386
- }
387
- td.attribute_name {
388
- width: 200px;
389
- }
390
- .plus, .minus {
391
- margin-top: 6px;
392
- }
393
- .fl {
394
- float: left;
395
- }
396
- .fr {
397
- float: right;
398
- }
399
- }
400
- &:first-child {
401
- /* main file */
402
- h3 {
403
- background: #EAF2FA;
404
- background-image: linear-gradient(bottom, rgb(218,230,242) 0%, rgb(234,242,250) 100%);
405
- background-image: -o-linear-gradient(bottom, rgb(218,230,242) 0%, rgb(234,242,250) 100%);
406
- background-image: -moz-linear-gradient(bottom, rgb(218,230,242) 0%, rgb(234,242,250) 100%);
407
- background-image: -webkit-linear-gradient(bottom, rgb(218,230,242) 0%, rgb(234,242,250) 100%);
408
- background-image: -ms-linear-gradient(bottom, rgb(218,230,242) 0%, rgb(234,242,250) 100%);
409
 
410
- background-image: -webkit-gradient(
411
- linear,
412
- left bottom,
413
- left top,
414
- color-stop(0, rgb(218,230,242)),
415
- color-stop(1, rgb(234,242,250))
416
- );
417
- border-color: #d3deea;
418
- color: #21759B;
419
- }
420
- }
421
- }
422
- .plus:before {
423
- .iconbefore( "\f132" );
424
- }
425
- .minus:before {
426
- .iconbefore( "\f460" );
427
- }
428
- .dlm_upload_file:before {
429
- .iconbefore( "\f317" );
430
- }
431
- .dlm_browse_for_file:before {
432
- .iconbefore( "\f322" );
433
- }
434
- }
435
  }
436
 
437
  /* Writepanel forms */
438
  #download-monitor-options {
439
- .inside {
440
- padding: 0;
441
- margin: 0;
442
- }
443
- .form-field-checkbox {
444
- label {
445
- display: inline;
446
- padding: 0 0 4px;
447
- }
448
- input {
449
- display: inline-block;
450
- width: auto;
451
- vertical-align: middle;
452
- }
453
- .description {
454
- padding: 4px 0 0 0;
455
- display: block;
456
- }
457
- }
458
- .access_permissions {
459
- margin: 0 !important;
460
- border-top: 1px solid white;
461
- border-bottom: 1px solid #DFDFDF;
462
- padding: 7px 12px !important;
463
- overflow: hidden;
464
- zoom: 1;
465
 
466
- h4 {
467
- margin-bottom: .5em;
468
- margin: 0 0 .5em;
469
- }
470
- ul {
471
- background: #fff;
472
- border: 1px solid #dfdfdf;
473
- height: 110px;
474
- overflow: auto;
475
- padding: .5em .9em;
476
- margin: 0;
477
- }
478
- }
479
- p {
480
- margin: 0 !important;
481
- border-top: 1px solid white;
482
- border-bottom: 1px solid #DFDFDF;
483
- padding: 7px 12px !important;
484
- overflow: hidden;
485
- zoom: 1;
486
- }
487
  }
488
 
489
  #insert-download {
490
- padding: 20px 20px;
491
 
492
- .updated, .error {
493
- margin-left: 0;
494
- margin-right: 0;
495
- }
496
- h2 {
497
- margin-top: 0;
498
- }
499
- label {
500
- margin: 0 0 .25em 0;
501
- display: block;
502
- font-size: 1.1em;
503
- }
504
- span.description {
505
- display: block;
506
- }
507
- input.input {
508
- margin: 0 0 .25em 0;
509
- display: block;
510
- width: 100%;
511
- font-size: 1.1em;
512
- }
513
- .add_link {
514
- float: right;
515
- }
516
- ul.page-numbers {
517
- overflow: hidden;
518
- zoom: 1;
519
- margin: 0 auto;
520
- padding: 0;
521
- text-align: center;
522
- li {
523
- display: inline-block;
524
- margin: 0;
525
- list-style: none outside;
526
- line-height: 1em;
527
- a, span {
528
- text-decoration: none;
529
- border: 1px solid #ddd;
530
- -webkit-border-radius: 4px;
531
- border-radius: 4px;
532
- padding: 8px;
533
- display: block;
534
- }
535
- span {
536
- border-color: #eee;
537
- }
538
- }
539
- }
540
- legend {
541
- font-weight: bold;
542
- display: block;
543
- margin: 0 0 1em;
544
- }
545
- fieldset {
546
- label {
547
- display: block;
548
- margin: 0 0 .5em;
549
- }
550
- }
551
  }
552
 
553
- /* Addons */
554
- .dlm_addons_wrap {
555
- .items {
556
- overflow: hidden;
557
- li {
558
- display: inline-block;
559
- margin: 0 10px 10px 0 !important;
560
- padding: 0;
561
- vertical-align: top;
562
- width: 250px;
563
- border: 1px solid #ddd;
564
- -webkit-box-shadow:
565
- inset 0 1px 0 rgba(255,255,255,0.2),
566
- inset 0 -1px 0 rgba(0,0,0,0.1);
567
- box-shadow:
568
- inset 0 1px 0 rgba(255,255,255,0.2),
569
- inset 0 -1px 0 rgba(0,0,0,0.1);
570
- overflow: hidden;
571
- position: relative;
572
- a {
573
- color: inherit;
574
- text-decoration: none;
575
- }
576
- img {
577
- max-width: 100%;
578
- height: auto;
579
- display: block;
580
- margin: 0;
581
- background: #fff;
582
- }
583
- h2 {
584
- margin: 0 !important;
585
- padding: 10px 20px !important;
586
- line-height: 1;
587
- background: rgba(255,255,255,0.8);
588
- color: #000;
589
- position: absolute;
590
- max-width: 280px;
591
- top: 20px;
592
- left: 0;
593
- font-size: 18px;
594
- text-shadow: none;
595
- }
596
- .third_party {
597
- display: none;
598
- }
599
- p {
600
- padding: 20px !important;
601
- margin: 0 !important;
602
- border-top: 1px solid #f1f1f1;
603
- }
604
- .cost {
605
- display: none;
606
- }
607
- }
608
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
609
  }
1
  .iconbefore( @glyph: "\f333" ) {
2
+ font-family: dashicons !important;
3
+ speak: none;
4
+ font-weight: normal;
5
+ font-variant: normal;
6
+ text-transform: none;
7
+ -webkit-font-smoothing: antialiased;
8
+ -moz-osx-font-smoothing: grayscale;
9
+ margin: 0 4px 0 0;
10
+ content: @glyph;
11
+ top: 1px;
12
+ left: -1px;
13
+ font-size: 1em;
14
+ line-height: inherit;
15
+ position: relative;
16
+ vertical-align: top;
17
  }
18
 
19
  /* Logs */
20
  #dlm_logs {
21
+ td {
22
+ padding: 7px 7px;
23
+ vertical-align: middle;
24
+ }
25
+ .column-status {
26
+ width: 4em;
27
+ }
28
+ td.column-status {
29
+ font-size: 10px;
30
+ vertical-align: middle;
31
+ text-align: center;
32
+ span {
33
+ color: #fff;
34
+ font-weight: normal;
35
+ -moz-border-radius: 50%;
36
+ -webkit-border-radius: 50%;
37
+ border-radius: 50%;
38
+ height: 16px;
39
+ line-height: 16px;
40
+ width: 16px;
41
+ display: inline-block;
42
+ }
43
+ .failed {
44
+ background-color: #df9d1d;
45
+ }
46
+ .redirected {
47
+ background-color: #74a721;
48
+ }
49
+ .completed {
50
+ background-color: #1c769b;
51
+ }
52
+ }
53
+ td.column-user_ip, td.column-user_agent {
54
+ font-family: monospace;
55
+ font-weight: normal;
56
+ }
57
+ span.description {
58
+ font-weight: normal;
59
+ }
60
+ .column-download, .column-file, .column-user, .column-user_ua {
61
+ width: 16% !important;
62
+ }
63
+ .column-user_ip, .column-date {
64
+ width: 6% !important;
65
+ }
66
  }
67
 
68
  /* File lists */
69
  ul.download_monitor_file_browser {
70
+ list-style: none outside;
71
+ margin: 0;
72
+ border: 1px solid #ddd;
73
+ -moz-border-radius: 3px;
74
+ -webkit-border-radius: 3px;
75
+ border-radius: 3px;
76
+ background: #f9f9f9;
77
+ padding: 5px 5px;
78
+ -moz-box-shadow: inset 0 0 0 1px #fff;
79
+ -webkit-box-shadow: inset 0 0 0 1px #fff;
80
+ box-shadow: inset 0 0 0 1px #fff;
81
 
82
+ li {
83
+ padding: 0;
84
+ margin: 0;
85
+ a {
86
+ color: #21759B;
87
+ display: block;
88
+ padding: 4px 0 4px 4px;
89
+ text-decoration: none;
90
 
91
+ &:hover {
92
+ background-color: #eaf2fa;
93
+ }
94
+ &:before {
95
+ .iconbefore("\f123");
96
+ }
97
+ &.folder:before {
98
+ .iconbefore("\f318");
99
+ }
100
 
101
+ // Videos
102
+ &.filetype-mov, &.filetype-avi, &.filetype-3g2, &.filetype-3gp, &.filetype-asf, &.filetype-asx, &.filetype-mp4, &.filetype-mpg, &.filetype-rm, &.filetype-srt, &.filetype-vob, &.filetype-wmv {
103
+ &:before {
104
+ .iconbefore("\f126");
105
+ }
106
+ }
107
 
108
+ // Audio
109
+ &.filetype-mp3, &.filetype-aif, &.filetype-iff, &.filetype-m3u, &.filetype-m4a, &.filetype-mid, &.filetype-midi, &.filetype-mpa, &.filetype-ra, &.filetype-wav, &.filetype-wma {
110
+ &:before {
111
+ .iconbefore("\f127");
112
+ }
113
+ }
114
 
115
+ // Images
116
+ &.filetype-psd, &.filetype-ai, &.filetype-eps, &.filetype-ps, &.filetype-svg, &.filetype-bmp, &.filetype-dds, &.filetype-gif, &.filetype-jpg, &.filetype-jpeg, &.filetype-png, &.filetype-pspimage, &.filetype-tga, &.filetype-thm, &.filetype-tif, &.filetype-yuv, &.filetype-ico {
117
+ &:before {
118
+ .iconbefore("\f128");
119
+ }
120
+ }
121
+ }
122
 
123
+ &.nofiles {
124
+ color: #999;
125
+ font-style: italic;
126
+ padding: 4px 0;
127
+ }
128
 
129
+ ul {
130
+ list-style: none outside;
131
+ margin: 0;
132
+ padding: 0 0 0 28px;
133
 
134
+ &.loading {
135
+ background: url(../images/ajax-loader.gif) no-repeat 24px 0;
136
+ height: 32px;
137
+ }
138
+ }
139
+ }
140
  }
141
 
142
  /* Download list */
143
  table.wp-list-table {
144
+ .column-thumb {
145
+ width: 44px;
146
+ text-align: center;
147
+ white-space: nowrap
148
+ }
149
+ .column-dlm_download_cat, .column-dlm_download_tag, .column-file {
150
+ width: 11% !important;
151
+ }
152
+ .column-title, .column-file {
153
+ width: 17% !important;
154
+ }
155
+ .column-download_id, .column-version {
156
+ width: 5em;
157
+ }
158
+ th.column-thumb, th.column-download_count, th.column-members_only, th.column-redirect_only, th.column-featured {
159
+ span:first-child {
160
+ float: none;
161
+ display: inline-block;
162
+ width: 1em;
163
+ height: 1em;
164
+ line-height: 1em;
165
+ padding: 2px 0 0 0;
166
+ overflow: hidden;
167
+ }
168
+ .sorting-indicator {
169
+ float: right;
170
+ }
171
+ }
172
+ th.column-thumb {
173
+ width: 52px;
174
+ text-align: center;
175
+ span:first-child {
176
+ &:before {
177
+ .iconbefore("\f128");
178
+ }
179
+ }
180
+ }
181
+ th.column-download_count {
182
+ width: 5em;
183
+ span:first-child {
184
+ &:before {
185
+ .iconbefore("\f346");
186
+ }
187
+ }
188
+ }
189
+ th.column-members_only {
190
+ width: 3.5em;
191
+ span:first-child {
192
+ &:before {
193
+ .iconbefore("\f338");
194
+ }
195
+ }
196
+ }
197
+ th.column-redirect_only {
198
+ width: 3.5em;
199
+ span:first-child {
200
+ &:before {
201
+ .iconbefore("\f103");
202
+ }
203
+ }
204
+ }
205
+ th.column-featured {
206
+ width: 3.5em;
207
+ span:first-child {
208
+ &:before {
209
+ .iconbefore("\f155");
210
+ }
211
+ }
212
+ }
213
+ td.column-download_count, td.column-members_only, td.column-redirect_only, td.column-featured {
214
+ text-align: left;
215
+ padding-left: 11px;
216
+ span.na {
217
+ color: #999;
218
+ width: 1em;
219
+ height: 1em;
220
+ line-height: 1em;
221
+ display: inline-block;
222
+ overflow: hidden;
223
+ vertical-align: middle;
224
+ &:before {
225
+ .iconbefore("\f460");
226
+ }
227
+ }
228
+ span.yes {
229
+ width: 1em;
230
+ height: 1em;
231
+ line-height: 1em;
232
+ display: inline-block;
233
+ overflow: hidden;
234
+ vertical-align: middle;
235
+ &:before {
236
+ .iconbefore("\f147");
237
+ }
238
+ }
239
+ }
240
+ .column-thumb img {
241
+ padding: 2px;
242
+ margin: 0;
243
+ border: 1px solid #dfdfdf;
244
+ vertical-align: middle;
245
+ width: 32px;
246
+ height: 32px;
247
+ }
248
  }
249
 
250
  /* Meta boxes */
251
  #download-monitor-file {
252
+ .inside {
253
+ padding: 0;
254
+ margin: 0;
255
+ }
256
+ .dlm-metaboxes-wrapper {
257
+ .expand_all, .close_all {
258
+ float: right;
259
+ margin-left: 1em;
260
+ line-height: 22px;
261
+ text-decoration: none;
262
+ }
263
+ .expand_all {
264
+ &:before {
265
+ .iconbefore("\f168");
266
+ }
267
+ }
268
+ .close_all {
269
+ &:before {
270
+ .iconbefore("\f460");
271
+ }
272
+ }
273
+ p.toolbar {
274
+ margin: 0 !important;
275
+ border-top: 1px solid white;
276
+ border-bottom: 1px solid #DFDFDF;
277
+ padding: 7px 12px !important;
278
+ overflow: hidden;
279
+ zoom: 1;
280
 
281
+ a.button {
282
+ float: left;
283
+ margin: 0;
284
+ }
285
+ }
286
+ select.attribute_taxonomy, button.add_attribute, button.add_variable_attribute, .fr {
287
+ float: right;
288
+ margin: 0 0 0 6px;
289
+ }
290
+ .dlm-metaboxes {
291
+ padding: 0 12px 0;
292
+ }
293
+ .dlm-metabox-sortable-placeholder {
294
+ border-color: #bbb;
295
+ background-color: #f5f5f5;
296
+ margin: 9px 0;
297
+ border-width: 1px;
298
+ border-style: dashed;
299
+ }
300
+ .dlm-metabox {
301
+ background: #ececec;
302
+ border: 1px solid #ececec;
303
+ margin: 9px 0 !important;
304
+ h3 {
305
+ margin: 0 !important;
306
+ padding: 6px !important;
307
+ font-size: 1em !important;
308
+ overflow: hidden;
309
+ zoom: 1;
310
+ cursor: move;
311
+ button {
312
+ float: right;
313
+ }
314
+ strong {
315
+ font-weight: normal;
316
+ line-height: 24px;
317
+ }
318
+ select {
319
+ font-family: sans-serif;
320
+ }
321
+ .handlediv {
322
+ background-position: 6px 5px !important;
323
+ display: none;
324
+ height: 24px;
325
+ }
326
+ }
327
+ &:hover h3 .handlediv {
328
+ display: block;
329
+ }
330
+ table {
331
+ width: 100%;
332
+ position: relative;
333
+ background: #fff;
334
+ padding: 3px;
335
+ td {
336
+ text-align: left;
337
+ padding: 6px 6px;
338
+ vertical-align: top;
339
+ border: 0;
340
+ line-height: 26px;
341
+ label {
342
+ text-align: left;
343
+ display: block;
344
+ line-height: 21px;
345
+ }
346
+ input {
347
+ float: left;
348
+ min-width: 200px;
349
+ }
350
+ input, textarea {
351
+ width: 100%;
352
+ margin: 0;
353
+ display: block;
354
+ font-size: 14px;
355
+ padding: 4px;
356
+ color: #555;
357
+ }
358
+ textarea {
359
+ height: 7.5em;
360
+ }
361
+ select {
362
+ width: 100%;
363
+ }
364
+ input.short {
365
+ width: 200px;
366
+ }
367
+ input.checkbox {
368
+ width: auto;
369
+ min-width: inherit;
370
+ vertical-align: middle;
371
+ display: inline;
372
+ float: none;
373
+ }
374
+ input.date-picker-field {
375
+ width: 50%;
376
+ min-width: inherit;
377
+ float: none;
378
+ display: inline;
379
+ }
380
+ input.minute, input.hour {
381
+ width: 2em;
382
+ min-width: inherit;
383
+ float: none;
384
+ display: inline;
385
+ }
386
+ }
387
+ td.attribute_name {
388
+ width: 200px;
389
+ }
390
+ .plus, .minus {
391
+ margin-top: 6px;
392
+ }
393
+ .fl {
394
+ float: left;
395
+ }
396
+ .fr {
397
+ float: right;
398
+ }
399
+ }
400
+ &:first-child {
401
+ /* main file */
402
+ h3 {
403
+ background: #EAF2FA;
404
+ background-image: linear-gradient(bottom, rgb(218, 230, 242) 0%, rgb(234, 242, 250) 100%);
405
+ background-image: -o-linear-gradient(bottom, rgb(218, 230, 242) 0%, rgb(234, 242, 250) 100%);
406
+ background-image: -moz-linear-gradient(bottom, rgb(218, 230, 242) 0%, rgb(234, 242, 250) 100%);
407
+ background-image: -webkit-linear-gradient(bottom, rgb(218, 230, 242) 0%, rgb(234, 242, 250) 100%);
408
+ background-image: -ms-linear-gradient(bottom, rgb(218, 230, 242) 0%, rgb(234, 242, 250) 100%);
409
 
410
+ background-image: -webkit-gradient(
411
+ linear,
412
+ left bottom,
413
+ left top,
414
+ color-stop(0, rgb(218, 230, 242)),
415
+ color-stop(1, rgb(234, 242, 250))
416
+ );
417
+ border-color: #d3deea;
418
+ color: #21759B;
419
+ }
420
+ }
421
+ }
422
+ .plus:before {
423
+ .iconbefore("\f132");
424
+ }
425
+ .minus:before {
426
+ .iconbefore("\f460");
427
+ }
428
+ .dlm_upload_file:before {
429
+ .iconbefore("\f317");
430
+ }
431
+ .dlm_browse_for_file:before {
432
+ .iconbefore("\f322");
433
+ }
434
+ }
435
  }
436
 
437
  /* Writepanel forms */
438
  #download-monitor-options {
439
+ .inside {
440
+ padding: 0;
441
+ margin: 0;
442
+ }
443
+ .form-field-checkbox {
444
+ label {
445
+ display: inline;
446
+ padding: 0 0 4px;
447
+ }
448
+ input {
449
+ display: inline-block;
450
+ width: auto;
451
+ vertical-align: middle;
452
+ }
453
+ .description {
454
+ padding: 4px 0 0 0;
455
+ display: block;
456
+ }
457
+ }
458
+ .access_permissions {
459
+ margin: 0 !important;
460
+ border-top: 1px solid white;
461
+ border-bottom: 1px solid #DFDFDF;
462
+ padding: 7px 12px !important;
463
+ overflow: hidden;
464
+ zoom: 1;
465
 
466
+ h4 {
467
+ margin-bottom: .5em;
468
+ margin: 0 0 .5em;
469
+ }
470
+ ul {
471
+ background: #fff;
472
+ border: 1px solid #dfdfdf;
473
+ height: 110px;
474
+ overflow: auto;
475
+ padding: .5em .9em;
476
+ margin: 0;
477
+ }
478
+ }
479
+ p {
480
+ margin: 0 !important;
481
+ border-top: 1px solid white;
482
+ border-bottom: 1px solid #DFDFDF;
483
+ padding: 7px 12px !important;
484
+ overflow: hidden;
485
+ zoom: 1;
486
+ }
487
  }
488
 
489
  #insert-download {
490
+ padding: 20px 20px;
491
 
492
+ .updated, .error {
493
+ margin-left: 0;
494
+ margin-right: 0;
495
+ }
496
+ h2 {
497
+ margin-top: 0;
498
+ }
499
+ label {
500
+ margin: 0 0 .25em 0;
501
+ display: block;
502
+ font-size: 1.1em;
503
+ }
504
+ span.description {
505
+ display: block;
506
+ }
507
+ input.input {
508
+ margin: 0 0 .25em 0;
509
+ display: block;
510
+ width: 100%;
511
+ font-size: 1.1em;
512
+ }
513
+ .add_link {
514
+ float: right;
515
+ }
516
+ ul.page-numbers {
517
+ overflow: hidden;
518
+ zoom: 1;
519
+ margin: 0 auto;
520
+ padding: 0;
521
+ text-align: center;
522
+ li {
523
+ display: inline-block;
524
+ margin: 0;
525
+ list-style: none outside;
526
+ line-height: 1em;
527
+ a, span {
528
+ text-decoration: none;
529
+ border: 1px solid #ddd;
530
+ -webkit-border-radius: 4px;
531
+ border-radius: 4px;
532
+ padding: 8px;
533
+ display: block;
534
+ }
535
+ span {
536
+ border-color: #eee;
537
+ }
538
+ }
539
+ }
540
+ legend {
541
+ font-weight: bold;
542
+ display: block;
543
+ margin: 0 0 1em;
544
+ }
545
+ fieldset {
546
+ label {
547
+ display: block;
548
+ margin: 0 0 .5em;
549
+ }
550
+ }
551
  }
552
 
553
+ .dlm_extensions_wrap {
554
+ h2 {
555
+ a.dlm-reload-button {
556
+ float: right;
557
+ }
558
+ }
559
+ .dlm_extensions {
560
+ padding: 15px 0;
561
+ overflow: hidden;
562
+ div.dlm_extension {
563
+ cursor: auto !important;
564
+ a {
565
+ color: #444;
566
+ text-decoration: none;
567
+ }
568
+ .dlm_extension_img_wrapper {
569
+ width: 100%;
570
+ background: #419CCB;
571
+ text-align: center;
572
+ img {
573
+ max-width: 100%;
574
+ margin: 0 auto;
575
+ }
576
+ }
577
+ h3 {
578
+ padding: 0 20px;
579
+
580
+ }
581
+ p.extension-desc {
582
+ min-height: 85px;
583
+ padding: 0 20px;
584
+ }
585
+ .product_footer {
586
+ padding: 0 20px 15px;
587
+ .loop_price {
588
+ font-weight: bold;
589
+ &.sale {
590
+ color: #008000;
591
+ strike {
592
+ color: #444;
593
+ }
594
+ }
595
+ }
596
+ .loop_more {
597
+ color: #459ac9;
598
+ text-decoration: none;
599
+ font-weight: bold;
600
+ float: right;
601
+ }
602
+ }
603
+ .extension_license {
604
+ // padding: 0 10% 10%;
605
+ padding: 0 20px 20px;
606
+ -webkit-box-sizing: border-box;
607
+ -moz-box-sizing: border-box;
608
+ box-sizing: border-box;
609
+ p.license-status {
610
+ padding: 5px 0;
611
+ margin: 5px 0;
612
+ background: red;
613
+ font-weight: bold;
614
+ font-size: 1.2em;
615
+ color: #fff;
616
+ text-align: center;
617
+ }
618
+ p.license-status.active {
619
+ background: #008000;
620
+ }
621
+ input {
622
+ width: 100%;
623
+ margin: 7px 0;
624
+ padding: 7px;
625
+ }
626
+ a.button-primary {
627
+ width: 100%;
628
+ margin: 5px auto 0;
629
+ color: #fff;
630
+ text-align: center;
631
+ }
632
+ }
633
+ }
634
+ }
635
+
636
  }
assets/css/dashboard.css CHANGED
@@ -1 +1 @@
1
- table.download_chart{width:100%}table.download_chart thead{display:none}table.download_chart td,table.download_chart th{padding:5px;vertical-align:middle;line-height:1.5em}table.download_chart th{text-align:left;font-weight:400;padding-left:0}table.download_chart td:last-child{padding-right:0}table.download_chart tr:first-child td,table.download_chart tr:first-child th{padding-top:0}table.download_chart tr:last-child td,table.download_chart tr:last-child th{border-bottom:0;padding-bottom:0}table.download_chart span.bar{padding:0 0 0 1px;height:1.5em;float:left;margin-right:5px;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;-moz-border-radius:2px;-webkit-border-radius:2px;border-radius:2px;bprder:1px solid ##6e6e6e;background:#6e6e6e;background-image:-webkit-gradient(linear,left bottom,left top,from(#747474),to(#6e6e6e));background-image:-webkit-linear-gradient(bottom,#747474,#6e6e6e);background-image:-moz-linear-gradient(bottom,#747474,#6e6e6e);background-image:-o-linear-gradient(bottom,#747474,#6e6e6e);background-image:linear-gradient(to top,#747474,#6e6e6e)}
1
+ table.download_chart{width:100%}table.download_chart thead{display:none}table.download_chart td,table.download_chart th{padding:5px;vertical-align:middle;line-height:1.5em}table.download_chart th{text-align:left;font-weight:400;padding-left:0}table.download_chart td:last-child{padding-right:0}table.download_chart tr:first-child td,table.download_chart tr:first-child th{padding-top:0}table.download_chart tr:last-child td,table.download_chart tr:last-child th{border-bottom:0;padding-bottom:0}table.download_chart span.bar{padding:0 0 0 1px;height:1.5em;float:left;margin-right:5px;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;-moz-border-radius:2px;-webkit-border-radius:2px;border-radius:2px;bprder:1px solid # #6e6e6e;background:#6e6e6e;background-image:-webkit-gradient(linear,left bottom,left top,from(#747474),to(#6e6e6e));background-image:-webkit-linear-gradient(bottom,#747474,#6e6e6e);background-image:-moz-linear-gradient(bottom,#747474,#6e6e6e);background-image:-o-linear-gradient(bottom,#747474,#6e6e6e);background-image:linear-gradient(to top,#747474,#6e6e6e)}
assets/css/dashboard.less CHANGED
@@ -1,50 +1,50 @@
1
  /* Widgets */
2
  table.download_chart {
3
- width: 100%;
4
- thead {
5
- display: none;
6
- }
7
- td, th {
8
- padding: 5px;
9
- vertical-align: middle;
10
- line-height: 1.5em;
11
- }
12
- th {
13
- text-align: left;
14
- font-weight: normal;
15
- padding-left: 0;
16
- }
17
- td:last-child {
18
- padding-right: 0;
19
- }
20
- tr:first-child {
21
- td, th {
22
- padding-top: 0;
23
- }
24
- }
25
- tr:last-child {
26
- td, th {
27
- border-bottom: 0;
28
- padding-bottom: 0;
29
- }
30
- }
31
- span.bar {
32
- padding: 0 0 0 1px;
33
- height: 1.5em;
34
- float: left;
35
- margin-right: 5px;
36
- -moz-box-sizing: border-box;
37
- -webkit-box-sizing: border-box;
38
- box-sizing: border-box;
39
- -moz-border-radius: 2px;
40
- -webkit-border-radius: 2px;
41
- border-radius: 2px;
42
- bprder:1px solid ##6e6e6e;
43
- background:#6e6e6e;
44
- background-image:-webkit-gradient(linear,left bottom,left top,from(#747474),to(#6e6e6e));
45
- background-image:-webkit-linear-gradient(bottom,#747474,#6e6e6e);
46
- background-image:-moz-linear-gradient(bottom,#747474,#6e6e6e);
47
- background-image:-o-linear-gradient(bottom,#747474,#6e6e6e);
48
- background-image:linear-gradient(to top,#747474,#6e6e6e);
49
- }
50
  }
1
  /* Widgets */
2
  table.download_chart {
3
+ width: 100%;
4
+ thead {
5
+ display: none;
6
+ }
7
+ td, th {
8
+ padding: 5px;
9
+ vertical-align: middle;
10
+ line-height: 1.5em;
11
+ }
12
+ th {
13
+ text-align: left;
14
+ font-weight: normal;
15
+ padding-left: 0;
16
+ }
17
+ td:last-child {
18
+ padding-right: 0;
19
+ }
20
+ tr:first-child {
21
+ td, th {
22
+ padding-top: 0;
23
+ }
24
+ }
25
+ tr:last-child {
26
+ td, th {
27
+ border-bottom: 0;
28
+ padding-bottom: 0;
29
+ }
30
+ }
31
+ span.bar {
32
+ padding: 0 0 0 1px;
33
+ height: 1.5em;
34
+ float: left;
35
+ margin-right: 5px;
36
+ -moz-box-sizing: border-box;
37
+ -webkit-box-sizing: border-box;
38
+ box-sizing: border-box;
39
+ -moz-border-radius: 2px;
40
+ -webkit-border-radius: 2px;
41
+ border-radius: 2px;
42
+ bprder: 1px solid # #6e6e6e;
43
+ background: #6e6e6e;
44
+ background-image: -webkit-gradient(linear, left bottom, left top, from(#747474), to(#6e6e6e));
45
+ background-image: -webkit-linear-gradient(bottom, #747474, #6e6e6e);
46
+ background-image: -moz-linear-gradient(bottom, #747474, #6e6e6e);
47
+ background-image: -o-linear-gradient(bottom, #747474, #6e6e6e);
48
+ background-image: linear-gradient(to top, #747474, #6e6e6e);
49
+ }
50
  }
assets/css/frontend.less CHANGED
@@ -1,173 +1,187 @@
1
  .download-box {
2
- width: 250px;
3
- border: 1px solid #ccc;
4
- -moz-border-radius: 4px;
5
- -webkit-border-radius: 4px;
6
- border-radius: 4px;
7
- text-align: center;
8
- position: relative;
9
- margin: 1em auto;
10
- box-shadow: 0 2px 4px rgba(0,0,0,0.1),inset 0 1px 0 rgba(255,255,255,0.4);
11
-
12
- img.wp-post-image {
13
- margin: 0;
14
- padding: 0;
15
- display: block;
16
- width: 100%;
17
- -moz-border-radius: 0;
18
- -webkit-border-radius: 0;
19
- -moz-border-top-left-radius: 3px;
20
- -moz-border-top-right-radius: 3px;
21
- -webkit-border-top-left-radius: 3px;
22
- -webkit-border-top-right-radius: 3px;
23
- border-radius: 0;
24
- border-top-left-radius: 3px;
25
- border-top-right-radius: 3px;
26
- box-shadow: inset 0 1px 0 rgba(255,255,255,0.4);
27
- }
28
-
29
- .download-box-content {
30
- padding: 0 1em 1em;
31
- }
32
-
33
- .download-count {
34
- -moz-border-radius: 1em;
35
- -webkit-border-radius: 1em;
36
- border-radius: 1em;
37
- color: #777;
38
- text-shadow: 0 1px 0 rgba(255,255,255,0.5);
39
- background: #ddd;
40
- box-shadow: 0 2px 4px rgba(0,0,0,0.1), inset 0 1px 0 rgba(255,255,255,0.4);
41
- position: absolute;
42
- top: 0;
43
- right: 0;
44
- padding: .5em;
45
- height: 1em;
46
- width: auto;
47
- min-width: 1em;
48
- font-size: 1em;
49
- text-align: center;
50
- vertical-align: middle;
51
- line-height: 1em;
52
- border: 1px solid #bbb;
53
- margin: -.5em -.5em 0 0;
54
- }
55
  }
56
 
57
  .download-button {
58
- text-align: center;
59
- text-decoration: none;
60
- padding: 0.75em 1em;
61
- color: #fff;
62
- display: block;
63
- font-size: 1.2em;
64
- line-height: 1.5em;
65
- background-color: #0099cc;
66
- background-image: -webkit-linear-gradient(#009fd4, #0099cc, #0086b2);
67
- background-image: -moz-linear-gradient(#009fd4, #0099cc, #0086b2);
68
- -moz-border-radius: 4px;
69
- -webkit-border-radius: 4px;
70
- border-radius: 4px;
71
- text-shadow: 0 -1px 0 rgba(0,0,0,0.5);
72
- box-shadow: 0 2px 4px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.4);
73
- border: 1px solid #0086b2;
74
- cursor: pointer;
75
-
76
- &:hover {
77
- color: #fff;
78
- background-color: #0099cc;
79
- background-image: -webkit-linear-gradient(#0099cc, #0086b2);
80
- background-image: -moz-linear-gradient(#0099cc, #0086b2);
81
- }
82
-
83
- small {
84
- font-size: 0.8em;
85
- opacity: 0.8;
86
- display: block;
87
- }
88
  }
89
 
90
  .filetype-icon {
91
- padding-left: 19px;
92
- background-repeat: no-repeat;
93
- background-position: left;
94
- background-image: url(../images/filetypes/document.png);
95
  }
 
96
  .filetype-pdf {
97
- background-image: url(../images/filetypes/document-pdf.png);
98
  }
 
99
  .filetype-m4r, .filetype-au, .filetype-snd, .filetype-mid, .filetype-midi, .filetype-kar, .filetype-mpga, .filetype-mp2, .filetype-mp3, .filetype-aif, .filetype-aiff, .filetype-aifc, .filetype-m3u, .filetype-ram, .filetype-rm, .filetype-rpm, .filetype-ra, .filetype-wav, .filetype-wave {
100
- background-image: url(../images/filetypes/document-music.png);
101
  }
 
102
  .filetype-mpeg, .filetype-mpg, .filetype-mpe, .filetype-qt, .filetype-mov, .filetype-mxu, .filetype-avi, .filetype-movie, .filetype-mp4, .filetype-divx {
103
- background-image: url(../images/filetypes/document-film.png);
104
  }
 
105
  .filetype-zip, .filetype-gz, .filetype-rar, .filetype-sit, .filetype-tar, .filetype-7z {
106
- background-image: url(../images/filetypes/document-zipper.png);
107
  }
 
108
  .filetype-xls, .filetype-tsv, .filetype-csv {
109
- background-image: url(../images/filetypes/document-excel.png);
110
  }
111
- .filetype-doc,.filetype-docx {
112
- background-image: url(../images/filetypes/document-word-text.png);
 
113
  }
 
114
  .filetype-ai {
115
- background-image: url(../images/filetypes/document-illustrator.png);
116
  }
 
117
  .filetype-swf {
118
- background-image: url(../images/filetypes/document-flash-movie.png);
119
  }
 
120
  .filetype-eps, .filetype-ps, .filetype-bmp, .filetype-gif, .filetype-ief, .filetype-jpeg, .filetype-jpg, .filetype-jpe, .filetype-png, .filetype-tiff, .filetype-tif, .filetype-djv, .filetype-wbmp, .filetype-ras, .filetype-pnm, .filetype-pbm, .filetype-pgm, .filetype-ppm, .filetype-rgb, .filetype-xbm, .filetype-xpm, .filetype-xwd {
121
- background-image: url(../images/filetypes/document-image.png);
122
  }
 
123
  .filetype-psd {
124
- background-image: url(../images/filetypes/document-photoshop.png);
125
  }
 
126
  .filetype-ppt {
127
- background-image: url(../images/filetypes/document-powerpoint.png);
128
  }
 
129
  .filetype-js, .filetype-css, .filetype-as, .filetype-htm, .filetype-htaccess, .filetype-sql, .filetype-html, .filetype-php, .filetype-xml, .filetype-xsl {
130
- background-image: url(../images/filetypes/document-code.png);
131
  }
 
132
  .filetype-rtx, .filetype-rtf {
133
- background-image: url(../images/filetypes/document-text-image.png);
134
  }
 
135
  .filetype-txt {
136
- background-image: url(../images/filetypes/document-text.png);
137
  }
138
 
139
  nav.download-monitor-pagination, #content nav.download-monitor-pagination {
140
- text-align: center;
141
- ul {
142
- display: inline-block;
143
- white-space: nowrap;
144
- padding:0;
145
- clear: both;
146
- border: 1px solid #eee;
147
- border-right: 0;
148
- margin: 1px;
149
- li {
150
- border-right: 1px solid #eee;
151
- padding: 0;
152
- margin: 0;
153
- float: left;
154
- display: inline;
155
- overflow: hidden;
156
- a, span {
157
- margin: 0;
158
- text-decoration: none;
159
- padding: 0;
160
- line-height: 1em;
161
- font-size: 1em;
162
- font-weight: normal;
163
- padding: .5em;
164
- min-width: 1em;
165
- display: block;
166
- }
167
- span.current, a:hover, a:focus {
168
- background: #eee;
169
- color: darken( #eee, 40 );
170
- }
171
- }
172
- }
173
  }
1
  .download-box {
2
+ width: 250px;
3
+ border: 1px solid #ccc;
4
+ -moz-border-radius: 4px;
5
+ -webkit-border-radius: 4px;
6
+ border-radius: 4px;
7
+ text-align: center;
8
+ position: relative;
9
+ margin: 1em auto;
10
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.4);
11
+
12
+ img.wp-post-image {
13
+ margin: 0;
14
+ padding: 0;
15
+ display: block;
16
+ width: 100%;
17
+ -moz-border-radius: 0;
18
+ -webkit-border-radius: 0;
19
+ -moz-border-top-left-radius: 3px;
20
+ -moz-border-top-right-radius: 3px;
21
+ -webkit-border-top-left-radius: 3px;
22
+ -webkit-border-top-right-radius: 3px;
23
+ border-radius: 0;
24
+ border-top-left-radius: 3px;
25
+ border-top-right-radius: 3px;
26
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
27
+ }
28
+
29
+ .download-box-content {
30
+ padding: 0 1em 1em;
31
+ }
32
+
33
+ .download-count {
34
+ -moz-border-radius: 1em;
35
+ -webkit-border-radius: 1em;
36
+ border-radius: 1em;
37
+ color: #777;
38
+ text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
39
+ background: #ddd;
40
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.4);
41
+ position: absolute;
42
+ top: 0;
43
+ right: 0;
44
+ padding: .5em;
45
+ height: 1em;
46
+ width: auto;
47
+ min-width: 1em;
48
+ font-size: 1em;
49
+ text-align: center;
50
+ vertical-align: middle;
51
+ line-height: 1em;
52
+ border: 1px solid #bbb;
53
+ margin: -.5em -.5em 0 0;
54
+ }
55
  }
56
 
57
  .download-button {
58
+ text-align: center;
59
+ text-decoration: none;
60
+ padding: 0.75em 1em;
61
+ color: #fff;
62
+ display: block;
63
+ font-size: 1.2em;
64
+ line-height: 1.5em;
65
+ background-color: #0099cc;
66
+ background-image: -webkit-linear-gradient(#009fd4, #0099cc, #0086b2);
67
+ background-image: -moz-linear-gradient(#009fd4, #0099cc, #0086b2);
68
+ -moz-border-radius: 4px;
69
+ -webkit-border-radius: 4px;
70
+ border-radius: 4px;
71
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.5);
72
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.4);
73
+ border: 1px solid #0086b2;
74
+ cursor: pointer;
75
+
76
+ &:hover {
77
+ color: #fff;
78
+ background-color: #0099cc;
79
+ background-image: -webkit-linear-gradient(#0099cc, #0086b2);
80
+ background-image: -moz-linear-gradient(#0099cc, #0086b2);
81
+ }
82
+
83
+ small {
84
+ font-size: 0.8em;
85
+ opacity: 0.8;
86
+ display: block;
87
+ }
88
  }
89
 
90
  .filetype-icon {
91
+ padding-left: 19px;
92
+ background-repeat: no-repeat;
93
+ background-position: left;
94
+ background-image: url(../images/filetypes/document.png);
95
  }
96
+
97
  .filetype-pdf {
98
+ background-image: url(../images/filetypes/document-pdf.png);
99
  }
100
+
101
  .filetype-m4r, .filetype-au, .filetype-snd, .filetype-mid, .filetype-midi, .filetype-kar, .filetype-mpga, .filetype-mp2, .filetype-mp3, .filetype-aif, .filetype-aiff, .filetype-aifc, .filetype-m3u, .filetype-ram, .filetype-rm, .filetype-rpm, .filetype-ra, .filetype-wav, .filetype-wave {
102
+ background-image: url(../images/filetypes/document-music.png);
103
  }
104
+
105
  .filetype-mpeg, .filetype-mpg, .filetype-mpe, .filetype-qt, .filetype-mov, .filetype-mxu, .filetype-avi, .filetype-movie, .filetype-mp4, .filetype-divx {
106
+ background-image: url(../images/filetypes/document-film.png);
107
  }
108
+
109
  .filetype-zip, .filetype-gz, .filetype-rar, .filetype-sit, .filetype-tar, .filetype-7z {
110
+ background-image: url(../images/filetypes/document-zipper.png);
111
  }
112
+
113
  .filetype-xls, .filetype-tsv, .filetype-csv {
114
+ background-image: url(../images/filetypes/document-excel.png);
115
  }
116
+
117
+ .filetype-doc, .filetype-docx {
118
+ background-image: url(../images/filetypes/document-word-text.png);
119
  }
120
+
121
  .filetype-ai {
122
+ background-image: url(../images/filetypes/document-illustrator.png);
123
  }
124
+
125
  .filetype-swf {
126
+ background-image: url(../images/filetypes/document-flash-movie.png);
127
  }
128
+
129
  .filetype-eps, .filetype-ps, .filetype-bmp, .filetype-gif, .filetype-ief, .filetype-jpeg, .filetype-jpg, .filetype-jpe, .filetype-png, .filetype-tiff, .filetype-tif, .filetype-djv, .filetype-wbmp, .filetype-ras, .filetype-pnm, .filetype-pbm, .filetype-pgm, .filetype-ppm, .filetype-rgb, .filetype-xbm, .filetype-xpm, .filetype-xwd {
130
+ background-image: url(../images/filetypes/document-image.png);
131
  }
132
+
133
  .filetype-psd {
134
+ background-image: url(../images/filetypes/document-photoshop.png);
135
  }
136
+
137
  .filetype-ppt {
138
+ background-image: url(../images/filetypes/document-powerpoint.png);
139
  }
140
+
141
  .filetype-js, .filetype-css, .filetype-as, .filetype-htm, .filetype-htaccess, .filetype-sql, .filetype-html, .filetype-php, .filetype-xml, .filetype-xsl {
142
+ background-image: url(../images/filetypes/document-code.png);
143
  }
144
+
145
  .filetype-rtx, .filetype-rtf {
146
+ background-image: url(../images/filetypes/document-text-image.png);
147
  }
148
+
149
  .filetype-txt {
150
+ background-image: url(../images/filetypes/document-text.png);
151
  }
152
 
153
  nav.download-monitor-pagination, #content nav.download-monitor-pagination {
154
+ text-align: center;
155
+ ul {
156
+ display: inline-block;
157
+ white-space: nowrap;
158
+ padding: 0;
159
+ clear: both;
160
+ border: 1px solid #eee;
161
+ border-right: 0;
162
+ margin: 1px;
163
+ li {
164
+ border-right: 1px solid #eee;
165
+ padding: 0;
166
+ margin: 0;
167
+ float: left;
168
+ display: inline;
169
+ overflow: hidden;
170
+ a, span {
171
+ margin: 0;
172
+ text-decoration: none;
173
+ padding: 0;
174
+ line-height: 1em;
175
+ font-size: 1em;
176
+ font-weight: normal;
177
+ padding: .5em;
178
+ min-width: 1em;
179
+ display: block;
180
+ }
181
+ span.current, a:hover, a:focus {
182
+ background: #eee;
183
+ color: darken(#eee, 40);
184
+ }
185
+ }
186
+ }
187
  }
assets/css/menu.less CHANGED
@@ -1,24 +1,24 @@
1
  /* Menu */
2
  #adminmenu {
3
- #menu-posts-dlm_download {
4
- .wp-menu-image:before {
5
- content: "\f316";
6
- font-family: "dashicons" !important;
7
- font-style: normal;
8
- font-weight: normal;
9
- speak: none;
10
 
11
- display: inline-block;
12
- text-decoration: inherit;
13
- width: 1em;
14
- text-align: center;
15
 
16
- /* For safety - reset parent styles, that can break glyph codes*/
17
- font-variant: normal;
18
- text-transform: none;
19
 
20
- /* fix buttons height, for twitter bootstrap */
21
- line-height: 1em;
22
- }
23
- }
24
  }
1
  /* Menu */
2
  #adminmenu {
3
+ #menu-posts-dlm_download {
4
+ .wp-menu-image:before {
5
+ content: "\f316";
6
+ font-family: "dashicons" !important;
7
+ font-style: normal;
8
+ font-weight: normal;
9
+ speak: none;
10
 
11
+ display: inline-block;
12
+ text-decoration: inherit;
13
+ width: 1em;
14
+ text-align: center;
15
 
16
+ /* For safety - reset parent styles, that can break glyph codes*/
17
+ font-variant: normal;
18
+ text-transform: none;
19
 
20
+ /* fix buttons height, for twitter bootstrap */
21
+ line-height: 1em;
22
+ }
23
+ }
24
  }
assets/images/cross.png DELETED
Binary file
assets/images/download_count_head.png DELETED
Binary file
assets/images/downloads-icon.gif DELETED
Binary file
assets/images/featured_head.png DELETED
Binary file
assets/images/folder-horizontal-open.png DELETED
Binary file
assets/images/folder-horizontal.png DELETED
Binary file
assets/images/media-button-download.gif DELETED
Binary file
assets/images/member_head.png DELETED
Binary file
assets/images/menu_icon.png DELETED
Binary file
assets/images/on.png DELETED
Binary file
assets/images/redirect_head.png DELETED
Binary file
assets/js/edit-download.js ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery( function ( $ ) {
2
+
3
+ // Expand all files
4
+ jQuery( '.expand_all' ).click( function () {
5
+ jQuery( this ).closest( '.dlm-metaboxes-wrapper' ).find( '.dlm-metabox table' ).show();
6
+ return false;
7
+ } );
8
+
9
+ // Close all files
10
+ jQuery( '.close_all' ).click( function () {
11
+ jQuery( this ).closest( '.dlm-metaboxes-wrapper' ).find( '.dlm-metabox table' ).hide();
12
+ return false;
13
+ } );
14
+
15
+ // Open/close
16
+ jQuery( '.dlm-metaboxes-wrapper' ).on( 'click', '.dlm-metabox h3', function ( event ) {
17
+ // If the user clicks on some form input inside the h3, like a select list (for variations), the box should not be toggled
18
+ if ( jQuery( event.target ).filter( ':input, option' ).length ) return;
19
+
20
+ jQuery( this ).next( '.dlm-metabox-content' ).toggle();
21
+ } );
22
+
23
+ // Closes all to begin
24
+ jQuery( '.dlm-metabox.closed' ).each( function () {
25
+ jQuery( this ).find( '.dlm-metabox-content' ).hide();
26
+ } );
27
+
28
+ // Date picker
29
+ jQuery( ".date-picker-field" ).datepicker( {
30
+ dateFormat: "yy-mm-dd",
31
+ numberOfMonths: 1,
32
+ showButtonPanel: true,
33
+ } );
34
+
35
+ // Ordering
36
+ jQuery( '.downloadable_files' ).sortable( {
37
+ items: '.downloadable_file',
38
+ cursor: 'move',
39
+ axis: 'y',
40
+ handle: 'h3',
41
+ scrollSensitivity: 40,
42
+ forcePlaceholderSize: true,
43
+ helper: 'clone',
44
+ opacity: 0.65,
45
+ placeholder: 'dlm-metabox-sortable-placeholder',
46
+ start: function ( event, ui ) {
47
+ ui.item.css( 'background-color', '#f6f6f6' );
48
+ },
49
+ stop: function ( event, ui ) {
50
+ ui.item.removeAttr( 'style' );
51
+ downloadable_file_row_indexes();
52
+ }
53
+ } );
54
+
55
+ function downloadable_file_row_indexes() {
56
+ jQuery( '.downloadable_files .downloadable_file' ).each( function ( index, el ) {
57
+ jQuery( '.file_menu_order', el ).val( parseInt( jQuery( el ).index( '.downloadable_files .downloadable_file' ) ) );
58
+ } );
59
+ };
60
+
61
+ // Add a file
62
+ jQuery( '.download_monitor_files' ).on( 'click', 'a.add_file', function () {
63
+
64
+ jQuery( '.download_monitor_files' ).block( {
65
+ message: null,
66
+ overlayCSS: {
67
+ background: '#fff url(' + $( '#dlm-plugin-url' ).val() + '/assets/images/ajax-loader.gif) no-repeat center',
68
+ opacity: 0.6
69
+ }
70
+ } );
71
+
72
+ var size = jQuery( '.downloadable_files .downloadable_file' ).size();
73
+
74
+ var data = {
75
+ action: 'download_monitor_add_file',
76
+ post_id: $( '#dlm-post-id' ).val(),
77
+ size: size,
78
+ security: $( '#dlm-ajax-nonce-add-file' ).val()
79
+ };
80
+
81
+ jQuery.post( ajaxurl, data, function ( response ) {
82
+
83
+ jQuery( '.downloadable_files' ).prepend( response );
84
+
85
+ downloadable_file_row_indexes();
86
+
87
+ jQuery( '.download_monitor_files' ).unblock();
88
+
89
+ // Date picker
90
+ jQuery( ".date-picker-field" ).datepicker( {
91
+ dateFormat: "yy-mm-dd",
92
+ numberOfMonths: 1,
93
+ showButtonPanel: true
94
+ } );
95
+ } );
96
+
97
+ return false;
98
+
99
+ } );
100
+
101
+ // Remove a file
102
+ jQuery( '.download_monitor_files' ).on( 'click', 'button.remove_file', function ( e ) {
103
+ e.preventDefault();
104
+ var answer = confirm( dlm_ed_strings.confirm_delete );
105
+ if ( answer ) {
106
+
107
+ var el = jQuery( this ).closest( '.downloadable_file' );
108
+ var file_id = el.attr( 'data-file' );
109
+
110
+ if ( file_id > 0 ) {
111
+
112
+ jQuery( el ).block( {
113
+ message: null,
114
+ overlayCSS: {
115
+ background: '#fff url(' + $( '#dlm-plugin-url' ).val() + '/assets/images/ajax-loader.gif) no-repeat center',
116
+ opacity: 0.6
117
+ }
118
+ } );
119
+
120
+ var data = {
121
+ action: 'download_monitor_remove_file',
122
+ file_id: file_id,
123
+ download_id: $( '#dlm-post-id' ).val(),
124
+ security: $( '#dlm-ajax-nonce-remove-file' ).val()
125
+ };
126
+
127
+ jQuery.post( ajaxurl, data, function ( response ) {
128
+ jQuery( el ).fadeOut( '300' ).remove();
129
+ }
130
+ )
131
+ ;
132
+
133
+ } else {
134
+ jQuery( el ).fadeOut( '300' ).remove();
135
+ }
136
+ }
137
+ return false;
138
+ } );
139
+
140
+ // Browse for file
141
+ jQuery( '.download_monitor_files' ).on( 'click', 'a.dlm_browse_for_file', function ( e ) {
142
+
143
+ downloadable_files_field = jQuery( this ).closest( '.downloadable_file' ).find( 'textarea[name^="downloadable_file_urls"]' );
144
+
145
+ window.send_to_editor = window.send_to_browse_file_url;
146
+
147
+ tb_show( dlm_ed_strings.browse_file, 'media-upload.php?post_id=' + $( '#dlm-post-id' ).val() + '&amp;type=downloadable_file_browser&amp;from=wpdlm01&amp;TB_iframe=true' );
148
+
149
+ return false;
150
+ } );
151
+
152
+ window.send_to_browse_file_url = function ( html ) {
153
+
154
+ if ( html ) {
155
+ old = jQuery.trim( jQuery( downloadable_files_field ).val() );
156
+ if ( old ) old = old + "\n";
157
+ jQuery( downloadable_files_field ).val( old + html );
158
+ }
159
+
160
+ tb_remove();
161
+
162
+ window.send_to_editor = window.send_to_editor_default;
163
+ }
164
+
165
+ // Uploading files
166
+ var dlm_upload_file_frame;
167
+
168
+ jQuery( document ).on( 'click', '.dlm_upload_file', function ( event ) {
169
+
170
+ var $el = $( this );
171
+ var $file_path_field = $el.parent().parent().find( '.downloadable_file_urls' );
172
+ var file_paths = $file_path_field.val();
173
+
174
+ event.preventDefault();
175
+
176
+ // If the media frame already exists, reopen it.
177
+ if ( dlm_upload_file_frame ) {
178
+ dlm_upload_file_frame.open();
179
+ return;
180
+ }
181
+
182
+ var downloadable_file_states = [
183
+ // Main states.
184
+ new wp.media.controller.Library( {
185
+ library: wp.media.query(),
186
+ multiple: true,
187
+ title: $el.data( 'choose' ),
188
+ priority: 20,
189
+ filterable: 'uploaded',
190
+ } )
191
+ ];
192
+
193
+ // Create the media frame.
194
+ dlm_upload_file_frame = wp.media.frames.downloadable_file = wp.media( {
195
+ // Set the title of the modal.
196
+ title: $el.data( 'choose' ),
197
+ library: {
198
+ type: ''
199
+ },
200
+ button: {
201
+ text: $el.data( 'update' ),
202
+ },
203
+ multiple: true,
204
+ states: downloadable_file_states,
205
+ } );
206
+
207
+ // When an image is selected, run a callback.
208
+ dlm_upload_file_frame.on( 'select', function () {
209
+
210
+ var selection = dlm_upload_file_frame.state().get( 'selection' );
211
+
212
+ selection.map( function ( attachment ) {
213
+
214
+ attachment = attachment.toJSON();
215
+
216
+ if ( attachment.url )
217
+ file_paths = file_paths ? file_paths + "\n" + attachment.url : attachment.url
218
+
219
+ } );
220
+
221
+ $file_path_field.val( file_paths );
222
+ } );
223
+
224
+ // Set post to 0 and set our custom type
225
+ dlm_upload_file_frame.on( 'ready', function () {
226
+ dlm_upload_file_frame.uploader.options.uploader.params = {
227
+ type: 'dlm_download'
228
+ };
229
+ } );
230
+
231
+ // Finally, open the modal.
232
+ dlm_upload_file_frame.open();
233
+ } );
234
+
235
+ } );
assets/js/edit-download.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(function(a){function b(){jQuery(".downloadable_files .downloadable_file").each(function(a,b){jQuery(".file_menu_order",b).val(parseInt(jQuery(b).index(".downloadable_files .downloadable_file")))})}jQuery(".expand_all").click(function(){return jQuery(this).closest(".dlm-metaboxes-wrapper").find(".dlm-metabox table").show(),!1}),jQuery(".close_all").click(function(){return jQuery(this).closest(".dlm-metaboxes-wrapper").find(".dlm-metabox table").hide(),!1}),jQuery(".dlm-metaboxes-wrapper").on("click",".dlm-metabox h3",function(a){jQuery(a.target).filter(":input, option").length||jQuery(this).next(".dlm-metabox-content").toggle()}),jQuery(".dlm-metabox.closed").each(function(){jQuery(this).find(".dlm-metabox-content").hide()}),jQuery(".date-picker-field").datepicker({dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:!0}),jQuery(".downloadable_files").sortable({items:".downloadable_file",cursor:"move",axis:"y",handle:"h3",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65,placeholder:"dlm-metabox-sortable-placeholder",start:function(a,b){b.item.css("background-color","#f6f6f6")},stop:function(a,c){c.item.removeAttr("style"),b()}}),jQuery(".download_monitor_files").on("click","a.add_file",function(){jQuery(".download_monitor_files").block({message:null,overlayCSS:{background:"#fff url("+a("#dlm-plugin-url").val()+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var c=jQuery(".downloadable_files .downloadable_file").size(),d={action:"download_monitor_add_file",post_id:a("#dlm-post-id").val(),size:c,security:a("#dlm-ajax-nonce-add-file").val()};return jQuery.post(ajaxurl,d,function(a){jQuery(".downloadable_files").prepend(a),b(),jQuery(".download_monitor_files").unblock(),jQuery(".date-picker-field").datepicker({dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:!0})}),!1}),jQuery(".download_monitor_files").on("click","button.remove_file",function(b){b.preventDefault();var c=confirm(dlm_ed_strings.confirm_delete);if(c){var d=jQuery(this).closest(".downloadable_file"),e=d.attr("data-file");if(e>0){jQuery(d).block({message:null,overlayCSS:{background:"#fff url("+a("#dlm-plugin-url").val()+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var f={action:"download_monitor_remove_file",file_id:e,download_id:a("#dlm-post-id").val(),security:a("#dlm-ajax-nonce-remove-file").val()};jQuery.post(ajaxurl,f,function(){jQuery(d).fadeOut("300").remove()})}else jQuery(d).fadeOut("300").remove()}return!1}),jQuery(".download_monitor_files").on("click","a.dlm_browse_for_file",function(){return downloadable_files_field=jQuery(this).closest(".downloadable_file").find('textarea[name^="downloadable_file_urls"]'),window.send_to_editor=window.send_to_browse_file_url,tb_show(dlm_ed_strings.browse_file,"media-upload.php?post_id="+a("#dlm-post-id").val()+"&amp;type=downloadable_file_browser&amp;from=wpdlm01&amp;TB_iframe=true"),!1}),window.send_to_browse_file_url=function(a){a&&(old=jQuery.trim(jQuery(downloadable_files_field).val()),old&&(old+="\n"),jQuery(downloadable_files_field).val(old+a)),tb_remove(),window.send_to_editor=window.send_to_editor_default};var c;jQuery(document).on("click",".dlm_upload_file",function(b){var d=a(this),e=d.parent().parent().find(".downloadable_file_urls"),f=e.val();if(b.preventDefault(),c)return void c.open();var g=[new wp.media.controller.Library({library:wp.media.query(),multiple:!0,title:d.data("choose"),priority:20,filterable:"uploaded"})];c=wp.media.frames.downloadable_file=wp.media({title:d.data("choose"),library:{type:""},button:{text:d.data("update")},multiple:!0,states:g}),c.on("select",function(){var a=c.state().get("selection");a.map(function(a){a=a.toJSON(),a.url&&(f=f?f+"\n"+a.url:a.url)}),e.val(f)}),c.on("ready",function(){c.uploader.options.uploader.params={type:"dlm_download"}}),c.open()})});
assets/js/edit-post.js ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ jQuery( function ($) {
2
+ // Browse for file
3
+ jQuery( 'body' ).on( 'click', 'a.add_download', function () {
4
+
5
+ tb_show( dlm_ep_strings.insert_download, 'media-upload.php?post_id=' + $( this ).attr( 'rel' ) + '&amp;type=add_download&amp;from=wpdlm01&amp;TB_iframe=true&amp;height=200' );
6
+
7
+ return false;
8
+ } );
9
+ } );
assets/js/edit-post.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(function(a){jQuery("body").on("click","a.add_download",function(){return tb_show(dlm_ep_strings.insert_download,"media-upload.php?post_id="+a(this).attr("rel")+"&amp;type=add_download&amp;from=wpdlm01&amp;TB_iframe=true&amp;height=200"),!1})});
assets/js/extensions.js ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery( function ( $ ) {
2
+ $.each( $( '.extension_license a' ), function ( k, v ) {
3
+ $( v ).click( function () {
4
+ var wrap = $( v ).closest( '.extension_license' );
5
+
6
+ var ex_ac = ('inactive' == $( wrap ).find( '#status' ).val() ) ? 'activate' : 'deactivate';
7
+
8
+ $.post( ajaxurl, {
9
+ action: 'dlm_extension',
10
+ nonce: $( '#dlm-ajax-nonce' ).val(),
11
+ product_id: $( wrap ).find( '#product_id' ).val(),
12
+ key: $( wrap ).find( '#key' ).val(),
13
+ email: $( wrap ).find( '#email' ).val(),
14
+ extension_action: ex_ac
15
+ }, function ( response ) {
16
+ if ( response.result == 'failed' ) {
17
+ alert( response.message );
18
+ } else {
19
+ if ( 'activate' == ex_ac ) {
20
+ $( wrap ).find( '.license-status' ).addClass( 'active' ).html( 'ACTIVE' );
21
+ $( wrap ).find( '.button' ).html( 'Deactivate' );
22
+ $( wrap ).find( '#status' ).val( 'active' );
23
+ $( wrap ).find( '#key' ).attr('disabled', true);
24
+ $( wrap ).find( '#email' ).attr('disabled', true);
25
+ } else {
26
+ $( wrap ).find( '.license-status' ).removeClass( 'active' ).html( 'INACTIVE' );
27
+ $( wrap ).find( '.button' ).html( 'Activate' );
28
+ $( wrap ).find( '#status' ).val( 'inactive' );
29
+ $( wrap ).find( '#key' ).attr('disabled', false);
30
+ $( wrap ).find( '#email' ).attr('disabled', false);
31
+ }
32
+ }
33
+ } );
34
+
35
+ } );
36
+ } );
37
+ } );
assets/js/extensions.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(function(a){a.each(a(".extension_license a"),function(b,c){a(c).click(function(){var b=a(c).closest(".extension_license"),d="inactive"==a(b).find("#status").val()?"activate":"deactivate";a.post(ajaxurl,{action:"dlm_extension",nonce:a("#dlm-ajax-nonce").val(),product_id:a(b).find("#product_id").val(),key:a(b).find("#key").val(),email:a(b).find("#email").val(),extension_action:d},function(c){"failed"==c.result?alert(c.message):"activate"==d?(a(b).find(".license-status").addClass("active").html("ACTIVE"),a(b).find(".button").html("Deactivate"),a(b).find("#status").val("active"),a(b).find("#key").attr("disabled",!0),a(b).find("#email").attr("disabled",!0)):(a(b).find(".license-status").removeClass("active").html("INACTIVE"),a(b).find(".button").html("Activate"),a(b).find("#status").val("inactive"),a(b).find("#key").attr("disabled",!1),a(b).find("#email").attr("disabled",!1))})})})});
assets/js/jqueryFileTree/jqueryFileTree.min.js DELETED
@@ -1,33 +0,0 @@
1
- // jQuery File Tree Plugin
2
- //
3
- // Version 1.01
4
- //
5
- // Cory S.N. LaViska
6
- // A Beautiful Site (http://abeautifulsite.net/)
7
- // 24 March 2008
8
- //
9
- // Visit http://abeautifulsite.net/notebook.php?article=58 for more information
10
- //
11
- // Usage: $('.fileTreeDemo').fileTree( options, callback )
12
- //
13
- // Options: root - root folder to display; default = /
14
- // script - location of the serverside AJAX file to use; default = jqueryFileTree.php
15
- // folderEvent - event to trigger expand/collapse; default = click
16
- // expandSpeed - default = 500 (ms); use -1 for no animation
17
- // collapseSpeed - default = 500 (ms); use -1 for no animation
18
- // expandEasing - easing function to use on expand (optional)
19
- // collapseEasing - easing function to use on collapse (optional)
20
- // multiFolder - whether or not to limit the browser to one subfolder at a time
21
- // loadMessage - Message to display while initial tree loads (can be HTML)
22
- //
23
- // History:
24
- //
25
- // 1.01 - updated to work with foreign characters in directory/file names (12 April 2008)
26
- // 1.00 - released (24 March 2008)
27
- //
28
- // TERMS OF USE
29
- //
30
- // This plugin is dual-licensed under the GNU General Public License and the MIT License and
31
- // is copyright 2008 A Beautiful Site, LLC.
32
- //
33
- jQuery&&function(e){e.extend(e.fn,{fileTree:function(t,n){if(!t)var t={};t.root==undefined&&(t.root="/");t.script==undefined&&(t.script="jqueryFileTree.php");t.folderEvent==undefined&&(t.folderEvent="click");t.expandSpeed==undefined&&(t.expandSpeed=500);t.collapseSpeed==undefined&&(t.collapseSpeed=500);t.expandEasing==undefined&&(t.expandEasing=null);t.collapseEasing==undefined&&(t.collapseEasing=null);t.multiFolder==undefined&&(t.multiFolder=!0);t.loadMessage==undefined&&(t.loadMessage="Loading...");e(this).each(function(){function r(n,r){e(n).addClass("wait");e(".jqueryFileTree.start").remove();e.post(t.script,{dir:r},function(s){e(n).find(".start").html("");e(n).removeClass("wait").append(s);t.root==r?e(n).find("UL:hidden").show():e(n).find("UL:hidden").slideDown({duration:t.expandSpeed,easing:t.expandEasing});i(n)})}function i(i){e(i).find("LI A").bind(t.folderEvent,function(){if(e(this).parent().hasClass("directory"))if(e(this).parent().hasClass("collapsed")){if(!t.multiFolder){e(this).parent().parent().find("UL").slideUp({duration:t.collapseSpeed,easing:t.collapseEasing});e(this).parent().parent().find("LI.directory").removeClass("expanded").addClass("collapsed")}e(this).parent().find("UL").remove();r(e(this).parent(),escape(e(this).attr("rel").match(/.*\//)));e(this).parent().removeClass("collapsed").addClass("expanded")}else{e(this).parent().find("UL").slideUp({duration:t.collapseSpeed,easing:t.collapseEasing});e(this).parent().removeClass("expanded").addClass("collapsed")}else n(e(this).attr("rel"));return!1});t.folderEvent.toLowerCase!="click"&&e(i).find("LI A").bind("click",function(){return!1})}e(this).html('<ul class="jqueryFileTree start"><li class="wait">'+t.loadMessage+"<li></ul>");r(e(this),escape(t.root))})}})}(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/js/settings.js ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery( function ( $ ) {
2
+ $( '.nav-tab-wrapper a' ).click( function () {
3
+ $( '.settings_panel' ).hide();
4
+ $( '.nav-tab-active' ).removeClass( 'nav-tab-active' );
5
+ $( $( this ).attr( 'href' ) ).show();
6
+ $( this ).addClass( 'nav-tab-active' );
7
+ return false;
8
+ } );
9
+ $( '#setting-dlm_default_template' ).change( function () {
10
+ if ( $( this ).val() == 'custom' ) {
11
+ $( '#setting-dlm_custom_template' ).closest( 'tr' ).show();
12
+ } else {
13
+ $( '#setting-dlm_custom_template' ).closest( 'tr' ).hide();
14
+ }
15
+ } ).change();
16
+
17
+ $( '.nav-tab-wrapper a:first' ).click();
18
+ } );
assets/js/settings.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(function(a){a(".nav-tab-wrapper a").click(function(){return a(".settings_panel").hide(),a(".nav-tab-active").removeClass("nav-tab-active"),a(a(this).attr("href")).show(),a(this).addClass("nav-tab-active"),!1}),a("#setting-dlm_default_template").change(function(){"custom"==a(this).val()?a("#setting-dlm_custom_template").closest("tr").show():a("#setting-dlm_custom_template").closest("tr").hide()}).change(),a(".nav-tab-wrapper a:first").click()});
download-monitor.php CHANGED
@@ -1,685 +1,77 @@
1
  <?php
2
  /*
3
- Plugin Name: Download Monitor
4
- Plugin URI: http://mikejolley.com/projects/download-monitor/
5
- Description: A full solution for managing downloadable files, monitoring downloads and outputting download links and file information on your WordPress powered site.
6
- Version: 1.5.1
7
- Author: Mike Jolley
8
- Author URI: http://mikejolley.com
9
- Requires at least: 3.8
10
- Tested up to: 3.9
11
-
12
- Copyright: © 2014 Mike Jolley.
13
- License: GNU General Public License v3.0
14
- License URI: http://www.gnu.org/licenses/gpl-3.0.html
 
 
 
 
 
 
 
 
 
 
 
15
  */
16
 
17
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
18
-
19
- /**
20
- * WP_DLM class.
21
- *
22
- * Main Class which inits the CPT and plugin
23
- */
24
- class WP_DLM {
25
-
26
- private $plugin_url;
27
- private $plugin_path;
28
- private $_inline_js;
29
-
30
- /**
31
- * __construct function.
32
- *
33
- * @access public
34
- * @return void
35
- */
36
- public function __construct() {
37
- global $wpdb;
38
-
39
- // Define constants
40
- define( 'DLM_VERSION', '1.5.0' );
41
-
42
- // Table for logs
43
- $wpdb->download_log = $wpdb->prefix . 'download_log';
44
-
45
- // Include required files
46
- if ( is_admin() ) {
47
- include_once( 'includes/admin/class-dlm-admin.php' );
48
- }
49
-
50
- if ( defined('DOING_AJAX') ) {
51
- include_once( 'includes/class-dlm-ajax-handler.php' );
52
- }
53
-
54
- if ( get_option( 'dlm_enable_logging' ) == 1 ) {
55
- include_once( 'includes/class-dlm-logging.php' );
56
- }
57
-
58
- include_once( 'includes/download-functions.php' );
59
- include_once( 'includes/class-dlm-download.php' );
60
- include_once( 'includes/class-dlm-download-version.php' );
61
- include_once( 'includes/class-dlm-download-handler.php' );
62
- include_once( 'includes/class-dlm-shortcodes.php' );
63
-
64
- // Activation
65
- register_activation_hook( basename( dirname( __FILE__ ) ) . '/' . basename( __FILE__ ), array( $this, 'init_user_roles' ), 10 );
66
- register_activation_hook( basename( dirname( __FILE__ ) ) . '/' . basename( __FILE__ ), array( $this, 'init_taxonomy' ), 10 );
67
- register_activation_hook( basename( dirname( __FILE__ ) ) . '/' . basename( __FILE__ ), array( $this, 'install_tables' ), 10 );
68
- register_activation_hook( basename( dirname( __FILE__ ) ) . '/' . basename( __FILE__ ), array( $this, 'directory_protection' ), 10 );
69
- register_activation_hook( basename( dirname( __FILE__ ) ) . '/' . basename( __FILE__ ), array( $GLOBALS['DLM_Download_Handler'], 'add_endpoint' ), 10 );
70
- register_activation_hook( basename( dirname( __FILE__ ) ) . '/' . basename( __FILE__ ), 'flush_rewrite_rules', 11 );
71
-
72
- // Actions
73
- add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_links' ) );
74
- add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
75
- add_action( 'init', array( $this, 'register_globals' ) );
76
- add_action( 'init', array( $this, 'init_taxonomy' ) );
77
- add_action( 'after_setup_theme', array( $this, 'compatibility' ) );
78
- add_action( 'the_post', array( $this, 'setup_download_data' ) );
79
- add_action( 'wp_enqueue_scripts', array( $this, 'frontend_scripts' ) );
80
- add_action( 'wp_footer', array( $this, 'output_inline_js' ), 25 );
81
- add_action( 'admin_footer', array( $this, 'output_inline_js' ), 25 );
82
- add_action( 'widgets_init', array( $this, 'register_widgets' ) );
83
- }
84
-
85
- /**
86
- * Add links to admin plugins page.
87
- * @param array $links
88
- * @return array
89
- */
90
- public function plugin_links( $links ) {
91
- $plugin_links = array(
92
- '<a href="' . admin_url( 'edit.php?post_type=dlm_download&page=download-monitor-settings' ) . '">' . __( 'Settings', 'download-monitor' ) . '</a>',
93
- '<a href="http://mikejolley.com/projects/download-monitor/add-ons/">' . __( 'Add-ons', 'download-monitor' ) . '</a>',
94
- '<a href="https://github.com/mikejolley/download-monitor/wiki">' . __( 'Docs', 'download-monitor' ) . '</a>',
95
- );
96
- return array_merge( $plugin_links, $links );
97
- }
98
-
99
- /**
100
- * frontend_scripts function.
101
- *
102
- * @access public
103
- * @return void
104
- */
105
- public function frontend_scripts() {
106
- wp_enqueue_style( 'dlm-frontend', $this->plugin_url() . '/assets/css/frontend.css' );
107
- }
108
-
109
- /**
110
- * Localisation
111
- *
112
- * @access private
113
- * @return void
114
- */
115
- public function load_plugin_textdomain() {
116
- load_textdomain( 'download-monitor', WP_LANG_DIR . '/download-monitor/download_monitor-' . get_locale() . '.mo' );
117
- load_plugin_textdomain( 'download-monitor', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
118
- }
119
-
120
- /**
121
- * Register environment globals
122
- *
123
- * @access private
124
- * @return void
125
- */
126
- public function register_globals() {
127
- $GLOBALS['dlm_download'] = null;
128
- }
129
-
130
- /**
131
- * When the_post is called, get product data too
132
- *
133
- * @access public
134
- * @param mixed $post
135
- * @return void
136
- */
137
- public function setup_download_data( $post ) {
138
- if ( is_int( $post ) )
139
- $post = get_post( $post );
140
-
141
- if ( $post->post_type !== 'dlm_download' )
142
- return;
143
-
144
- $GLOBALS['dlm_download'] = new DLM_Download( $post->ID );
145
- }
146
-
147
- /**
148
- * Add Theme Compatibility
149
- *
150
- * @access public
151
- * @return void
152
- */
153
- public function compatibility() {
154
- // Post thumbnail support
155
- if ( ! current_theme_supports( 'post-thumbnails' ) ) {
156
- add_theme_support( 'post-thumbnails' );
157
- remove_post_type_support( 'post', 'thumbnail' );
158
- remove_post_type_support( 'page', 'thumbnail' );
159
- } else {
160
- add_post_type_support( 'download', 'thumbnail' );
161
- }
162
- }
163
-
164
- /**
165
- * install_tables function.
166
- *
167
- * @access public
168
- * @return void
169
- */
170
- public function install_tables() {
171
- global $wpdb;
172
-
173
- $wpdb->hide_errors();
174
-
175
- $collate = '';
176
-
177
- if ( $wpdb->has_cap( 'collation' ) ) {
178
- if( ! empty( $wpdb->charset ) )
179
- $collate .= "DEFAULT CHARACTER SET $wpdb->charset";
180
- if( ! empty( $wpdb->collate ) )
181
- $collate .= " COLLATE $wpdb->collate";
182
- }
183
-
184
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
185
-
186
- $dlm_tables = "
187
- CREATE TABLE {$wpdb->download_log} (
188
- ID bigint(20) NOT NULL auto_increment,
189
- type varchar(200) NOT NULL default 'download',
190
- user_id bigint(20) NOT NULL,
191
- user_ip varchar(200) NOT NULL,
192
- user_agent varchar(200) NOT NULL,
193
- download_id bigint(20) NOT NULL,
194
- version_id bigint(20) NOT NULL,
195
- version varchar(200) NOT NULL,
196
- download_date datetime NOT NULL default '0000-00-00 00:00:00',
197
- download_status varchar(200) NULL,
198
- download_status_message varchar(200) NULL,
199
- PRIMARY KEY (ID),
200
- KEY attribute_name (download_id)
201
- ) $collate;
202
- ";
203
- dbDelta( $dlm_tables );
204
- }
205
-
206
- /**
207
- * Init user roles
208
- *
209
- * @access public
210
- * @return void
211
- */
212
- public function init_user_roles() {
213
- global $wp_roles;
214
-
215
- if ( class_exists('WP_Roles') && ! isset( $wp_roles ) )
216
- $wp_roles = new WP_Roles();
217
-
218
- if ( is_object( $wp_roles ) ) {
219
- $wp_roles->add_cap( 'administrator', 'manage_downloads' );
220
- }
221
- }
222
-
223
- /**
224
- * Init taxonomies
225
- *
226
- * @access public
227
- * @return void
228
- */
229
- public function init_taxonomy() {
230
-
231
- if ( post_type_exists( "dlm_download" ) )
232
- return;
233
- /**
234
- * Taxonomies
235
- */
236
- register_taxonomy( 'dlm_download_category',
237
- array( 'dlm_download' ),
238
- apply_filters( 'dlm_download_category_args', array(
239
- 'hierarchical' => true,
240
- 'update_count_callback' => '_update_post_term_count',
241
- 'label' => __( 'Categories', 'download-monitor'),
242
- 'labels' => array(
243
- 'name' => __( 'Categories', 'download-monitor'),
244
- 'singular_name' => __( 'Download Category', 'download-monitor'),
245
- 'search_items' => __( 'Search Download Categories', 'download-monitor'),
246
- 'all_items' => __( 'All Download Categories', 'download-monitor'),
247
- 'parent_item' => __( 'Parent Download Category', 'download-monitor'),
248
- 'parent_item_colon' => __( 'Parent Download Category:', 'download-monitor'),
249
- 'edit_item' => __( 'Edit Download Category', 'download-monitor'),
250
- 'update_item' => __( 'Update Download Category', 'download-monitor'),
251
- 'add_new_item' => __( 'Add New Download Category', 'download-monitor'),
252
- 'new_item_name' => __( 'New Download Category Name', 'download-monitor')
253
- ),
254
- 'show_ui' => true,
255
- 'query_var' => true,
256
- 'capabilities' => array(
257
- 'manage_terms' => 'manage_downloads',
258
- 'edit_terms' => 'manage_downloads',
259
- 'delete_terms' => 'manage_downloads',
260
- 'assign_terms' => 'manage_downloads',
261
- ),
262
- 'rewrite' => false,
263
- 'show_in_nav_menus' => false
264
- ) )
265
- );
266
-
267
- register_taxonomy( 'dlm_download_tag',
268
- array( 'dlm_download' ),
269
- apply_filters( 'dlm_download_tag_args', array(
270
- 'hierarchical' => false,
271
- 'label' => __( 'Tags', 'download-monitor'),
272
- 'labels' => array(
273
- 'name' => __( 'Tags', 'download-monitor'),
274
- 'singular_name' => __( 'Download Tag', 'download-monitor'),
275
- 'search_items' => __( 'Search Download Tags', 'download-monitor'),
276
- 'all_items' => __( 'All Download Tags', 'download-monitor'),
277
- 'parent_item' => __( 'Parent Download Tag', 'download-monitor'),
278
- 'parent_item_colon' => __( 'Parent Download Tag:', 'download-monitor'),
279
- 'edit_item' => __( 'Edit Download Tag', 'download-monitor'),
280
- 'update_item' => __( 'Update Download Tag', 'download-monitor'),
281
- 'add_new_item' => __( 'Add New Download Tag', 'download-monitor'),
282
- 'new_item_name' => __( 'New Download Tag Name', 'download-monitor')
283
- ),
284
- 'show_ui' => true,
285
- 'query_var' => true,
286
- 'capabilities' => array(
287
- 'manage_terms' => 'manage_downloads',
288
- 'edit_terms' => 'manage_downloads',
289
- 'delete_terms' => 'manage_downloads',
290
- 'assign_terms' => 'manage_downloads',
291
- ),
292
- 'rewrite' => false,
293
- 'show_in_nav_menus' => false
294
- ) )
295
- );
296
-
297
- /**
298
- * Post Types
299
- */
300
- register_post_type( "dlm_download",
301
- apply_filters( 'dlm_cpt_dlm_download_args', array(
302
- 'labels' => array(
303
- 'all_items' => __( 'All Downloads', 'download-monitor' ),
304
- 'name' => __( 'Downloads', 'download-monitor' ),
305
- 'singular_name' => __( 'Download', 'download-monitor' ),
306
- 'add_new' => __( 'Add New', 'download-monitor' ),
307
- 'add_new_item' => __( 'Add Download', 'download-monitor' ),
308
- 'edit' => __( 'Edit', 'download-monitor' ),
309
- 'edit_item' => __( 'Edit Download', 'download-monitor' ),
310
- 'new_item' => __( 'New Download', 'download-monitor' ),
311
- 'view' => __( 'View Download', 'download-monitor' ),
312
- 'view_item' => __( 'View Download', 'download-monitor' ),
313
- 'search_items' => __( 'Search Downloads', 'download-monitor' ),
314
- 'not_found' => __( 'No Downloads found', 'download-monitor' ),
315
- 'not_found_in_trash' => __( 'No Downloads found in trash', 'download-monitor' ),
316
- 'parent' => __( 'Parent Download', 'download-monitor' )
317
- ),
318
- 'description' => __( 'This is where you can create and manage downloads for your site.', 'download-monitor' ),
319
- 'public' => false,
320
- 'show_ui' => true,
321
- 'capability_type' => 'post',
322
- 'capabilities' => array(
323
- 'publish_posts' => 'manage_downloads',
324
- 'edit_posts' => 'manage_downloads',
325
- 'edit_others_posts' => 'manage_downloads',
326
- 'delete_posts' => 'manage_downloads',
327
- 'delete_others_posts' => 'manage_downloads',
328
- 'read_private_posts' => 'manage_downloads',
329
- 'edit_post' => 'manage_downloads',
330
- 'delete_post' => 'manage_downloads',
331
- 'read_post' => 'manage_downloads'
332
- ),
333
- 'publicly_queryable' => false,
334
- 'exclude_from_search' => true,
335
- 'hierarchical' => false,
336
- 'rewrite' => false,
337
- 'query_var' => false,
338
- 'supports' => apply_filters( 'dlm_cpt_dlm_download_supports', array( 'title', 'editor', 'excerpt', 'thumbnail', 'custom-fields' ) ),
339
- 'has_archive' => false,
340
- 'show_in_nav_menus' => false
341
- ) )
342
- );
343
-
344
- register_post_type( "dlm_download_version",
345
- apply_filters( 'dlm_cpt_dlm_download_version_args', array(
346
- 'public' => false,
347
- 'show_ui' => false,
348
- 'publicly_queryable' => false,
349
- 'exclude_from_search' => true,
350
- 'hierarchical' => false,
351
- 'rewrite' => false,
352
- 'query_var' => false,
353
- 'show_in_nav_menus' => false
354
- ) )
355
- );
356
- }
357
-
358
- /**
359
- * register_widgets function.
360
- *
361
- * @access public
362
- * @return void
363
- */
364
- function register_widgets() {
365
- include_once( 'includes/widgets/class-dlm-widget-downloads.php' );
366
 
367
- register_widget( 'DLM_Widget_Downloads' );
368
- }
369
-
370
- /** Helper functions *****************************************************/
371
-
372
- /**
373
- * get_template_part function.
374
- *
375
- * @access public
376
- * @param mixed $slug
377
- * @param string $name (default: '')
378
- * @return void
379
- */
380
- public function get_template_part( $slug, $name = '', $custom_dir = '' ) {
381
- $template = '';
382
-
383
- // Look in yourtheme/slug-name.php and yourtheme/download-monitor/slug-name.php
384
- if ( $name )
385
- $template = locate_template( array ( "{$slug}-{$name}.php", "download-monitor/{$slug}-{$name}.php" ) );
386
-
387
- // Get default slug-name.php
388
- if ( ! $template && $name && file_exists( $this->plugin_path() . "/templates/{$slug}-{$name}.php" ) )
389
- $template = $this->plugin_path() . "/templates/{$slug}-{$name}.php";
390
-
391
- // If a custom path was defined, check that next
392
- if ( ! $template && $custom_dir && file_exists( trailingslashit( $custom_dir ) . "{$slug}-{$name}.php" ) )
393
- $template = trailingslashit( $custom_dir ) . "{$slug}-{$name}.php";
394
 
395
- // If template file doesn't exist, look in yourtheme/slug.php and yourtheme/download-monitor/slug.php
396
- if ( ! $template )
397
- $template = locate_template( array( "{$slug}.php", "download-monitor/{$slug}.php" ) );
398
 
399
- // If a custom path was defined, check that next
400
- if ( ! $template && $custom_dir && file_exists( trailingslashit( $custom_dir ) . "{$slug}-{$name}.php" ) )
401
- $template = trailingslashit( $custom_dir ) . "{$slug}.php";
402
 
403
- // Get default slug-name.php
404
- if ( ! $template && file_exists( $this->plugin_path() . "/templates/{$slug}.php" ) )
405
- $template = $this->plugin_path() . "/templates/{$slug}.php";
406
 
407
- if ( $template )
408
- load_template( $template, false );
409
- }
410
-
411
- /**
412
- * Get the plugin url
413
- *
414
- * @access public
415
- * @return string
416
- */
417
- public function plugin_url() {
418
- if ( $this->plugin_url )
419
- return $this->plugin_url;
420
-
421
- return $this->plugin_url = plugins_url( basename( plugin_dir_path(__FILE__) ), basename( __FILE__ ) );
422
- }
423
-
424
- /**
425
- * Get the plugin path
426
- *
427
- * @access public
428
- * @return string
429
- */
430
- public function plugin_path() {
431
- if ( $this->plugin_path )
432
- return $this->plugin_path;
433
 
434
- return $this->plugin_path = plugin_dir_path( __FILE__ );
435
- }
436
-
437
- /**
438
- * Enqueue JS to be added to the footer.
439
- *
440
- * @access public
441
- * @param mixed $code
442
- * @return void
443
- */
444
- public function add_inline_js( $code ) {
445
- $this->_inline_js .= "\n" . $code . "\n";
446
- }
447
-
448
- /**
449
- * Output enqueued JS
450
- *
451
- * @access public
452
- * @return void
453
- */
454
- public function output_inline_js() {
455
- if ( $this->_inline_js ) {
456
- echo "<!-- Download Monitor JavaScript-->\n<script type=\"text/javascript\">\njQuery(document).ready(function($) {";
457
- echo $this->_inline_js;
458
- echo "});\n</script>\n";
459
- $this->_inline_js = '';
460
- }
461
- }
462
-
463
- /**
464
- * Returns a listing of all files in the specified folder and all subdirectories up to 100 levels deep.
465
- * The depth of the recursiveness can be controlled by the $levels param.
466
- *
467
- * @access public
468
- * @param string $folder (default: '')
469
- * @return void
470
- */
471
- function list_files( $folder = '' ) {
472
- if ( empty($folder) )
473
- return false;
474
-
475
- $files = array();
476
- if ( $dir = @opendir( $folder ) ) {
477
- while (($file = readdir( $dir ) ) !== false ) {
478
- if ( in_array($file, array('.', '..') ) )
479
- continue;
480
- if ( is_dir( $folder . '/' . $file ) ) {
481
-
482
- $files[] = array(
483
- 'type' => 'folder',
484
- 'path' => $folder . '/' . $file
485
- );
486
-
487
- } else {
488
-
489
- $files[] = array(
490
- 'type' => 'file',
491
- 'path' => $folder . '/' . $file
492
- );
493
-
494
- }
495
- }
496
- }
497
- @closedir( $dir );
498
- return $files;
499
- }
500
 
501
- /**
502
- * Protect the upload dir on activation.
503
- *
504
- * @access public
505
- * @return void
506
- */
507
- public function directory_protection() {
508
-
509
- // Install files and folders for uploading files and prevent hotlinking
510
- $upload_dir = wp_upload_dir();
511
-
512
- $files = array(
513
- array(
514
- 'base' => $upload_dir['basedir'] . '/dlm_uploads',
515
- 'file' => '.htaccess',
516
- 'content' => 'deny from all'
517
- ),
518
- array(
519
- 'base' => $upload_dir['basedir'] . '/dlm_uploads',
520
- 'file' => 'index.html',
521
- 'content' => ''
522
- )
523
- );
524
-
525
- foreach ( $files as $file ) {
526
- if ( wp_mkdir_p( $file['base'] ) && ! file_exists( trailingslashit( $file['base'] ) . $file['file'] ) ) {
527
- if ( $file_handle = @fopen( trailingslashit( $file['base'] ) . $file['file'], 'w' ) ) {
528
- fwrite( $file_handle, $file['content'] );
529
- fclose( $file_handle );
530
- }
531
- }
532
- }
533
- }
534
-
535
- /**
536
- * Parse a file path and return the new path and whether or not it's remote
537
- * @param string $file_path
538
- * @return array
539
- */
540
- public function parse_file_path( $file_path ) {
541
- $remote_file = true;
542
- $parsed_file_path = parse_url( $file_path );
543
-
544
- $wp_uploads = wp_upload_dir();
545
- $wp_uploads_dir = $wp_uploads['basedir'];
546
- $wp_uploads_url = $wp_uploads['baseurl'];
547
-
548
- if ( ( ! isset( $parsed_file_path['scheme'] ) || ! in_array( $parsed_file_path['scheme'], array( 'http', 'https', 'ftp' ) ) ) && isset( $parsed_file_path['path'] ) && file_exists( $parsed_file_path['path'] ) ) {
549
-
550
- /** This is an absolute path */
551
- $remote_file = false;
552
-
553
- } elseif( strpos( $file_path, $wp_uploads_url ) !== false ) {
554
-
555
- /** This is a local file given by URL so we need to figure out the path */
556
- $remote_file = false;
557
- $file_path = str_replace( $wp_uploads_url, $wp_uploads_dir, $file_path );
558
- $file_path = realpath( $file_path );
559
-
560
- } elseif( is_multisite() && ( strpos( $file_path, network_site_url( '/', 'http' ) ) !== false || strpos( $file_path, network_site_url( '/', 'https' ) ) !== false ) ) {
561
-
562
- /** This is a local file outside of wp-content so figure out the path */
563
- $remote_file = false;
564
- // Try to replace network url
565
- $file_path = str_replace( network_site_url( '/', 'https' ), ABSPATH, $file_path );
566
- $file_path = str_replace( network_site_url( '/', 'http' ), ABSPATH, $file_path );
567
- // Try to replace upload URL
568
- $file_path = str_replace( $wp_uploads_url, $wp_uploads_dir, $file_path );
569
- $file_path = realpath( $file_path );
570
-
571
- } elseif( strpos( $file_path, site_url( '/', 'http' ) ) !== false || strpos( $file_path, site_url( '/', 'https' ) ) !== false ) {
572
-
573
- /** This is a local file outside of wp-content so figure out the path */
574
- $remote_file = false;
575
- $file_path = str_replace( site_url( '/', 'https' ), ABSPATH, $file_path );
576
- $file_path = str_replace( site_url( '/', 'http' ), ABSPATH, $file_path );
577
- $file_path = realpath( $file_path );
578
-
579
- } elseif ( file_exists( ABSPATH . $file_path ) ) {
580
-
581
- /** Path needs an abspath to work */
582
- $remote_file = false;
583
- $file_path = ABSPATH . $file_path;
584
- $file_path = realpath( $file_path );
585
- }
586
-
587
- return array( $file_path, $remote_file );
588
- }
589
-
590
- /**
591
- * Gets the filesize of a path or URL.
592
- *
593
- * @access public
594
- * @return string size on success, -1 on failure
595
- */
596
- public function get_filesize( $file_path ) {
597
- if ( $file_path ) {
598
- list( $file_path, $remote_file ) = $this->parse_file_path( $file_path );
599
 
600
- if ( ! empty( $file_path ) ) {
601
- if ( $remote_file ) {
602
- $file = wp_remote_head( $file_path );
603
 
604
- if ( ! is_wp_error( $file ) && ! empty( $file['headers']['content-length'] ) ) {
605
- return $file['headers']['content-length'];
606
- }
607
- } else {
608
- if ( file_exists( $file_path ) && ( $filesize = filesize( $file_path ) ) ) {
609
- return $filesize;
610
- }
611
- }
612
- }
613
- }
614
 
615
- return -1;
616
- }
617
 
618
- /**
619
- * Gets md5, sha1 and crc32 hashes for a file and store it.
620
- *
621
- * @access public
622
- * @return array of sizes
623
- */
624
- public function get_file_hashes( $file_path ) {
625
- $md5 = false;
626
- $sha1 = false;
627
- $crc32 = false;
628
 
629
- if ( $file_path ) {
630
- list( $file_path, $remote_file ) = $this->parse_file_path( $file_path );
631
 
632
- if ( ! empty( $file_path ) ) {
633
- if ( ! $remote_file || apply_filters( 'dlm_allow_remote_hash_file', false ) ) {
634
- if ( get_option( 'dlm_generate_hash_md5' ) ) {
635
- $md5 = hash_file( 'md5', $file_path );
636
- }
637
- if ( get_option( 'dlm_generate_hash_sha1' ) ) {
638
- $sha1 = hash_file( 'sha1', $file_path );
639
- }
640
- if ( get_option( 'dlm_generate_hash_crc32b' ) ) {
641
- $crc32 = hash_file( 'crc32b', $file_path );
642
- }
643
- }
644
- }
645
- }
646
 
647
- return array( 'md5' => $md5, 'sha1' => $sha1, 'crc32' => $crc32 );
648
- }
649
 
650
- /**
651
- * Encode files for storage
652
- * @param array $files
653
- * @return string
654
- */
655
- public function json_encode_files( $files ) {
656
- if ( version_compare( phpversion(), "5.4.0", ">=" ) ) {
657
- $files = json_encode( $files, JSON_UNESCAPED_UNICODE );
658
- } else {
659
- $files = json_encode( $files );
660
- if ( function_exists( 'mb_convert_encoding' ) ) {
661
- $files = preg_replace_callback( '/\\\\u([0-9a-f]{4})/i', array( $this, 'json_unscaped_unicode_fallback' ), $files );
662
- }
663
- }
664
- return $files;
665
  }
666
 
667
- /**
668
- * Fallback for PHP < 5.4 where JSON_UNESCAPED_UNICODE does not exist.
669
- * @param array $matches
670
- * @return string
671
- */
672
- public function json_unscaped_unicode_fallback( $matches ) {
673
- $sym = mb_convert_encoding(
674
- pack( 'H*', $matches[1] ),
675
- 'UTF-8',
676
- 'UTF-16'
677
- );
678
- return $sym;
679
- }
680
- }
681
 
682
- /**
683
- * Init download_monitor class
684
- */
685
- $GLOBALS['download_monitor'] = new WP_DLM();
1
  <?php
2
  /*
3
+ Plugin Name: Download Monitor
4
+ Plugin URI: https://www.download-monitor.com
5
+ Description: A full solution for managing downloadable files, monitoring downloads and outputting download links and file information on your WordPress powered site.
6
+ Version: 1.6.0
7
+ Author: Barry Kooij & Mike Jolley
8
+ Author URI: http://www.download-monitor.com
9
+ Requires at least: 3.8
10
+ Tested up to: 4.1
11
+
12
+ License: GPL v3
13
+
14
+ This program is free software: you can redistribute it and/or modify
15
+ it under the terms of the GNU General Public License as published by
16
+ the Free Software Foundation, either version 3 of the License, or
17
+ (at your option) any later version.
18
+
19
+ This program is distributed in the hope that it will be useful,
20
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ GNU General Public License for more details.
23
+
24
+ You should have received a copy of the GNU General Public License
25
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
26
  */
27
 
28
+ if ( ! defined( 'ABSPATH' ) ) {
29
+ exit;
30
+ } // Exit if accessed directly
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
+ function __download_monitor_main() {
 
 
34
 
35
+ // Define DLM Version
36
+ define( 'DLM_VERSION', '1.6.0' );
 
37
 
38
+ // Define DLM FILE
39
+ define( 'DLM_PLUGIN_FILE', __FILE__ );
 
40
 
41
+ // Require class file
42
+ require_once plugin_dir_path( DLM_PLUGIN_FILE ) . 'includes/class-wp-dlm.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
+ // Create DLM object
45
+ $dlm = new WP_DLM();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
 
47
+ // Backwards compatibility
48
+ $GLOBALS['download_monitor'] = $dlm;
49
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
+ // Init plugin
52
+ add_action( 'plugins_loaded', '__download_monitor_main', 10 );
 
53
 
54
+ if ( is_admin() && ! is_multisite() && ( false === defined( 'DOING_AJAX' ) || false === DOING_AJAX ) ) {
 
 
 
 
 
 
 
 
 
55
 
56
+ define( 'DLM_PLUGIN_FILE_INSTALLER', __FILE__ );
 
57
 
58
+ // Installer function
59
+ function __download_monitor_install() {
 
 
 
 
 
 
 
 
60
 
61
+ // Load installer functions
62
+ require_once plugin_dir_path( DLM_PLUGIN_FILE_INSTALLER ) . 'includes/class-dlm-installer.php';
63
 
64
+ // DLM Installer
65
+ $installer = new DLM_Installer();
 
 
 
 
 
 
 
 
 
 
 
 
66
 
67
+ // Install DLM
68
+ $installer->install();
69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  }
71
 
72
+ // Activation hook
73
+ register_activation_hook( DLM_PLUGIN_FILE_INSTALLER, '__download_monitor_install' );
 
 
 
 
 
 
 
 
 
 
 
 
74
 
75
+ // Flush Rewrites on Activation
76
+ register_activation_hook( DLM_PLUGIN_FILE_INSTALLER, 'flush_rewrite_rules', 11 );
77
+ }
 
includes/admin/class-dlm-addons.php DELETED
@@ -1,59 +0,0 @@
1
- <?php
2
- /**
3
- * Addons Page
4
- */
5
-
6
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
7
-
8
- if ( ! class_exists( 'DLM_Addons' ) ) :
9
-
10
- /**
11
- * DLM_Addons Class
12
- */
13
- class DLM_Addons {
14
-
15
- /**
16
- * Handles output of the reports page in admin.
17
- */
18
- public function output() {
19
-
20
- if ( false === ( $addons = get_transient( 'download_monitor_addons_html' ) ) ) {
21
-
22
- $raw_addons = wp_remote_get( 'http://mikejolley.com/projects/download-monitor/add-ons/' );
23
-
24
- if ( ! is_wp_error( $raw_addons ) ) {
25
-
26
- $raw_addons = wp_remote_retrieve_body( $raw_addons );
27
-
28
- // Get Products
29
- $dom = new DOMDocument();
30
- libxml_use_internal_errors(true);
31
- $dom->loadHTML( $raw_addons );
32
-
33
- $xpath = new DOMXPath( $dom );
34
- $tags = $xpath->query('//ul[@class="items"]');
35
- foreach ( $tags as $tag ) {
36
- $addons = $tag->ownerDocument->saveXML( $tag );
37
- break;
38
- }
39
-
40
- $addons = wp_kses_post( $addons );
41
-
42
- if ( $addons )
43
- set_transient( 'download_monitor_addons_html', $addons, 60*60*24*7 ); // Cached for a week
44
- }
45
- }
46
-
47
- ?>
48
- <div class="wrap dlm_addons_wrap">
49
- <div class="icon32 icon32-posts-dlm_download" id="icon-edit"><br /></div>
50
- <h2><?php _e( 'Download Monitor Add-ons', 'download-monitor' ); ?></h2>
51
- <?php echo $addons; ?>
52
- </div>
53
- <?php
54
- }
55
- }
56
-
57
- endif;
58
-
59
- return new DLM_Addons();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/admin/class-dlm-admin-cpt.php CHANGED
@@ -1,9 +1,14 @@
1
  <?php
2
 
3
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
4
 
5
  /**
6
  * DLM_Admin_CPT class.
 
 
 
7
  */
8
  class DLM_Admin_CPT {
9
 
@@ -11,7 +16,6 @@ class DLM_Admin_CPT {
11
  * __construct function.
12
  *
13
  * @access public
14
- * @return void
15
  */
16
  public function __construct() {
17
  add_action( "restrict_manage_posts", array( $this, "downloads_by_category" ) );
@@ -28,42 +32,48 @@ class DLM_Admin_CPT {
28
  * downloads_by_category function.
29
  *
30
  * @access public
 
31
  * @param int $show_counts (default: 1)
32
  * @param int $hierarchical (default: 1)
33
  * @param int $show_uncategorized (default: 1)
34
  * @param string $orderby (default: '')
 
35
  * @return void
36
  */
37
  public function downloads_by_category( $show_counts = 1, $hierarchical = 1, $show_uncategorized = 1, $orderby = '' ) {
38
  global $typenow, $wp_query;
39
 
40
- if ( $typenow != 'dlm_download' )
41
- return;
 
42
 
43
  include_once( 'class-dlm-category-walker.php' );
44
 
45
- $r = array();
46
- $r['pad_counts'] = 1;
47
- $r['hierarchical'] = $hierarchical;
48
- $r['hide_empty'] = 1;
49
- $r['show_count'] = $show_counts;
50
- $r['selected'] = ( isset( $wp_query->query['dlm_download_category'] ) ) ? $wp_query->query['dlm_download_category'] : '';
51
 
52
  $r['menu_order'] = false;
53
 
54
- if ( $orderby == 'order' )
55
  $r['menu_order'] = 'asc';
56
- elseif ( $orderby )
57
  $r['orderby'] = $orderby;
 
58
 
59
  $terms = get_terms( 'dlm_download_category', $r );
60
 
61
- if (!$terms) return;
 
 
62
 
63
- $output = "<select name='dlm_download_category' id='dropdown_dlm_download_category'>";
64
- $output .= '<option value="" ' . selected( isset( $_GET['dlm_download_category'] ) ? $_GET['dlm_download_category'] : '', '', false ) . '>'.__( 'Select a category', 'download-monitor' ).'</option>';
65
  $output .= $this->walk_category_dropdown_tree( $terms, 0, $r );
66
- $output .="</select>";
67
 
68
  echo $output;
69
  }
@@ -78,37 +88,45 @@ class DLM_Admin_CPT {
78
  $args = func_get_args();
79
 
80
  // the user's options are the third parameter
81
- if ( empty($args[2]['walker']) || !is_a($args[2]['walker'], 'Walker') )
82
- $walker = new DLM_Category_Walker;
83
- else
84
  $walker = $args[2]['walker'];
 
85
 
86
  return call_user_func_array( array( $walker, 'walk' ), $args );
87
  }
 
88
  /**
89
  * delete_post function.
90
  *
91
  * @access public
 
92
  * @param mixed $id
 
93
  * @return void
94
  */
95
  public function delete_post( $id ) {
96
  global $wpdb;
97
 
98
- if ( ! current_user_can( 'delete_posts' ) )
99
  return;
 
100
 
101
  if ( $id > 0 ) {
102
 
103
  $post_type = get_post_type( $id );
104
 
105
- switch( $post_type ) {
106
  case 'dlm_download' :
107
- if ( $versions =& get_children( 'post_parent=' . $id . '&post_type=dlm_download_version' ) )
108
- if ( $versions )
109
- foreach ( $versions as $child )
110
  wp_delete_post( $child->ID, true );
111
- break;
 
 
 
112
  }
113
  }
114
  }
@@ -120,8 +138,10 @@ class DLM_Admin_CPT {
120
  * @return void
121
  */
122
  public function enter_title_here( $text, $post ) {
123
- if ( $post->post_type == 'dlm_download' )
124
  return __( 'Download title', 'download-monitor' );
 
 
125
  return $text;
126
  }
127
 
@@ -129,25 +149,27 @@ class DLM_Admin_CPT {
129
  * post_updated_messages function.
130
  *
131
  * @access public
 
132
  * @param mixed $messages
 
133
  * @return void
134
  */
135
  public function post_updated_messages( $messages ) {
136
- global $post, $post_ID;
137
 
138
  $messages['dlm_download'] = array(
139
- 0 => '', // Unused. Messages start at index 1.
140
- 1 => __('Download updated.', 'download-monitor'),
141
- 2 => __('Custom field updated.', 'download-monitor'),
142
- 3 => __('Custom field deleted.', 'download-monitor'),
143
- 4 => __('Download updated.', 'download-monitor'),
144
- 5 => isset($_GET['revision']) ? sprintf( __('Download restored to revision from %s', 'download-monitor'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
145
- 6 => __('Download published.', 'download-monitor'),
146
- 7 => __('Download saved.', 'download-monitor'),
147
- 8 => __('Download submitted.', 'download-monitor'),
148
- 9 => sprintf( __('Download scheduled for: <strong>%1$s</strong>.', 'download-monitor'),
149
- date_i18n( __( 'M j, Y @ G:i', 'download-monitor' ), strtotime( $post->post_date ) ) ),
150
- 10 => __('Download draft updated.', 'download-monitor'),
151
  );
152
 
153
  return $messages;
@@ -157,25 +179,27 @@ class DLM_Admin_CPT {
157
  * columns function.
158
  *
159
  * @access public
 
160
  * @param mixed $columns
161
- * @return void
 
162
  */
163
  public function columns( $columns ) {
164
  $columns = array();
165
 
166
  $columns["cb"] = "<input type=\"checkbox\" />";
167
- $columns["thumb"] = '<span>' . __("Image", 'download-monitor') . '</span>';
168
- $columns["title"] = __("Title", 'download-monitor');
169
- $columns["download_id"] = __("ID", 'download-monitor');
170
- $columns["file"] = __("File", 'download-monitor');
171
- $columns["version"] = __("Version", 'download-monitor');
172
- $columns["download_cat"] = __("Categories", 'download-monitor');
173
- $columns["download_tag"] = __("Tags", 'download-monitor');
174
  $columns["download_count"] = __( "Download count", 'download-monitor' );
175
  $columns["featured"] = __( "Featured", 'download-monitor' );
176
  $columns["members_only"] = __( "Members only", 'download-monitor' );
177
  $columns["redirect_only"] = __( "Redirect only", 'download-monitor' );
178
- $columns["date"] = __("Date posted", 'download-monitor');
179
 
180
  return $columns;
181
  }
@@ -184,78 +208,87 @@ class DLM_Admin_CPT {
184
  * custom_columns function.
185
  *
186
  * @access public
 
187
  * @param mixed $column
 
188
  * @return void
189
  */
190
  public function custom_columns( $column ) {
191
- global $post, $download_monitor;
192
 
193
- $download = new DLM_Download( $post->ID );
194
- $file = $download->get_file_version();
195
 
196
- switch ($column) {
197
  case "thumb" :
198
  echo $download->get_the_image();
199
- break;
200
  case "download_id" :
201
  echo $post->ID;
202
- break;
203
  case "download_cat" :
204
- if ( ! $terms = get_the_term_list( $post->ID, 'dlm_download_category', '', ', ', '' ) ) echo '<span class="na">&ndash;</span>'; else echo $terms;
205
- break;
 
 
 
 
206
  case "download_tag" :
207
- if ( ! $terms = get_the_term_list( $post->ID, 'dlm_download_tag', '', ', ', '' ) ) echo '<span class="na">&ndash;</span>'; else echo $terms;
208
- break;
 
 
 
 
209
  case "featured" :
210
-
211
- if ( $download->is_featured() )
212
  echo '<span class="yes">' . __( 'Yes', 'download-monitor' ) . '</span>';
213
- else
214
  echo '<span class="na">&ndash;</span>';
215
-
216
- break;
217
  case "members_only" :
218
-
219
- if ( $download->is_members_only() )
220
  echo '<span class="yes">' . __( 'Yes', 'download-monitor' ) . '</span>';
221
- else
222
  echo '<span class="na">&ndash;</span>';
223
-
224
- break;
225
  case "redirect_only" :
226
-
227
- if ( $download->redirect_only() )
228
  echo '<span class="yes">' . __( 'Yes', 'download-monitor' ) . '</span>';
229
- else
230
  echo '<span class="na">&ndash;</span>';
231
-
232
- break;
233
  case "file" :
234
  if ( $file ) {
235
  echo '<a href="' . $download->get_the_download_link() . '"><code>' . $file->filename;
236
- if ( $size = $download->get_the_filesize() )
237
  echo ' &ndash; ' . $size;
 
238
  echo '</code></a>';
239
- } else
240
  echo '<span class="na">&ndash;</span>';
241
- break;
 
242
  case "version" :
243
- if ( $file && $file->version )
244
  echo $file->version;
245
- else
246
  echo '<span class="na">&ndash;</span>';
247
- break;
 
248
  case "download_count" :
249
  echo number_format( $download->get_the_download_count(), 0, '.', ',' );
250
- break;
251
  case "featured" :
252
-
253
- if ( $download->is_featured() )
254
- echo '<img src="' . $download_monitor->plugin_url() . '/assets/images/on.png" alt="yes" />';
255
- else
256
  echo '<span class="na">&ndash;</span>';
257
-
258
- break;
259
  }
260
  }
261
 
@@ -263,7 +296,9 @@ class DLM_Admin_CPT {
263
  * sortable_columns function.
264
  *
265
  * @access public
 
266
  * @param mixed $columns
 
267
  * @return void
268
  */
269
  public function sortable_columns( $columns ) {
@@ -274,6 +309,7 @@ class DLM_Admin_CPT {
274
  'members_only' => 'members_only',
275
  'redirect_only' => 'redirect_only',
276
  );
 
277
  return wp_parse_args( $custom, $columns );
278
  }
279
 
@@ -281,40 +317,42 @@ class DLM_Admin_CPT {
281
  * sort_columns function.
282
  *
283
  * @access public
 
284
  * @param mixed $vars
 
285
  * @return void
286
  */
287
  public function sort_columns( $vars ) {
288
  if ( isset( $vars['orderby'] ) ) {
289
- if ( 'download_id' == $vars['orderby'] )
290
  $vars['orderby'] = 'ID';
291
-
292
- elseif ( 'download_count' == $vars['orderby'] )
293
  $vars = array_merge( $vars, array(
294
- 'meta_key' => '_download_count',
295
- 'orderby' => 'meta_value_num'
296
  ) );
297
 
298
- elseif ( 'featured' == $vars['orderby'] )
299
  $vars = array_merge( $vars, array(
300
- 'meta_key' => '_featured',
301
- 'orderby' => 'meta_value'
302
  ) );
303
 
304
- elseif ( 'members_only' == $vars['orderby'] )
305
  $vars = array_merge( $vars, array(
306
- 'meta_key' => '_members_only',
307
- 'orderby' => 'meta_value'
308
  ) );
309
 
310
- elseif ( 'redirect_only' == $vars['orderby'] )
311
  $vars = array_merge( $vars, array(
312
- 'meta_key' => '_redirect_only',
313
- 'orderby' => 'meta_value'
314
  ) );
 
315
  }
 
316
  return $vars;
317
  }
318
- }
319
 
320
- new DLM_Admin_CPT();
1
  <?php
2
 
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
 
7
  /**
8
  * DLM_Admin_CPT class.
9
+ *
10
+ * Add/modify CPT screen
11
+ *
12
  */
13
  class DLM_Admin_CPT {
14
 
16
  * __construct function.
17
  *
18
  * @access public
 
19
  */
20
  public function __construct() {
21
  add_action( "restrict_manage_posts", array( $this, "downloads_by_category" ) );
32
  * downloads_by_category function.
33
  *
34
  * @access public
35
+ *
36
  * @param int $show_counts (default: 1)
37
  * @param int $hierarchical (default: 1)
38
  * @param int $show_uncategorized (default: 1)
39
  * @param string $orderby (default: '')
40
+ *
41
  * @return void
42
  */
43
  public function downloads_by_category( $show_counts = 1, $hierarchical = 1, $show_uncategorized = 1, $orderby = '' ) {
44
  global $typenow, $wp_query;
45
 
46
+ if ( $typenow != 'dlm_download' ) {
47
+ return;
48
+ }
49
 
50
  include_once( 'class-dlm-category-walker.php' );
51
 
52
+ $r = array();
53
+ $r['pad_counts'] = 1;
54
+ $r['hierarchical'] = $hierarchical;
55
+ $r['hide_empty'] = 1;
56
+ $r['show_count'] = $show_counts;
57
+ $r['selected'] = ( isset( $wp_query->query['dlm_download_category'] ) ) ? $wp_query->query['dlm_download_category'] : '';
58
 
59
  $r['menu_order'] = false;
60
 
61
+ if ( $orderby == 'order' ) {
62
  $r['menu_order'] = 'asc';
63
+ } elseif ( $orderby ) {
64
  $r['orderby'] = $orderby;
65
+ }
66
 
67
  $terms = get_terms( 'dlm_download_category', $r );
68
 
69
+ if ( ! $terms ) {
70
+ return;
71
+ }
72
 
73
+ $output = "<select name='dlm_download_category' id='dropdown_dlm_download_category'>";
74
+ $output .= '<option value="" ' . selected( isset( $_GET['dlm_download_category'] ) ? $_GET['dlm_download_category'] : '', '', false ) . '>' . __( 'Select a category', 'download-monitor' ) . '</option>';
75
  $output .= $this->walk_category_dropdown_tree( $terms, 0, $r );
76
+ $output .= "</select>";
77
 
78
  echo $output;
79
  }
88
  $args = func_get_args();
89
 
90
  // the user's options are the third parameter
91
+ if ( empty( $args[2]['walker'] ) || ! is_a( $args[2]['walker'], 'Walker' ) ) {
92
+ $walker = new DLM_Category_Walker();
93
+ } else {
94
  $walker = $args[2]['walker'];
95
+ }
96
 
97
  return call_user_func_array( array( $walker, 'walk' ), $args );
98
  }
99
+
100
  /**
101
  * delete_post function.
102
  *
103
  * @access public
104
+ *
105
  * @param mixed $id
106
+ *
107
  * @return void
108
  */
109
  public function delete_post( $id ) {
110
  global $wpdb;
111
 
112
+ if ( ! current_user_can( 'delete_posts' ) ) {
113
  return;
114
+ }
115
 
116
  if ( $id > 0 ) {
117
 
118
  $post_type = get_post_type( $id );
119
 
120
+ switch ( $post_type ) {
121
  case 'dlm_download' :
122
+ if ( $versions =& get_children( 'post_parent=' . $id . '&post_type=dlm_download_version' ) ) {
123
+ if ( $versions ) {
124
+ foreach ( $versions as $child ) {
125
  wp_delete_post( $child->ID, true );
126
+ }
127
+ }
128
+ }
129
+ break;
130
  }
131
  }
132
  }
138
  * @return void
139
  */
140
  public function enter_title_here( $text, $post ) {
141
+ if ( 'dlm_download' == $post->post_type ) {
142
  return __( 'Download title', 'download-monitor' );
143
+ }
144
+
145
  return $text;
146
  }
147
 
149
  * post_updated_messages function.
150
  *
151
  * @access public
152
+ *
153
  * @param mixed $messages
154
+ *
155
  * @return void
156
  */
157
  public function post_updated_messages( $messages ) {
158
+ global $post;
159
 
160
  $messages['dlm_download'] = array(
161
+ 0 => '', // Unused. Messages start at index 1.
162
+ 1 => __( 'Download updated.', 'download-monitor' ),
163
+ 2 => __( 'Custom field updated.', 'download-monitor' ),
164
+ 3 => __( 'Custom field deleted.', 'download-monitor' ),
165
+ 4 => __( 'Download updated.', 'download-monitor' ),
166
+ 5 => isset( $_GET['revision'] ) ? sprintf( __( 'Download restored to revision from %s', 'download-monitor' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
167
+ 6 => __( 'Download published.', 'download-monitor' ),
168
+ 7 => __( 'Download saved.', 'download-monitor' ),
169
+ 8 => __( 'Download submitted.', 'download-monitor' ),
170
+ 9 => sprintf( __( 'Download scheduled for: <strong>%1$s</strong>.', 'download-monitor' ),
171
+ date_i18n( __( 'M j, Y @ G:i', 'download-monitor' ), strtotime( $post->post_date ) ) ),
172
+ 10 => __( 'Download draft updated.', 'download-monitor' ),
173
  );
174
 
175
  return $messages;
179
  * columns function.
180
  *
181
  * @access public
182
+ *
183
  * @param mixed $columns
184
+ *
185
+ * @return array
186
  */
187
  public function columns( $columns ) {
188
  $columns = array();
189
 
190
  $columns["cb"] = "<input type=\"checkbox\" />";
191
+ $columns["thumb"] = '<span>' . __( "Image", 'download-monitor' ) . '</span>';
192
+ $columns["title"] = __( "Title", 'download-monitor' );
193
+ $columns["download_id"] = __( "ID", 'download-monitor' );
194
+ $columns["file"] = __( "File", 'download-monitor' );
195
+ $columns["version"] = __( "Version", 'download-monitor' );
196
+ $columns["download_cat"] = __( "Categories", 'download-monitor' );
197
+ $columns["download_tag"] = __( "Tags", 'download-monitor' );
198
  $columns["download_count"] = __( "Download count", 'download-monitor' );
199
  $columns["featured"] = __( "Featured", 'download-monitor' );
200
  $columns["members_only"] = __( "Members only", 'download-monitor' );
201
  $columns["redirect_only"] = __( "Redirect only", 'download-monitor' );
202
+ $columns["date"] = __( "Date posted", 'download-monitor' );
203
 
204
  return $columns;
205
  }
208
  * custom_columns function.
209
  *
210
  * @access public
211
+ *
212
  * @param mixed $column
213
+ *
214
  * @return void
215
  */
216
  public function custom_columns( $column ) {
217
+ global $post;
218
 
219
+ $download = new DLM_Download( $post->ID );
220
+ $file = $download->get_file_version();
221
 
222
+ switch ( $column ) {
223
  case "thumb" :
224
  echo $download->get_the_image();
225
+ break;
226
  case "download_id" :
227
  echo $post->ID;
228
+ break;
229
  case "download_cat" :
230
+ if ( ! $terms = get_the_term_list( $post->ID, 'dlm_download_category', '', ', ', '' ) ) {
231
+ echo '<span class="na">&ndash;</span>';
232
+ } else {
233
+ echo $terms;
234
+ }
235
+ break;
236
  case "download_tag" :
237
+ if ( ! $terms = get_the_term_list( $post->ID, 'dlm_download_tag', '', ', ', '' ) ) {
238
+ echo '<span class="na">&ndash;</span>';
239
+ } else {
240
+ echo $terms;
241
+ }
242
+ break;
243
  case "featured" :
244
+ if ( $download->is_featured() ) {
 
245
  echo '<span class="yes">' . __( 'Yes', 'download-monitor' ) . '</span>';
246
+ } else {
247
  echo '<span class="na">&ndash;</span>';
248
+ }
249
+ break;
250
  case "members_only" :
251
+ if ( $download->is_members_only() ) {
 
252
  echo '<span class="yes">' . __( 'Yes', 'download-monitor' ) . '</span>';
253
+ } else {
254
  echo '<span class="na">&ndash;</span>';
255
+ }
256
+ break;
257
  case "redirect_only" :
258
+ if ( $download->redirect_only() ) {
 
259
  echo '<span class="yes">' . __( 'Yes', 'download-monitor' ) . '</span>';
260
+ } else {
261
  echo '<span class="na">&ndash;</span>';
262
+ }
263
+ break;
264
  case "file" :
265
  if ( $file ) {
266
  echo '<a href="' . $download->get_the_download_link() . '"><code>' . $file->filename;
267
+ if ( $size = $download->get_the_filesize() ) {
268
  echo ' &ndash; ' . $size;
269
+ }
270
  echo '</code></a>';
271
+ } else {
272
  echo '<span class="na">&ndash;</span>';
273
+ }
274
+ break;
275
  case "version" :
276
+ if ( $file && $file->version ) {
277
  echo $file->version;
278
+ } else {
279
  echo '<span class="na">&ndash;</span>';
280
+ }
281
+ break;
282
  case "download_count" :
283
  echo number_format( $download->get_the_download_count(), 0, '.', ',' );
284
+ break;
285
  case "featured" :
286
+ if ( $download->is_featured() ) {
287
+ echo '<img src="' . WP_DLM::get_plugin_url() . '/assets/images/on.png" alt="yes" />';
288
+ } else {
 
289
  echo '<span class="na">&ndash;</span>';
290
+ }
291
+ break;
292
  }
293
  }
294
 
296
  * sortable_columns function.
297
  *
298
  * @access public
299
+ *
300
  * @param mixed $columns
301
+ *
302
  * @return void
303
  */
304
  public function sortable_columns( $columns ) {
309
  'members_only' => 'members_only',
310
  'redirect_only' => 'redirect_only',
311
  );
312
+
313
  return wp_parse_args( $custom, $columns );
314
  }
315
 
317
  * sort_columns function.
318
  *
319
  * @access public
320
+ *
321
  * @param mixed $vars
322
+ *
323
  * @return void
324
  */
325
  public function sort_columns( $vars ) {
326
  if ( isset( $vars['orderby'] ) ) {
327
+ if ( 'download_id' == $vars['orderby'] ) {
328
  $vars['orderby'] = 'ID';
329
+ } elseif ( 'download_count' == $vars['orderby'] ) {
 
330
  $vars = array_merge( $vars, array(
331
+ 'meta_key' => '_download_count',
332
+ 'orderby' => 'meta_value_num'
333
  ) );
334
 
335
+ } elseif ( 'featured' == $vars['orderby'] ) {
336
  $vars = array_merge( $vars, array(
337
+ 'meta_key' => '_featured',
338
+ 'orderby' => 'meta_value'
339
  ) );
340
 
341
+ } elseif ( 'members_only' == $vars['orderby'] ) {
342
  $vars = array_merge( $vars, array(
343
+ 'meta_key' => '_members_only',
344
+ 'orderby' => 'meta_value'
345
  ) );
346
 
347
+ } elseif ( 'redirect_only' == $vars['orderby'] ) {
348
  $vars = array_merge( $vars, array(
349
+ 'meta_key' => '_redirect_only',
350
+ 'orderby' => 'meta_value'
351
  ) );
352
+ }
353
  }
354
+
355
  return $vars;
356
  }
 
357
 
358
+ }
includes/admin/class-dlm-admin-dashboard.php CHANGED
@@ -1,6 +1,8 @@
1
  <?php
2
 
3
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
4
 
5
  /**
6
  * DLM_Admin_Dashboard class.
@@ -11,14 +13,17 @@ class DLM_Admin_Dashboard {
11
  * __construct function.
12
  *
13
  * @access public
14
- * @return void
15
  */
16
  public function __construct() {
17
 
18
- if ( ! current_user_can( 'manage_downloads' ) )
19
  return;
 
20
 
21
- wp_add_dashboard_widget( 'dlm_popular_downloads', __( 'Popular Downloads', 'download-monitor' ), array( $this, 'popular_downloads' ) );
 
 
 
22
  }
23
 
24
  /**
@@ -30,64 +35,66 @@ class DLM_Admin_Dashboard {
30
  public function popular_downloads() {
31
 
32
  $args = array(
33
- 'post_status' => 'publish',
34
- 'post_type' => 'dlm_download',
35
- 'no_found_rows' => 1,
36
- 'posts_per_page' => 10,
37
- 'orderby' => 'meta_value_num',
38
- 'order' => 'desc',
39
- 'meta_query' => array(
40
- array(
41
- 'key' => '_download_count',
42
- 'value' => '0',
43
- 'compare' => '>'
44
- )
45
- ),
46
- 'meta_key' => '_download_count',
47
- 'fields' => 'ids'
48
- );
49
-
50
- $download_ids = get_posts( $args );
51
-
52
- if ( empty( $download_ids ) ) {
53
- echo '<p>' . __( 'There are no stats available yet!', 'download-monitor' ) . '</p>';
54
- return;
55
- }
56
-
57
- $downloads = array();
58
-
59
- foreach ( $download_ids as $download_id ) {
60
- $downloads[ $download_id ] = get_post_meta( $download_id, '_download_count', true );
61
- }
62
-
63
- if ( $downloads )
64
- $max_count = max( $downloads );
65
- ?>
66
- <table class="download_chart" cellpadding="0" cellspacing="0">
67
- <thead>
68
- <tr>
69
- <th scope="col"><?php _e( 'Download', "download_monitor" ); ?></th>
70
- <th scope="col"><?php _e( 'Download count', "download_monitor" ); ?></th>
71
- </tr>
72
- </thead>
 
 
73
  <tbody>
74
- <?php
75
- if ( $downloads ) foreach ( $downloads as $download_id => $count ) {
76
- $download = new DLM_Download( $download_id );
 
77
 
78
- $width = $count / ( $max_count ? $max_count : 1 ) * 67;
79
 
80
- echo '<tr>
81
  <th scope="row" style="width:25%;"><a href="' . admin_url( 'post.php?post=' . $download_id . '&action=edit' ) . '">' . $download->get_the_title() . '</a></th>
82
  <td><span class="bar" style="width:' . $width . '%;"></span>' . number_format( $count, 0, '.', ',' ) . '</td>
83
  </tr>';
84
- }
85
- ?>
 
86
  </tbody>
87
- </table>
88
- <?php
89
  }
90
 
91
- }
92
-
93
- new DLM_Admin_Dashboard();
1
  <?php
2
 
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
 
7
  /**
8
  * DLM_Admin_Dashboard class.
13
  * __construct function.
14
  *
15
  * @access public
 
16
  */
17
  public function __construct() {
18
 
19
+ if ( ! current_user_can( 'manage_downloads' ) ) {
20
  return;
21
+ }
22
 
23
+ wp_add_dashboard_widget( 'dlm_popular_downloads', __( 'Popular Downloads', 'download-monitor' ), array(
24
+ $this,
25
+ 'popular_downloads'
26
+ ) );
27
  }
28
 
29
  /**
35
  public function popular_downloads() {
36
 
37
  $args = array(
38
+ 'post_status' => 'publish',
39
+ 'post_type' => 'dlm_download',
40
+ 'no_found_rows' => 1,
41
+ 'posts_per_page' => 10,
42
+ 'orderby' => 'meta_value_num',
43
+ 'order' => 'desc',
44
+ 'meta_query' => array(
45
+ array(
46
+ 'key' => '_download_count',
47
+ 'value' => '0',
48
+ 'compare' => '>'
49
+ )
50
+ ),
51
+ 'meta_key' => '_download_count',
52
+ 'fields' => 'ids'
53
+ );
54
+
55
+ $download_ids = get_posts( $args );
56
+
57
+ if ( empty( $download_ids ) ) {
58
+ echo '<p>' . __( 'There are no stats available yet!', 'download-monitor' ) . '</p>';
59
+
60
+ return;
61
+ }
62
+
63
+ $downloads = array();
64
+
65
+ foreach ( $download_ids as $download_id ) {
66
+ $downloads[ $download_id ] = get_post_meta( $download_id, '_download_count', true );
67
+ }
68
+
69
+ if ( $downloads ) {
70
+ $max_count = max( $downloads );
71
+ }
72
+ ?>
73
+ <table class="download_chart" cellpadding="0" cellspacing="0">
74
+ <thead>
75
+ <tr>
76
+ <th scope="col"><?php _e( 'Download', "download_monitor" ); ?></th>
77
+ <th scope="col"><?php _e( 'Download count', "download_monitor" ); ?></th>
78
+ </tr>
79
+ </thead>
80
  <tbody>
81
+ <?php
82
+ if ( $downloads ) {
83
+ foreach ( $downloads as $download_id => $count ) {
84
+ $download = new DLM_Download( $download_id );
85
 
86
+ $width = $count / ( $max_count ? $max_count : 1 ) * 67;
87
 
88
+ echo '<tr>
89
  <th scope="row" style="width:25%;"><a href="' . admin_url( 'post.php?post=' . $download_id . '&action=edit' ) . '">' . $download->get_the_title() . '</a></th>
90
  <td><span class="bar" style="width:' . $width . '%;"></span>' . number_format( $count, 0, '.', ',' ) . '</td>
91
  </tr>';
92
+ }
93
+ }
94
+ ?>
95
  </tbody>
96
+ </table>
97
+ <?php
98
  }
99
 
100
+ }
 
 
includes/admin/class-dlm-admin-extensions.php ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Addons Page
4
+ */
5
+
6
+ if ( ! defined( 'ABSPATH' ) ) {
7
+ exit;
8
+ } // Exit if accessed directly
9
+
10
+
11
+ /**
12
+ * DLM_Admin_Extensions Class
13
+ */
14
+ class DLM_Admin_Extensions {
15
+
16
+ /**
17
+ * Handles output of the reports page in admin.
18
+ */
19
+ public function output() {
20
+
21
+ // Allow user to reload extensions
22
+ if ( isset( $_GET['dlm-force-recheck'] ) ) {
23
+ delete_transient( 'dlm_extension_json' );
24
+ }
25
+
26
+ // Load extension json
27
+ if ( false === ( $extension_json = get_transient( 'dlm_extension_json' ) ) ) {
28
+
29
+ // Extension request
30
+ $extension_request = wp_remote_get( 'https://download-monitor.com/?dlm-extensions=true' );
31
+
32
+ if ( ! is_wp_error( $extension_request ) ) {
33
+
34
+ // The extension json from server
35
+ $extension_json = wp_remote_retrieve_body( $extension_request );
36
+
37
+ // Set Transient
38
+ set_transient( 'dlm_extension_json', $extension_json, DAY_IN_SECONDS );
39
+ }
40
+ }
41
+
42
+ ?>
43
+ <div class="wrap dlm_extensions_wrap">
44
+ <div class="icon32 icon32-posts-dlm_download" id="icon-edit"><br/></div>
45
+ <h2><?php _e( 'Download Monitor Extensions', 'download-monitor' ); ?> <a href="<?php echo add_query_arg( 'dlm-force-recheck', '1' ); ?>" class="button dlm-reload-button">Reload Extensions</a></h2>
46
+ <?php
47
+
48
+ if ( false !== $extension_json ) {
49
+
50
+ // Get all extensions
51
+ $response = json_decode( $extension_json );
52
+
53
+ // Display message if it's there
54
+ if ( isset( $response->message ) && '' !== $response->message ) {
55
+ echo '<div id="message" class="updated">' . $response->message . '</div>' . PHP_EOL;
56
+ }
57
+
58
+ if ( count( $response ) > 0 && isset( $response->extensions ) && count( $response->extensions ) > 0 ) {
59
+
60
+ // Extensions
61
+ $extensions = $response->extensions;
62
+
63
+ // Get products
64
+ $products = DLM_Product_Manager::get()->get_products();
65
+
66
+ // Loop through extensions
67
+ $installed_extensions = array();
68
+
69
+ foreach ( $extensions as $extension_key => $extension ) {
70
+ if ( isset( $products[ $extension->product_id ] ) ) {
71
+ $installed_extensions[] = $extension;
72
+ unset( $extensions[ $extension_key ] );
73
+ }
74
+ }
75
+
76
+ echo "<p>Extend Download Monitor with it's powerful free and paid extensions.</p>" . PHP_EOL;
77
+ ?>
78
+ <h2 class="nav-tab-wrapper">
79
+ <a href="#available-extensions" class="nav-tab nav-tab-active">Available Extensions</a>
80
+ <?php if ( count( $installed_extensions ) > 0 ) { ?><a href="#installed-extensions" class="nav-tab">Installed Extensions</a><?php } ?>
81
+ </h2>
82
+ <?php
83
+
84
+
85
+ // Available Extensions
86
+ if ( count( $extensions ) > 0 ) {
87
+
88
+ echo '<div id="available-extensions" class="settings_panel">' . PHP_EOL;
89
+ echo '<div class="theme-browser dlm_extensions">';
90
+
91
+ foreach ( $extensions as $extension ) {
92
+
93
+ $sale = false;
94
+ if ( $extension->price > 0 ) {
95
+ $price_display = '$' . $extension->price;
96
+ if ( '' != $extension->sale_price && $extension->sale_price > 0 ) {
97
+ $price_display = '<strike>$' . $extension->price . '</strike> $' . $extension->sale_price;
98
+ $sale = true;
99
+ }
100
+ } else {
101
+ $price_display = 'FREE';
102
+ }
103
+
104
+ //$price_display = ( ( $extension->price > 0 ) ? '$' . $extension->price : 'FREE' );
105
+
106
+ echo '<div class="theme dlm_extension">';
107
+ echo '<a href="' . $extension->url . '" target="_blank">';
108
+ echo '<div class="dlm_extension_img_wrapper"><img src="' . $extension->image . '" alt="' . $extension->name . '" /></div>' . PHP_EOL;
109
+ echo '<h3>' . $extension->name . '</h3>' . PHP_EOL;
110
+ echo '<p class="extension-desc">' . $extension->desc . '</p>';
111
+ echo '<div class="product_footer">';
112
+ echo '<span class="loop_price' . ( ( $sale ) ? ' sale' : '' ) . '">' . $price_display . '</span>';
113
+ echo '<span class="loop_more">Get This Extension</span>';
114
+ echo '</div>';
115
+ echo '</a>';
116
+ echo '</div>';
117
+ }
118
+
119
+ echo '</div>';
120
+ echo '</div>';
121
+
122
+
123
+ }else if ( count( $installed_extensions ) > 0 ) {
124
+ echo '<p>Wow, looks like you installed all our extensions. Thanks, you rock!</p>';
125
+ }
126
+
127
+ // Installed Extensions
128
+ if ( count( $installed_extensions ) > 0 ) {
129
+
130
+ echo '<div id="installed-extensions" class="settings_panel">' . PHP_EOL;
131
+
132
+ echo '<div class="theme-browser dlm_extensions">';
133
+ foreach ( $installed_extensions as $extension ) {
134
+
135
+ // Get the product
136
+ $license = $products[ $extension->product_id ]->get_license();
137
+
138
+ echo '<div class="theme dlm_extension">';
139
+
140
+ echo '<div class="dlm_extension_img_wrapper"><img src="' . $extension->image . '" alt="' . $extension->name . '" /></div>' . PHP_EOL;
141
+ echo '<h3>' . $extension->name . '</h3>' . PHP_EOL;
142
+
143
+ echo '<div class="extension_license">' . PHP_EOL;
144
+ echo '<p class="license-status' . ( ( $license->is_active() ) ? ' active' : '' ) . '">' . strtoupper( $license->get_status() ) . '</p>' . PHP_EOL;
145
+ echo '<input type="hidden" id="dlm-ajax-nonce" value="' . wp_create_nonce( 'dlm-ajax-nonce' ) . '" />' . PHP_EOL;
146
+ echo '<input type="hidden" id="status" value="' . $license->get_status() . '" />' . PHP_EOL;
147
+ echo '<input type="hidden" id="product_id" value="' . $extension->product_id . '" />' . PHP_EOL;
148
+ echo '<input type="text" name="key" id="key" value="' . $license->get_key() . '" placeholder="License Key"' . ( ( $license->is_active() ) ? ' disabled="disabled"' : '' ) . ' />' . PHP_EOL;
149
+ echo '<input type="text" name="email" id="email" value="' . $license->get_email() . '" placeholder="License Email"' . ( ( $license->is_active() ) ? ' disabled="disabled"' : '' ) . ' />' . PHP_EOL;
150
+ echo '<a href="javscript:;" class="button button-primary">' . ( ( $license->is_active() ) ? 'Deactivate' : 'Activate' ) . '</a>';
151
+ echo '</div>' . PHP_EOL;
152
+
153
+ echo '</div>';
154
+ }
155
+ echo '</div>';
156
+ echo '</div>'.PHP_EOL;
157
+
158
+ }
159
+
160
+ }
161
+
162
+ } else {
163
+ echo "<p>Couldn't load extensions, please try again later.</p>" . PHP_EOL;
164
+ }
165
+ ?>
166
+ </div>
167
+ <?php
168
+ }
169
+ }
includes/admin/class-dlm-admin-media-browser.php CHANGED
@@ -1,6 +1,8 @@
1
  <?php
2
 
3
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
4
 
5
  /**
6
  * DLM_Admin_Media_Browser class.
@@ -11,7 +13,6 @@ class DLM_Admin_Media_Browser {
11
  * __construct function.
12
  *
13
  * @access public
14
- * @return void
15
  */
16
  public function __construct() {
17
  add_action( 'media_upload_downloadable_file_browser', array( $this, 'media_browser' ) );
@@ -24,13 +25,15 @@ class DLM_Admin_Media_Browser {
24
  * @return void
25
  */
26
  public function media_browser() {
27
- global $download_monitor;
 
28
 
29
- $files = $download_monitor->list_files( ABSPATH, 1 );
 
30
 
31
  echo '<!DOCTYPE html><html lang="en"><head><title>' . __( 'Browse for a file', 'download-monitor' ) . '</title>';
32
 
33
- wp_enqueue_style( 'download_monitor_admin_css', $download_monitor->plugin_url() . '/assets/css/admin.css', array( 'dashicons' ) );
34
  do_action( 'admin_print_styles' );
35
  do_action( 'admin_print_scripts' );
36
  do_action( 'admin_head' );
@@ -39,23 +42,27 @@ class DLM_Admin_Media_Browser {
39
 
40
  echo '<ul class="download_monitor_file_browser">';
41
 
42
- foreach( $files as $found_file ) {
43
 
44
  $file = pathinfo( $found_file['path'] );
45
 
46
  if ( $found_file['type'] == 'folder' ) {
47
 
48
- echo '<li><a href="#" class="folder" data-path="' . trailingslashit( $file['dirname'] ) . $file['basename'] . '">' . $file['basename'] . '</a></li>';
49
 
50
  } else {
51
 
52
- $filename = $file['basename'];
53
  $extension = ( empty( $file['extension'] ) ) ? '' : $file['extension'];
54
 
55
- if ( substr( $filename, 0, 1 ) == '.' ) continue; // Ignore files starting with . like htaccess
56
- if ( in_array( $extension, array( '', 'php', 'html', 'htm', 'tmp' ) ) ) continue; // Ignored file types
 
 
 
 
57
 
58
- echo '<li><a href="#" class="file filetype-' . sanitize_title( $extension ) . '" data-path="' . trailingslashit( $file['dirname'] ) . $file['basename'] . '">' . $file['basename'] . '</a></li>';
59
 
60
  }
61
 
@@ -64,54 +71,52 @@ class DLM_Admin_Media_Browser {
64
  echo '</ul>';
65
  ?>
66
  <script type="text/javascript">
67
- jQuery(function() {
68
- jQuery('.download_monitor_file_browser').on('click', 'a', function(){
69
 
70
- var $link = jQuery(this);
71
- var $parent = $link.closest('li');
72
 
73
- if ( $link.is('.file') ) {
74
 
75
  var win = window.dialogArguments || opener || parent || top;
76
 
77
- win.send_to_editor( $link.attr('data-path') );
78
 
79
- } else if ( $link.is('.folder_open') ) {
80
 
81
- $parent.find('ul').remove();
82
- $link.removeClass('folder_open');
83
 
84
  } else {
85
 
86
- $link.after('<ul class="load_tree loading"></ul>');
87
 
88
  var data = {
89
- action: 'download_monitor_list_files',
90
- path: jQuery(this).attr('data-path'),
91
- security: '<?php echo wp_create_nonce("list-files"); ?>'
92
  };
93
 
94
- jQuery.post('<?php echo admin_url('admin-ajax.php'); ?>', data, function(response) {
95
 
96
- $link.addClass('folder_open');
97
 
98
  if ( response ) {
99
- $parent.find('.load_tree').html( response );
100
  } else {
101
- $parent.find('.load_tree').html( '<li class="nofiles"><?php _e('No files found', 'download-monitor'); ?></li>' );
102
  }
103
- $parent.find('.load_tree').removeClass('load_tree loading');
104
 
105
- });
106
  }
107
  return false;
108
- });
109
- });
110
  </script>
111
  <?php
112
  echo '</body></html>';
113
  }
114
 
115
- }
116
-
117
- new DLM_Admin_Media_Browser();
1
  <?php
2
 
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
 
7
  /**
8
  * DLM_Admin_Media_Browser class.
13
  * __construct function.
14
  *
15
  * @access public
 
16
  */
17
  public function __construct() {
18
  add_action( 'media_upload_downloadable_file_browser', array( $this, 'media_browser' ) );
25
  * @return void
26
  */
27
  public function media_browser() {
28
+ // File Manager
29
+ $file_manager = new DLM_File_Manager();
30
 
31
+ // Files
32
+ $files = $file_manager->list_files( ABSPATH, 1 );
33
 
34
  echo '<!DOCTYPE html><html lang="en"><head><title>' . __( 'Browse for a file', 'download-monitor' ) . '</title>';
35
 
36
+ wp_enqueue_style( 'download_monitor_admin_css', WP_DLM::get_plugin_url() . '/assets/css/admin.css', array( 'dashicons' ) );
37
  do_action( 'admin_print_styles' );
38
  do_action( 'admin_print_scripts' );
39
  do_action( 'admin_head' );
42
 
43
  echo '<ul class="download_monitor_file_browser">';
44
 
45
+ foreach ( $files as $found_file ) {
46
 
47
  $file = pathinfo( $found_file['path'] );
48
 
49
  if ( $found_file['type'] == 'folder' ) {
50
 
51
+ echo '<li><a href="#" class="folder" data-path="' . trailingslashit( $file['dirname'] ) . $file['basename'] . '">' . $file['basename'] . '</a></li>';
52
 
53
  } else {
54
 
55
+ $filename = $file['basename'];
56
  $extension = ( empty( $file['extension'] ) ) ? '' : $file['extension'];
57
 
58
+ if ( substr( $filename, 0, 1 ) == '.' ) {
59
+ continue;
60
+ } // Ignore files starting with . like htaccess
61
+ if ( in_array( $extension, array( '', 'php', 'html', 'htm', 'tmp' ) ) ) {
62
+ continue;
63
+ } // Ignored file types
64
 
65
+ echo '<li><a href="#" class="file filetype-' . sanitize_title( $extension ) . '" data-path="' . trailingslashit( $file['dirname'] ) . $file['basename'] . '">' . $file['basename'] . '</a></li>';
66
 
67
  }
68
 
71
  echo '</ul>';
72
  ?>
73
  <script type="text/javascript">
74
+ jQuery( function () {
75
+ jQuery( '.download_monitor_file_browser' ).on( 'click', 'a', function () {
76
 
77
+ var $link = jQuery( this );
78
+ var $parent = $link.closest( 'li' );
79
 
80
+ if ( $link.is( '.file' ) ) {
81
 
82
  var win = window.dialogArguments || opener || parent || top;
83
 
84
+ win.send_to_editor( $link.attr( 'data-path' ) );
85
 
86
+ } else if ( $link.is( '.folder_open' ) ) {
87
 
88
+ $parent.find( 'ul' ).remove();
89
+ $link.removeClass( 'folder_open' );
90
 
91
  } else {
92
 
93
+ $link.after( '<ul class="load_tree loading"></ul>' );
94
 
95
  var data = {
96
+ action: 'download_monitor_list_files',
97
+ path: jQuery( this ).attr( 'data-path' ),
98
+ security: '<?php echo wp_create_nonce("list-files"); ?>'
99
  };
100
 
101
+ jQuery.post( '<?php echo admin_url('admin-ajax.php'); ?>', data, function ( response ) {
102
 
103
+ $link.addClass( 'folder_open' );
104
 
105
  if ( response ) {
106
+ $parent.find( '.load_tree' ).html( response );
107
  } else {
108
+ $parent.find( '.load_tree' ).html( '<li class="nofiles"><?php _e('No files found', 'download-monitor'); ?></li>' );
109
  }
110
+ $parent.find( '.load_tree' ).removeClass( 'load_tree loading' );
111
 
112
+ } );
113
  }
114
  return false;
115
+ } );
116
+ } );
117
  </script>
118
  <?php
119
  echo '</body></html>';
120
  }
121
 
122
+ }
 
 
includes/admin/{class-dlm-admin-insert.php → class-dlm-admin-media-insert.php} RENAMED
@@ -1,16 +1,17 @@
1
  <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
3
 
4
  /**
5
  * DLM_Admin_Insert class.
6
  */
7
- class DLM_Admin_Insert {
8
 
9
  /**
10
  * __construct function.
11
  *
12
  * @access public
13
- * @return void
14
  */
15
  public function __construct() {
16
  add_action( 'media_buttons', array( $this, 'media_buttons' ), 20 );
@@ -20,32 +21,19 @@ class DLM_Admin_Insert {
20
  /**
21
  * media_buttons function.
22
  *
 
 
23
  * @access public
24
  * @return void
25
  */
26
  public function media_buttons( $editor_id = 'content' ) {
27
- global $download_monitor, $post;
28
 
29
- if ( $post->post_type == 'dlm_download' )
30
  return;
 
31
 
32
- echo '<a href="#" class="button insert-download add_download" data-editor="' . esc_attr( $editor_id ) . '" title="' . esc_attr__( 'Insert Download', 'download-monitor' ) . '">' . __( 'Insert Download', 'download-monitor' ) . '</a>';
33
-
34
- ob_start();
35
- ?>
36
- jQuery(function(){
37
- // Browse for file
38
- jQuery('body').on('click', 'a.add_download', function(e){
39
-
40
- tb_show('<?php esc_attr_e( 'Insert Download', 'download-monitor' ); ?>', 'media-upload.php?post_id=<?php echo $post->ID; ?>&amp;type=add_download&amp;from=wpdlm01&amp;TB_iframe=true&amp;height=200');
41
-
42
- return false;
43
- });
44
- });
45
- <?php
46
-
47
- $js_code = ob_get_clean();
48
- $download_monitor->add_inline_js( $js_code );
49
  }
50
 
51
  /**
@@ -55,10 +43,9 @@ class DLM_Admin_Insert {
55
  * @return void
56
  */
57
  public function media_browser() {
58
- global $download_monitor;
59
 
60
  // Enqueue scripts and styles for panel
61
- wp_enqueue_style( 'download_monitor_admin_css', $download_monitor->plugin_url() . '/assets/css/admin.css', array( 'dashicons' ) );
62
  wp_enqueue_script( 'common' );
63
  wp_enqueue_style( 'global' );
64
  wp_enqueue_style( 'wp-admin' );
@@ -75,12 +62,14 @@ class DLM_Admin_Insert {
75
 
76
  ?>
77
  <h2 class="nav-tab-wrapper">
78
- <a href="#insert-shortcode" class="nav-tab nav-tab-active"><?php _e( 'Insert Shortcode', 'download-monitor' ); ?></a><a href="#quick-add" class="nav-tab"><?php _e( 'Quick-add download', 'download-monitor' ); ?></a>
 
 
79
  </h2>
80
  <?php
81
 
82
  // Handle quick-add form
83
- if ( ! empty( $_POST['download_url'] ) && ! empty( $_POST['download_title'] ) && wp_verify_nonce( $_POST['quick-add-nonce'], 'quick-add') ) {
84
 
85
  $url = stripslashes( $_POST['download_url'] );
86
  $title = sanitize_text_field( stripslashes( $_POST['download_title'] ) );
@@ -118,26 +107,35 @@ class DLM_Admin_Insert {
118
 
119
  $file_id = wp_insert_post( $file );
120
 
121
- if ( ! $file_id )
122
  throw new Exception( __( 'Error: File was not created.', 'download-monitor' ) );
 
 
 
 
123
 
124
  // Meta
125
  update_post_meta( $file_id, '_version', $version );
126
- update_post_meta( $file_id, '_filesize', $download_monitor->get_filesize( $url ) );
127
- update_post_meta( $file_id, '_files', $download_monitor->json_encode_files( array( $url ) ) );
128
 
129
- $hashes = $download_monitor->get_file_hashes( $url );
 
130
 
 
131
  update_post_meta( $file_id, '_md5', $hashes['md5'] );
132
  update_post_meta( $file_id, '_sha1', $hashes['sha1'] );
133
  update_post_meta( $file_id, '_crc32', $hashes['crc32'] );
134
 
 
135
  echo '<div class="updated"><p>' . __( 'Download successfully created.', 'download-monitor' ) . '</p></div>';
136
 
137
- } else throw new Exception( __( 'Error: Download was not created.', 'download-monitor' ) );
 
 
138
 
139
  } catch ( Exception $e ) {
140
- echo '<div class="error"><p>' . $e->getMessage() . "</p></div>";
141
  }
142
 
143
  }
@@ -147,7 +145,7 @@ class DLM_Admin_Insert {
147
  'post_status' => 'publish',
148
  'post_type' => 'dlm_download',
149
  'orderby' => 'ID',
150
- 'posts_per_page' => -1
151
  ) );
152
  ?>
153
  <form id="insert-shortcode">
@@ -155,47 +153,50 @@ class DLM_Admin_Insert {
155
  <fieldset>
156
  <legend><?php _e( 'Choose a download', 'download-monitor' ); ?>:</legend>
157
  <?php
158
- $limit = 10;
159
- $page = isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
160
-
161
- $dlm_query = new WP_Query( array(
162
- 'post_status' => 'publish',
163
- 'post_type' => 'dlm_download',
164
- 'posts_per_page' => $limit,
165
- 'offset' => ( $page - 1 ) * $limit
166
- ) );
167
-
168
- while ( $dlm_query->have_posts() ) {
169
- $dlm_query->the_post();
170
- $download = new DLM_Download( $dlm_query->post->ID );
171
- echo '<label><input name="download_id" class="radio" type="radio" value="' . absint( $download->id ) . '" /> #' . $download->id . ' &ndash; ' . $download->get_the_title() . ' &ndash; ' . $download->get_the_filename() .'</label>';
172
- }
173
-
174
- if ( $dlm_query->max_num_pages > 1 ) {
175
- echo paginate_links( apply_filters( 'download_monitor_pagination_args', array(
176
- 'base' => str_replace( 999999999, '%#%', get_pagenum_link( 999999999 ) ),
177
- 'format' => '',
178
- 'current' => $page,
179
- 'total' => $dlm_query->max_num_pages,
180
- 'prev_text' => '&larr;',
181
- 'next_text' => '&rarr;',
182
- 'type' => 'list',
183
- 'end_size' => 3,
184
- 'mid_size' => 3
185
- ) ) );
186
- }
187
  ?>
188
  </fieldset>
189
-
190
  <p>
191
  <label for="template_name"><?php _e( 'Template', 'download-monitor' ); ?>:</label>
192
- <input type="text" id="template_name" value="" class="input" placeholder="<?php _e( 'Template Name', 'download-monitor' ); ?>" />
 
193
  <span class="description">
194
  <?php _e( 'Leaving this blank will use the default <code>content-download.php</code> template file. If you enter, for example, <code>image</code>, the <code>content-download-image.php</code> template will be used instead.', 'download-monitor' ); ?>
195
  </span>
196
  </p>
 
197
  <p>
198
- <input type="button" class="button insert_download button-primary button-large" value="<?php _e( 'Insert Shortcode', 'download-monitor' ); ?>" />
 
199
  </p>
200
 
201
  </form>
@@ -207,27 +208,39 @@ class DLM_Admin_Insert {
207
  <div id="drag-drop-area" style="height:240px">
208
  <div class="drag-drop-inside">
209
  <p class="drag-drop-info"><?php _e( 'Drop file here', 'download-monitor' ); ?></p>
 
210
  <p><?php echo _x( 'or', 'Drop file here *or* select file', 'download-monitor' ); ?></p>
211
- <p class="drag-drop-buttons"><input id="plupload-browse-button" type="button" value="<?php esc_attr_e( 'Select File', 'download-monitor' ); ?>" class="button" /></p>
 
 
 
212
  </div>
213
  </div>
214
- <p><a href="#" class="add_manually"><?php _e( 'Enter URL manually', 'download-monitor' ); ?> &rarr;</a></p>
 
215
  </div>
216
  <div id="quick-add-details" style="display:none">
217
  <p>
218
  <label for="download_url"><?php _e( 'Download URL', 'download-monitor' ); ?>:</label>
219
- <input type="text" name="download_url" id="download_url" value="" class="download_url input" placeholder="<?php _e( 'Required URL', 'download-monitor' ); ?>" />
 
220
  </p>
 
221
  <p>
222
  <label for="download_title"><?php _e( 'Download Title', 'download-monitor' ); ?>:</label>
223
- <input type="text" name="download_title" id="download_title" value="" class="download_title input" placeholder="<?php _e( 'Required title', 'download-monitor' ); ?>" />
 
224
  </p>
 
225
  <p>
226
  <label for="download_version"><?php _e( 'Version', 'download-monitor' ); ?>:</label>
227
- <input type="text" name="download_version" id="download_version" value="" class="input" placeholder="<?php _e( 'Optional version number', 'download-monitor' ); ?>" />
 
228
  </p>
 
229
  <p>
230
- <input type="submit" class="button button-primary button-large" value="<?php _e( 'Save Download', 'download-monitor' ); ?>" />
 
231
  <?php wp_nonce_field( 'quick-add', 'quick-add-nonce' ) ?>
232
  </p>
233
  </div>
@@ -235,25 +248,25 @@ class DLM_Admin_Insert {
235
  </form>
236
 
237
  <script type="text/javascript">
238
- jQuery(function() {
239
 
240
- jQuery('.nav-tab-wrapper a').click(function() {
241
- jQuery('#insert-shortcode, #quick-add').hide();
242
- jQuery(jQuery(this).attr('href')).show();
243
- jQuery('a.nav-tab-active').removeClass('nav-tab-active');
244
- jQuery(this).addClass('nav-tab-active');
245
  return false;
246
- });
247
 
248
- jQuery('#quick-add').hide();
249
 
250
- jQuery('body').on('click', '.insert_download', function(){
251
 
252
  var win = window.dialogArguments || opener || parent || top;
253
 
254
- var download_id = jQuery('input[name="download_id"]:checked').val();
255
- var template = jQuery('#template_name').val();
256
- var shortcode = '[download id="' + download_id + '"';
257
 
258
  if ( template )
259
  shortcode = shortcode + ' template="' + template + '"';
@@ -263,13 +276,13 @@ class DLM_Admin_Insert {
263
  win.send_to_editor( shortcode );
264
 
265
  return false;
266
- });
267
 
268
- jQuery('.add_manually').click(function() {
269
- jQuery('#plupload-upload-ui').slideUp();
270
- jQuery('#quick-add-details').slideDown();
271
  return false;
272
- });
273
 
274
  <?php
275
  $plupload_init = array(
@@ -300,64 +313,62 @@ class DLM_Admin_Insert {
300
  ?>
301
 
302
  // create the uploader and pass the config from above
303
- var uploader = new plupload.Uploader(<?php echo json_encode( $plupload_init ); ?>);
304
 
305
  // checks if browser supports drag and drop upload, makes some css adjustments if necessary
306
- uploader.bind('Init', function(up){
307
- var uploaddiv = jQuery('#plupload-upload-ui');
308
 
309
  if ( up.features.dragdrop ) {
310
- uploaddiv.addClass('drag-drop');
311
 
312
- jQuery('#drag-drop-area')
313
- .bind('dragover.wp-uploader', function() {
314
- uploaddiv.addClass('drag-over');
315
- })
316
- .bind('dragleave.wp-uploader, drop.wp-uploader', function() {
317
- uploaddiv.removeClass('drag-over');
318
- });
319
 
320
  } else {
321
- uploaddiv.removeClass('drag-drop');
322
- jQuery('#drag-drop-area').unbind('.wp-uploader');
323
  }
324
- });
325
 
326
  uploader.init();
327
 
328
  // a file was added in the queue
329
- uploader.bind('FilesAdded', function(up, files) {
330
- var hundredmb = 100 * 1024 * 1024, max = parseInt(up.settings.max_file_size, 10);
331
 
332
- plupload.each(files, function(file) {
333
  if ( max > hundredmb && file.size > hundredmb && up.runtime != 'html5' ) {
334
  // file size error?
335
  } else {
336
- jQuery('.drag-drop-inside').html('<p><?php _e( 'Please wait...', 'download-monitor' ); ?></p>');
337
  }
338
- });
339
 
340
  up.refresh();
341
  up.start();
342
- });
343
 
344
  // a file was uploaded
345
- uploader.bind('FileUploaded', function( up, file, response ) {
346
- jQuery('#quick-add-details').find('input.download_url').val( response.response );
347
- jQuery('#quick-add-details').find('input.download_title').val( basename( response.response ) );
348
- jQuery('#plupload-upload-ui').slideUp();
349
- jQuery('#quick-add-details').slideDown();
350
- });
351
-
352
- function basename(path) {
353
- return path.split('/').reverse()[0];
354
  }
355
 
356
- });
357
  </script>
358
  <?php
359
  echo '</body></html>';
360
  }
361
- }
362
-
363
- new DLM_Admin_Insert();
1
  <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ } // Exit if accessed directly
5
 
6
  /**
7
  * DLM_Admin_Insert class.
8
  */
9
+ class DLM_Admin_Media_Insert {
10
 
11
  /**
12
  * __construct function.
13
  *
14
  * @access public
 
15
  */
16
  public function __construct() {
17
  add_action( 'media_buttons', array( $this, 'media_buttons' ), 20 );
21
  /**
22
  * media_buttons function.
23
  *
24
+ * @param String $editor_id
25
+ *
26
  * @access public
27
  * @return void
28
  */
29
  public function media_buttons( $editor_id = 'content' ) {
30
+ global $post;
31
 
32
+ if ( empty( $post ) || 'dlm_download' === $post->post_type ) {
33
  return;
34
+ }
35
 
36
+ echo '<a href="#" class="button insert-download add_download" data-editor="' . esc_attr( $editor_id ) . '" title="' . esc_attr__( 'Insert Download', 'download-monitor' ) . '" rel="' . $post->ID . '" >' . __( 'Insert Download', 'download-monitor' ) . '</a>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  }
38
 
39
  /**
43
  * @return void
44
  */
45
  public function media_browser() {
 
46
 
47
  // Enqueue scripts and styles for panel
48
+ wp_enqueue_style( 'download_monitor_admin_css', WP_DLM::get_plugin_url() . '/assets/css/admin.css', array( 'dashicons' ) );
49
  wp_enqueue_script( 'common' );
50
  wp_enqueue_style( 'global' );
51
  wp_enqueue_style( 'wp-admin' );
62
 
63
  ?>
64
  <h2 class="nav-tab-wrapper">
65
+ <a href="#insert-shortcode"
66
+ class="nav-tab nav-tab-active"><?php _e( 'Insert Shortcode', 'download-monitor' ); ?></a><a
67
+ href="#quick-add" class="nav-tab"><?php _e( 'Quick-add download', 'download-monitor' ); ?></a>
68
  </h2>
69
  <?php
70
 
71
  // Handle quick-add form
72
+ if ( ! empty( $_POST['download_url'] ) && ! empty( $_POST['download_title'] ) && wp_verify_nonce( $_POST['quick-add-nonce'], 'quick-add' ) ) {
73
 
74
  $url = stripslashes( $_POST['download_url'] );
75
  $title = sanitize_text_field( stripslashes( $_POST['download_title'] ) );
107
 
108
  $file_id = wp_insert_post( $file );
109
 
110
+ if ( ! $file_id ) {
111
  throw new Exception( __( 'Error: File was not created.', 'download-monitor' ) );
112
+ }
113
+
114
+ // File Manager
115
+ $file_manager = new DLM_File_Manager();
116
 
117
  // Meta
118
  update_post_meta( $file_id, '_version', $version );
119
+ update_post_meta( $file_id, '_filesize', $file_manager->get_file_size( $url ) );
120
+ update_post_meta( $file_id, '_files', $file_manager->json_encode_files( array( $url ) ) );
121
 
122
+ // Hashes
123
+ $hashes = $file_manager->get_file_hashes( $url );
124
 
125
+ // Set hashes
126
  update_post_meta( $file_id, '_md5', $hashes['md5'] );
127
  update_post_meta( $file_id, '_sha1', $hashes['sha1'] );
128
  update_post_meta( $file_id, '_crc32', $hashes['crc32'] );
129
 
130
+ // Success message
131
  echo '<div class="updated"><p>' . __( 'Download successfully created.', 'download-monitor' ) . '</p></div>';
132
 
133
+ } else {
134
+ throw new Exception( __( 'Error: Download was not created.', 'download-monitor' ) );
135
+ }
136
 
137
  } catch ( Exception $e ) {
138
+ echo '<div class="error"><p>' . $e->getMessage() . "</p></div>";
139
  }
140
 
141
  }
145
  'post_status' => 'publish',
146
  'post_type' => 'dlm_download',
147
  'orderby' => 'ID',
148
+ 'posts_per_page' => - 1
149
  ) );
150
  ?>
151
  <form id="insert-shortcode">
153
  <fieldset>
154
  <legend><?php _e( 'Choose a download', 'download-monitor' ); ?>:</legend>
155
  <?php
156
+ $limit = 10;
157
+ $page = isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
158
+
159
+ $dlm_query = new WP_Query( array(
160
+ 'post_status' => 'publish',
161
+ 'post_type' => 'dlm_download',
162
+ 'posts_per_page' => $limit,
163
+ 'offset' => ( $page - 1 ) * $limit
164
+ ) );
165
+
166
+ while ( $dlm_query->have_posts() ) {
167
+ $dlm_query->the_post();
168
+ $download = new DLM_Download( $dlm_query->post->ID );
169
+ echo '<label><input name="download_id" class="radio" type="radio" value="' . absint( $download->id ) . '" /> #' . $download->id . ' &ndash; ' . $download->get_the_title() . ' &ndash; ' . $download->get_the_filename() . '</label>';
170
+ }
171
+
172
+ if ( $dlm_query->max_num_pages > 1 ) {
173
+ echo paginate_links( apply_filters( 'download_monitor_pagination_args', array(
174
+ 'base' => str_replace( 999999999, '%#%', get_pagenum_link( 999999999 ) ),
175
+ 'format' => '',
176
+ 'current' => $page,
177
+ 'total' => $dlm_query->max_num_pages,
178
+ 'prev_text' => '&larr;',
179
+ 'next_text' => '&rarr;',
180
+ 'type' => 'list',
181
+ 'end_size' => 3,
182
+ 'mid_size' => 3
183
+ ) ) );
184
+ }
185
  ?>
186
  </fieldset>
187
+
188
  <p>
189
  <label for="template_name"><?php _e( 'Template', 'download-monitor' ); ?>:</label>
190
+ <input type="text" id="template_name" value="" class="input"
191
+ placeholder="<?php _e( 'Template Name', 'download-monitor' ); ?>"/>
192
  <span class="description">
193
  <?php _e( 'Leaving this blank will use the default <code>content-download.php</code> template file. If you enter, for example, <code>image</code>, the <code>content-download-image.php</code> template will be used instead.', 'download-monitor' ); ?>
194
  </span>
195
  </p>
196
+
197
  <p>
198
+ <input type="button" class="button insert_download button-primary button-large"
199
+ value="<?php _e( 'Insert Shortcode', 'download-monitor' ); ?>"/>
200
  </p>
201
 
202
  </form>
208
  <div id="drag-drop-area" style="height:240px">
209
  <div class="drag-drop-inside">
210
  <p class="drag-drop-info"><?php _e( 'Drop file here', 'download-monitor' ); ?></p>
211
+
212
  <p><?php echo _x( 'or', 'Drop file here *or* select file', 'download-monitor' ); ?></p>
213
+
214
+ <p class="drag-drop-buttons"><input id="plupload-browse-button" type="button"
215
+ value="<?php esc_attr_e( 'Select File', 'download-monitor' ); ?>"
216
+ class="button"/></p>
217
  </div>
218
  </div>
219
+ <p><a href="#" class="add_manually"><?php _e( 'Enter URL manually', 'download-monitor' ); ?> &rarr;</a>
220
+ </p>
221
  </div>
222
  <div id="quick-add-details" style="display:none">
223
  <p>
224
  <label for="download_url"><?php _e( 'Download URL', 'download-monitor' ); ?>:</label>
225
+ <input type="text" name="download_url" id="download_url" value="" class="download_url input"
226
+ placeholder="<?php _e( 'Required URL', 'download-monitor' ); ?>"/>
227
  </p>
228
+
229
  <p>
230
  <label for="download_title"><?php _e( 'Download Title', 'download-monitor' ); ?>:</label>
231
+ <input type="text" name="download_title" id="download_title" value="" class="download_title input"
232
+ placeholder="<?php _e( 'Required title', 'download-monitor' ); ?>"/>
233
  </p>
234
+
235
  <p>
236
  <label for="download_version"><?php _e( 'Version', 'download-monitor' ); ?>:</label>
237
+ <input type="text" name="download_version" id="download_version" value="" class="input"
238
+ placeholder="<?php _e( 'Optional version number', 'download-monitor' ); ?>"/>
239
  </p>
240
+
241
  <p>
242
+ <input type="submit" class="button button-primary button-large"
243
+ value="<?php _e( 'Save Download', 'download-monitor' ); ?>"/>
244
  <?php wp_nonce_field( 'quick-add', 'quick-add-nonce' ) ?>
245
  </p>
246
  </div>
248
  </form>
249
 
250
  <script type="text/javascript">
251
+ jQuery( function () {
252
 
253
+ jQuery( '.nav-tab-wrapper a' ).click( function () {
254
+ jQuery( '#insert-shortcode, #quick-add' ).hide();
255
+ jQuery( jQuery( this ).attr( 'href' ) ).show();
256
+ jQuery( 'a.nav-tab-active' ).removeClass( 'nav-tab-active' );
257
+ jQuery( this ).addClass( 'nav-tab-active' );
258
  return false;
259
+ } );
260
 
261
+ jQuery( '#quick-add' ).hide();
262
 
263
+ jQuery( 'body' ).on( 'click', '.insert_download', function () {
264
 
265
  var win = window.dialogArguments || opener || parent || top;
266
 
267
+ var download_id = jQuery( 'input[name="download_id"]:checked' ).val();
268
+ var template = jQuery( '#template_name' ).val();
269
+ var shortcode = '[download id="' + download_id + '"';
270
 
271
  if ( template )
272
  shortcode = shortcode + ' template="' + template + '"';
276
  win.send_to_editor( shortcode );
277
 
278
  return false;
279
+ } );
280
 
281
+ jQuery( '.add_manually' ).click( function () {
282
+ jQuery( '#plupload-upload-ui' ).slideUp();
283
+ jQuery( '#quick-add-details' ).slideDown();
284
  return false;
285
+ } );
286
 
287
  <?php
288
  $plupload_init = array(
313
  ?>
314
 
315
  // create the uploader and pass the config from above
316
+ var uploader = new plupload.Uploader( <?php echo json_encode( $plupload_init ); ?> );
317
 
318
  // checks if browser supports drag and drop upload, makes some css adjustments if necessary
319
+ uploader.bind( 'Init', function ( up ) {
320
+ var uploaddiv = jQuery( '#plupload-upload-ui' );
321
 
322
  if ( up.features.dragdrop ) {
323
+ uploaddiv.addClass( 'drag-drop' );
324
 
325
+ jQuery( '#drag-drop-area' )
326
+ .bind( 'dragover.wp-uploader', function () {
327
+ uploaddiv.addClass( 'drag-over' );
328
+ } )
329
+ .bind( 'dragleave.wp-uploader, drop.wp-uploader', function () {
330
+ uploaddiv.removeClass( 'drag-over' );
331
+ } );
332
 
333
  } else {
334
+ uploaddiv.removeClass( 'drag-drop' );
335
+ jQuery( '#drag-drop-area' ).unbind( '.wp-uploader' );
336
  }
337
+ } );
338
 
339
  uploader.init();
340
 
341
  // a file was added in the queue
342
+ uploader.bind( 'FilesAdded', function ( up, files ) {
343
+ var hundredmb = 100 * 1024 * 1024, max = parseInt( up.settings.max_file_size, 10 );
344
 
345
+ plupload.each( files, function ( file ) {
346
  if ( max > hundredmb && file.size > hundredmb && up.runtime != 'html5' ) {
347
  // file size error?
348
  } else {
349
+ jQuery( '.drag-drop-inside' ).html( '<p><?php _e( 'Please wait...', 'download-monitor' ); ?></p>' );
350
  }
351
+ } );
352
 
353
  up.refresh();
354
  up.start();
355
+ } );
356
 
357
  // a file was uploaded
358
+ uploader.bind( 'FileUploaded', function ( up, file, response ) {
359
+ jQuery( '#quick-add-details' ).find( 'input.download_url' ).val( response.response );
360
+ jQuery( '#quick-add-details' ).find( 'input.download_title' ).val( basename( response.response ) );
361
+ jQuery( '#plupload-upload-ui' ).slideUp();
362
+ jQuery( '#quick-add-details' ).slideDown();
363
+ } );
364
+
365
+ function basename( path ) {
366
+ return path.split( '/' ).reverse()[ 0 ];
367
  }
368
 
369
+ } );
370
  </script>
371
  <?php
372
  echo '</body></html>';
373
  }
374
+ }
 
 
includes/admin/class-dlm-admin-scripts.php ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
+
7
+ class DLM_Admin_Scripts {
8
+
9
+ /**
10
+ * Setup hooks
11
+ */
12
+ public function setup() {
13
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
14
+ }
15
+
16
+ /**
17
+ * Enqueue admin scripts
18
+ */
19
+ public function enqueue_scripts() {
20
+ global $pagenow, $post;
21
+
22
+ if ( $pagenow == 'post.php' || $pagenow == 'post-new.php' ) {
23
+
24
+ // Enqueue Edit Post JS
25
+ wp_enqueue_script(
26
+ 'dlm_edit_post',
27
+ plugins_url( '/assets/js/edit-post' . ( ( ! SCRIPT_DEBUG ) ? '.min' : '' ) . '.js', WP_DLM::get_plugin_file() ),
28
+ array( 'jquery' ),
29
+ DLM_VERSION
30
+ );
31
+
32
+ // Make JavaScript strings translatable
33
+ wp_localize_script( 'dlm_edit_post', 'dlm_ep_strings', $this->get_strings( 'edit-post' ) );
34
+
35
+ // Enqueue Downloadable Files Metabox JS
36
+ if ( ( $pagenow == 'post.php' && isset( $post ) && 'dlm_download' === $post->post_type ) || ( $pagenow == 'post-new.php' && isset( $_GET['post_type'] ) && 'dlm_download' == $_GET['post_type'] ) ) {
37
+
38
+ // Enqueue Edit Download JS
39
+ wp_enqueue_script(
40
+ 'dlm_edit_download',
41
+ plugins_url( '/assets/js/edit-download' . ( ( ! SCRIPT_DEBUG ) ? '.min' : '' ) . '.js', WP_DLM::get_plugin_file() ),
42
+ array( 'jquery' ),
43
+ DLM_VERSION
44
+ );
45
+
46
+ // Make JavaScript strings translatable
47
+ wp_localize_script( 'dlm_edit_download', 'dlm_ed_strings', $this->get_strings( 'edit-download' ) );
48
+ }
49
+
50
+
51
+ }
52
+
53
+ if ( 'edit.php' == $pagenow && isset( $_GET['page'] ) && ( 'download-monitor-settings' === $_GET['page'] || 'dlm-extensions' === $_GET['page'] ) ) {
54
+
55
+ // Enqueue Settings JS
56
+ wp_enqueue_script(
57
+ 'dlm_settings',
58
+ plugins_url( '/assets/js/settings' . ( ( ! SCRIPT_DEBUG ) ? '.min' : '' ) . '.js', WP_DLM::get_plugin_file() ),
59
+ array( 'jquery' ),
60
+ DLM_VERSION
61
+ );
62
+
63
+
64
+ if ( 'dlm-extensions' === $_GET['page'] ) {
65
+ // Enqueue Extesions JS
66
+ wp_enqueue_script(
67
+ 'dlm_extensions',
68
+ plugins_url( '/assets/js/extensions' . ( ( ! SCRIPT_DEBUG ) ? '.min' : '' ) . '.js', WP_DLM::get_plugin_file() ),
69
+ array( 'jquery' ),
70
+ DLM_VERSION
71
+ );
72
+ }
73
+
74
+ }
75
+
76
+
77
+ }
78
+
79
+ /**
80
+ * Get JS strings
81
+ *
82
+ * @param $file
83
+ *
84
+ * @return array
85
+ */
86
+ private function get_strings( $file ) {
87
+ switch ( $file ) {
88
+ case 'edit-post':
89
+ $strings = array(
90
+ 'insert_download' => __( 'Insert Download', 'download-monitor' )
91
+ );
92
+ break;
93
+ case 'edit-download':
94
+ $strings = array(
95
+ 'confirm_delete' => __( 'Are you sure you want to delete this file ? ', 'download - monitor' ),
96
+ 'browse_file' => __( 'Browse for a file', 'download - monitor' ),
97
+ );
98
+ break;
99
+ default:
100
+ $strings = array();
101
+ }
102
+
103
+ return $strings;
104
+ }
105
+
106
+ }
includes/admin/class-dlm-admin-writepanels.php CHANGED
@@ -1,6 +1,8 @@
1
  <?php
2
 
3
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
4
 
5
  /**
6
  * DLM_Admin class.
@@ -11,7 +13,6 @@ class DLM_Admin_Writepanels {
11
  * __construct function.
12
  *
13
  * @access public
14
- * @return void
15
  */
16
  public function __construct() {
17
  add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
@@ -26,13 +27,22 @@ class DLM_Admin_Writepanels {
26
  * @return void
27
  */
28
  public function add_meta_boxes() {
29
- add_meta_box( 'download-monitor-options', __( 'Download Options', 'download-monitor' ), array( $this, 'download_options' ), 'dlm_download', 'side', 'high' );
30
- add_meta_box( 'download-monitor-file', __( 'Downloadable Files/Versions', 'download-monitor' ), array( $this, 'download_files' ), 'dlm_download', 'normal', 'high' );
 
 
 
 
 
 
31
 
32
  // Excerpt
33
- if ( function_exists('wp_editor') ) {
34
  remove_meta_box( 'postexcerpt', 'dlm_download', 'normal' );
35
- add_meta_box( 'postexcerpt', __('Short Description', 'download-monitor'), array( $this, 'short_description' ), 'dlm_download', 'normal', 'high' );
 
 
 
36
  }
37
  }
38
 
@@ -40,7 +50,9 @@ class DLM_Admin_Writepanels {
40
  * download_options function.
41
  *
42
  * @access public
 
43
  * @param mixed $post
 
44
  * @return void
45
  */
46
  public function download_options( $post ) {
@@ -82,27 +94,34 @@ class DLM_Admin_Writepanels {
82
  * @return void
83
  */
84
  public function download_files() {
85
- global $post, $download_monitor;
86
 
87
  wp_nonce_field( 'save_meta_data', 'dlm_nonce' );
88
  ?>
89
  <div class="download_monitor_files dlm-metaboxes-wrapper">
90
 
 
 
 
 
 
91
  <?php do_action( 'dlm_download_monitor_files_writepanel_start' ); ?>
92
 
93
  <p class="toolbar">
94
- <a href="#" class="button plus add_file"><?php _e('Add file', 'download-monitor'); ?></a>
95
- <a href="#" class="close_all"><?php _e('Close all', 'download-monitor'); ?></a><a href="#" class="expand_all"><?php _e('Expand all', 'download-monitor'); ?></a>
 
96
  </p>
97
 
98
  <div class="dlm-metaboxes downloadable_files">
99
  <?php
100
- $i = -1;
101
- $files = get_posts( 'post_parent=' . $post->ID . '&post_type=dlm_download_version&orderby=menu_order&order=ASC&post_status=any&numberposts=-1' );
102
 
103
- if ( $files ) foreach ( $files as $file ) {
 
104
 
105
- $i++;
106
  $file_id = $file->ID;
107
  $file_version = ( $file_version = get_post_meta( $file->ID, '_version', true ) ) ? $file_version : '';
108
  $file_post_date = $file->post_date;
@@ -119,6 +138,7 @@ class DLM_Admin_Writepanels {
119
 
120
  include( 'html-downloadable-file-version.php' );
121
  }
 
122
  ?>
123
  </div>
124
 
@@ -126,249 +146,25 @@ class DLM_Admin_Writepanels {
126
 
127
  </div>
128
  <?php
129
- ob_start();
130
- ?>
131
- jQuery(function(){
132
-
133
- // Expand all files
134
- jQuery('.expand_all').click(function(){
135
- jQuery(this).closest('.dlm-metaboxes-wrapper').find('.dlm-metabox table').show();
136
- return false;
137
- });
138
-
139
- // Close all files
140
- jQuery('.close_all').click(function(){
141
- jQuery(this).closest('.dlm-metaboxes-wrapper').find('.dlm-metabox table').hide();
142
- return false;
143
- });
144
-
145
- // Open/close
146
- jQuery('.dlm-metaboxes-wrapper').on('click', '.dlm-metabox h3', function(event){
147
- // If the user clicks on some form input inside the h3, like a select list (for variations), the box should not be toggled
148
- if (jQuery(event.target).filter(':input, option').length) return;
149
-
150
- jQuery(this).next('.dlm-metabox-content').toggle();
151
- });
152
-
153
- // Closes all to begin
154
- jQuery('.dlm-metabox.closed').each(function(){
155
- jQuery(this).find('.dlm-metabox-content').hide();
156
- });
157
-
158
- // Date picker
159
- jQuery( ".date-picker-field" ).datepicker({
160
- dateFormat: "yy-mm-dd",
161
- numberOfMonths: 1,
162
- showButtonPanel: true,
163
- });
164
-
165
- // Ordering
166
- jQuery('.downloadable_files').sortable({
167
- items:'.downloadable_file',
168
- cursor:'move',
169
- axis:'y',
170
- handle: 'h3',
171
- scrollSensitivity:40,
172
- forcePlaceholderSize: true,
173
- helper: 'clone',
174
- opacity: 0.65,
175
- placeholder: 'dlm-metabox-sortable-placeholder',
176
- start:function(event,ui){
177
- ui.item.css('background-color','#f6f6f6');
178
- },
179
- stop:function(event,ui){
180
- ui.item.removeAttr('style');
181
- downloadable_file_row_indexes();
182
- }
183
- });
184
-
185
- function downloadable_file_row_indexes() {
186
- jQuery('.downloadable_files .downloadable_file').each(function(index, el){
187
- jQuery('.file_menu_order', el).val( parseInt( jQuery(el).index('.downloadable_files .downloadable_file') ) );
188
- });
189
- };
190
-
191
- // Add a file
192
- jQuery('.download_monitor_files').on('click', 'a.add_file', function(){
193
-
194
- jQuery('.download_monitor_files').block({ message: null, overlayCSS: { background: '#fff url(<?php echo $download_monitor->plugin_url(); ?>/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6 } });
195
-
196
- var size = jQuery('.downloadable_files .downloadable_file').size();
197
-
198
- var data = {
199
- action: 'download_monitor_add_file',
200
- post_id: <?php echo $post->ID; ?>,
201
- size: size,
202
- security: '<?php echo wp_create_nonce("add-file"); ?>'
203
- };
204
-
205
- jQuery.post('<?php echo admin_url('admin-ajax.php'); ?>', data, function(response) {
206
-
207
- jQuery('.downloadable_files').prepend( response );
208
-
209
- downloadable_file_row_indexes();
210
-
211
- jQuery('.download_monitor_files').unblock();
212
-
213
- // Date picker
214
- jQuery( ".date-picker-field" ).datepicker({
215
- dateFormat: "yy-mm-dd",
216
- numberOfMonths: 1,
217
- showButtonPanel: true,
218
- });
219
- });
220
-
221
- return false;
222
-
223
- });
224
-
225
- // Remove a file
226
- jQuery('.download_monitor_files').on('click', 'button.remove_file', function(e){
227
- e.preventDefault();
228
- var answer = confirm('<?php _e( 'Are you sure you want to delete this file?', 'download-monitor' ); ?>');
229
- if ( answer ) {
230
-
231
- var el = jQuery(this).closest('.downloadable_file');
232
- var file_id = el.attr('data-file');
233
-
234
- if ( file_id > 0 ) {
235
-
236
- jQuery(el).block({ message: null, overlayCSS: { background: '#fff url(<?php echo $download_monitor->plugin_url(); ?>/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6 } });
237
-
238
- var data = {
239
- action: 'download_monitor_remove_file',
240
- file_id: file_id,
241
- download_id: '<?php echo $post->ID; ?>',
242
- security: '<?php echo wp_create_nonce( "remove-file" ); ?>'
243
- };
244
-
245
- jQuery.post('<?php echo admin_url('admin-ajax.php'); ?>', data, function(response) {
246
- jQuery(el).fadeOut('300').remove();
247
- });
248
-
249
- } else {
250
- jQuery(el).fadeOut('300').remove();
251
- }
252
- }
253
- return false;
254
- });
255
-
256
- // Browse for file
257
- jQuery('.download_monitor_files').on('click', 'a.dlm_browse_for_file', function(e){
258
-
259
- downloadable_files_field = jQuery(this).closest('.downloadable_file').find('textarea[name^="downloadable_file_urls"]');
260
-
261
- window.send_to_editor = window.send_to_browse_file_url;
262
-
263
- tb_show('<?php esc_attr_e( 'Browse for a file', 'download-monitor' ); ?>', 'media-upload.php?post_id=<?php echo $post->ID; ?>&amp;type=downloadable_file_browser&amp;from=wpdlm01&amp;TB_iframe=true');
264
-
265
- return false;
266
- });
267
-
268
- window.send_to_browse_file_url = function(html) {
269
-
270
- if ( html ) {
271
- old = jQuery.trim( jQuery(downloadable_files_field).val() );
272
- if ( old ) old = old + "\n";
273
- jQuery(downloadable_files_field).val( old + html );
274
- }
275
-
276
- tb_remove();
277
-
278
- window.send_to_editor = window.send_to_editor_default;
279
- }
280
-
281
- // Uploading files
282
- var dlm_upload_file_frame;
283
-
284
- jQuery(document).on( 'click', '.dlm_upload_file', function( event ){
285
-
286
- var $el = $(this);
287
- var $file_path_field = $el.parent().parent().find('.downloadable_file_urls');
288
- var file_paths = $file_path_field.val();
289
-
290
- event.preventDefault();
291
-
292
- // If the media frame already exists, reopen it.
293
- if ( dlm_upload_file_frame ) {
294
- dlm_upload_file_frame.open();
295
- return;
296
- }
297
-
298
- var downloadable_file_states = [
299
- // Main states.
300
- new wp.media.controller.Library({
301
- library: wp.media.query(),
302
- multiple: true,
303
- title: $el.data('choose'),
304
- priority: 20,
305
- filterable: 'uploaded',
306
- })
307
- ];
308
-
309
- // Create the media frame.
310
- dlm_upload_file_frame = wp.media.frames.downloadable_file = wp.media({
311
- // Set the title of the modal.
312
- title: $el.data('choose'),
313
- library: {
314
- type: ''
315
- },
316
- button: {
317
- text: $el.data('update'),
318
- },
319
- multiple: true,
320
- states: downloadable_file_states,
321
- });
322
-
323
- // When an image is selected, run a callback.
324
- dlm_upload_file_frame.on( 'select', function() {
325
-
326
- var selection = dlm_upload_file_frame.state().get('selection');
327
-
328
- selection.map( function( attachment ) {
329
-
330
- attachment = attachment.toJSON();
331
-
332
- if ( attachment.url )
333
- file_paths = file_paths ? file_paths + "\n" + attachment.url : attachment.url
334
-
335
- } );
336
-
337
- $file_path_field.val( file_paths );
338
- });
339
-
340
- // Set post to 0 and set our custom type
341
- dlm_upload_file_frame.on( 'ready', function() {
342
- dlm_upload_file_frame.uploader.options.uploader.params = {
343
- type: 'dlm_download'
344
- };
345
- });
346
-
347
- // Finally, open the modal.
348
- dlm_upload_file_frame.open();
349
- });
350
-
351
- });
352
- <?php
353
- $js_code = ob_get_clean();
354
- $download_monitor->add_inline_js( $js_code );
355
  }
356
 
357
  /**
358
  * short_description function.
359
  *
360
  * @access public
 
361
  * @param mixed $post
 
362
  * @return void
363
  */
364
  public function short_description( $post ) {
365
  $settings = array(
366
- 'quicktags' => array( 'buttons' => 'em,strong,link' ),
367
- 'textarea_name' => 'excerpt',
368
- 'quicktags' => true,
369
- 'tinymce' => true,
370
- 'editor_css' => '<style>#wp-excerpt-editor-container .wp-editor-area{height:200px; width:100%;}</style>'
371
- );
372
 
373
  wp_editor( htmlspecialchars_decode( $post->post_excerpt ), 'excerpt', $settings );
374
  }
@@ -377,18 +173,34 @@ class DLM_Admin_Writepanels {
377
  * save_post function.
378
  *
379
  * @access public
 
380
  * @param mixed $post_id
381
  * @param mixed $post
 
382
  * @return void
383
  */
384
  public function save_post( $post_id, $post ) {
385
- if ( empty( $post_id ) || empty( $post ) || empty( $_POST ) ) return;
386
- if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return;
387
- if ( is_int( wp_is_post_revision( $post ) ) ) return;
388
- if ( is_int( wp_is_post_autosave( $post ) ) ) return;
389
- if ( empty($_POST['dlm_nonce']) || ! wp_verify_nonce( $_POST['dlm_nonce'], 'save_meta_data' ) ) return;
390
- if ( ! current_user_can( 'edit_post', $post_id ) ) return;
391
- if ( $post->post_type != 'dlm_download' ) return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
392
 
393
  do_action( 'dlm_save_meta_boxes', $post_id, $post );
394
  }
@@ -397,16 +209,18 @@ class DLM_Admin_Writepanels {
397
  * save function.
398
  *
399
  * @access public
 
400
  * @param mixed $post_id
401
  * @param mixed $post
 
402
  * @return void
403
  */
404
  public function save_meta_boxes( $post_id, $post ) {
405
- global $wpdb, $download_monitor;
406
 
407
  // Update options
408
- $_featured = ( isset( $_POST['_featured'] ) ) ? 'yes' : 'no';
409
- $_members_only = ( isset( $_POST['_members_only'] ) ) ? 'yes' : 'no';
410
  $_redirect_only = ( isset( $_POST['_redirect_only'] ) ) ? 'yes' : 'no';
411
 
412
  update_post_meta( $post_id, '_featured', $_featured );
@@ -418,19 +232,20 @@ class DLM_Admin_Writepanels {
418
  // Process files
419
  if ( isset( $_POST['downloadable_file_id'] ) ) {
420
 
421
- $downloadable_file_id = $_POST['downloadable_file_id'];
422
- $downloadable_file_menu_order = $_POST['downloadable_file_menu_order'];
423
- $downloadable_file_version = $_POST['downloadable_file_version'];
424
- $downloadable_file_urls = $_POST['downloadable_file_urls'];
425
- $downloadable_file_date = $_POST['downloadable_file_date'];
426
- $downloadable_file_date_hour = $_POST['downloadable_file_date_hour'];
427
- $downloadable_file_date_minute = $_POST['downloadable_file_date_minute'];
428
- $downloadable_file_download_count = $_POST['downloadable_file_download_count'];
429
 
430
  for ( $i = 0; $i <= max( array_keys( $downloadable_file_id ) ); $i ++ ) {
431
 
432
- if ( ! isset( $downloadable_file_id[ $i ] ) )
433
  continue;
 
434
 
435
  $file_id = absint( $downloadable_file_id[ $i ] );
436
  $file_menu_order = absint( $downloadable_file_menu_order[ $i ] );
@@ -441,15 +256,16 @@ class DLM_Admin_Writepanels {
441
  $file_download_count = sanitize_text_field( $downloadable_file_download_count[ $i ] );
442
  $files = array_filter( array_map( 'trim', explode( "\n", $downloadable_file_urls[ $i ] ) ) );
443
 
444
- if ( ! $file_id )
445
  continue;
 
446
 
447
  // Generate a useful post title
448
  $file_post_title = 'Download #' . $post_id . ' File Version';
449
 
450
  // Generate date
451
  if ( empty( $file_date ) ) {
452
- $date = current_time('timestamp');
453
  } else {
454
  $date = strtotime( $file_date . ' ' . $file_date_hour . ':' . $file_date_minute . ':00' );
455
  }
@@ -462,16 +278,19 @@ class DLM_Admin_Writepanels {
462
  'post_date' => date( 'Y-m-d H:i:s', $date )
463
  ), array( 'ID' => $file_id ) );
464
 
 
 
 
465
  // Update post meta
466
  update_post_meta( $file_id, '_version', $file_version );
467
- update_post_meta( $file_id, '_files', $download_monitor->json_encode_files( $files ) );
468
 
469
- $filesize = -1;
470
  $main_file_path = current( $files );
471
 
472
  if ( $main_file_path ) {
473
- $filesize = $download_monitor->get_filesize( $main_file_path );
474
- $hashes = $download_monitor->get_file_hashes( $main_file_path );
475
  update_post_meta( $file_id, '_filesize', $filesize );
476
  update_post_meta( $file_id, '_md5', $hashes['md5'] );
477
  update_post_meta( $file_id, '_sha1', $hashes['sha1'] );
@@ -497,8 +316,9 @@ class DLM_Admin_Writepanels {
497
  // Sync download_count
498
  update_post_meta( $post_id, '_download_count', $total_download_count );
499
 
 
 
 
500
  do_action( 'dlm_save_metabox', $post_id, $post );
501
  }
502
- }
503
-
504
- new DLM_Admin_Writepanels();
1
  <?php
2
 
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
 
7
  /**
8
  * DLM_Admin class.
13
  * __construct function.
14
  *
15
  * @access public
 
16
  */
17
  public function __construct() {
18
  add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
27
  * @return void
28
  */
29
  public function add_meta_boxes() {
30
+ add_meta_box( 'download-monitor-options', __( 'Download Options', 'download-monitor' ), array(
31
+ $this,
32
+ 'download_options'
33
+ ), 'dlm_download', 'side', 'high' );
34
+ add_meta_box( 'download-monitor-file', __( 'Downloadable Files/Versions', 'download-monitor' ), array(
35
+ $this,
36
+ 'download_files'
37
+ ), 'dlm_download', 'normal', 'high' );
38
 
39
  // Excerpt
40
+ if ( function_exists( 'wp_editor' ) ) {
41
  remove_meta_box( 'postexcerpt', 'dlm_download', 'normal' );
42
+ add_meta_box( 'postexcerpt', __( 'Short Description', 'download-monitor' ), array(
43
+ $this,
44
+ 'short_description'
45
+ ), 'dlm_download', 'normal', 'high' );
46
  }
47
  }
48
 
50
  * download_options function.
51
  *
52
  * @access public
53
+ *
54
  * @param mixed $post
55
+ *
56
  * @return void
57
  */
58
  public function download_options( $post ) {
94
  * @return void
95
  */
96
  public function download_files() {
97
+ global $post;
98
 
99
  wp_nonce_field( 'save_meta_data', 'dlm_nonce' );
100
  ?>
101
  <div class="download_monitor_files dlm-metaboxes-wrapper">
102
 
103
+ <input type="hidden" name="dlm_post_id" id="dlm-post-id" value="<?php echo $post->ID; ?>" />
104
+ <input type="hidden" name="dlm_post_id" id="dlm-plugin-url" value="<?php echo WP_DLM::get_plugin_url(); ?>" />
105
+ <input type="hidden" name="dlm_post_id" id="dlm-ajax-nonce-add-file" value="<?php echo wp_create_nonce( "add-file" ); ?>" />
106
+ <input type="hidden" name="dlm_post_id" id="dlm-ajax-nonce-remove-file" value="<?php wp_create_nonce( "remove-file" ); ?>" />
107
+
108
  <?php do_action( 'dlm_download_monitor_files_writepanel_start' ); ?>
109
 
110
  <p class="toolbar">
111
+ <a href="#" class="button plus add_file"><?php _e( 'Add file', 'download-monitor' ); ?></a>
112
+ <a href="#" class="close_all"><?php _e( 'Close all', 'download-monitor' ); ?></a>
113
+ <a href="#" class="expand_all"><?php _e( 'Expand all', 'download-monitor' ); ?></a>
114
  </p>
115
 
116
  <div class="dlm-metaboxes downloadable_files">
117
  <?php
118
+ $i = - 1;
119
+ $files = get_posts( 'post_parent=' . $post->ID . '&post_type=dlm_download_version&orderby=menu_order&order=ASC&post_status=any&numberposts=-1' );
120
 
121
+ if ( $files ) {
122
+ foreach ( $files as $file ) {
123
 
124
+ $i ++;
125
  $file_id = $file->ID;
126
  $file_version = ( $file_version = get_post_meta( $file->ID, '_version', true ) ) ? $file_version : '';
127
  $file_post_date = $file->post_date;
138
 
139
  include( 'html-downloadable-file-version.php' );
140
  }
141
+ }
142
  ?>
143
  </div>
144
 
146
 
147
  </div>
148
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  }
150
 
151
  /**
152
  * short_description function.
153
  *
154
  * @access public
155
+ *
156
  * @param mixed $post
157
+ *
158
  * @return void
159
  */
160
  public function short_description( $post ) {
161
  $settings = array(
162
+ 'quicktags' => array( 'buttons' => 'em,strong,link' ),
163
+ 'textarea_name' => 'excerpt',
164
+ 'quicktags' => true,
165
+ 'tinymce' => true,
166
+ 'editor_css' => '<style>#wp-excerpt-editor-container .wp-editor-area{height:200px; width:100%;}</style>'
167
+ );
168
 
169
  wp_editor( htmlspecialchars_decode( $post->post_excerpt ), 'excerpt', $settings );
170
  }
173
  * save_post function.
174
  *
175
  * @access public
176
+ *
177
  * @param mixed $post_id
178
  * @param mixed $post
179
+ *
180
  * @return void
181
  */
182
  public function save_post( $post_id, $post ) {
183
+ if ( empty( $post_id ) || empty( $post ) || empty( $_POST ) ) {
184
+ return;
185
+ }
186
+ if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
187
+ return;
188
+ }
189
+ if ( is_int( wp_is_post_revision( $post ) ) ) {
190
+ return;
191
+ }
192
+ if ( is_int( wp_is_post_autosave( $post ) ) ) {
193
+ return;
194
+ }
195
+ if ( empty( $_POST['dlm_nonce'] ) || ! wp_verify_nonce( $_POST['dlm_nonce'], 'save_meta_data' ) ) {
196
+ return;
197
+ }
198
+ if ( ! current_user_can( 'edit_post', $post_id ) ) {
199
+ return;
200
+ }
201
+ if ( $post->post_type != 'dlm_download' ) {
202
+ return;
203
+ }
204
 
205
  do_action( 'dlm_save_meta_boxes', $post_id, $post );
206
  }
209
  * save function.
210
  *
211
  * @access public
212
+ *
213
  * @param mixed $post_id
214
  * @param mixed $post
215
+ *
216
  * @return void
217
  */
218
  public function save_meta_boxes( $post_id, $post ) {
219
+ global $wpdb;
220
 
221
  // Update options
222
+ $_featured = ( isset( $_POST['_featured'] ) ) ? 'yes' : 'no';
223
+ $_members_only = ( isset( $_POST['_members_only'] ) ) ? 'yes' : 'no';
224
  $_redirect_only = ( isset( $_POST['_redirect_only'] ) ) ? 'yes' : 'no';
225
 
226
  update_post_meta( $post_id, '_featured', $_featured );
232
  // Process files
233
  if ( isset( $_POST['downloadable_file_id'] ) ) {
234
 
235
+ $downloadable_file_id = $_POST['downloadable_file_id'];
236
+ $downloadable_file_menu_order = $_POST['downloadable_file_menu_order'];
237
+ $downloadable_file_version = $_POST['downloadable_file_version'];
238
+ $downloadable_file_urls = $_POST['downloadable_file_urls'];
239
+ $downloadable_file_date = $_POST['downloadable_file_date'];
240
+ $downloadable_file_date_hour = $_POST['downloadable_file_date_hour'];
241
+ $downloadable_file_date_minute = $_POST['downloadable_file_date_minute'];
242
+ $downloadable_file_download_count = $_POST['downloadable_file_download_count'];
243
 
244
  for ( $i = 0; $i <= max( array_keys( $downloadable_file_id ) ); $i ++ ) {
245
 
246
+ if ( ! isset( $downloadable_file_id[ $i ] ) ) {
247
  continue;
248
+ }
249
 
250
  $file_id = absint( $downloadable_file_id[ $i ] );
251
  $file_menu_order = absint( $downloadable_file_menu_order[ $i ] );
256
  $file_download_count = sanitize_text_field( $downloadable_file_download_count[ $i ] );
257
  $files = array_filter( array_map( 'trim', explode( "\n", $downloadable_file_urls[ $i ] ) ) );
258
 
259
+ if ( ! $file_id ) {
260
  continue;
261
+ }
262
 
263
  // Generate a useful post title
264
  $file_post_title = 'Download #' . $post_id . ' File Version';
265
 
266
  // Generate date
267
  if ( empty( $file_date ) ) {
268
+ $date = current_time( 'timestamp' );
269
  } else {
270
  $date = strtotime( $file_date . ' ' . $file_date_hour . ':' . $file_date_minute . ':00' );
271
  }
278
  'post_date' => date( 'Y-m-d H:i:s', $date )
279
  ), array( 'ID' => $file_id ) );
280
 
281
+ // File Manager
282
+ $file_manager = new DLM_File_Manager();
283
+
284
  // Update post meta
285
  update_post_meta( $file_id, '_version', $file_version );
286
+ update_post_meta( $file_id, '_files', $file_manager->json_encode_files( $files ) );
287
 
288
+ $filesize = - 1;
289
  $main_file_path = current( $files );
290
 
291
  if ( $main_file_path ) {
292
+ $filesize = $file_manager->get_file_size( $main_file_path );
293
+ $hashes = $file_manager->get_file_hashes( $main_file_path );
294
  update_post_meta( $file_id, '_filesize', $filesize );
295
  update_post_meta( $file_id, '_md5', $hashes['md5'] );
296
  update_post_meta( $file_id, '_sha1', $hashes['sha1'] );
316
  // Sync download_count
317
  update_post_meta( $post_id, '_download_count', $total_download_count );
318
 
319
+ // Delete transients
320
+ delete_transient( 'dlm_file_version_ids_' . $post_id );
321
+
322
  do_action( 'dlm_save_metabox', $post_id, $post );
323
  }
324
+ }
 
 
includes/admin/class-dlm-admin.php CHANGED
@@ -1,6 +1,8 @@
1
  <?php
2
 
3
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
4
 
5
  /**
6
  * DLM_Admin class.
@@ -10,17 +12,9 @@ class DLM_Admin {
10
  private $settings;
11
 
12
  /**
13
- * __construct function.
14
- *
15
- * @access public
16
- * @return void
17
  */
18
- public function __construct() {
19
- include_once( 'class-dlm-admin-writepanels.php' );
20
- include_once( 'class-dlm-admin-media-browser.php' );
21
- include_once( 'class-dlm-admin-cpt.php' );
22
- include_once( 'class-dlm-admin-insert.php' );
23
-
24
  // Directory protection
25
  add_filter( 'mod_rewrite_rules', array( $this, 'ms_files_protection' ) );
26
  add_filter( 'upload_dir', array( $this, 'upload_dir' ) );
@@ -37,16 +31,18 @@ class DLM_Admin {
37
  * ms_files_protection function.
38
  *
39
  * @access public
 
40
  * @param mixed $rewrite
 
41
  * @return void
42
  */
43
  public function ms_files_protection( $rewrite ) {
44
- global $wp_rewrite;
45
 
46
- if ( ! is_multisite() )
47
- return $rewrite;
 
48
 
49
- $rule = "\n# DLM Rules - Protect Files from ms-files.php\n\n";
50
  $rule .= "<IfModule mod_rewrite.c>\n";
51
  $rule .= "RewriteEngine On\n";
52
  $rule .= "RewriteCond %{QUERY_STRING} file=dlm_uploads/ [NC]\n";
@@ -60,15 +56,17 @@ class DLM_Admin {
60
  * upload_dir function.
61
  *
62
  * @access public
 
63
  * @param mixed $pathdata
 
64
  * @return void
65
  */
66
  public function upload_dir( $pathdata ) {
67
 
68
- if ( isset( $_POST['type'] ) && $_POST['type'] == 'dlm_download' ) {
69
  if ( empty( $pathdata['subdir'] ) ) {
70
  $pathdata['path'] = $pathdata['path'] . '/dlm_uploads';
71
- $pathdata['url'] = $pathdata['url']. '/dlm_uploads';
72
  $pathdata['subdir'] = '/dlm_uploads';
73
  } else {
74
  $new_subdir = '/dlm_uploads' . $pathdata['subdir'];
@@ -91,16 +89,16 @@ class DLM_Admin {
91
  private function init_settings() {
92
  $this->settings = apply_filters( 'download_monitor_settings',
93
  array(
94
- 'general' => array(
95
  __( 'General', 'download-monitor' ),
96
  array(
97
  array(
98
- 'name' => 'dlm_default_template',
99
- 'std' => '',
100
- 'label' => __( 'Default Template', 'download-monitor' ),
101
- 'desc' => __( 'Choose which template is used for <code>[download]</code> shortcodes by default (this can be overridden by the <code>format</code> argument).', 'download-monitor' ),
102
- 'type' => 'select',
103
- 'options' => array(
104
  '' => __( 'Default - Title and count', 'download-monitor' ),
105
  'button' => __( 'Button - CSS styled button showing title and count', 'download-monitor' ),
106
  'box' => __( 'Box - Box showing thumbnail, title, count, filename and filesize.', 'download-monitor' ),
@@ -111,34 +109,34 @@ class DLM_Admin {
111
  )
112
  ),
113
  array(
114
- 'name' => 'dlm_custom_template',
115
- 'std' => '',
116
- 'label' => __( 'Custom Template', 'download-monitor' ),
117
- 'desc' => __( 'Leaving this blank will use the default <code>content-download.php</code> template file. If you enter, for example, <code>image</code>, the <code>content-download-image.php</code> template will be used instead. You can add custom templates inside your theme folder.', 'download-monitor' )
118
  ),
119
  array(
120
- 'name' => 'dlm_generate_hash_md5',
121
- 'std' => '0',
122
- 'label' => __( 'MD5 hashes', 'download-monitor' ),
123
- 'cb_label' => __( 'Generate MD5 hash for uploaded files', 'download-monitor' ),
124
- 'desc' => '',
125
- 'type' => 'checkbox'
126
  ),
127
  array(
128
- 'name' => 'dlm_generate_hash_sha1',
129
- 'std' => '0',
130
- 'label' => __( 'SHA1 hashes', 'download-monitor' ),
131
- 'cb_label' => __( 'Generate SHA1 hash for uploaded files', 'download-monitor' ),
132
- 'desc' => '',
133
- 'type' => 'checkbox'
134
  ),
135
  array(
136
- 'name' => 'dlm_generate_hash_crc32b',
137
- 'std' => '0',
138
- 'label' => __( 'CRC32B hashes', 'download-monitor' ),
139
- 'cb_label' => __( 'Generate CRC32B hash for uploaded files', 'download-monitor' ),
140
- 'desc' => __( 'Hashes can optionally be output via shortcodes, but may cause performance issues with large files.', 'download-monitor' ),
141
- 'type' => 'checkbox'
142
  ),
143
  ),
144
  ),
@@ -146,67 +144,67 @@ class DLM_Admin {
146
  __( 'Endpoint', 'download-monitor' ),
147
  array(
148
  array(
149
- 'name' => 'dlm_download_endpoint',
150
- 'std' => 'download',
151
- 'placeholder' => __( 'download', 'download-monitor' ),
152
- 'label' => __( 'Download Endpoint', 'download-monitor' ),
153
- 'desc' => sprintf( __( 'Define what endpoint should be used for download links. By default this will be <code>%s</code>.', 'download-monitor' ), home_url( '/download/' ) )
154
  ),
155
  array(
156
- 'name' => 'dlm_download_endpoint_value',
157
- 'std' => 'ID',
158
- 'label' => __( 'Endpoint Value', 'download-monitor' ),
159
- 'desc' => sprintf( __( 'Define what unique value should be used on the end of your endpoint to identify the downloadable file. e.g. ID would give a link like <code>%s</code>', 'download-monitor' ), home_url( '/download/10/' ) ),
160
- 'type' => 'select',
161
- 'options' => array(
162
  'ID' => __( 'Download ID', 'download-monitor' ),
163
  'slug' => __( 'Download slug', 'download-monitor' )
164
  )
165
  ),
166
  array(
167
- 'name' => 'dlm_xsendfile_enabled',
168
- 'std' => '',
169
- 'label' => __( 'X-Accel-Redirect / X-Sendfile', 'download-monitor' ),
170
- 'cb_label' => __( 'Enable', 'download-monitor' ),
171
- 'desc' => __( 'If supported, <code>X-Accel-Redirect</code> / <code>X-Sendfile</code> can be used to serve downloads instead of PHP (server requires <code>mod_xsendfile</code>).', 'download-monitor' ),
172
- 'type' => 'checkbox'
173
  ),
174
  array(
175
- 'name' => 'dlm_hotlink_protection_enabled',
176
- 'std' => '',
177
- 'label' => __( 'Prevent hotlinking', 'download-monitor' ),
178
- 'cb_label' => __( 'Enable', 'download-monitor' ),
179
- 'desc' => __( 'If enabled, the download handler will check the PHP referer to see if it originated from your site and if not, redirect them to the homepage.', 'download-monitor' ),
180
- 'type' => 'checkbox'
181
  )
182
  )
183
  ),
184
- 'logging' => array(
185
  __( 'Logging', 'download-monitor' ),
186
  array(
187
  array(
188
- 'name' => 'dlm_enable_logging',
189
- 'cb_label' => __( 'Enable', 'download-monitor' ),
190
- 'std' => '1',
191
- 'label' => __( 'Download Log', 'download-monitor' ),
192
- 'desc' => __( 'Log download attempts, IP addresses and more.', 'download-monitor' ),
193
- 'type' => 'checkbox'
194
  ),
195
  array(
196
- 'name' => 'dlm_ip_blacklist',
197
- 'std' => '192.168.0.*',
198
- 'label' => __( 'Blacklist IPs', 'download-monitor' ),
199
- 'desc' => __( 'List IP Addresses to blacklist, 1 per line. Use <code>*</code> for a wildcard.', 'download-monitor' ),
200
- 'placeholder' => '',
201
- 'type' => 'textarea'
202
  ),
203
  array(
204
- 'name' => 'dlm_user_agent_blacklist',
205
- 'std' => 'Googlebot',
206
- 'label' => __( 'Blacklist user agents', 'download-monitor' ),
207
- 'desc' => __( 'List browser user agents to blacklist, 1 per line.', 'download-monitor' ),
208
  'placeholder' => '',
209
- 'type' => 'textarea'
210
  ),
211
  )
212
  )
@@ -225,8 +223,9 @@ class DLM_Admin {
225
 
226
  foreach ( $this->settings as $section ) {
227
  foreach ( $section[1] as $option ) {
228
- if ( isset( $option['std'] ) )
229
  add_option( $option['name'], $option['std'] );
 
230
  register_setting( 'download-monitor', $option['name'] );
231
  }
232
  }
@@ -239,33 +238,39 @@ class DLM_Admin {
239
  * @return void
240
  */
241
  public function admin_enqueue_scripts( $hook ) {
242
- global $download_monitor, $post;
243
 
244
- wp_enqueue_style( 'download_monitor_menu_css', $download_monitor->plugin_url() . '/assets/css/menu.css' );
245
 
246
- if ( $hook == 'index.php' )
247
- wp_enqueue_style( 'download_monitor_dashboard_css', $download_monitor->plugin_url() . '/assets/css/dashboard.css' );
 
248
 
249
  $enqueue = false;
250
 
251
- if ( $hook == 'post-new.php' || $hook == 'post.php' || $hook == 'edit.php' )
252
- if ( ( ! empty( $_GET['post_type'] ) && $_GET['post_type'] == 'dlm_download' ) || ( ! empty( $post->post_type ) && 'dlm_download' === $post->post_type ) )
253
  $enqueue = true;
 
 
254
 
255
- if ( strstr( $hook, 'dlm_download_page' ) )
256
  $enqueue = true;
 
257
 
258
- if ( $hook == 'edit-tags.php' && strstr( $_GET['taxonomy'], 'dlm_download' ) )
259
  $enqueue = true;
 
260
 
261
- if ( ! $enqueue )
262
- return;
 
263
 
264
- wp_enqueue_script( 'jquery-blockui', $download_monitor->plugin_url() . '/assets/js/blockui.min.js', array( 'jquery' ), '2.61' );
265
  wp_enqueue_script( 'jquery-ui-sortable' );
266
  wp_enqueue_script( 'jquery-ui-datepicker' );
267
- wp_enqueue_style( 'jquery-ui-style', (is_ssl()) ? 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' : 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' );
268
- wp_enqueue_style( 'download_monitor_admin_css', $download_monitor->plugin_url() . '/assets/css/admin.css', array( 'dashicons' ) );
269
  }
270
 
271
  /**
@@ -275,21 +280,38 @@ class DLM_Admin {
275
  * @return void
276
  */
277
  public function admin_menu() {
278
- if ( get_option( 'dlm_enable_logging' ) == 1 )
279
- add_submenu_page( 'edit.php?post_type=dlm_download', __( 'Logs', 'download-monitor' ), __( 'Logs', 'download-monitor' ), 'manage_options', 'download-monitor-logs', array( $this, 'log_viewer' ) );
280
 
281
- add_submenu_page( 'edit.php?post_type=dlm_download', __( 'Settings', 'download-monitor' ), __( 'Settings', 'download-monitor' ), 'manage_options', 'download-monitor-settings', array( $this, 'settings_page' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
282
 
283
- if ( apply_filters( 'dlm_show_addons_page', true ) )
284
- add_submenu_page( 'edit.php?post_type=dlm_download', __( 'Download Monitor Add-ons', 'download-monitor' ), __( 'Add-ons', 'download-monitor' ) , 'manage_options', 'dlm-addons', array( $this, 'addons_page' ) );
285
  }
286
 
287
  /**
288
- * Output addons page
289
  */
290
- public function addons_page() {
291
- $addons = include( 'class-dlm-addons.php' );
292
- $addons->output();
293
  }
294
 
295
  /**
@@ -299,8 +321,6 @@ class DLM_Admin {
299
  * @return void
300
  */
301
  public function settings_page() {
302
- global $download_monitor;
303
-
304
  $this->init_settings();
305
  ?>
306
  <div class="wrap">
@@ -309,108 +329,105 @@ class DLM_Admin {
309
  <?php settings_fields( 'download-monitor' ); ?>
310
  <?php screen_icon(); ?>
311
 
312
- <h2 class="nav-tab-wrapper">
313
- <?php
314
- foreach ( $this->settings as $key => $section ) {
315
- echo '<a href="#settings-' . sanitize_title( $key ) . '" class="nav-tab">' . esc_html( $section[0] ) . '</a>';
316
- }
317
- ?>
318
- </h2><br/>
319
 
320
  <?php
321
- if ( ! empty( $_GET['settings-updated'] ) ) {
322
- flush_rewrite_rules();
323
- echo '<div class="updated fade"><p>' . __( 'Settings successfully saved', 'download-monitor' ) . '</p></div>';
324
- }
325
 
326
- foreach ( $this->settings as $key => $section ) {
327
 
328
- echo '<div id="settings-' . sanitize_title( $key ) . '" class="settings_panel">';
329
 
330
- echo '<table class="form-table">';
331
 
332
- foreach ( $section[1] as $option ) {
333
 
334
- $placeholder = ( ! empty( $option['placeholder'] ) ) ? 'placeholder="' . $option['placeholder'] . '"' : '';
335
 
336
- echo '<tr valign="top"><th scope="row"><label for="setting-' . $option['name'] . '">' . $option['label'] . '</a></th><td>';
337
 
338
- if ( ! isset( $option['type'] ) ) $option['type'] = '';
 
 
339
 
340
- $value = get_option( $option['name'] );
341
 
342
- switch ( $option['type'] ) {
343
 
344
- case "checkbox" :
345
 
346
- ?><label><input id="setting-<?php echo $option['name']; ?>" name="<?php echo $option['name']; ?>" type="checkbox" value="1" <?php checked( '1', $value ); ?> /> <?php echo $option['cb_label']; ?></label><?php
 
 
 
347
 
348
- if ( $option['desc'] )
349
- echo ' <p class="description">' . $option['desc'] . '</p>';
 
350
 
351
  break;
352
- case "textarea" :
353
 
354
- ?><textarea id="setting-<?php echo $option['name']; ?>" class="large-text" cols="50" rows="3" name="<?php echo $option['name']; ?>" <?php echo $placeholder; ?>><?php echo esc_textarea( $value ); ?></textarea><?php
 
 
355
 
356
- if ( $option['desc'] )
357
- echo ' <p class="description">' . $option['desc'] . '</p>';
 
358
 
359
  break;
360
- case "select" :
361
 
362
- ?><select id="setting-<?php echo $option['name']; ?>" class="regular-text" name="<?php echo $option['name']; ?>"><?php
363
- foreach( $option['options'] as $key => $name )
364
- echo '<option value="' . esc_attr( $key ) . '" ' . selected( $value, $key, false ) . '>' . esc_html( $name ) . '</option>';
365
- ?></select><?php
 
 
366
 
367
- if ( $option['desc'] )
368
- echo ' <p class="description">' . $option['desc'] . '</p>';
 
369
 
370
  break;
371
- default :
372
 
373
- ?><input id="setting-<?php echo $option['name']; ?>" class="regular-text" type="text" name="<?php echo $option['name']; ?>" value="<?php esc_attr_e( $value ); ?>" <?php echo $placeholder; ?> /><?php
 
 
374
 
375
- if ( $option['desc'] )
376
- echo ' <p class="description">' . $option['desc'] . '</p>';
 
377
 
378
  break;
379
 
380
- }
381
-
382
- echo '</td></tr>';
383
  }
384
 
385
- echo '</table></div>';
386
-
387
  }
 
 
 
 
388
  ?>
389
  <p class="submit">
390
- <input type="submit" class="button-primary" value="<?php _e( 'Save Changes', 'download-monitor' ); ?>" />
 
391
  </p>
392
- </form>
393
  </div>
394
  <?php
395
-
396
- $download_monitor->add_inline_js("
397
- jQuery('.nav-tab-wrapper a').click(function() {
398
- jQuery('.settings_panel').hide();
399
- jQuery('.nav-tab-active').removeClass('nav-tab-active');
400
- jQuery( jQuery(this).attr('href') ).show();
401
- jQuery(this).addClass('nav-tab-active');
402
- return false;
403
- });
404
- jQuery('#setting-dlm_default_template').change(function(){
405
- if ( jQuery(this).val() == 'custom' ) {
406
- jQuery('#setting-dlm_custom_template').closest('tr').show();
407
- } else {
408
- jQuery('#setting-dlm_custom_template').closest('tr').hide();
409
- }
410
- }).change();
411
-
412
- jQuery('.nav-tab-wrapper a:first').click();
413
- ");
414
  }
415
 
416
  /**
@@ -420,23 +437,29 @@ class DLM_Admin {
420
  * @return void
421
  */
422
  function log_viewer() {
423
- if ( ! class_exists( 'WP_List_Table' ) )
424
  require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
 
425
 
426
  require_once( 'class-dlm-logging-list-table.php' );
427
 
428
- $DLM_Logging_List_Table = new DLM_Logging_List_Table();
429
- $DLM_Logging_List_Table->prepare_items();
430
- ?>
431
- <div class="wrap">
432
- <div id="icon-edit" class="icon32 icon32-posts-dlm_download"><br/></div>
433
-
434
- <h2><?php _e( 'Download Logs', 'download-monitor' ); ?> <a href="<?php echo add_query_arg( 'dlm_download_logs', 'true' ); ?>" class="add-new-h2"><?php _e( 'Export CSV', 'download-monitor' ); ?></a> <a href="<?php echo wp_nonce_url( add_query_arg( 'dlm_delete_logs', 'true' ), 'delete_logs' ); ?>" class="add-new-h2"><?php _e( 'Delete Logs', 'download-monitor' ); ?></a></h2><br/>
435
- <form id="dlm_logs">
436
- <?php $DLM_Logging_List_Table->display() ?>
437
- </form>
438
- </div>
439
- <?php
 
 
 
 
 
440
  }
441
 
442
  /**
@@ -445,8 +468,9 @@ class DLM_Admin {
445
  public function delete_logs() {
446
  global $wpdb;
447
 
448
- if ( empty( $_GET['dlm_delete_logs'] ) )
449
  return;
 
450
 
451
  check_admin_referer( 'delete_logs' );
452
 
@@ -459,66 +483,69 @@ class DLM_Admin {
459
  public function export_logs() {
460
  global $wpdb;
461
 
462
- if ( empty( $_GET['dlm_download_logs'] ) )
463
  return;
 
464
 
465
  $filter_status = isset( $_REQUEST['filter_status'] ) ? sanitize_text_field( $_REQUEST['filter_status'] ) : '';
466
- $filter_month = ! empty( $_REQUEST['filter_month'] ) ? sanitize_text_field( $_REQUEST['filter_month'] ) : '';
467
 
468
  $items = $wpdb->get_results(
469
  $wpdb->prepare(
470
- "SELECT * FROM {$wpdb->download_log}
471
  WHERE type = 'download'
472
  " . ( $filter_status ? "AND download_status = '%s'" : "%s" ) . "
473
  " . ( $filter_month ? "AND download_date >= '%s'" : "%s" ) . "
474
  " . ( $filter_month ? "AND download_date <= '%s'" : "%s" ) . "
475
  ORDER BY download_date DESC",
476
- ( $filter_status ? $filter_status : "" ),
477
- ( $filter_month ? date( 'Y-m-01', strtotime( $filter_month ) ) : "" ),
478
- ( $filter_month ? date( 'Y-m-t', strtotime( $filter_month ) ) : "" )
479
- )
480
- );
481
-
482
- $rows = array();
483
- $row = array();
484
- $row[] = __( 'Download ID', 'download-monitor' );
485
- $row[] = __( 'Version ID', 'download-monitor' );
486
- $row[] = __( 'Filename', 'download-monitor' );
487
- $row[] = __( 'User ID', 'download-monitor' );
488
- $row[] = __( 'User Login', 'download-monitor' );
489
- $row[] = __( 'User Email', 'download-monitor' );
490
- $row[] = __( 'User IP', 'download-monitor' );
491
- $row[] = __( 'User Agent', 'download-monitor' );
492
- $row[] = __( 'Date', 'download-monitor' );
493
- $row[] = __( 'Status', 'download-monitor' );
494
- $rows[] = '"' . implode( '","', $row ) . '"';
495
 
496
  if ( ! empty( $items ) ) {
497
  foreach ( $items as $item ) {
498
- $row = array();
499
- $row[] = $item->download_id;
500
- $row[] = $item->version_id;
501
 
502
  $download = new DLM_Download( $item->download_id );
503
- $download->set_version( $item->version_id );
504
 
505
- if ( $download->exists() && $download->get_the_filename() )
506
- $row[] = $download->get_the_filename();
507
- else
508
- $row[] = '-';
 
509
 
510
- $row[] = $item->user_id;
511
 
512
- if ( $item->user_id )
513
- $user = get_user_by( 'id', $item->user_id );
 
514
 
515
- if ( ! isset( $user ) || ! $user ) {
516
- $row[] = '-';
517
- $row[] = '-';
518
- } else {
519
- $row[] = $user->user_login;
520
- $row[] = $user->user_email;
521
- }
522
 
523
  $row[] = $item->user_ip;
524
  $row[] = $item->user_agent;
@@ -545,8 +572,6 @@ class DLM_Admin {
545
  * @return void
546
  */
547
  public function admin_dashboard() {
548
- include_once( 'class-dlm-admin-dashboard.php' );
549
  }
550
- }
551
-
552
- new DLM_Admin();
1
  <?php
2
 
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
 
7
  /**
8
  * DLM_Admin class.
12
  private $settings;
13
 
14
  /**
15
+ * Setup actions etc.
 
 
 
16
  */
17
+ public function setup() {
 
 
 
 
 
18
  // Directory protection
19
  add_filter( 'mod_rewrite_rules', array( $this, 'ms_files_protection' ) );
20
  add_filter( 'upload_dir', array( $this, 'upload_dir' ) );
31
  * ms_files_protection function.
32
  *
33
  * @access public
34
+ *
35
  * @param mixed $rewrite
36
+ *
37
  * @return void
38
  */
39
  public function ms_files_protection( $rewrite ) {
 
40
 
41
+ if ( ! is_multisite() ) {
42
+ return $rewrite;
43
+ }
44
 
45
+ $rule = "\n# DLM Rules - Protect Files from ms-files.php\n\n";
46
  $rule .= "<IfModule mod_rewrite.c>\n";
47
  $rule .= "RewriteEngine On\n";
48
  $rule .= "RewriteCond %{QUERY_STRING} file=dlm_uploads/ [NC]\n";
56
  * upload_dir function.
57
  *
58
  * @access public
59
+ *
60
  * @param mixed $pathdata
61
+ *
62
  * @return void
63
  */
64
  public function upload_dir( $pathdata ) {
65
 
66
+ if ( isset( $_POST['type'] ) && 'dlm_download' === $_POST['type'] ) {
67
  if ( empty( $pathdata['subdir'] ) ) {
68
  $pathdata['path'] = $pathdata['path'] . '/dlm_uploads';
69
+ $pathdata['url'] = $pathdata['url'] . '/dlm_uploads';
70
  $pathdata['subdir'] = '/dlm_uploads';
71
  } else {
72
  $new_subdir = '/dlm_uploads' . $pathdata['subdir'];
89
  private function init_settings() {
90
  $this->settings = apply_filters( 'download_monitor_settings',
91
  array(
92
+ 'general' => array(
93
  __( 'General', 'download-monitor' ),
94
  array(
95
  array(
96
+ 'name' => 'dlm_default_template',
97
+ 'std' => '',
98
+ 'label' => __( 'Default Template', 'download-monitor' ),
99
+ 'desc' => __( 'Choose which template is used for <code>[download]</code> shortcodes by default (this can be overridden by the <code>format</code> argument).', 'download-monitor' ),
100
+ 'type' => 'select',
101
+ 'options' => array(
102
  '' => __( 'Default - Title and count', 'download-monitor' ),
103
  'button' => __( 'Button - CSS styled button showing title and count', 'download-monitor' ),
104
  'box' => __( 'Box - Box showing thumbnail, title, count, filename and filesize.', 'download-monitor' ),
109
  )
110
  ),
111
  array(
112
+ 'name' => 'dlm_custom_template',
113
+ 'std' => '',
114
+ 'label' => __( 'Custom Template', 'download-monitor' ),
115
+ 'desc' => __( 'Leaving this blank will use the default <code>content-download.php</code> template file. If you enter, for example, <code>image</code>, the <code>content-download-image.php</code> template will be used instead. You can add custom templates inside your theme folder.', 'download-monitor' )
116
  ),
117
  array(
118
+ 'name' => 'dlm_generate_hash_md5',
119
+ 'std' => '0',
120
+ 'label' => __( 'MD5 hashes', 'download-monitor' ),
121
+ 'cb_label' => __( 'Generate MD5 hash for uploaded files', 'download-monitor' ),
122
+ 'desc' => '',
123
+ 'type' => 'checkbox'
124
  ),
125
  array(
126
+ 'name' => 'dlm_generate_hash_sha1',
127
+ 'std' => '0',
128
+ 'label' => __( 'SHA1 hashes', 'download-monitor' ),
129
+ 'cb_label' => __( 'Generate SHA1 hash for uploaded files', 'download-monitor' ),
130
+ 'desc' => '',
131
+ 'type' => 'checkbox'
132
  ),
133
  array(
134
+ 'name' => 'dlm_generate_hash_crc32b',
135
+ 'std' => '0',
136
+ 'label' => __( 'CRC32B hashes', 'download-monitor' ),
137
+ 'cb_label' => __( 'Generate CRC32B hash for uploaded files', 'download-monitor' ),
138
+ 'desc' => __( 'Hashes can optionally be output via shortcodes, but may cause performance issues with large files.', 'download-monitor' ),
139
+ 'type' => 'checkbox'
140
  ),
141
  ),
142
  ),
144
  __( 'Endpoint', 'download-monitor' ),
145
  array(
146
  array(
147
+ 'name' => 'dlm_download_endpoint',
148
+ 'std' => 'download',
149
+ 'placeholder' => __( 'download', 'download-monitor' ),
150
+ 'label' => __( 'Download Endpoint', 'download-monitor' ),
151
+ 'desc' => sprintf( __( 'Define what endpoint should be used for download links. By default this will be <code>%s</code>.', 'download-monitor' ), home_url( '/download/' ) )
152
  ),
153
  array(
154
+ 'name' => 'dlm_download_endpoint_value',
155
+ 'std' => 'ID',
156
+ 'label' => __( 'Endpoint Value', 'download-monitor' ),
157
+ 'desc' => sprintf( __( 'Define what unique value should be used on the end of your endpoint to identify the downloadable file. e.g. ID would give a link like <code>%s</code>', 'download-monitor' ), home_url( '/download/10/' ) ),
158
+ 'type' => 'select',
159
+ 'options' => array(
160
  'ID' => __( 'Download ID', 'download-monitor' ),
161
  'slug' => __( 'Download slug', 'download-monitor' )
162
  )
163
  ),
164
  array(
165
+ 'name' => 'dlm_xsendfile_enabled',
166
+ 'std' => '',
167
+ 'label' => __( 'X-Accel-Redirect / X-Sendfile', 'download-monitor' ),
168
+ 'cb_label' => __( 'Enable', 'download-monitor' ),
169
+ 'desc' => __( 'If supported, <code>X-Accel-Redirect</code> / <code>X-Sendfile</code> can be used to serve downloads instead of PHP (server requires <code>mod_xsendfile</code>).', 'download-monitor' ),
170
+ 'type' => 'checkbox'
171
  ),
172
  array(
173
+ 'name' => 'dlm_hotlink_protection_enabled',
174
+ 'std' => '',
175
+ 'label' => __( 'Prevent hotlinking', 'download-monitor' ),
176
+ 'cb_label' => __( 'Enable', 'download-monitor' ),
177
+ 'desc' => __( 'If enabled, the download handler will check the PHP referer to see if it originated from your site and if not, redirect them to the homepage.', 'download-monitor' ),
178
+ 'type' => 'checkbox'
179
  )
180
  )
181
  ),
182
+ 'logging' => array(
183
  __( 'Logging', 'download-monitor' ),
184
  array(
185
  array(
186
+ 'name' => 'dlm_enable_logging',
187
+ 'cb_label' => __( 'Enable', 'download-monitor' ),
188
+ 'std' => '1',
189
+ 'label' => __( 'Download Log', 'download-monitor' ),
190
+ 'desc' => __( 'Log download attempts, IP addresses and more.', 'download-monitor' ),
191
+ 'type' => 'checkbox'
192
  ),
193
  array(
194
+ 'name' => 'dlm_ip_blacklist',
195
+ 'std' => '192.168.0.*',
196
+ 'label' => __( 'Blacklist IPs', 'download-monitor' ),
197
+ 'desc' => __( 'List IP Addresses to blacklist, 1 per line. Use <code>*</code> for a wildcard.', 'download-monitor' ),
198
+ 'placeholder' => '',
199
+ 'type' => 'textarea'
200
  ),
201
  array(
202
+ 'name' => 'dlm_user_agent_blacklist',
203
+ 'std' => 'Googlebot',
204
+ 'label' => __( 'Blacklist user agents', 'download-monitor' ),
205
+ 'desc' => __( 'List browser user agents to blacklist, 1 per line.', 'download-monitor' ),
206
  'placeholder' => '',
207
+ 'type' => 'textarea'
208
  ),
209
  )
210
  )
223
 
224
  foreach ( $this->settings as $section ) {
225
  foreach ( $section[1] as $option ) {
226
+ if ( isset( $option['std'] ) ) {
227
  add_option( $option['name'], $option['std'] );
228
+ }
229
  register_setting( 'download-monitor', $option['name'] );
230
  }
231
  }
238
  * @return void
239
  */
240
  public function admin_enqueue_scripts( $hook ) {
241
+ global $post;
242
 
243
+ wp_enqueue_style( 'download_monitor_menu_css', WP_DLM::get_plugin_url() . '/assets/css/menu.css' );
244
 
245
+ if ( $hook == 'index.php' ) {
246
+ wp_enqueue_style( 'download_monitor_dashboard_css', WP_DLM::get_plugin_url() . '/assets/css/dashboard.css' );
247
+ }
248
 
249
  $enqueue = false;
250
 
251
+ if ( $hook == 'post-new.php' || $hook == 'post.php' || $hook == 'edit.php' ) {
252
+ if ( ( ! empty( $_GET['post_type'] ) && $_GET['post_type'] == 'dlm_download' ) || ( ! empty( $post->post_type ) && 'dlm_download' === $post->post_type ) ) {
253
  $enqueue = true;
254
+ }
255
+ }
256
 
257
+ if ( strstr( $hook, 'dlm_download_page' ) ) {
258
  $enqueue = true;
259
+ }
260
 
261
+ if ( $hook == 'edit-tags.php' && strstr( $_GET['taxonomy'], 'dlm_download' ) ) {
262
  $enqueue = true;
263
+ }
264
 
265
+ if ( ! $enqueue ) {
266
+ return;
267
+ }
268
 
269
+ wp_enqueue_script( 'jquery-blockui', WP_DLM::get_plugin_url() . '/assets/js/blockui.min.js', array( 'jquery' ), '2.61' );
270
  wp_enqueue_script( 'jquery-ui-sortable' );
271
  wp_enqueue_script( 'jquery-ui-datepicker' );
272
+ wp_enqueue_style( 'jquery-ui-style', ( is_ssl() ) ? 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' : 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' );
273
+ wp_enqueue_style( 'download_monitor_admin_css', WP_DLM::get_plugin_url() . '/assets/css/admin.css', array( 'dashicons' ) );
274
  }
275
 
276
  /**
280
  * @return void
281
  */
282
  public function admin_menu() {
 
 
283
 
284
+ // Logging object
285
+ $logging = new DLM_Logging();
286
+
287
+ // Logs page
288
+ if ( $logging->is_logging_enabled() ) {
289
+ add_submenu_page( 'edit.php?post_type=dlm_download', __( 'Logs', 'download-monitor' ), __( 'Logs', 'download-monitor' ), 'manage_options', 'download-monitor-logs', array(
290
+ $this,
291
+ 'log_viewer'
292
+ ) );
293
+ }
294
+
295
+ // Settings page
296
+ add_submenu_page( 'edit.php?post_type=dlm_download', __( 'Settings', 'download-monitor' ), __( 'Settings', 'download-monitor' ), 'manage_options', 'download-monitor-settings', array(
297
+ $this,
298
+ 'settings_page'
299
+ ) );
300
+
301
+ // Extensions page
302
+ add_submenu_page( 'edit.php?post_type=dlm_download', __( 'Download Monitor Extensions', 'download-monitor' ), __( 'Extensions', 'download-monitor' ), 'manage_options', 'dlm-extensions', array(
303
+ $this,
304
+ 'extensions_page'
305
+ ) );
306
 
 
 
307
  }
308
 
309
  /**
310
+ * Output extensions page
311
  */
312
+ public function extensions_page() {
313
+ $admin_extensions = new DLM_Admin_Extensions();
314
+ $admin_extensions->output();
315
  }
316
 
317
  /**
321
  * @return void
322
  */
323
  public function settings_page() {
 
 
324
  $this->init_settings();
325
  ?>
326
  <div class="wrap">
329
  <?php settings_fields( 'download-monitor' ); ?>
330
  <?php screen_icon(); ?>
331
 
332
+ <h2 class="nav-tab-wrapper">
333
+ <?php
334
+ foreach ( $this->settings as $key => $section ) {
335
+ echo '<a href="#settings-' . sanitize_title( $key ) . '" class="nav-tab">' . esc_html( $section[0] ) . '</a>';
336
+ }
337
+ ?>
338
+ </h2><br/>
339
 
340
  <?php
341
+ if ( ! empty( $_GET['settings-updated'] ) ) {
342
+ flush_rewrite_rules();
343
+ echo '<div class="updated fade"><p>' . __( 'Settings successfully saved', 'download-monitor' ) . '</p></div>';
344
+ }
345
 
346
+ foreach ( $this->settings as $key => $section ) {
347
 
348
+ echo '<div id="settings-' . sanitize_title( $key ) . '" class="settings_panel">';
349
 
350
+ echo '<table class="form-table">';
351
 
352
+ foreach ( $section[1] as $option ) {
353
 
354
+ $placeholder = ( ! empty( $option['placeholder'] ) ) ? 'placeholder="' . $option['placeholder'] . '"' : '';
355
 
356
+ echo '<tr valign="top"><th scope="row"><label for="setting-' . $option['name'] . '">' . $option['label'] . '</a></th><td>';
357
 
358
+ if ( ! isset( $option['type'] ) ) {
359
+ $option['type'] = '';
360
+ }
361
 
362
+ $value = get_option( $option['name'] );
363
 
364
+ switch ( $option['type'] ) {
365
 
366
+ case "checkbox" :
367
 
368
+ ?><label><input id="setting-<?php echo $option['name']; ?>"
369
+ name="<?php echo $option['name']; ?>" type="checkbox"
370
+ value="1" <?php checked( '1', $value ); ?> /> <?php echo $option['cb_label']; ?>
371
+ </label><?php
372
 
373
+ if ( $option['desc'] ) {
374
+ echo ' <p class="description">' . $option['desc'] . '</p>';
375
+ }
376
 
377
  break;
378
+ case "textarea" :
379
 
380
+ ?><textarea id="setting-<?php echo $option['name']; ?>" class="large-text" cols="50"
381
+ rows="3"
382
+ name="<?php echo $option['name']; ?>" <?php echo $placeholder; ?>><?php echo esc_textarea( $value ); ?></textarea><?php
383
 
384
+ if ( $option['desc'] ) {
385
+ echo ' <p class="description">' . $option['desc'] . '</p>';
386
+ }
387
 
388
  break;
389
+ case "select" :
390
 
391
+ ?><select id="setting-<?php echo $option['name']; ?>" class="regular-text"
392
+ name="<?php echo $option['name']; ?>"><?php
393
+ foreach ( $option['options'] as $key => $name ) {
394
+ echo '<option value="' . esc_attr( $key ) . '" ' . selected( $value, $key, false ) . '>' . esc_html( $name ) . '</option>';
395
+ }
396
+ ?></select><?php
397
 
398
+ if ( $option['desc'] ) {
399
+ echo ' <p class="description">' . $option['desc'] . '</p>';
400
+ }
401
 
402
  break;
403
+ default :
404
 
405
+ ?><input id="setting-<?php echo $option['name']; ?>" class="regular-text" type="text"
406
+ name="<?php echo $option['name']; ?>"
407
+ value="<?php esc_attr_e( $value ); ?>" <?php echo $placeholder; ?> /><?php
408
 
409
+ if ( $option['desc'] ) {
410
+ echo ' <p class="description">' . $option['desc'] . '</p>';
411
+ }
412
 
413
  break;
414
 
 
 
 
415
  }
416
 
417
+ echo '</td></tr>';
 
418
  }
419
+
420
+ echo '</table></div>';
421
+
422
+ }
423
  ?>
424
  <p class="submit">
425
+ <input type="submit" class="button-primary"
426
+ value="<?php _e( 'Save Changes', 'download-monitor' ); ?>"/>
427
  </p>
428
+ </form>
429
  </div>
430
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
431
  }
432
 
433
  /**
437
  * @return void
438
  */
439
  function log_viewer() {
440
+ if ( ! class_exists( 'WP_List_Table' ) ) {
441
  require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
442
+ }
443
 
444
  require_once( 'class-dlm-logging-list-table.php' );
445
 
446
+ $DLM_Logging_List_Table = new DLM_Logging_List_Table();
447
+ $DLM_Logging_List_Table->prepare_items();
448
+ ?>
449
+ <div class="wrap">
450
+ <div id="icon-edit" class="icon32 icon32-posts-dlm_download"><br/></div>
451
+
452
+ <h2><?php _e( 'Download Logs', 'download-monitor' ); ?> <a
453
+ href="<?php echo add_query_arg( 'dlm_download_logs', 'true' ); ?>"
454
+ class="add-new-h2"><?php _e( 'Export CSV', 'download-monitor' ); ?></a> <a
455
+ href="<?php echo wp_nonce_url( add_query_arg( 'dlm_delete_logs', 'true' ), 'delete_logs' ); ?>"
456
+ class="add-new-h2"><?php _e( 'Delete Logs', 'download-monitor' ); ?></a></h2><br/>
457
+
458
+ <form id="dlm_logs">
459
+ <?php $DLM_Logging_List_Table->display() ?>
460
+ </form>
461
+ </div>
462
+ <?php
463
  }
464
 
465
  /**
468
  public function delete_logs() {
469
  global $wpdb;
470
 
471
+ if ( empty( $_GET['dlm_delete_logs'] ) ) {
472
  return;
473
+ }
474
 
475
  check_admin_referer( 'delete_logs' );
476
 
483
  public function export_logs() {
484
  global $wpdb;
485
 
486
+ if ( empty( $_GET['dlm_download_logs'] ) ) {
487
  return;
488
+ }
489
 
490
  $filter_status = isset( $_REQUEST['filter_status'] ) ? sanitize_text_field( $_REQUEST['filter_status'] ) : '';
491
+ $filter_month = ! empty( $_REQUEST['filter_month'] ) ? sanitize_text_field( $_REQUEST['filter_month'] ) : '';
492
 
493
  $items = $wpdb->get_results(
494
  $wpdb->prepare(
495
+ "SELECT * FROM {$wpdb->download_log}
496
  WHERE type = 'download'
497
  " . ( $filter_status ? "AND download_status = '%s'" : "%s" ) . "
498
  " . ( $filter_month ? "AND download_date >= '%s'" : "%s" ) . "
499
  " . ( $filter_month ? "AND download_date <= '%s'" : "%s" ) . "
500
  ORDER BY download_date DESC",
501
+ ( $filter_status ? $filter_status : "" ),
502
+ ( $filter_month ? date( 'Y-m-01', strtotime( $filter_month ) ) : "" ),
503
+ ( $filter_month ? date( 'Y-m-t', strtotime( $filter_month ) ) : "" )
504
+ )
505
+ );
506
+
507
+ $rows = array();
508
+ $row = array();
509
+ $row[] = __( 'Download ID', 'download-monitor' );
510
+ $row[] = __( 'Version ID', 'download-monitor' );
511
+ $row[] = __( 'Filename', 'download-monitor' );
512
+ $row[] = __( 'User ID', 'download-monitor' );
513
+ $row[] = __( 'User Login', 'download-monitor' );
514
+ $row[] = __( 'User Email', 'download-monitor' );
515
+ $row[] = __( 'User IP', 'download-monitor' );
516
+ $row[] = __( 'User Agent', 'download-monitor' );
517
+ $row[] = __( 'Date', 'download-monitor' );
518
+ $row[] = __( 'Status', 'download-monitor' );
519
+ $rows[] = '"' . implode( '","', $row ) . '"';
520
 
521
  if ( ! empty( $items ) ) {
522
  foreach ( $items as $item ) {
523
+ $row = array();
524
+ $row[] = $item->download_id;
525
+ $row[] = $item->version_id;
526
 
527
  $download = new DLM_Download( $item->download_id );
528
+ $download->set_version( $item->version_id );
529
 
530
+ if ( $download->exists() && $download->get_the_filename() ) {
531
+ $row[] = $download->get_the_filename();
532
+ } else {
533
+ $row[] = '-';
534
+ }
535
 
536
+ $row[] = $item->user_id;
537
 
538
+ if ( $item->user_id ) {
539
+ $user = get_user_by( 'id', $item->user_id );
540
+ }
541
 
542
+ if ( ! isset( $user ) || ! $user ) {
543
+ $row[] = '-';
544
+ $row[] = '-';
545
+ } else {
546
+ $row[] = $user->user_login;
547
+ $row[] = $user->user_email;
548
+ }
549
 
550
  $row[] = $item->user_ip;
551
  $row[] = $item->user_agent;
572
  * @return void
573
  */
574
  public function admin_dashboard() {
575
+ new DLM_Admin_Dashboard();
576
  }
577
+ }
 
 
includes/admin/class-dlm-category-walker.php CHANGED
@@ -1,5 +1,7 @@
1
  <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
3
 
4
  /**
5
  * DLM_Category_Walker class.
@@ -9,7 +11,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
9
  class DLM_Category_Walker extends Walker {
10
 
11
  var $tree_type = 'category';
12
- var $db_fields = array ('parent' => 'parent', 'id' => 'term_id', 'slug' => 'slug' );
13
 
14
  /**
15
  * @see Walker::start_el()
@@ -22,10 +24,11 @@ class DLM_Category_Walker extends Walker {
22
  */
23
  function start_el( &$output, $object, $depth = 0, $args = array(), $current_object_id = 0 ) {
24
 
25
- if ( ! empty( $args['hierarchical'] ) )
26
- $pad = str_repeat('&nbsp;', $depth * 3);
27
- else
28
  $pad = '';
 
29
 
30
  $cat_name = apply_filters( 'list_product_cats', $object->name, $object );
31
 
@@ -33,15 +36,17 @@ class DLM_Category_Walker extends Walker {
33
 
34
  $output .= "\t<option class=\"level-$depth\" value=\"" . $value . "\"";
35
 
36
- if ( $value == $args['selected'] || ( is_array( $args['selected'] ) && in_array( $value, $args['selected'] ) ) )
37
  $output .= ' selected="selected"';
 
38
 
39
  $output .= '>';
40
 
41
  $output .= $pad . __( $cat_name, 'download-monitor' );
42
 
43
- if ( ! empty( $args['show_count'] ) )
44
  $output .= '&nbsp;(' . $object->count . ')';
 
45
 
46
  $output .= "</option>\n";
47
  }
1
  <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ } // Exit if accessed directly
5
 
6
  /**
7
  * DLM_Category_Walker class.
11
  class DLM_Category_Walker extends Walker {
12
 
13
  var $tree_type = 'category';
14
+ var $db_fields = array( 'parent' => 'parent', 'id' => 'term_id', 'slug' => 'slug' );
15
 
16
  /**
17
  * @see Walker::start_el()
24
  */
25
  function start_el( &$output, $object, $depth = 0, $args = array(), $current_object_id = 0 ) {
26
 
27
+ if ( ! empty( $args['hierarchical'] ) ) {
28
+ $pad = str_repeat( '&nbsp;', $depth * 3 );
29
+ } else {
30
  $pad = '';
31
+ }
32
 
33
  $cat_name = apply_filters( 'list_product_cats', $object->name, $object );
34
 
36
 
37
  $output .= "\t<option class=\"level-$depth\" value=\"" . $value . "\"";
38
 
39
+ if ( $value == $args['selected'] || ( is_array( $args['selected'] ) && in_array( $value, $args['selected'] ) ) ) {
40
  $output .= ' selected="selected"';
41
+ }
42
 
43
  $output .= '>';
44
 
45
  $output .= $pad . __( $cat_name, 'download-monitor' );
46
 
47
+ if ( ! empty( $args['show_count'] ) ) {
48
  $output .= '&nbsp;(' . $object->count . ')';
49
+ }
50
 
51
  $output .= "</option>\n";
52
  }
includes/admin/class-dlm-logging-list-table.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * DLM_Logging_List_Table class.
4
  *
@@ -11,87 +12,93 @@ class DLM_Logging_List_Table extends WP_List_Table {
11
  *
12
  * @access public
13
  */
14
- function __construct(){
15
  global $status, $page, $wpdb;
16
 
17
  parent::__construct( array(
18
- 'singular' => 'log',
19
- 'plural' => 'logs',
20
- 'ajax' => false
21
  ) );
22
 
23
  $this->filter_status = isset( $_REQUEST['filter_status'] ) ? sanitize_text_field( $_REQUEST['filter_status'] ) : '';
24
  $this->logs_per_page = ! empty( $_REQUEST['logs_per_page'] ) ? intval( $_REQUEST['logs_per_page'] ) : 25;
25
  $this->filter_month = ! empty( $_REQUEST['filter_month'] ) ? sanitize_text_field( $_REQUEST['filter_month'] ) : '';
26
 
27
- if ( $this->logs_per_page < 1 )
28
  $this->logs_per_page = 9999999999999;
 
29
  }
30
 
31
  /**
32
  * column_default function.
33
  *
34
  * @access public
 
35
  * @param mixed $log
36
  * @param mixed $column_name
 
37
  * @return void
38
  */
39
  function column_default( $log, $column_name ) {
40
- switch( $column_name ) {
41
  case 'status' :
42
  switch ( $log->download_status ) {
43
  case 'failed' :
44
  $download_status = '<span class="failed" title="' . esc_attr( $log->download_status_message ) . '">&#10082;</span>';
45
- break;
46
  case 'redirected' :
47
  $download_status = '<span class="redirected" title="' . esc_attr( $log->download_status_message ) . '">&#10140;</span>';
48
- break;
49
  default :
50
  $download_status = '<span class="completed" title="' . __( 'Download Complete', 'download-monitor' ) . '">&#10004;</span>';
51
- break;
52
  }
53
 
54
  return $download_status;
55
- break;
56
  case 'date' :
57
  return '<time title="' . date_i18n( get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' ), strtotime( $log->download_date ) ) . '"">' . sprintf( __( '%s ago', 'download-monitor' ), human_time_diff( strtotime( $log->download_date ), current_time( 'timestamp' ) ) ) . '</time>';
58
- break;
59
  case 'download' :
60
  $download = new DLM_Download( $log->download_id );
61
  $download->set_version( $log->version_id );
62
 
63
  if ( ! $download->exists() ) {
64
- $download_string = sprintf( __( 'Download #%d (no longer exists)', 'download-monitor' ), $log->download_id );
65
  } else {
66
  $download_string = '<a href="' . admin_url( 'post.php?post=' . $download->id . '&action=edit' ) . '">';
67
  $download_string .= '#' . $download->id . ' &ndash; ' . $download->get_the_title();
68
  $download_string .= '</a>';
69
  }
70
 
71
- if ( $log->version )
72
  $download_string .= ' (' . sprintf( __( 'v%s', 'download-monitor' ), $log->version ) . ')';
 
73
 
74
  return $download_string;
75
- break;
76
  case 'file' :
77
  $download = new DLM_Download( $log->download_id );
78
  $download->set_version( $log->version_id );
79
 
80
- if ( $download->exists() && $download->get_the_filename() )
81
  $download_string = '<code>' . $download->get_the_filename() . '</code>';
82
- else
83
  $download_string = '&ndash;';
 
84
 
85
  return $download_string;
86
- break;
87
  case 'user' :
88
- if ( $log->user_id )
89
  $user = get_user_by( 'id', $log->user_id );
 
90
 
91
  if ( ! isset( $user ) || ! $user ) {
92
- $user_string = __( 'Non-member', 'download-monitor' );
93
  } else {
94
- $user_string = '<a href="' . admin_url( 'user-edit.php?user_id=' . $user->ID ) . '">';
95
  $user_string .= $user->user_login . ' &ndash; ';
96
  $user_string .= '<a href="mailto:' . $user->user_email . '">';
97
  $user_string .= $user->user_email;
@@ -99,15 +106,15 @@ class DLM_Logging_List_Table extends WP_List_Table {
99
  }
100
 
101
  return $user_string;
102
- break;
103
  case 'user_ip' :
104
  return '<a href="http://whois.arin.net/rest/ip/' . $log->user_ip . '" target="_blank">' . $log->user_ip . '</a>';
105
- break;
106
  case 'user_ua' :
107
  $ua = $this->uaparser->parse( $log->user_agent );
108
 
109
  return $ua->toFullString;
110
- break;
111
  }
112
  }
113
 
@@ -117,16 +124,17 @@ class DLM_Logging_List_Table extends WP_List_Table {
117
  * @access public
118
  * @return void
119
  */
120
- public function get_columns(){
121
  $columns = array(
122
- 'status' => '',
123
- 'download' => __( 'Download', 'download-monitor' ),
124
- 'file' => __( 'File', 'download-monitor' ),
125
- 'user' => __( 'User', 'download-monitor' ),
126
- 'user_ip' => __( 'IP Address', 'download-monitor' ),
127
- 'user_ua' => __( 'User Agent', 'download-monitor' ),
128
- 'date' => __( 'Date', 'download-monitor' ),
129
  );
 
130
  return $columns;
131
  }
132
 
@@ -135,69 +143,77 @@ class DLM_Logging_List_Table extends WP_List_Table {
135
  */
136
  public function display_tablenav( $which ) {
137
  ?>
138
- <div class="tablenav <?php echo esc_attr( $which ); ?>">
139
- <?php if ( 'top' == $which ) : ?>
140
- <div class="alignleft actions">
141
- <select name="filter_status">
142
- <option value=""><?php _e( 'Any status', 'download-monitor' ); ?></option>
143
- <option value="failed" <?php selected( $this->filter_status, 'failed' ); ?>><?php _e( 'Failed', 'download-monitor' ); ?></option>
144
- <option value="redirected" <?php selected( $this->filter_status, 'redirected' ); ?>><?php _e( 'Redirected', 'download-monitor' ); ?></option>
145
- <option value="completed" <?php selected( $this->filter_status, 'completed' ); ?>><?php _e( 'Completed', 'download-monitor' ); ?></option>
146
- </select>
147
- <?php
148
- global $wpdb, $wp_locale;
149
-
150
- $months = $wpdb->get_results( "
 
 
 
151
  SELECT DISTINCT YEAR( download_date ) AS year, MONTH( download_date ) AS month
152
  FROM {$wpdb->download_log}
153
  WHERE type = 'download'
154
  ORDER BY download_date DESC
155
  "
156
- );
157
-
158
- $month_count = count( $months );
159
-
160
- if ( $month_count && ! ( 1 == $month_count && 0 == $months[0]->month ) ) :
161
- $m = isset( $_GET['filter_month'] ) ? $_GET['filter_month'] : 0;
162
- ?>
163
- <select name="filter_month">
164
- <option <?php selected( $m, 0 ); ?> value='0'><?php _e( 'Show all dates' ); ?></option>
165
- <?php
166
- foreach ( $months as $arc_row ) {
167
- if ( 0 == $arc_row->year )
168
- continue;
169
-
170
- $month = zeroise( $arc_row->month, 2 );
171
- $year = $arc_row->year;
172
-
173
- printf( "<option %s value='%s'>%s</option>\n",
174
- selected( $m, $year . '-' . $month, false ),
175
- esc_attr( $year . '-' . $month ),
176
-
177
- sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month ), $year )
178
- );
179
- }
180
- ?>
181
- </select>
182
- <?php endif;
183
  ?>
184
- <select name="logs_per_page">
185
- <option value="25"><?php _e( '25 per page', 'download-monitor' ); ?></option>
186
- <option value="50" <?php selected( $this->logs_per_page, 50 ) ?>><?php _e( '50 per page', 'download-monitor' ); ?></option>
187
- <option value="100" <?php selected( $this->logs_per_page, 100 ) ?>><?php _e( '100 per page', 'download-monitor' ); ?></option>
188
- <option value="200" <?php selected( $this->logs_per_page, 200 ) ?>><?php _e( '200 per page', 'download-monitor' ); ?></option>
189
- <option value="-1" <?php selected( $this->logs_per_page, -1 ) ?>><?php _e( 'Show All', 'download-monitor' ); ?></option>
 
 
 
 
 
 
 
 
 
 
 
 
 
190
  </select>
191
- <input type="hidden" name="post_type" value="dlm_download" />
192
- <input type="hidden" name="page" value="download-monitor-logs" />
193
- <input type="submit" value="<?php _e( 'Filter', 'download-monitor' ); ?>" class="button" />
194
- </div>
195
- <?php endif; ?>
196
- <?php
197
- $this->extra_tablenav( $which );
198
- $this->pagination( $which );
199
- ?>
200
- <br class="clear" />
 
 
 
 
 
 
 
 
 
 
 
 
 
201
  </div><?php
202
  }
203
 
@@ -221,14 +237,17 @@ class DLM_Logging_List_Table extends WP_List_Table {
221
 
222
  $query_where = " type = 'download' ";
223
 
224
- if ( $this->filter_status )
225
  $query_where .= " AND download_status = '{$filter_status}' ";
 
226
 
227
- if ( $this->filter_month )
228
  $query_where .= " AND download_date >= '" . date( 'Y-m-01', strtotime( $this->filter_month ) ) . "' ";
 
229
 
230
- if ( $this->filter_month )
231
  $query_where .= " AND download_date <= '" . date( 'Y-m-t', strtotime( $this->filter_month ) ) . "' ";
 
232
 
233
  // Total Count of Logs
234
  $total_items = $wpdb->get_var( "SELECT COUNT(ID) FROM {$wpdb->download_log} WHERE {$query_where};" );
@@ -250,8 +269,9 @@ class DLM_Logging_List_Table extends WP_List_Table {
250
  ) );
251
 
252
  // Parser
253
- if ( ! class_exists( 'UAParser' ) )
254
- require_once( "uaparser/uaparser.php" );
 
255
 
256
  $this->uaparser = new UAParser;
257
  }
1
  <?php
2
+
3
  /**
4
  * DLM_Logging_List_Table class.
5
  *
12
  *
13
  * @access public
14
  */
15
+ function __construct() {
16
  global $status, $page, $wpdb;
17
 
18
  parent::__construct( array(
19
+ 'singular' => 'log',
20
+ 'plural' => 'logs',
21
+ 'ajax' => false
22
  ) );
23
 
24
  $this->filter_status = isset( $_REQUEST['filter_status'] ) ? sanitize_text_field( $_REQUEST['filter_status'] ) : '';
25
  $this->logs_per_page = ! empty( $_REQUEST['logs_per_page'] ) ? intval( $_REQUEST['logs_per_page'] ) : 25;
26
  $this->filter_month = ! empty( $_REQUEST['filter_month'] ) ? sanitize_text_field( $_REQUEST['filter_month'] ) : '';
27
 
28
+ if ( $this->logs_per_page < 1 ) {
29
  $this->logs_per_page = 9999999999999;
30
+ }
31
  }
32
 
33
  /**
34
  * column_default function.
35
  *
36
  * @access public
37
+ *
38
  * @param mixed $log
39
  * @param mixed $column_name
40
+ *
41
  * @return void
42
  */
43
  function column_default( $log, $column_name ) {
44
+ switch ( $column_name ) {
45
  case 'status' :
46
  switch ( $log->download_status ) {
47
  case 'failed' :
48
  $download_status = '<span class="failed" title="' . esc_attr( $log->download_status_message ) . '">&#10082;</span>';
49
+ break;
50
  case 'redirected' :
51
  $download_status = '<span class="redirected" title="' . esc_attr( $log->download_status_message ) . '">&#10140;</span>';
52
+ break;
53
  default :
54
  $download_status = '<span class="completed" title="' . __( 'Download Complete', 'download-monitor' ) . '">&#10004;</span>';
55
+ break;
56
  }
57
 
58
  return $download_status;
59
+ break;
60
  case 'date' :
61
  return '<time title="' . date_i18n( get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' ), strtotime( $log->download_date ) ) . '"">' . sprintf( __( '%s ago', 'download-monitor' ), human_time_diff( strtotime( $log->download_date ), current_time( 'timestamp' ) ) ) . '</time>';
62
+ break;
63
  case 'download' :
64
  $download = new DLM_Download( $log->download_id );
65
  $download->set_version( $log->version_id );
66
 
67
  if ( ! $download->exists() ) {
68
+ $download_string = sprintf( __( 'Download #%d (no longer exists)', 'download-monitor' ), $log->download_id );
69
  } else {
70
  $download_string = '<a href="' . admin_url( 'post.php?post=' . $download->id . '&action=edit' ) . '">';
71
  $download_string .= '#' . $download->id . ' &ndash; ' . $download->get_the_title();
72
  $download_string .= '</a>';
73
  }
74
 
75
+ if ( $log->version ) {
76
  $download_string .= ' (' . sprintf( __( 'v%s', 'download-monitor' ), $log->version ) . ')';
77
+ }
78
 
79
  return $download_string;
80
+ break;
81
  case 'file' :
82
  $download = new DLM_Download( $log->download_id );
83
  $download->set_version( $log->version_id );
84
 
85
+ if ( $download->exists() && $download->get_the_filename() ) {
86
  $download_string = '<code>' . $download->get_the_filename() . '</code>';
87
+ } else {
88
  $download_string = '&ndash;';
89
+ }
90
 
91
  return $download_string;
92
+ break;
93
  case 'user' :
94
+ if ( $log->user_id ) {
95
  $user = get_user_by( 'id', $log->user_id );
96
+ }
97
 
98
  if ( ! isset( $user ) || ! $user ) {
99
+ $user_string = __( 'Non-member', 'download-monitor' );
100
  } else {
101
+ $user_string = '<a href="' . admin_url( 'user-edit.php?user_id=' . $user->ID ) . '">';
102
  $user_string .= $user->user_login . ' &ndash; ';
103
  $user_string .= '<a href="mailto:' . $user->user_email . '">';
104
  $user_string .= $user->user_email;
106
  }
107
 
108
  return $user_string;
109
+ break;
110
  case 'user_ip' :
111
  return '<a href="http://whois.arin.net/rest/ip/' . $log->user_ip . '" target="_blank">' . $log->user_ip . '</a>';
112
+ break;
113
  case 'user_ua' :
114
  $ua = $this->uaparser->parse( $log->user_agent );
115
 
116
  return $ua->toFullString;
117
+ break;
118
  }
119
  }
120
 
124
  * @access public
125
  * @return void
126
  */
127
+ public function get_columns() {
128
  $columns = array(
129
+ 'status' => '',
130
+ 'download' => __( 'Download', 'download-monitor' ),
131
+ 'file' => __( 'File', 'download-monitor' ),
132
+ 'user' => __( 'User', 'download-monitor' ),
133
+ 'user_ip' => __( 'IP Address', 'download-monitor' ),
134
+ 'user_ua' => __( 'User Agent', 'download-monitor' ),
135
+ 'date' => __( 'Date', 'download-monitor' ),
136
  );
137
+
138
  return $columns;
139
  }
140
 
143
  */
144
  public function display_tablenav( $which ) {
145
  ?>
146
+ <div class="tablenav <?php echo esc_attr( $which ); ?>">
147
+ <?php if ( 'top' == $which ) : ?>
148
+ <div class="alignleft actions">
149
+ <select name="filter_status">
150
+ <option value=""><?php _e( 'Any status', 'download-monitor' ); ?></option>
151
+ <option
152
+ value="failed" <?php selected( $this->filter_status, 'failed' ); ?>><?php _e( 'Failed', 'download-monitor' ); ?></option>
153
+ <option
154
+ value="redirected" <?php selected( $this->filter_status, 'redirected' ); ?>><?php _e( 'Redirected', 'download-monitor' ); ?></option>
155
+ <option
156
+ value="completed" <?php selected( $this->filter_status, 'completed' ); ?>><?php _e( 'Completed', 'download-monitor' ); ?></option>
157
+ </select>
158
+ <?php
159
+ global $wpdb, $wp_locale;
160
+
161
+ $months = $wpdb->get_results( "
162
  SELECT DISTINCT YEAR( download_date ) AS year, MONTH( download_date ) AS month
163
  FROM {$wpdb->download_log}
164
  WHERE type = 'download'
165
  ORDER BY download_date DESC
166
  "
167
+ );
168
+
169
+ $month_count = count( $months );
170
+
171
+ if ( $month_count && ! ( 1 == $month_count && 0 == $months[0]->month ) ) :
172
+ $m = isset( $_GET['filter_month'] ) ? $_GET['filter_month'] : 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
173
  ?>
174
+ <select name="filter_month">
175
+ <option <?php selected( $m, 0 ); ?> value='0'><?php _e( 'Show all dates' ); ?></option>
176
+ <?php
177
+ foreach ( $months as $arc_row ) {
178
+ if ( 0 == $arc_row->year ) {
179
+ continue;
180
+ }
181
+
182
+ $month = zeroise( $arc_row->month, 2 );
183
+ $year = $arc_row->year;
184
+
185
+ printf( "<option %s value='%s'>%s</option>\n",
186
+ selected( $m, $year . '-' . $month, false ),
187
+ esc_attr( $year . '-' . $month ),
188
+
189
+ sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month ), $year )
190
+ );
191
+ }
192
+ ?>
193
  </select>
194
+ <?php endif;
195
+ ?>
196
+ <select name="logs_per_page">
197
+ <option value="25"><?php _e( '25 per page', 'download-monitor' ); ?></option>
198
+ <option
199
+ value="50" <?php selected( $this->logs_per_page, 50 ) ?>><?php _e( '50 per page', 'download-monitor' ); ?></option>
200
+ <option
201
+ value="100" <?php selected( $this->logs_per_page, 100 ) ?>><?php _e( '100 per page', 'download-monitor' ); ?></option>
202
+ <option
203
+ value="200" <?php selected( $this->logs_per_page, 200 ) ?>><?php _e( '200 per page', 'download-monitor' ); ?></option>
204
+ <option
205
+ value="-1" <?php selected( $this->logs_per_page, - 1 ) ?>><?php _e( 'Show All', 'download-monitor' ); ?></option>
206
+ </select>
207
+ <input type="hidden" name="post_type" value="dlm_download"/>
208
+ <input type="hidden" name="page" value="download-monitor-logs"/>
209
+ <input type="submit" value="<?php _e( 'Filter', 'download-monitor' ); ?>" class="button"/>
210
+ </div>
211
+ <?php endif; ?>
212
+ <?php
213
+ $this->extra_tablenav( $which );
214
+ $this->pagination( $which );
215
+ ?>
216
+ <br class="clear"/>
217
  </div><?php
218
  }
219
 
237
 
238
  $query_where = " type = 'download' ";
239
 
240
+ if ( $this->filter_status ) {
241
  $query_where .= " AND download_status = '{$filter_status}' ";
242
+ }
243
 
244
+ if ( $this->filter_month ) {
245
  $query_where .= " AND download_date >= '" . date( 'Y-m-01', strtotime( $this->filter_month ) ) . "' ";
246
+ }
247
 
248
+ if ( $this->filter_month ) {
249
  $query_where .= " AND download_date <= '" . date( 'Y-m-t', strtotime( $this->filter_month ) ) . "' ";
250
+ }
251
 
252
  // Total Count of Logs
253
  $total_items = $wpdb->get_var( "SELECT COUNT(ID) FROM {$wpdb->download_log} WHERE {$query_where};" );
269
  ) );
270
 
271
  // Parser
272
+ if ( ! class_exists( 'UAParser' ) ) {
273
+ require_once( "uaparser/uaparser.php" );
274
+ }
275
 
276
  $this->uaparser = new UAParser;
277
  }
includes/admin/html-downloadable-file-version.php CHANGED
@@ -2,9 +2,10 @@
2
  <h3>
3
  <button type="button" class="remove_file button"><?php _e( 'Remove', 'download-monitor' ); ?></button>
4
  <div class="handlediv" title="<?php _e( 'Click to toggle', 'download-monitor' ); ?>"></div>
5
- <strong>#<?php echo $file_id; ?> &mdash; <?php echo sprintf( __( 'Version <span class="version">%s</span> (%s)', 'download-monitor' ), ( $file_version ) ? $file_version : __('n/a', 'download-monitor'), date_i18n( get_option( 'date_format' ), strtotime( $file_post_date ) ) ); ?> &mdash; <?php echo sprintf( _n('Downloaded %s time', 'Downloaded %s times', $file_download_count, 'download-monitor'), $file_download_count ); ?></strong>
6
- <input type="hidden" name="downloadable_file_id[<?php echo $i; ?>]" value="<?php echo $file_id; ?>" />
7
- <input type="hidden" class="file_menu_order" name="downloadable_file_menu_order[<?php echo $i; ?>]" value="<?php echo $i; ?>" />
 
8
  </h3>
9
  <table cellpadding="0" cellspacing="0" class="dlm-metabox-content">
10
  <tbody>
@@ -12,55 +13,70 @@
12
  <?php do_action( 'dlm_downloadable_file_version_table_start' ); ?>
13
 
14
  <tr>
15
- <td width="1%">
16
- <label><?php _e( 'Version', 'download-monitor' ); ?>:</label>
17
- <input type="text" class="short" name="downloadable_file_version[<?php echo $i; ?>]" placeholder="<?php _e( 'n/a', 'download-monitor' ); ?>" value="<?php echo $file_version; ?>" />
18
- </td>
19
- <td rowspan="3">
 
20
 
21
- <label><?php _e( 'File URL(s)', 'download-monitor' ); ?>:</label>
22
- <textarea name="downloadable_file_urls[<?php echo $i; ?>]" wrap="off" class="downloadable_file_urls" cols="5" rows="5" placeholder="<?php _e( 'Enter one file path/URL per line - multiple files will be used as mirrors (chosen at random).', 'download-monitor' ); ?>"><?php echo esc_textarea( implode( "\n", $file_urls ) ); ?></textarea>
23
- <p>
24
- <?php
25
- $buttons = apply_filters( 'dlm_downloadable_file_version_buttons', array(
26
- 'upload_file' => array(
27
- 'text' => __( 'Upload file', 'download-monitor' ),
28
- 'data' => array(
29
- 'choose' => __( 'Choose a file', 'download-monitor' ),
30
- 'update' => __( 'Insert file URL', 'download-monitor' ),
31
- )
32
- ),
33
- 'browse_for_file' => array(
34
- 'text' => __( 'Browse for file', 'download-monitor' )
35
- )
36
- ) );
37
 
38
- foreach ( $buttons as $key => $button ) {
39
- echo '<a href="#" class="button dlm_' . esc_attr( $key ) . '" ';
40
- if ( ! empty( $button['data'] ) )
41
- foreach ( $button['data'] as $data_key => $data_value )
42
- echo 'data-' . esc_attr( $data_key ) . '="' . esc_attr( $data_value ) . '" ';
43
- echo '>' . esc_html( $button['text'] ) . '</a> ';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  }
45
- ?>
46
- </p>
 
 
 
47
 
48
- </td>
49
- </tr>
50
- <tr>
51
- <td>
52
- <label><?php _e( 'Download count', 'download-monitor' ); ?>:</label>
53
- <input type="text" class="short" name="downloadable_file_download_count[<?php echo $i; ?>]" placeholder="<?php echo $file_download_count; ?>" />
54
- </td>
55
- </tr>
56
- <tr>
57
- <td>
58
- <label><?php _e('File Date', 'download-monitor'); ?>:</label>
59
- <input type="text" class="date-picker-field" name="downloadable_file_date[<?php echo $i; ?>]" maxlength="10" value="<?php echo date('Y-m-d', strtotime( $file_post_date ) ); ?>" /> @ <input type="text" class="hour" placeholder="<?php _e('h', 'download-monitor') ?>" name="downloadable_file_date_hour[<?php echo $i; ?>]" maxlength="2" size="2" value="<?php echo date('H', strtotime( $file_post_date ) ); ?>" />:<input type="text" class="minute" placeholder="<?php _e('m', 'download-monitor') ?>" name="downloadable_file_date_minute[<?php echo $i; ?>]" maxlength="2" size="2" value="<?php echo date('i', strtotime( $file_post_date ) ); ?>" />
60
- </td>
61
- </tr>
 
 
 
 
 
 
 
 
 
62
 
63
- <?php do_action( 'dlm_downloadable_file_version_table_end' ); ?>
64
 
65
  </tbody>
66
  </table>
2
  <h3>
3
  <button type="button" class="remove_file button"><?php _e( 'Remove', 'download-monitor' ); ?></button>
4
  <div class="handlediv" title="<?php _e( 'Click to toggle', 'download-monitor' ); ?>"></div>
5
+ <strong>#<?php echo $file_id; ?> &mdash; <?php echo sprintf( __( 'Version <span class="version">%s</span> (%s)', 'download-monitor' ), ( $file_version ) ? $file_version : __( 'n/a', 'download-monitor' ), date_i18n( get_option( 'date_format' ), strtotime( $file_post_date ) ) ); ?> &mdash; <?php echo sprintf( _n( 'Downloaded %s time', 'Downloaded %s times', $file_download_count, 'download-monitor' ), $file_download_count ); ?></strong>
6
+ <input type="hidden" name="downloadable_file_id[<?php echo $i; ?>]" value="<?php echo $file_id; ?>"/>
7
+ <input type="hidden" class="file_menu_order" name="downloadable_file_menu_order[<?php echo $i; ?>]"
8
+ value="<?php echo $i; ?>"/>
9
  </h3>
10
  <table cellpadding="0" cellspacing="0" class="dlm-metabox-content">
11
  <tbody>
13
  <?php do_action( 'dlm_downloadable_file_version_table_start' ); ?>
14
 
15
  <tr>
16
+ <td width="1%">
17
+ <label><?php _e( 'Version', 'download-monitor' ); ?>:</label>
18
+ <input type="text" class="short" name="downloadable_file_version[<?php echo $i; ?>]"
19
+ placeholder="<?php _e( 'n/a', 'download-monitor' ); ?>" value="<?php echo $file_version; ?>"/>
20
+ </td>
21
+ <td rowspan="3">
22
 
23
+ <label><?php _e( 'File URL(s)', 'download-monitor' ); ?>:</label>
24
+ <textarea name="downloadable_file_urls[<?php echo $i; ?>]" wrap="off" class="downloadable_file_urls"
25
+ cols="5" rows="5"
26
+ placeholder="<?php _e( 'Enter one file path/URL per line - multiple files will be used as mirrors (chosen at random).', 'download-monitor' ); ?>"><?php echo esc_textarea( implode( "\n", $file_urls ) ); ?></textarea>
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
+ <p>
29
+ <?php
30
+ $buttons = apply_filters( 'dlm_downloadable_file_version_buttons', array(
31
+ 'upload_file' => array(
32
+ 'text' => __( 'Upload file', 'download-monitor' ),
33
+ 'data' => array(
34
+ 'choose' => __( 'Choose a file', 'download-monitor' ),
35
+ 'update' => __( 'Insert file URL', 'download-monitor' ),
36
+ )
37
+ ),
38
+ 'browse_for_file' => array(
39
+ 'text' => __( 'Browse for file', 'download-monitor' )
40
+ )
41
+ ) );
42
+
43
+ foreach ( $buttons as $key => $button ) {
44
+ echo '<a href="#" class="button dlm_' . esc_attr( $key ) . '" ';
45
+ if ( ! empty( $button['data'] ) ) {
46
+ foreach ( $button['data'] as $data_key => $data_value ) {
47
+ echo 'data-' . esc_attr( $data_key ) . '="' . esc_attr( $data_value ) . '" ';
48
  }
49
+ }
50
+ echo '>' . esc_html( $button['text'] ) . '</a> ';
51
+ }
52
+ ?>
53
+ </p>
54
 
55
+ </td>
56
+ </tr>
57
+ <tr>
58
+ <td>
59
+ <label><?php _e( 'Download count', 'download-monitor' ); ?>:</label>
60
+ <input type="text" class="short" name="downloadable_file_download_count[<?php echo $i; ?>]"
61
+ placeholder="<?php echo $file_download_count; ?>"/>
62
+ </td>
63
+ </tr>
64
+ <tr>
65
+ <td>
66
+ <label><?php _e( 'File Date', 'download-monitor' ); ?>:</label>
67
+ <input type="text" class="date-picker-field" name="downloadable_file_date[<?php echo $i; ?>]"
68
+ maxlength="10" value="<?php echo date( 'Y-m-d', strtotime( $file_post_date ) ); ?>"/> @ <input
69
+ type="text" class="hour" placeholder="<?php _e( 'h', 'download-monitor' ) ?>"
70
+ name="downloadable_file_date_hour[<?php echo $i; ?>]" maxlength="2" size="2"
71
+ value="<?php echo date( 'H', strtotime( $file_post_date ) ); ?>"/>:<input type="text" class="minute"
72
+ placeholder="<?php _e( 'm', 'download-monitor' ) ?>"
73
+ name="downloadable_file_date_minute[<?php echo $i; ?>]"
74
+ maxlength="2" size="2"
75
+ value="<?php echo date( 'i', strtotime( $file_post_date ) ); ?>"/>
76
+ </td>
77
+ </tr>
78
 
79
+ <?php do_action( 'dlm_downloadable_file_version_table_end' ); ?>
80
 
81
  </tbody>
82
  </table>
includes/admin/uaparser/lib/json/jsonwrapper.php CHANGED
@@ -2,6 +2,7 @@
2
 
3
  require_once 'JSON.php';
4
 
 
5
  function json_encode($arg) {
6
  global $services_json;
7
  if (!isset($services_json)) {
@@ -9,7 +10,9 @@ function json_encode($arg) {
9
  }
10
  return $services_json->encode($arg);
11
  }
 
12
 
 
13
  function json_decode($arg) {
14
  global $services_json;
15
  if (!isset($services_json)) {
@@ -17,5 +20,4 @@ function json_decode($arg) {
17
  }
18
  return $services_json->decode($arg);
19
  }
20
-
21
- ?>
2
 
3
  require_once 'JSON.php';
4
 
5
+ if ( ! function_exists('json_encode') ) {
6
  function json_encode($arg) {
7
  global $services_json;
8
  if (!isset($services_json)) {
10
  }
11
  return $services_json->encode($arg);
12
  }
13
+ }
14
 
15
+ if ( ! function_exists('json_decode') ) {
16
  function json_decode($arg) {
17
  global $services_json;
18
  if (!isset($services_json)) {
20
  }
21
  return $services_json->decode($arg);
22
  }
23
+ }
 
includes/class-dlm-ajax-handler.php CHANGED
@@ -1,23 +1,25 @@
1
  <?php
2
 
3
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
4
 
5
  /**
6
- * WP_DLM_Ajax_Handler class.
7
  */
8
- class WP_DLM_Ajax_Handler {
9
 
10
  /**
11
  * __construct function.
12
  *
13
  * @access public
14
- * @return void
15
  */
16
  public function __construct() {
17
  add_action( 'wp_ajax_download_monitor_remove_file', array( $this, 'remove_file' ) );
18
  add_action( 'wp_ajax_download_monitor_add_file', array( $this, 'add_file' ) );
19
  add_action( 'wp_ajax_download_monitor_list_files', array( $this, 'list_files' ) );
20
  add_action( 'wp_ajax_download_monitor_insert_panel_upload', array( $this, 'insert_panel_upload' ) );
 
21
  }
22
 
23
  /**
@@ -100,34 +102,46 @@ class WP_DLM_Ajax_Handler {
100
  * @return void
101
  */
102
  public function list_files() {
103
- global $download_monitor;
104
 
 
105
  check_ajax_referer( 'list-files', 'security' );
106
 
107
- if ( ! current_user_can('manage_downloads') ) return false;
 
 
 
108
 
109
  $path = esc_attr( stripslashes( $_POST['path'] ) );
110
 
111
  if ( $path ) {
112
- $files = $download_monitor->list_files( $path );
113
 
114
- foreach( $files as $found_file ) {
 
 
 
 
 
 
115
 
116
  $file = pathinfo( $found_file['path'] );
117
 
118
  if ( $found_file['type'] == 'folder' ) {
119
 
120
- echo '<li><a href="#" class="folder" data-path="' . trailingslashit( $file['dirname'] ) . $file['basename'] . '">' . $file['basename'] . '</a></li>';
121
 
122
  } else {
123
 
124
- $filename = $file['basename'];
125
  $extension = ( empty( $file['extension'] ) ) ? '' : $file['extension'];
126
 
127
- if ( substr( $filename, 0, 1 ) == '.' ) continue; // Ignore files starting with . like htaccess
128
- if ( in_array( $extension, array( '', 'php', 'html', 'htm', 'tmp' ) ) ) continue; // Ignored file types
 
 
 
 
129
 
130
- echo '<li><a href="#" class="file filetype-' . sanitize_title( $extension ) . '" data-path="' . trailingslashit( $file['dirname'] ) . $file['basename'] . '">' . $file['basename'] . '</a></li>';
131
 
132
  }
133
 
@@ -136,6 +150,50 @@ class WP_DLM_Ajax_Handler {
136
 
137
  die();
138
  }
139
- }
140
 
141
- new WP_DLM_Ajax_Handler();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
 
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
 
7
  /**
8
+ * DLM_Ajax_Handler class.
9
  */
10
+ class DLM_Ajax_Handler {
11
 
12
  /**
13
  * __construct function.
14
  *
15
  * @access public
 
16
  */
17
  public function __construct() {
18
  add_action( 'wp_ajax_download_monitor_remove_file', array( $this, 'remove_file' ) );
19
  add_action( 'wp_ajax_download_monitor_add_file', array( $this, 'add_file' ) );
20
  add_action( 'wp_ajax_download_monitor_list_files', array( $this, 'list_files' ) );
21
  add_action( 'wp_ajax_download_monitor_insert_panel_upload', array( $this, 'insert_panel_upload' ) );
22
+ add_action( 'wp_ajax_dlm_extension', array( $this, 'handle_extensions' ) );
23
  }
24
 
25
  /**
102
  * @return void
103
  */
104
  public function list_files() {
 
105
 
106
+ // Check Nonce
107
  check_ajax_referer( 'list-files', 'security' );
108
 
109
+ // Check user rights
110
+ if ( ! current_user_can( 'manage_downloads' ) ) {
111
+ return false;
112
+ }
113
 
114
  $path = esc_attr( stripslashes( $_POST['path'] ) );
115
 
116
  if ( $path ) {
 
117
 
118
+ // The File Manager
119
+ $file_manager = new DLM_File_Manager();
120
+
121
+ // List all files
122
+ $files = $file_manager->list_files( $path );
123
+
124
+ foreach ( $files as $found_file ) {
125
 
126
  $file = pathinfo( $found_file['path'] );
127
 
128
  if ( $found_file['type'] == 'folder' ) {
129
 
130
+ echo '<li><a href="#" class="folder" data-path="' . trailingslashit( $file['dirname'] ) . $file['basename'] . '">' . $file['basename'] . '</a></li>';
131
 
132
  } else {
133
 
134
+ $filename = $file['basename'];
135
  $extension = ( empty( $file['extension'] ) ) ? '' : $file['extension'];
136
 
137
+ if ( substr( $filename, 0, 1 ) == '.' ) {
138
+ continue;
139
+ } // Ignore files starting with . like htaccess
140
+ if ( in_array( $extension, array( '', 'php', 'html', 'htm', 'tmp' ) ) ) {
141
+ continue;
142
+ } // Ignored file types
143
 
144
+ echo '<li><a href="#" class="file filetype-' . sanitize_title( $extension ) . '" data-path="' . trailingslashit( $file['dirname'] ) . $file['basename'] . '">' . $file['basename'] . '</a></li>';
145
 
146
  }
147
 
150
 
151
  die();
152
  }
 
153
 
154
+ /**
155
+ * Handle extensions AJAX
156
+ */
157
+ public function handle_extensions() {
158
+
159
+ // Check nonce
160
+ check_ajax_referer( 'dlm-ajax-nonce', 'nonce' );
161
+
162
+ // Post vars
163
+ $product_id = sanitize_text_field( $_POST['product_id'] );
164
+ $key = sanitize_text_field( $_POST['key'] );
165
+ $email = sanitize_text_field( $_POST['email'] );
166
+ $extension_action = $_POST['extension_action'];
167
+
168
+ // Get products
169
+ $products = DLM_Product_Manager::get()->get_products();
170
+
171
+ // Check if product exists
172
+ if ( isset( $products[ $product_id ] ) ) {
173
+
174
+ // Get correct product
175
+ $product = $products[ $product_id ];
176
+
177
+ // Set new key in license object
178
+ $product->get_license()->set_key( $key );
179
+
180
+ // Set new email in license object
181
+ $product->get_license()->set_email( $email );
182
+
183
+
184
+
185
+ if( 'activate' === $extension_action ) {
186
+ // Try to activate the license
187
+ $response = $product->activate();
188
+ }else {
189
+ // Try to deactivate the license
190
+ $response = $product->deactivate();
191
+ }
192
+
193
+ }
194
+
195
+ // Send JSON
196
+ wp_send_json( $response );
197
+
198
+ }
199
+ }
includes/class-dlm-autoloader.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
+
7
+ class DLM_Autoloader {
8
+
9
+ private $path;
10
+
11
+ /**
12
+ * The Constructor, sets the path of the class directory.
13
+ *
14
+ * @param $path
15
+ */
16
+ public function __construct( $path ) {
17
+ $this->path = $path;
18
+ }
19
+
20
+
21
+ /**
22
+ * Autoloader load method. Load the class.
23
+ *
24
+ * @param $class_name
25
+ */
26
+ public function load( $class_name ) {
27
+
28
+ // Only load DLM
29
+ if ( 0 === strpos( $class_name, 'DLM_' ) ) {
30
+
31
+ // String to lower
32
+ $class_name = strtolower( $class_name );
33
+
34
+ // Format file name
35
+ $file_name = 'class-' . str_ireplace( '_', '-', str_ireplace( 'DLM_', 'dlm-', $class_name ) ) . '.php';
36
+
37
+ // Setup the file path
38
+ $file_path = $this->path;
39
+
40
+ // Check if we need to extend the class path
41
+ if ( strpos( $class_name, 'dlm_admin' ) === 0 ) {
42
+ $file_path .= 'admin/';
43
+ } else if ( strpos( $class_name, 'dlm_widget' ) === 0 ) {
44
+ $file_path .= 'widgets/';
45
+ } else if ( strpos( $class_name, 'dlm_product' ) === 0 ) {
46
+ $file_path .= 'product/';
47
+ }
48
+
49
+ // Append file name to clas path
50
+ $file_path .= $file_name;
51
+
52
+ // Check & load file
53
+ if ( file_exists( $file_path ) ) {
54
+ require_once( $file_path );
55
+ }
56
+
57
+ }
58
+
59
+ }
60
+
61
+ }
includes/class-dlm-debug-logger.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class DLM_Debug_Logger {
4
+
5
+ public static function deprecated( $method ) {
6
+
7
+ // Don't log if WP_DEBUG is off
8
+ if ( ! WP_DEBUG ) {
9
+ return;
10
+ }
11
+
12
+ // Debug message
13
+ $message = 'Deprecated method called: ' . $method . PHP_EOL;
14
+
15
+ /*
16
+ // Get stack trace
17
+ $stack_trace = debug_backtrace();
18
+
19
+ // Remove this method
20
+ array_shift( $stack_trace );
21
+
22
+ if ( count( $stack_trace ) > 0 ) {
23
+ foreach ( $stack_trace as $item ) {
24
+
25
+ // Add Class
26
+ if ( isset( $item['class'] ) ) {
27
+ $message .= $item['class'] . '::';
28
+ }
29
+
30
+ // Add Method / Functions
31
+ if ( isset( $item['function'] ) ) {
32
+ $message .= $item['function'] . ' - ';
33
+ }
34
+
35
+ // Add File
36
+ if ( isset( $item['file'] ) ) {
37
+ $message .= $item['file'];
38
+ }
39
+
40
+ // Add Line #
41
+ if ( isset( $item['line'] ) ) {
42
+ $message .= '#' . $item['line'];
43
+ }
44
+
45
+ // EOL
46
+ $message .= PHP_EOL;
47
+ }
48
+ }
49
+ */
50
+
51
+ error_log( $message, 0 );
52
+ }
53
+
54
+ }
includes/class-dlm-download-handler.php CHANGED
@@ -1,6 +1,8 @@
1
  <?php
2
 
3
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
4
 
5
  /**
6
  * DLM_Download_Handler class.
@@ -11,33 +13,39 @@ class DLM_Download_Handler {
11
  private $ep_value;
12
 
13
  /**
14
- * __construct function.
15
- *
16
- * @access public
17
- * @return void
18
  */
19
  public function __construct() {
20
  $this->endpoint = ( $endpoint = get_option( 'dlm_download_endpoint' ) ) ? $endpoint : 'download';
21
  $this->ep_value = ( $ep_value = get_option( 'dlm_download_endpoint_value' ) ) ? $ep_value : 'ID';
 
22
 
23
- add_filter( 'query_vars', array( $this, 'add_query_vars'), 0 );
24
- add_action( 'init', array( $this, 'add_endpoint'), 0 );
25
- add_action( 'parse_request', array( $this, 'handler'), 0 );
 
 
 
 
26
  add_action( 'dlm_can_download', array( $this, 'check_access' ), 10, 2 );
27
  }
28
 
 
29
  /**
30
  * Check access (hooked into dlm_can_download) checks if the download is members only and enfoces log in.
31
  *
32
  * Other plugins can use the 'dlm_can_download' filter directly to change access rights.
33
  *
34
  * @access public
 
35
  * @param mixed $download
 
36
  * @return void
37
  */
38
  public function check_access( $can_download, $download ) {
39
- if ( $download->is_members_only() && ! is_user_logged_in() )
40
  $can_download = false;
 
41
 
42
  return $can_download;
43
  }
@@ -50,6 +58,7 @@ class DLM_Download_Handler {
50
  */
51
  public function add_query_vars( $vars ) {
52
  $vars[] = $this->endpoint;
 
53
  return $vars;
54
  }
55
 
@@ -64,7 +73,7 @@ class DLM_Download_Handler {
64
  }
65
 
66
  /**
67
- * Listen for download requets and trigger downloading.
68
  *
69
  * @access public
70
  * @return void
@@ -76,7 +85,7 @@ class DLM_Download_Handler {
76
  $wp->query_vars[ $this->endpoint ] = $_GET[ $this->endpoint ];
77
  }
78
 
79
- if ( ! empty( $wp->query_vars[ $this->endpoint ] ) && strstr( $wp->request, $this->endpoint . '/' ) ) {
80
 
81
  // Prevent caching when endpoint is set
82
  define( 'DONOTCACHEPAGE', true );
@@ -107,10 +116,10 @@ class DLM_Download_Handler {
107
  switch ( $this->ep_value ) {
108
  case 'slug' :
109
  $download_id = absint( $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_name = '%s' AND post_type = 'dlm_download';", $raw_id ) ) );
110
- break;
111
  default :
112
  $download_id = absint( $raw_id );
113
- break;
114
  }
115
 
116
  if ( $download_id > 0 ) {
@@ -140,17 +149,13 @@ class DLM_Download_Handler {
140
  wp_die( get_the_password_form( $download_id ), __( 'Password Required', 'download-monitor' ) );
141
  }
142
  $this->trigger( $download, $version_id );
143
- }
144
-
145
- elseif ( $redirect = apply_filters( 'dlm_404_redirect', false ) ) {
146
  wp_redirect( $redirect );
147
- }
148
-
149
- else {
150
  wp_die( __( 'Download does not exist.', 'download-monitor' ) . ' <a href="' . home_url() . '">' . __( 'Go to homepage &rarr;', 'download-monitor' ) . '</a>', __( 'Download Error', 'download-monitor' ), array( 'response' => 404 ) );
151
  }
152
 
153
- die('1');
154
  }
155
  }
156
 
@@ -158,40 +163,52 @@ class DLM_Download_Handler {
158
  * Create a log if logging is enabled
159
  */
160
  private function log( $type = '', $status = '', $message = '', $download, $version ) {
161
- if ( function_exists( 'dlm_create_log' ) ) {
162
- dlm_create_log( $type, $status, $message, $download, $version );
 
 
 
 
 
 
 
 
163
  }
 
164
  }
165
 
166
  /**
167
  * trigger function.
168
  *
169
  * @access private
 
170
  * @param mixed $download
 
171
  * @return void
172
  */
173
  private function trigger( $download ) {
174
- global $download_monitor;
175
 
176
  $version = $download->get_file_version();
177
  $file_paths = $version->mirrors;
178
 
179
- if ( empty( $file_paths ) )
180
  wp_die( __( 'No file paths defined.', 'download-monitor' ) . ' <a href="' . home_url() . '">' . __( 'Go to homepage &rarr;', 'download-monitor' ) . '</a>', __( 'Download Error', 'download-monitor' ) );
 
181
 
182
- $file_path = $file_paths[ array_rand( $file_paths ) ];
183
 
184
- if ( ! $file_path )
185
  wp_die( __( 'No file paths defined.', 'download-monitor' ) . ' <a href="' . home_url() . '">' . __( 'Go to homepage &rarr;', 'download-monitor' ) . '</a>', __( 'Download Error', 'download-monitor' ) );
 
186
 
187
  // Check Access
188
  if ( ! apply_filters( 'dlm_can_download', true, $download, $version ) ) {
189
 
190
- if ( $redirect = apply_filters( 'dlm_access_denied_redirect', false ) )
191
  wp_redirect( $redirect );
192
-
193
- else
194
  wp_die( __( 'You do not have permission to access this download.', 'download-monitor' ) . ' <a href="' . home_url() . '">' . __( 'Go to homepage &rarr;', 'download-monitor' ) . '</a>', __( 'Download Error', 'download-monitor' ), array( 'response' => 200 ) );
 
195
 
196
  exit;
197
  }
@@ -204,7 +221,7 @@ class DLM_Download_Handler {
204
  do_action( 'dlm_downloading', $download, $version, $file_path );
205
 
206
  // Set cookie to prevent double logging
207
- setcookie( 'wp_dlm_downloading', $download->id, time()+60, COOKIEPATH, COOKIE_DOMAIN, false );
208
  }
209
 
210
  // Redirect to the file...
@@ -218,39 +235,43 @@ class DLM_Download_Handler {
218
  exit;
219
  }
220
 
221
- list( $file_path, $remote_file ) = $download_monitor->parse_file_path( $file_path );
 
 
 
 
222
 
223
  $this->download_headers( $file_path, $download, $version );
224
 
225
  if ( get_option( 'dlm_xsendfile_enabled' ) ) {
226
- if ( function_exists( 'apache_get_modules' ) && in_array( 'mod_xsendfile', apache_get_modules() ) ) {
227
 
228
- $this->log( 'download', 'redirected', __( 'Redirected to file', 'download-monitor' ), $download, $version );
229
 
230
- header( "X-Sendfile: $file_path" );
231
- exit;
232
 
233
- } elseif ( stristr( getenv( 'SERVER_SOFTWARE' ), 'lighttpd' ) ) {
234
 
235
- $this->log( 'download', 'redirected', __( 'Redirected to file', 'download-monitor' ), $download, $version );
236
 
237
- header( "X-LIGHTTPD-send-file: $file_path" );
238
- exit;
239
 
240
- } elseif ( stristr( getenv( 'SERVER_SOFTWARE' ), 'nginx' ) || stristr( getenv( 'SERVER_SOFTWARE' ), 'cherokee' ) ) {
241
 
242
- $this->log( 'download', 'redirected', __( 'Redirected to file', 'download-monitor' ), $download, $version );
243
 
244
- $file_path = str_ireplace( $_SERVER[ 'DOCUMENT_ROOT' ], '', $file_path );
245
  header( "X-Accel-Redirect: /$file_path" );
246
- exit;
247
- }
248
- }
249
 
250
- // multipart-download and download resuming support - http://www.phpgang.com/force-to-download-a-file-in-php_112.html
251
  if ( isset( $_SERVER['HTTP_RANGE'] ) && $version->filesize ) {
252
  list( $a, $range ) = explode( "=", $_SERVER['HTTP_RANGE'], 2 );
253
- list( $range ) = explode( ",",$range, 2 );
254
  list( $range, $range_end ) = explode( "-", $range );
255
  $range = intval( $range );
256
 
@@ -270,25 +291,25 @@ class DLM_Download_Handler {
270
  $range = false;
271
  }
272
 
273
- if ( $this->readfile_chunked( $file_path, $range ) ) {
274
 
275
- // Complete!
276
- $this->log( 'download', 'completed', '', $download, $version );
277
 
278
- } elseif ( $remote_file ) {
279
 
280
- // Redirect - we can't track if this completes or not
281
- $this->log( 'download', 'redirected', __( 'Redirected to remote file.', 'download-monitor' ), $download, $version );
282
 
283
- header( 'Location: ' . $file_path );
284
 
285
- } else {
286
- $this->log( 'download', 'failed', __( 'File not found', 'download-monitor' ), $download, $version );
287
 
288
- wp_die( __( 'File not found.', 'download-monitor' ) . ' <a href="' . home_url() . '">' . __( 'Go to homepage &rarr;', 'download-monitor' ) . '</a>', __( 'Download Error', 'download-monitor' ), array( 'response' => 404 ) );
289
- }
290
 
291
- exit;
292
  }
293
 
294
  /**
@@ -311,22 +332,26 @@ class DLM_Download_Handler {
311
  // Get file name
312
  $file_name = urldecode( basename( $file_path ) );
313
 
314
- if ( strstr( $file_name, '?' ) )
315
  $file_name = current( explode( '?', $file_name ) );
 
316
 
317
  // Environment + headers
318
- if ( ! ini_get('safe_mode') )
319
- @set_time_limit(0);
 
320
 
321
- if ( function_exists( 'get_magic_quotes_runtime' ) && get_magic_quotes_runtime() )
322
- @set_magic_quotes_runtime(0);
 
323
 
324
- if( function_exists( 'apache_setenv' ) )
325
  @apache_setenv( 'no-gzip', 1 );
 
326
 
327
  @session_write_close();
328
  @ini_set( 'zlib.output_compression', 'Off' );
329
- @error_reporting(0);
330
 
331
  /**
332
  * Prevents errors, for example: transfer closed with 3 bytes remaining to read
@@ -337,24 +362,32 @@ class DLM_Download_Handler {
337
  @ob_end_clean(); // Zip corruption fix
338
  }
339
 
 
 
340
  if ( $is_IE && is_ssl() ) {
341
  // IE bug prevents download via SSL when Cache Control and Pragma no-cache headers set.
342
- header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' );
343
- header( 'Cache-Control: private' );
344
  } else {
345
  nocache_headers();
346
  }
347
 
348
- header( "X-Robots-Tag: noindex, nofollow", true );
349
- header( "Content-Type: " . $mime_type );
350
- header( "Content-Description: File Transfer" );
351
- header( "Content-Disposition: attachment; filename=\"" . $file_name . "\";" );
352
- header( "Content-Transfer-Encoding: binary" );
 
 
 
 
 
353
 
354
- if ( $version->filesize ) {
355
- header( "Content-Length: " . $version->filesize );
356
- header( "Accept-Ranges: bytes" );
357
- }
 
358
  }
359
 
360
  /**
@@ -363,9 +396,11 @@ class DLM_Download_Handler {
363
  * Reads file in chunks so big downloads are possible without changing PHP.INI - http://codeigniter.com/wiki/Download_helper_for_large_files/
364
  *
365
  * @access public
 
366
  * @param string file
367
  * @param boolean return bytes of file
368
  * @param range if HTTP RANGE to seek
 
369
  * @return void
370
  */
371
  public function readfile_chunked( $file, $retbytes = true, $range = false ) {
@@ -374,27 +409,29 @@ class DLM_Download_Handler {
374
  $cnt = 0;
375
  $handle = fopen( $file, 'r' );
376
 
377
- if ( $handle === false )
378
  return false;
 
379
 
380
- if ( $range )
381
  fseek( $handle, $range );
 
382
 
383
  while ( ! feof( $handle ) ) {
384
  $buffer = fread( $handle, $chunksize );
385
  echo $buffer;
386
 
387
- if ( $retbytes )
388
  $cnt += strlen( $buffer );
 
389
  }
390
 
391
  $status = fclose( $handle );
392
 
393
- if ( $retbytes && $status )
394
  return $cnt;
 
395
 
396
  return $status;
397
  }
398
  }
399
-
400
- $GLOBALS['DLM_Download_Handler'] = new DLM_Download_Handler();
1
  <?php
2
 
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
 
7
  /**
8
  * DLM_Download_Handler class.
13
  private $ep_value;
14
 
15
  /**
16
+ * Constructor
 
 
 
17
  */
18
  public function __construct() {
19
  $this->endpoint = ( $endpoint = get_option( 'dlm_download_endpoint' ) ) ? $endpoint : 'download';
20
  $this->ep_value = ( $ep_value = get_option( 'dlm_download_endpoint_value' ) ) ? $ep_value : 'ID';
21
+ }
22
 
23
+ /**
24
+ * Setup Download Handler class
25
+ */
26
+ public function setup() {
27
+ add_filter( 'query_vars', array( $this, 'add_query_vars' ), 0 );
28
+ add_action( 'init', array( $this, 'add_endpoint' ), 0 );
29
+ add_action( 'parse_request', array( $this, 'handler' ), 0 );
30
  add_action( 'dlm_can_download', array( $this, 'check_access' ), 10, 2 );
31
  }
32
 
33
+
34
  /**
35
  * Check access (hooked into dlm_can_download) checks if the download is members only and enfoces log in.
36
  *
37
  * Other plugins can use the 'dlm_can_download' filter directly to change access rights.
38
  *
39
  * @access public
40
+ *
41
  * @param mixed $download
42
+ *
43
  * @return void
44
  */
45
  public function check_access( $can_download, $download ) {
46
+ if ( $download->is_members_only() && ! is_user_logged_in() ) {
47
  $can_download = false;
48
+ }
49
 
50
  return $can_download;
51
  }
58
  */
59
  public function add_query_vars( $vars ) {
60
  $vars[] = $this->endpoint;
61
+
62
  return $vars;
63
  }
64
 
73
  }
74
 
75
  /**
76
+ * Listen for download requests and trigger downloading.
77
  *
78
  * @access public
79
  * @return void
85
  $wp->query_vars[ $this->endpoint ] = $_GET[ $this->endpoint ];
86
  }
87
 
88
+ if ( ! empty( $wp->query_vars[ $this->endpoint ] ) && ( ( null === $wp->request ) || ( null !== $wp->request && strstr( $wp->request, $this->endpoint . '/' ) ) ) ) {
89
 
90
  // Prevent caching when endpoint is set
91
  define( 'DONOTCACHEPAGE', true );
116
  switch ( $this->ep_value ) {
117
  case 'slug' :
118
  $download_id = absint( $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_name = '%s' AND post_type = 'dlm_download';", $raw_id ) ) );
119
+ break;
120
  default :
121
  $download_id = absint( $raw_id );
122
+ break;
123
  }
124
 
125
  if ( $download_id > 0 ) {
149
  wp_die( get_the_password_form( $download_id ), __( 'Password Required', 'download-monitor' ) );
150
  }
151
  $this->trigger( $download, $version_id );
152
+ } elseif ( $redirect = apply_filters( 'dlm_404_redirect', false ) ) {
 
 
153
  wp_redirect( $redirect );
154
+ } else {
 
 
155
  wp_die( __( 'Download does not exist.', 'download-monitor' ) . ' <a href="' . home_url() . '">' . __( 'Go to homepage &rarr;', 'download-monitor' ) . '</a>', __( 'Download Error', 'download-monitor' ), array( 'response' => 404 ) );
156
  }
157
 
158
+ die( '1' );
159
  }
160
  }
161
 
163
  * Create a log if logging is enabled
164
  */
165
  private function log( $type = '', $status = '', $message = '', $download, $version ) {
166
+
167
+ // Logging object
168
+ $logging = new DLM_Logging();
169
+
170
+ // Check if logging is enabled
171
+ if( $logging->is_logging_enabled() ) {
172
+
173
+ // Create log
174
+ $logging->create_log( $type, $status, $message, $download, $version );
175
+
176
  }
177
+
178
  }
179
 
180
  /**
181
  * trigger function.
182
  *
183
  * @access private
184
+ *
185
  * @param mixed $download
186
+ *
187
  * @return void
188
  */
189
  private function trigger( $download ) {
 
190
 
191
  $version = $download->get_file_version();
192
  $file_paths = $version->mirrors;
193
 
194
+ if ( empty( $file_paths ) ) {
195
  wp_die( __( 'No file paths defined.', 'download-monitor' ) . ' <a href="' . home_url() . '">' . __( 'Go to homepage &rarr;', 'download-monitor' ) . '</a>', __( 'Download Error', 'download-monitor' ) );
196
+ }
197
 
198
+ $file_path = $file_paths[ array_rand( $file_paths ) ];
199
 
200
+ if ( ! $file_path ) {
201
  wp_die( __( 'No file paths defined.', 'download-monitor' ) . ' <a href="' . home_url() . '">' . __( 'Go to homepage &rarr;', 'download-monitor' ) . '</a>', __( 'Download Error', 'download-monitor' ) );
202
+ }
203
 
204
  // Check Access
205
  if ( ! apply_filters( 'dlm_can_download', true, $download, $version ) ) {
206
 
207
+ if ( $redirect = apply_filters( 'dlm_access_denied_redirect', false ) ) {
208
  wp_redirect( $redirect );
209
+ } else {
 
210
  wp_die( __( 'You do not have permission to access this download.', 'download-monitor' ) . ' <a href="' . home_url() . '">' . __( 'Go to homepage &rarr;', 'download-monitor' ) . '</a>', __( 'Download Error', 'download-monitor' ), array( 'response' => 200 ) );
211
+ }
212
 
213
  exit;
214
  }
221
  do_action( 'dlm_downloading', $download, $version, $file_path );
222
 
223
  // Set cookie to prevent double logging
224
+ setcookie( 'wp_dlm_downloading', $download->id, time() + 60, COOKIEPATH, COOKIE_DOMAIN, false );
225
  }
226
 
227
  // Redirect to the file...
235
  exit;
236
  }
237
 
238
+ // File Manager
239
+ $file_manager = new DLM_File_Manager();
240
+
241
+ // Parse file path
242
+ list( $file_path, $remote_file ) = $file_manager->parse_file_path( $file_path );
243
 
244
  $this->download_headers( $file_path, $download, $version );
245
 
246
  if ( get_option( 'dlm_xsendfile_enabled' ) ) {
247
+ if ( function_exists( 'apache_get_modules' ) && in_array( 'mod_xsendfile', apache_get_modules() ) ) {
248
 
249
+ $this->log( 'download', 'redirected', __( 'Redirected to file', 'download-monitor' ), $download, $version );
250
 
251
+ header( "X-Sendfile: $file_path" );
252
+ exit;
253
 
254
+ } elseif ( stristr( getenv( 'SERVER_SOFTWARE' ), 'lighttpd' ) ) {
255
 
256
+ $this->log( 'download', 'redirected', __( 'Redirected to file', 'download-monitor' ), $download, $version );
257
 
258
+ header( "X-LIGHTTPD-send-file: $file_path" );
259
+ exit;
260
 
261
+ } elseif ( stristr( getenv( 'SERVER_SOFTWARE' ), 'nginx' ) || stristr( getenv( 'SERVER_SOFTWARE' ), 'cherokee' ) ) {
262
 
263
+ $this->log( 'download', 'redirected', __( 'Redirected to file', 'download-monitor' ), $download, $version );
264
 
265
+ $file_path = str_ireplace( $_SERVER['DOCUMENT_ROOT'], '', $file_path );
266
  header( "X-Accel-Redirect: /$file_path" );
267
+ exit;
268
+ }
269
+ }
270
 
271
+ // multipart-download and download resuming support - http://www.phpgang.com/force-to-download-a-file-in-php_112.html
272
  if ( isset( $_SERVER['HTTP_RANGE'] ) && $version->filesize ) {
273
  list( $a, $range ) = explode( "=", $_SERVER['HTTP_RANGE'], 2 );
274
+ list( $range ) = explode( ",", $range, 2 );
275
  list( $range, $range_end ) = explode( "-", $range );
276
  $range = intval( $range );
277
 
291
  $range = false;
292
  }
293
 
294
+ if ( $this->readfile_chunked( $file_path, $range ) ) {
295
 
296
+ // Complete!
297
+ $this->log( 'download', 'completed', '', $download, $version );
298
 
299
+ } elseif ( $remote_file ) {
300
 
301
+ // Redirect - we can't track if this completes or not
302
+ $this->log( 'download', 'redirected', __( 'Redirected to remote file.', 'download-monitor' ), $download, $version );
303
 
304
+ header( 'Location: ' . $file_path );
305
 
306
+ } else {
307
+ $this->log( 'download', 'failed', __( 'File not found', 'download-monitor' ), $download, $version );
308
 
309
+ wp_die( __( 'File not found.', 'download-monitor' ) . ' <a href="' . home_url() . '">' . __( 'Go to homepage &rarr;', 'download-monitor' ) . '</a>', __( 'Download Error', 'download-monitor' ), array( 'response' => 404 ) );
310
+ }
311
 
312
+ exit;
313
  }
314
 
315
  /**
332
  // Get file name
333
  $file_name = urldecode( basename( $file_path ) );
334
 
335
+ if ( strstr( $file_name, '?' ) ) {
336
  $file_name = current( explode( '?', $file_name ) );
337
+ }
338
 
339
  // Environment + headers
340
+ if ( ! ini_get( 'safe_mode' ) ) {
341
+ @set_time_limit( 0 );
342
+ }
343
 
344
+ if ( function_exists( 'get_magic_quotes_runtime' ) && get_magic_quotes_runtime() ) {
345
+ @set_magic_quotes_runtime( 0 );
346
+ }
347
 
348
+ if ( function_exists( 'apache_setenv' ) ) {
349
  @apache_setenv( 'no-gzip', 1 );
350
+ }
351
 
352
  @session_write_close();
353
  @ini_set( 'zlib.output_compression', 'Off' );
354
+ @error_reporting( 0 );
355
 
356
  /**
357
  * Prevents errors, for example: transfer closed with 3 bytes remaining to read
362
  @ob_end_clean(); // Zip corruption fix
363
  }
364
 
365
+ $headers = array();
366
+
367
  if ( $is_IE && is_ssl() ) {
368
  // IE bug prevents download via SSL when Cache Control and Pragma no-cache headers set.
369
+ $headers['Expires'] = 'Wed, 11 Jan 1984 05:00:00 GMT';
370
+ $headers['Cache-Control'] = 'private';
371
  } else {
372
  nocache_headers();
373
  }
374
 
375
+ $headers['X-Robots-Tag'] = 'noindex, nofollow';
376
+ $headers['Content-Type'] = $mime_type;
377
+ $headers['Content-Description'] = 'File Transfer';
378
+ $headers['Content-Disposition'] = "attachment; filename=\"{$file_name}\";";
379
+ $headers['Content-Transfer-Encoding'] = 'binary';
380
+
381
+ if ( $version->filesize ) {
382
+ $headers['Content-Length'] = $version->filesize;
383
+ $headers['Accept-Ranges'] = 'bytes';
384
+ }
385
 
386
+ $headers = apply_filters( 'dlm_download_headers', $headers, $file_path, $download, $version );
387
+
388
+ foreach ( $headers as $key => $value ) {
389
+ header( $key . ': ' . $value );
390
+ }
391
  }
392
 
393
  /**
396
  * Reads file in chunks so big downloads are possible without changing PHP.INI - http://codeigniter.com/wiki/Download_helper_for_large_files/
397
  *
398
  * @access public
399
+ *
400
  * @param string file
401
  * @param boolean return bytes of file
402
  * @param range if HTTP RANGE to seek
403
+ *
404
  * @return void
405
  */
406
  public function readfile_chunked( $file, $retbytes = true, $range = false ) {
409
  $cnt = 0;
410
  $handle = fopen( $file, 'r' );
411
 
412
+ if ( $handle === false ) {
413
  return false;
414
+ }
415
 
416
+ if ( $range ) {
417
  fseek( $handle, $range );
418
+ }
419
 
420
  while ( ! feof( $handle ) ) {
421
  $buffer = fread( $handle, $chunksize );
422
  echo $buffer;
423
 
424
+ if ( $retbytes ) {
425
  $cnt += strlen( $buffer );
426
+ }
427
  }
428
 
429
  $status = fclose( $handle );
430
 
431
+ if ( $retbytes && $status ) {
432
  return $cnt;
433
+ }
434
 
435
  return $status;
436
  }
437
  }
 
 
includes/class-dlm-download-version.php CHANGED
@@ -1,5 +1,9 @@
1
  <?php
2
 
 
 
 
 
3
  /**
4
  * DLM_Download_Version class.
5
  */
@@ -9,12 +13,11 @@ class DLM_Download_Version {
9
  * __construct function.
10
  *
11
  * @access public
12
- * @return void
13
  */
14
  public function __construct( $version_id, $download_id ) {
15
- $this->id = absint( $version_id );
16
- $this->download_id = absint( $download_id );
17
-
18
  // Get Version Data
19
  $this->version = strtolower( get_post_meta( $this->id, '_version', true ) );
20
  $this->download_count = get_post_meta( $this->id, '_download_count', true );
@@ -33,9 +36,9 @@ class DLM_Download_Version {
33
  $this->mirrors = array();
34
  }
35
 
36
- $this->url = current( $this->mirrors );
37
- $this->filename = current( explode( '?', basename( $this->url ) ) );
38
- $this->filetype = strtolower( substr( strrchr( $this->filename, "." ), 1 ) );
39
 
40
  // If we don't have a filesize, lets get it now
41
  if ( $this->filesize === "" ) {
@@ -63,13 +66,17 @@ class DLM_Download_Version {
63
  * get_filesize function.
64
  *
65
  * @access public
66
- * @param mixed $file
 
 
67
  * @return string
68
  */
69
  public function get_filesize( $file_path ) {
70
- global $download_monitor;
 
71
 
72
- $filesize = $download_monitor->get_filesize( $file_path );
 
73
 
74
  update_post_meta( $this->id, '_filesize', $filesize );
75
 
@@ -80,13 +87,18 @@ class DLM_Download_Version {
80
  * get_file_hashes function.
81
  *
82
  * @access public
83
- * @param mixed $file
 
 
84
  * @return array
85
  */
86
  public function get_file_hashes( $file_path ) {
87
- global $download_monitor;
88
 
89
- $hashes = $download_monitor->get_file_hashes( $file_path );
 
 
 
 
90
 
91
  update_post_meta( $this->id, '_md5', $hashes['md5'] );
92
  update_post_meta( $this->id, '_sha1', $hashes['sha1'] );
1
  <?php
2
 
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
+
7
  /**
8
  * DLM_Download_Version class.
9
  */
13
  * __construct function.
14
  *
15
  * @access public
 
16
  */
17
  public function __construct( $version_id, $download_id ) {
18
+ $this->id = absint( $version_id );
19
+ $this->download_id = absint( $download_id );
20
+
21
  // Get Version Data
22
  $this->version = strtolower( get_post_meta( $this->id, '_version', true ) );
23
  $this->download_count = get_post_meta( $this->id, '_download_count', true );
36
  $this->mirrors = array();
37
  }
38
 
39
+ $this->url = current( $this->mirrors );
40
+ $this->filename = current( explode( '?', basename( $this->url ) ) );
41
+ $this->filetype = strtolower( substr( strrchr( $this->filename, "." ), 1 ) );
42
 
43
  // If we don't have a filesize, lets get it now
44
  if ( $this->filesize === "" ) {
66
  * get_filesize function.
67
  *
68
  * @access public
69
+ *
70
+ * @param string $file_path
71
+ *
72
  * @return string
73
  */
74
  public function get_filesize( $file_path ) {
75
+ // File Manager
76
+ $file_manager = new DLM_File_Manager();
77
 
78
+ // Get the file size
79
+ $filesize = $file_manager->get_filesize( $file_path );
80
 
81
  update_post_meta( $this->id, '_filesize', $filesize );
82
 
87
  * get_file_hashes function.
88
  *
89
  * @access public
90
+ *
91
+ * @param string $file_path
92
+ *
93
  * @return array
94
  */
95
  public function get_file_hashes( $file_path ) {
 
96
 
97
+ // File Manager
98
+ $file_manager = new DLM_File_Manager();
99
+
100
+ // Get the hashes
101
+ $hashes = $file_manager->get_file_hashes( $file_path );
102
 
103
  update_post_meta( $this->id, '_md5', $hashes['md5'] );
104
  update_post_meta( $this->id, '_sha1', $hashes['sha1'] );
includes/class-dlm-download.php CHANGED
@@ -1,4 +1,9 @@
1
  <?php
 
 
 
 
 
2
  /**
3
  * DLM_Download class.
4
  */
@@ -11,20 +16,23 @@ class DLM_Download {
11
  * __construct function.
12
  *
13
  * @access public
14
- * @param mixed $id
15
- * @return void
 
16
  */
17
  public function __construct( $id ) {
18
- $this->id = absint( $id );
19
- $this->post = get_post( $this->id );
20
- $this->version_id = ''; // Use latest current version
21
  }
22
 
23
  /**
24
  * __isset function.
25
  *
26
  * @access public
 
27
  * @param mixed $key
 
28
  * @return bool
29
  */
30
  public function __isset( $key ) {
@@ -35,23 +43,23 @@ class DLM_Download {
35
  * __get function.
36
  *
37
  * @access public
 
38
  * @param mixed $key
 
39
  * @return mixed
40
  */
41
  public function __get( $key ) {
42
 
43
  // Get values or default if not set
44
- if ( 'members_only' == $key )
45
  $value = ( $value = get_post_meta( $this->id, '_members_only', true ) ) ? $value : 'no';
46
-
47
- elseif ( 'featured' == $key )
48
  $value = ( $value = get_post_meta( $this->id, '_featured', true ) ) ? $value : 'no';
49
-
50
- elseif ( 'redirect_only' == $key )
51
  $value = ( $value = get_post_meta( $this->id, '_redirect_only', true ) ) ? $value : 'no';
52
-
53
- else
54
  $value = get_post_meta( $this->id, '_' . $key, true );
 
55
 
56
  return $value;
57
  }
@@ -70,7 +78,9 @@ class DLM_Download {
70
  * version_exists function.
71
  *
72
  * @access public
 
73
  * @param mixed $version_id
 
74
  * @return void
75
  */
76
  public function version_exists( $version_id ) {
@@ -81,14 +91,17 @@ class DLM_Download {
81
  * Set the download to a version other than the current / latest version it defaults to.
82
  *
83
  * @access public
 
84
  * @param mixed $version_id
 
85
  * @return void
86
  */
87
  public function set_version( $version_id = '' ) {
88
- if ( $this->version_exists( $version_id ) )
89
  $this->version_id = $version_id;
90
- else
91
  $this->version_id = '';
 
92
  }
93
 
94
  /**
@@ -135,23 +148,26 @@ class DLM_Download {
135
  * get_the_image function.
136
  *
137
  * @access public
 
138
  * @param string $size (default: 'full')
 
139
  * @return void
140
  */
141
  public function get_the_image( $size = 'full' ) {
142
- global $download_monitor;
143
-
144
- if ( has_post_thumbnail( $this->id ) )
145
  return get_the_post_thumbnail( $this->id, $size );
146
- else
147
- return '<img alt="Placeholder" class="wp-post-image" src="' . apply_filters( 'dlm_placeholder_image_src', $download_monitor->plugin_url() . '/assets/images/placeholder.png' ) . '" />';
 
148
  }
149
 
150
  /**
151
  * the_image function.
152
  *
153
  * @access public
 
154
  * @param string $size (default: 'full')
 
155
  * @return void
156
  */
157
  public function the_image( $size = 'full' ) {
@@ -166,9 +182,10 @@ class DLM_Download {
166
  */
167
  public function get_the_author() {
168
  $author_id = $this->post->post_author;
169
- $user = get_user_by( 'ID', $author_id );
170
- if ( $user )
171
  return $user->display_name;
 
172
  }
173
 
174
  /**
@@ -205,13 +222,13 @@ class DLM_Download {
205
  switch ( $ep_value ) {
206
  case 'slug' :
207
  $value = $this->post->post_name;
208
- break;
209
  default :
210
  $value = $this->id;
211
- break;
212
  }
213
 
214
- if ( get_option('permalink_structure') ) {
215
  $link = home_url( '/' . $endpoint . '/' . $value . '/', $scheme );
216
  } else {
217
  $link = add_query_arg( $endpoint, $value, home_url( '', $scheme ) );
@@ -219,10 +236,11 @@ class DLM_Download {
219
 
220
  if ( $this->version_id ) {
221
 
222
- if ( $this->has_version_number() )
223
  $link = add_query_arg( 'version', $this->get_the_version_number(), $link );
224
- else
225
  $link = add_query_arg( 'v', $this->version_id, $link );
 
226
  }
227
 
228
  return apply_filters( 'dlm_download_get_the_download_link', esc_url_raw( $link ), $this, $this->version_id );
@@ -242,14 +260,14 @@ class DLM_Download {
242
  * get_the_download_count function.
243
  *
244
  * @access public
245
- * @return void
246
  */
247
  public function get_the_download_count() {
248
- if ( $this->version_id ) {
249
- return absint( $this->get_file_version()->download_count );
250
- } else {
251
- return absint( $this->download_count );
252
- }
253
  }
254
 
255
  /**
@@ -321,10 +339,11 @@ class DLM_Download {
321
  * @return string
322
  */
323
  public function get_the_filesize() {
324
- $filesize = $this->get_file_version()->filesize;
325
 
326
- if ( $filesize > 0 )
327
  return size_format( $filesize );
 
328
  }
329
 
330
  /**
@@ -339,17 +358,22 @@ class DLM_Download {
339
 
340
  /**
341
  * Get the hash
 
342
  * @param string $type md5, sha1 or crc32
 
343
  * @return string
344
  */
345
  public function get_the_hash( $type = 'md5' ) {
346
- $hash = $this->get_file_version()->$type;
 
347
  return $hash;
348
  }
349
 
350
  /**
351
  * Get the hash
 
352
  * @param string $type md5, sha1 or crc32
 
353
  * @return string
354
  */
355
  public function the_hash( $type = 'md5' ) {
@@ -376,31 +400,32 @@ class DLM_Download {
376
  echo $this->get_the_filetype();
377
  }
378
 
379
- /**
380
- * Get a version by ID, or default to current version.
381
- *
382
- * @access public
383
- * @return void
384
- */
385
- public function get_file_version() {
386
- $version = false;
387
 
388
- if ( $this->version_id ) {
389
- $versions = $this->get_file_versions();
390
 
391
- if ( ! empty( $versions[ $this->version_id ] ) )
392
- $version = $versions[ $this->version_id ];
 
393
 
394
- } elseif ( $versions = $this->get_file_versions() ) {
395
- $version = array_shift( $versions );
396
- }
397
 
398
- if ( ! $version ) {
399
 
400
- $version = new stdClass();
401
 
402
- $version->id = 0;
403
- $version->download_id = $this->id;
404
  $version->mirrors = array();
405
  $version->url = '';
406
  $version->filename = '';
@@ -408,26 +433,26 @@ class DLM_Download {
408
  $version->version = '';
409
  $version->download_count = '';
410
  $version->filesize = '';
411
- }
412
 
413
- return $version;
414
- }
415
 
416
- /**
417
- * Get a version ID from a version string.
418
- *
419
- * @access public
420
- * @return void
421
- */
422
- public function get_version_id( $version_string = '' ) {
423
- $versions = $this->get_file_versions();
424
 
425
- foreach ( $versions as $version_id => $version ) {
426
- if ( ( is_numeric( $version->version ) && version_compare( $version->version, strtolower( $version_string ), '=' ) ) || strtolower( $version->version ) === strtolower( $version_string ) ) {
427
- return $version_id;
428
- }
429
- }
430
- }
431
 
432
  /**
433
  * is_featured function.
@@ -469,7 +494,7 @@ class DLM_Download {
469
  if ( ! is_array( $this->file_version_ids ) ) {
470
  $transient_name = 'dlm_file_version_ids_' . $this->id;
471
 
472
- if ( false === ( $this->file_version_ids = get_transient( $transient_name ) ) ) {
473
  $this->file_version_ids = get_posts( 'post_parent=' . $this->id . '&post_type=dlm_download_version&orderby=menu_order&order=ASC&fields=ids&post_status=publish&numberposts=-1' );
474
 
475
  set_transient( $transient_name, $this->file_version_ids, YEAR_IN_SECONDS );
@@ -479,24 +504,24 @@ class DLM_Download {
479
  return $this->file_version_ids;
480
  }
481
 
482
- /**
483
- * get_file_versions function.
484
- *
485
- * @access public
486
- * @return void
487
- */
488
- public function get_file_versions() {
489
- if ( $this->files ) {
490
- return $this->files;
491
- }
492
 
493
- $version_ids = $this->get_file_version_ids();
494
- $this->files = array();
495
 
496
- foreach ( $version_ids as $version_id ) {
497
- $this->files[ $version_id ] = new DLM_Download_Version( $version_id, $this->id );
498
- }
499
 
500
- return $this->files;
501
- }
502
  }
1
  <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
+
7
  /**
8
  * DLM_Download class.
9
  */
16
  * __construct function.
17
  *
18
  * @access public
19
+ *
20
+ * @param int $id
21
+ *
22
  */
23
  public function __construct( $id ) {
24
+ $this->id = absint( $id );
25
+ $this->post = get_post( $this->id );
26
+ $this->version_id = ''; // Use latest current version
27
  }
28
 
29
  /**
30
  * __isset function.
31
  *
32
  * @access public
33
+ *
34
  * @param mixed $key
35
+ *
36
  * @return bool
37
  */
38
  public function __isset( $key ) {
43
  * __get function.
44
  *
45
  * @access public
46
+ *
47
  * @param mixed $key
48
+ *
49
  * @return mixed
50
  */
51
  public function __get( $key ) {
52
 
53
  // Get values or default if not set
54
+ if ( 'members_only' == $key ) {
55
  $value = ( $value = get_post_meta( $this->id, '_members_only', true ) ) ? $value : 'no';
56
+ } elseif ( 'featured' == $key ) {
 
57
  $value = ( $value = get_post_meta( $this->id, '_featured', true ) ) ? $value : 'no';
58
+ } elseif ( 'redirect_only' == $key ) {
 
59
  $value = ( $value = get_post_meta( $this->id, '_redirect_only', true ) ) ? $value : 'no';
60
+ } else {
 
61
  $value = get_post_meta( $this->id, '_' . $key, true );
62
+ }
63
 
64
  return $value;
65
  }
78
  * version_exists function.
79
  *
80
  * @access public
81
+ *
82
  * @param mixed $version_id
83
+ *
84
  * @return void
85
  */
86
  public function version_exists( $version_id ) {
91
  * Set the download to a version other than the current / latest version it defaults to.
92
  *
93
  * @access public
94
+ *
95
  * @param mixed $version_id
96
+ *
97
  * @return void
98
  */
99
  public function set_version( $version_id = '' ) {
100
+ if ( $this->version_exists( $version_id ) ) {
101
  $this->version_id = $version_id;
102
+ } else {
103
  $this->version_id = '';
104
+ }
105
  }
106
 
107
  /**
148
  * get_the_image function.
149
  *
150
  * @access public
151
+ *
152
  * @param string $size (default: 'full')
153
+ *
154
  * @return void
155
  */
156
  public function get_the_image( $size = 'full' ) {
157
+ if ( has_post_thumbnail( $this->id ) ) {
 
 
158
  return get_the_post_thumbnail( $this->id, $size );
159
+ } else {
160
+ return '<img alt="Placeholder" class="wp-post-image" src="' . apply_filters( 'dlm_placeholder_image_src', WP_DLM::get_plugin_url() . '/assets/images/placeholder.png' ) . '" />';
161
+ }
162
  }
163
 
164
  /**
165
  * the_image function.
166
  *
167
  * @access public
168
+ *
169
  * @param string $size (default: 'full')
170
+ *
171
  * @return void
172
  */
173
  public function the_image( $size = 'full' ) {
182
  */
183
  public function get_the_author() {
184
  $author_id = $this->post->post_author;
185
+ $user = get_user_by( 'ID', $author_id );
186
+ if ( $user ) {
187
  return $user->display_name;
188
+ }
189
  }
190
 
191
  /**
222
  switch ( $ep_value ) {
223
  case 'slug' :
224
  $value = $this->post->post_name;
225
+ break;
226
  default :
227
  $value = $this->id;
228
+ break;
229
  }
230
 
231
+ if ( get_option( 'permalink_structure' ) ) {
232
  $link = home_url( '/' . $endpoint . '/' . $value . '/', $scheme );
233
  } else {
234
  $link = add_query_arg( $endpoint, $value, home_url( '', $scheme ) );
236
 
237
  if ( $this->version_id ) {
238
 
239
+ if ( $this->has_version_number() ) {
240
  $link = add_query_arg( 'version', $this->get_the_version_number(), $link );
241
+ } else {
242
  $link = add_query_arg( 'v', $this->version_id, $link );
243
+ }
244
  }
245
 
246
  return apply_filters( 'dlm_download_get_the_download_link', esc_url_raw( $link ), $this, $this->version_id );
260
  * get_the_download_count function.
261
  *
262
  * @access public
263
+ * @return int
264
  */
265
  public function get_the_download_count() {
266
+ if ( $this->version_id ) {
267
+ return absint( $this->get_file_version()->download_count );
268
+ } else {
269
+ return absint( $this->download_count );
270
+ }
271
  }
272
 
273
  /**
339
  * @return string
340
  */
341
  public function get_the_filesize() {
342
+ $filesize = $this->get_file_version()->filesize;
343
 
344
+ if ( $filesize > 0 ) {
345
  return size_format( $filesize );
346
+ }
347
  }
348
 
349
  /**
358
 
359
  /**
360
  * Get the hash
361
+ *
362
  * @param string $type md5, sha1 or crc32
363
+ *
364
  * @return string
365
  */
366
  public function get_the_hash( $type = 'md5' ) {
367
+ $hash = $this->get_file_version()->$type;
368
+
369
  return $hash;
370
  }
371
 
372
  /**
373
  * Get the hash
374
+ *
375
  * @param string $type md5, sha1 or crc32
376
+ *
377
  * @return string
378
  */
379
  public function the_hash( $type = 'md5' ) {
400
  echo $this->get_the_filetype();
401
  }
402
 
403
+ /**
404
+ * Get a version by ID, or default to current version.
405
+ *
406
+ * @access public
407
+ * @return void
408
+ */
409
+ public function get_file_version() {
410
+ $version = false;
411
 
412
+ if ( $this->version_id ) {
413
+ $versions = $this->get_file_versions();
414
 
415
+ if ( ! empty( $versions[ $this->version_id ] ) ) {
416
+ $version = $versions[ $this->version_id ];
417
+ }
418
 
419
+ } elseif ( $versions = $this->get_file_versions() ) {
420
+ $version = array_shift( $versions );
421
+ }
422
 
423
+ if ( ! $version ) {
424
 
425
+ $version = new stdClass();
426
 
427
+ $version->id = 0;
428
+ $version->download_id = $this->id;
429
  $version->mirrors = array();
430
  $version->url = '';
431
  $version->filename = '';
433
  $version->version = '';
434
  $version->download_count = '';
435
  $version->filesize = '';
436
+ }
437
 
438
+ return $version;
439
+ }
440
 
441
+ /**
442
+ * Get a version ID from a version string.
443
+ *
444
+ * @access public
445
+ * @return void
446
+ */
447
+ public function get_version_id( $version_string = '' ) {
448
+ $versions = $this->get_file_versions();
449
 
450
+ foreach ( $versions as $version_id => $version ) {
451
+ if ( ( is_numeric( $version->version ) && version_compare( $version->version, strtolower( $version_string ), '=' ) ) || strtolower( $version->version ) === strtolower( $version_string ) ) {
452
+ return $version_id;
453
+ }
454
+ }
455
+ }
456
 
457
  /**
458
  * is_featured function.
494
  if ( ! is_array( $this->file_version_ids ) ) {
495
  $transient_name = 'dlm_file_version_ids_' . $this->id;
496
 
497
+ if ( false === ( $this->file_version_ids = get_transient( $transient_name ) ) ) {
498
  $this->file_version_ids = get_posts( 'post_parent=' . $this->id . '&post_type=dlm_download_version&orderby=menu_order&order=ASC&fields=ids&post_status=publish&numberposts=-1' );
499
 
500
  set_transient( $transient_name, $this->file_version_ids, YEAR_IN_SECONDS );
504
  return $this->file_version_ids;
505
  }
506
 
507
+ /**
508
+ * get_file_versions function.
509
+ *
510
+ * @access public
511
+ * @return void
512
+ */
513
+ public function get_file_versions() {
514
+ if ( $this->files ) {
515
+ return $this->files;
516
+ }
517
 
518
+ $version_ids = $this->get_file_version_ids();
519
+ $this->files = array();
520
 
521
+ foreach ( $version_ids as $version_id ) {
522
+ $this->files[ $version_id ] = new DLM_Download_Version( $version_id, $this->id );
523
+ }
524
 
525
+ return $this->files;
526
+ }
527
  }
includes/class-dlm-file-manager.php ADDED
@@ -0,0 +1,221 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
+
7
+ class DLM_File_Manager {
8
+
9
+ /**
10
+ * Returns a listing of all files in the specified folder and all subdirectories up to 100 levels deep.
11
+ * The depth of the recursiveness can be controlled by the $levels param.
12
+ *
13
+ * @access public
14
+ *
15
+ * @param string $folder (default: '')
16
+ *
17
+ * @return void
18
+ */
19
+ public function list_files( $folder = '' ) {
20
+ if ( empty( $folder ) ) {
21
+ return false;
22
+ }
23
+
24
+ $files = array();
25
+ if ( $dir = @opendir( $folder ) ) {
26
+ while ( ( $file = readdir( $dir ) ) !== false ) {
27
+ if ( in_array( $file, array( '.', '..' ) ) ) {
28
+ continue;
29
+ }
30
+
31
+ if ( is_dir( $folder . '/' . $file ) ) {
32
+
33
+ $files[] = array(
34
+ 'type' => 'folder',
35
+ 'path' => $folder . '/' . $file
36
+ );
37
+
38
+ } else {
39
+
40
+ $files[] = array(
41
+ 'type' => 'file',
42
+ 'path' => $folder . '/' . $file
43
+ );
44
+
45
+ }
46
+ }
47
+ }
48
+ @closedir( $dir );
49
+
50
+ return $files;
51
+ }
52
+
53
+ /**
54
+ * Parse a file path and return the new path and whether or not it's remote
55
+ *
56
+ * @param string $file_path
57
+ *
58
+ * @return array
59
+ */
60
+ public function parse_file_path( $file_path ) {
61
+ $remote_file = true;
62
+ $parsed_file_path = parse_url( $file_path );
63
+
64
+ $wp_uploads = wp_upload_dir();
65
+ $wp_uploads_dir = $wp_uploads['basedir'];
66
+ $wp_uploads_url = $wp_uploads['baseurl'];
67
+
68
+ if ( ( ! isset( $parsed_file_path['scheme'] ) || ! in_array( $parsed_file_path['scheme'], array(
69
+ 'http',
70
+ 'https',
71
+ 'ftp'
72
+ ) ) ) && isset( $parsed_file_path['path'] ) && file_exists( $parsed_file_path['path'] )
73
+ ) {
74
+
75
+ /** This is an absolute path */
76
+ $remote_file = false;
77
+
78
+ } elseif ( strpos( $file_path, $wp_uploads_url ) !== false ) {
79
+
80
+ /** This is a local file given by URL so we need to figure out the path */
81
+ $remote_file = false;
82
+ $file_path = str_replace( $wp_uploads_url, $wp_uploads_dir, $file_path );
83
+ $file_path = realpath( $file_path );
84
+
85
+ } elseif ( is_multisite() && ( strpos( $file_path, network_site_url( '/', 'http' ) ) !== false || strpos( $file_path, network_site_url( '/', 'https' ) ) !== false ) ) {
86
+
87
+ /** This is a local file outside of wp-content so figure out the path */
88
+ $remote_file = false;
89
+ // Try to replace network url
90
+ $file_path = str_replace( network_site_url( '/', 'https' ), ABSPATH, $file_path );
91
+ $file_path = str_replace( network_site_url( '/', 'http' ), ABSPATH, $file_path );
92
+ // Try to replace upload URL
93
+ $file_path = str_replace( $wp_uploads_url, $wp_uploads_dir, $file_path );
94
+ $file_path = realpath( $file_path );
95
+
96
+ } elseif ( strpos( $file_path, site_url( '/', 'http' ) ) !== false || strpos( $file_path, site_url( '/', 'https' ) ) !== false ) {
97
+
98
+ /** This is a local file outside of wp-content so figure out the path */
99
+ $remote_file = false;
100
+ $file_path = str_replace( site_url( '/', 'https' ), ABSPATH, $file_path );
101
+ $file_path = str_replace( site_url( '/', 'http' ), ABSPATH, $file_path );
102
+ $file_path = realpath( $file_path );
103
+
104
+ } elseif ( file_exists( ABSPATH . $file_path ) ) {
105
+
106
+ /** Path needs an abspath to work */
107
+ $remote_file = false;
108
+ $file_path = ABSPATH . $file_path;
109
+ $file_path = realpath( $file_path );
110
+ }
111
+
112
+ return array( $file_path, $remote_file );
113
+ }
114
+
115
+ /**
116
+ * Gets the filesize of a path or URL.
117
+ *
118
+ * @access public
119
+ *
120
+ * @param string $file_path
121
+ *
122
+ * @return string size on success, -1 on failure
123
+ */
124
+ public function get_file_size( $file_path ) {
125
+ if ( $file_path ) {
126
+ list( $file_path, $remote_file ) = $this->parse_file_path( $file_path );
127
+
128
+ if ( ! empty( $file_path ) ) {
129
+ if ( $remote_file ) {
130
+ $file = wp_remote_head( $file_path );
131
+
132
+ if ( ! is_wp_error( $file ) && ! empty( $file['headers']['content-length'] ) ) {
133
+ return $file['headers']['content-length'];
134
+ }
135
+ } else {
136
+ if ( file_exists( $file_path ) && ( $filesize = filesize( $file_path ) ) ) {
137
+ return $filesize;
138
+ }
139
+ }
140
+ }
141
+ }
142
+
143
+ return -1;
144
+ }
145
+
146
+ /**
147
+ * Gets md5, sha1 and crc32 hashes for a file and store it.
148
+ *
149
+ * @access public
150
+ *
151
+ * @param string $file_path
152
+ *
153
+ * @return array of sizes
154
+ */
155
+ public function get_file_hashes( $file_path ) {
156
+ $md5 = false;
157
+ $sha1 = false;
158
+ $crc32 = false;
159
+
160
+ if ( $file_path ) {
161
+ list( $file_path, $remote_file ) = $this->parse_file_path( $file_path );
162
+
163
+ if ( ! empty( $file_path ) ) {
164
+ if ( ! $remote_file || apply_filters( 'dlm_allow_remote_hash_file', false ) ) {
165
+ if ( get_option( 'dlm_generate_hash_md5' ) ) {
166
+ $md5 = hash_file( 'md5', $file_path );
167
+ }
168
+ if ( get_option( 'dlm_generate_hash_sha1' ) ) {
169
+ $sha1 = hash_file( 'sha1', $file_path );
170
+ }
171
+ if ( get_option( 'dlm_generate_hash_crc32b' ) ) {
172
+ $crc32 = hash_file( 'crc32b', $file_path );
173
+ }
174
+ }
175
+ }
176
+ }
177
+
178
+ return array( 'md5' => $md5, 'sha1' => $sha1, 'crc32' => $crc32 );
179
+ }
180
+
181
+ /**
182
+ * Encode files for storage
183
+ *
184
+ * @param array $files
185
+ *
186
+ * @return string
187
+ */
188
+ public function json_encode_files( $files ) {
189
+ if ( version_compare( phpversion(), "5.4.0", ">=" ) ) {
190
+ $files = json_encode( $files, JSON_UNESCAPED_UNICODE );
191
+ } else {
192
+ $files = json_encode( $files );
193
+ if ( function_exists( 'mb_convert_encoding' ) ) {
194
+ $files = preg_replace_callback( '/\\\\u([0-9a-f]{4})/i', array(
195
+ $this,
196
+ 'json_unscaped_unicode_fallback'
197
+ ), $files );
198
+ }
199
+ }
200
+
201
+ return $files;
202
+ }
203
+
204
+ /**
205
+ * Fallback for PHP < 5.4 where JSON_UNESCAPED_UNICODE does not exist.
206
+ *
207
+ * @param array $matches
208
+ *
209
+ * @return string
210
+ */
211
+ public function json_unscaped_unicode_fallback( $matches ) {
212
+ $sym = mb_convert_encoding(
213
+ pack( 'H*', $matches[1] ),
214
+ 'UTF-8',
215
+ 'UTF-16'
216
+ );
217
+
218
+ return $sym;
219
+ }
220
+
221
+ }
includes/class-dlm-installer.php ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
+
7
+ class DLM_Installer {
8
+
9
+ /**
10
+ * Install all requirements for Download Monitor
11
+ */
12
+ public function install() {
13
+
14
+ // Init User Roles
15
+ $this->init_user_roles();
16
+
17
+ // Setup Taxonomies
18
+ require_once( 'class-dlm-taxonomy-manager.php' );
19
+ $taxonomy_manager = new DLM_Taxonomy_Manager();
20
+ $taxonomy_manager->setup();
21
+
22
+ // Setup Post Types
23
+ require_once( 'class-dlm-post-type-manager.php' );
24
+ $post_type_manager = new DLM_Post_Type_Manager();
25
+ $post_type_manager->setup();
26
+
27
+ // Create Database Table
28
+ $this->install_tables();
29
+
30
+ // Directory Protection
31
+ $this->directory_protection();
32
+
33
+ // Add endpoints
34
+ require_once( 'class-dlm-download-handler.php' );
35
+ $dlm_download_handler = new DLM_Download_Handler();
36
+ $dlm_download_handler->add_endpoint();
37
+
38
+ }
39
+
40
+ /**
41
+ * Init user roles
42
+ *
43
+ * @return void
44
+ */
45
+ private function init_user_roles() {
46
+ global $wp_roles;
47
+
48
+ if ( class_exists( 'WP_Roles' ) && ! isset( $wp_roles ) ) {
49
+ $wp_roles = new WP_Roles();
50
+ }
51
+
52
+ if ( is_object( $wp_roles ) ) {
53
+ $wp_roles->add_cap( 'administrator', 'manage_downloads' );
54
+ }
55
+ }
56
+
57
+ /**
58
+ * install_tables function.
59
+ *
60
+ * @return void
61
+ */
62
+ private function install_tables() {
63
+ global $wpdb;
64
+
65
+ $wpdb->hide_errors();
66
+
67
+ $collate = '';
68
+
69
+ if ( $wpdb->has_cap( 'collation' ) ) {
70
+ if ( ! empty( $wpdb->charset ) ) {
71
+ $collate .= "DEFAULT CHARACTER SET $wpdb->charset";
72
+ }
73
+ if ( ! empty( $wpdb->collate ) ) {
74
+ $collate .= " COLLATE $wpdb->collate";
75
+ }
76
+ }
77
+
78
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
79
+
80
+ $dlm_tables = "
81
+ CREATE TABLE `" . $wpdb->prefix . "download_log` (
82
+ ID bigint(20) NOT NULL auto_increment,
83
+ type varchar(200) NOT NULL default 'download',
84
+ user_id bigint(20) NOT NULL,
85
+ user_ip varchar(200) NOT NULL,
86
+ user_agent varchar(200) NOT NULL,
87
+ download_id bigint(20) NOT NULL,
88
+ version_id bigint(20) NOT NULL,
89
+ version varchar(200) NOT NULL,
90
+ download_date datetime NOT NULL default '0000-00-00 00:00:00',
91
+ download_status varchar(200) NULL,
92
+ download_status_message varchar(200) NULL,
93
+ PRIMARY KEY (ID),
94
+ KEY attribute_name (download_id)
95
+ ) $collate;
96
+ ";
97
+ dbDelta( $dlm_tables );
98
+ }
99
+
100
+ /**
101
+ * Protect the upload dir on activation.
102
+ *
103
+ * @access public
104
+ * @return void
105
+ */
106
+ private function directory_protection() {
107
+
108
+ // Install files and folders for uploading files and prevent hotlinking
109
+ $upload_dir = wp_upload_dir();
110
+
111
+ $files = array(
112
+ array(
113
+ 'base' => $upload_dir['basedir'] . '/dlm_uploads',
114
+ 'file' => '.htaccess',
115
+ 'content' => 'deny from all'
116
+ ),
117
+ array(
118
+ 'base' => $upload_dir['basedir'] . '/dlm_uploads',
119
+ 'file' => 'index.html',
120
+ 'content' => ''
121
+ )
122
+ );
123
+
124
+ foreach ( $files as $file ) {
125
+ if ( wp_mkdir_p( $file['base'] ) && ! file_exists( trailingslashit( $file['base'] ) . $file['file'] ) ) {
126
+ if ( $file_handle = @fopen( trailingslashit( $file['base'] ) . $file['file'], 'w' ) ) {
127
+ fwrite( $file_handle, $file['content'] );
128
+ fclose( $file_handle );
129
+ }
130
+ }
131
+ }
132
+ }
133
+
134
+ }
includes/class-dlm-logging.php CHANGED
@@ -1,12 +1,23 @@
1
  <?php
2
 
3
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
4
 
5
  /**
6
  * DLM_Logging class.
7
  */
8
  class DLM_Logging {
9
 
 
 
 
 
 
 
 
 
 
10
  /**
11
  * create_log function.
12
  *
@@ -14,9 +25,9 @@ class DLM_Logging {
14
  * @return void
15
  */
16
  public function create_log( $type, $status, $message, $download, $version ) {
17
- global $wpdb;
18
 
19
- $wpdb->hide_errors();
20
 
21
  $wpdb->insert(
22
  $wpdb->download_log,
@@ -67,28 +78,11 @@ class DLM_Logging {
67
  private function get_user_ua() {
68
  $ua = sanitize_text_field( isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : '' );
69
 
70
- if ( strlen( $ua ) > 200 )
71
  $ua = substr( $ua, 0, 199 );
 
72
 
73
  return $ua;
74
  }
75
  }
76
 
77
- $GLOBALS['dlm_logging'] = new DLM_Logging();
78
-
79
- /**
80
- * dlm_create_log function.
81
- *
82
- * @access public
83
- * @param string $type (default: '')
84
- * @param string $status (default: '')
85
- * @param string $message (default: '')
86
- * @param mixed $download
87
- * @param mixed $version
88
- * @return void
89
- */
90
- function dlm_create_log( $type = '', $status = '', $message = '', $download, $version ) {
91
- global $dlm_logging;
92
-
93
- $dlm_logging->create_log( $type, $status, $message, $download, $version );
94
- }
1
  <?php
2
 
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
 
7
  /**
8
  * DLM_Logging class.
9
  */
10
  class DLM_Logging {
11
 
12
+ /**
13
+ * Check if logging is enabled
14
+ *
15
+ * @return bool
16
+ */
17
+ public function is_logging_enabled() {
18
+ return (1 == get_option( 'dlm_enable_logging', 0 ));
19
+ }
20
+
21
  /**
22
  * create_log function.
23
  *
25
  * @return void
26
  */
27
  public function create_log( $type, $status, $message, $download, $version ) {
28
+ global $wpdb;
29
 
30
+ $wpdb->hide_errors();
31
 
32
  $wpdb->insert(
33
  $wpdb->download_log,
78
  private function get_user_ua() {
79
  $ua = sanitize_text_field( isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : '' );
80
 
81
+ if ( strlen( $ua ) > 200 ) {
82
  $ua = substr( $ua, 0, 199 );
83
+ }
84
 
85
  return $ua;
86
  }
87
  }
88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-dlm-post-type-manager.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class DLM_Post_Type_Manager {
4
+
5
+ /**
6
+ * Setup hooks
7
+ */
8
+ public function setup() {
9
+ add_action( 'init', array( $this, 'register' ), 10 );
10
+ }
11
+
12
+ /**
13
+ * Register Post Types
14
+ */
15
+ public function register() {
16
+
17
+ // Register Download Post Type
18
+ register_post_type( "dlm_download",
19
+ apply_filters( 'dlm_cpt_dlm_download_args', array(
20
+ 'labels' => array(
21
+ 'all_items' => __( 'All Downloads', 'download-monitor' ),
22
+ 'name' => __( 'Downloads', 'download-monitor' ),
23
+ 'singular_name' => __( 'Download', 'download-monitor' ),
24
+ 'add_new' => __( 'Add New', 'download-monitor' ),
25
+ 'add_new_item' => __( 'Add Download', 'download-monitor' ),
26
+ 'edit' => __( 'Edit', 'download-monitor' ),
27
+ 'edit_item' => __( 'Edit Download', 'download-monitor' ),
28
+ 'new_item' => __( 'New Download', 'download-monitor' ),
29
+ 'view' => __( 'View Download', 'download-monitor' ),
30
+ 'view_item' => __( 'View Download', 'download-monitor' ),
31
+ 'search_items' => __( 'Search Downloads', 'download-monitor' ),
32
+ 'not_found' => __( 'No Downloads found', 'download-monitor' ),
33
+ 'not_found_in_trash' => __( 'No Downloads found in trash', 'download-monitor' ),
34
+ 'parent' => __( 'Parent Download', 'download-monitor' )
35
+ ),
36
+ 'description' => __( 'This is where you can create and manage downloads for your site.', 'download-monitor' ),
37
+ 'public' => false,
38
+ 'show_ui' => true,
39
+ 'capability_type' => 'post',
40
+ 'capabilities' => array(
41
+ 'publish_posts' => 'manage_downloads',
42
+ 'edit_posts' => 'manage_downloads',
43
+ 'edit_others_posts' => 'manage_downloads',
44
+ 'delete_posts' => 'manage_downloads',
45
+ 'delete_others_posts' => 'manage_downloads',
46
+ 'read_private_posts' => 'manage_downloads',
47
+ 'edit_post' => 'manage_downloads',
48
+ 'delete_post' => 'manage_downloads',
49
+ 'read_post' => 'manage_downloads'
50
+ ),
51
+ 'publicly_queryable' => false,
52
+ 'exclude_from_search' => true,
53
+ 'hierarchical' => false,
54
+ 'rewrite' => false,
55
+ 'query_var' => false,
56
+ 'supports' => apply_filters( 'dlm_cpt_dlm_download_supports', array(
57
+ 'title',
58
+ 'editor',
59
+ 'excerpt',
60
+ 'thumbnail',
61
+ 'custom-fields'
62
+ ) ),
63
+ 'has_archive' => false,
64
+ 'show_in_nav_menus' => false
65
+ ) )
66
+ );
67
+
68
+ // Register Download Version Post Type
69
+ register_post_type( "dlm_download_version",
70
+ apply_filters( 'dlm_cpt_dlm_download_version_args', array(
71
+ 'public' => false,
72
+ 'show_ui' => false,
73
+ 'publicly_queryable' => false,
74
+ 'exclude_from_search' => true,
75
+ 'hierarchical' => false,
76
+ 'rewrite' => false,
77
+ 'query_var' => false,
78
+ 'show_in_nav_menus' => false
79
+ ) )
80
+ );
81
+
82
+ }
83
+
84
+ }
includes/class-dlm-shortcodes.php CHANGED
@@ -1,6 +1,8 @@
1
  <?php
2
 
3
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
4
 
5
  /**
6
  * DLM_Shortcodes class.
@@ -8,12 +10,9 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
8
  class DLM_Shortcodes {
9
 
10
  /**
11
- * __construct function.
12
- *
13
- * @access public
14
- * @return void
15
  */
16
- public function __construct() {
17
  add_shortcode( 'total_downloads', array( $this, 'total_downloads' ) );
18
  add_shortcode( 'total_files', array( $this, 'total_files' ) );
19
  add_shortcode( 'download', array( $this, 'download' ) );
@@ -55,11 +54,13 @@ class DLM_Shortcodes {
55
  * download function.
56
  *
57
  * @access public
58
- * @param mixed $atts
59
- * @return void
 
 
60
  */
61
  public function download( $atts, $content = '' ) {
62
- global $download_monitor, $dlm_download;
63
 
64
  extract( shortcode_atts( array(
65
  'id' => '',
@@ -71,54 +72,60 @@ class DLM_Shortcodes {
71
 
72
  $id = apply_filters( 'dlm_shortcode_download_id', $id );
73
 
74
- if ( empty( $id ) )
75
  return;
 
76
 
77
- // If we have content, wrap in a link only
78
- if ( $content ) {
79
 
80
- $download = new DLM_Download( $id );
81
 
82
- if ( $download->exists() ) {
83
 
84
- if ( $version )
85
  $version_id = $dlm_download->get_version_id( $version );
 
86
 
87
- if ( $version_id )
88
  $dlm_download->set_version( $version_id );
 
89
 
90
  return '<a href="' . $download->get_the_download_link() . '">' . $content . '</a>';
91
 
92
  } else {
93
  return '[' . __( 'Download not found', 'download-monitor' ) . ']';
94
  }
95
- }
96
-
97
- // If there is no content, get the template part
98
- else {
99
 
100
- ob_start();
101
 
102
  $downloads = new WP_Query( array(
103
- 'post_type' => 'dlm_download',
104
- 'posts_per_page' => 1,
105
- 'no_found_rows' => 1,
106
- 'post_status' => 'publish',
107
- 'p' => $id
108
- ) );
109
 
110
  if ( $downloads->have_posts() ) {
111
 
112
  while ( $downloads->have_posts() ) {
113
  $downloads->the_post();
114
 
115
- if ( $version )
116
  $version_id = $dlm_download->get_version_id( $version );
 
117
 
118
- if ( $version_id )
119
  $dlm_download->set_version( $version_id );
 
 
 
 
120
 
121
- $download_monitor->get_template_part( 'content-download', $template );
122
  }
123
 
124
  } else {
@@ -127,23 +134,24 @@ class DLM_Shortcodes {
127
 
128
  wp_reset_postdata();
129
 
130
- if ( $autop === 'true' || $autop === true )
131
  return wpautop( ob_get_clean() );
132
- else
133
  return ob_get_clean();
134
- }
 
135
  }
136
 
137
  /**
138
  * download_data function.
139
  *
140
  * @access public
141
- * @param mixed $atts
142
- * @param mixed $content
143
- * @return void
 
144
  */
145
  public function download_data( $atts ) {
146
- global $download_monitor;
147
 
148
  extract( shortcode_atts( array(
149
  'id' => '',
@@ -154,16 +162,19 @@ class DLM_Shortcodes {
154
 
155
  $id = apply_filters( 'dlm_shortcode_download_id', $id );
156
 
157
- if ( empty( $id ) || empty( $data ) )
158
  return;
 
159
 
160
  $download = new DLM_Download( $id );
161
 
162
- if ( $version )
163
  $version_id = $download->get_version_id( $version );
 
164
 
165
- if ( $version_id )
166
  $download->set_version( $version_id );
 
167
 
168
  switch ( $data ) {
169
 
@@ -219,11 +230,13 @@ class DLM_Shortcodes {
219
  * downloads function.
220
  *
221
  * @access public
 
222
  * @param mixed $atts
 
223
  * @return void
224
  */
225
  public function downloads( $atts ) {
226
- global $download_monitor, $dlm_max_num_pages;
227
 
228
  extract( shortcode_atts( array(
229
  // Query args
@@ -273,65 +286,68 @@ class DLM_Shortcodes {
273
  break;
274
  default :
275
  $orderby = 'title';
276
- break;
277
  }
278
 
279
- $args = array(
280
- 'post_type' => 'dlm_download',
281
- 'posts_per_page' => $per_page,
282
- 'offset' => $paginate ? ( max( 1, get_query_var( 'paged' ) ) - 1 ) * $per_page : $offset,
283
- 'post_status' => 'publish',
284
- 'orderby' => $orderby,
285
- 'order' => $order,
286
- '$meta_key' => $meta_key,
287
- 'post__in' => $post__in,
288
- 'post__not_in' => $post__not_in,
289
- 'meta_query' => array()
290
- );
291
-
292
- if ( $category || $tag ) {
293
- $args['tax_query'] = array( 'relation' => 'AND' );
294
-
295
- $categories = array_filter( explode( ',', $category ) );
296
- $tags = array_filter( explode( ',', $tag ) );
297
-
298
- if ( ! empty( $categories ) ) {
299
- $args['tax_query'][] = array(
300
  'taxonomy' => 'dlm_download_category',
301
  'field' => 'slug',
302
  'terms' => $categories,
303
  'include_children' => ( $category_include_children === 'true' || $category_include_children === true )
304
- );
305
- }
306
 
307
- if ( ! empty( $tags ) ) {
308
- $args['tax_query'][] = array(
309
- 'taxonomy' => 'dlm_download_tag',
310
  'field' => 'slug',
311
  'terms' => $tags
312
- );
313
- }
314
- }
315
-
316
- if ( $featured === 'true' || $featured === true ) {
317
- $args['meta_query'][] = array(
318
- 'key' => '_featured',
319
- 'value' => 'yes'
320
- );
321
- }
322
-
323
- if ( $members_only === 'true' || $members_only === true ) {
324
- $args['meta_query'][] = array(
325
- 'key' => '_members_only',
326
- 'value' => 'yes'
327
- );
328
- }
329
-
330
- ob_start();
331
 
332
  $downloads = new WP_Query( $args );
333
  $dlm_max_num_pages = $downloads->max_num_pages;
334
 
 
 
 
335
  if ( $downloads->have_posts() ) : ?>
336
 
337
  <?php echo html_entity_decode( $loop_start ); ?>
@@ -340,7 +356,7 @@ class DLM_Shortcodes {
340
 
341
  <?php echo html_entity_decode( $before ); ?>
342
 
343
- <?php $download_monitor->get_template_part( 'content-download', $template ); ?>
344
 
345
  <?php echo html_entity_decode( $after ); ?>
346
 
@@ -348,14 +364,14 @@ class DLM_Shortcodes {
348
 
349
  <?php echo html_entity_decode( $loop_end ); ?>
350
 
351
- <?php if ( $paginate ) $download_monitor->get_template_part( 'pagination', '' ); ?>
 
 
352
 
353
  <?php endif;
354
 
355
  wp_reset_postdata();
356
 
357
- return ob_get_clean();
358
  }
359
- }
360
-
361
- new DLM_Shortcodes();
1
  <?php
2
 
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
 
7
  /**
8
  * DLM_Shortcodes class.
10
  class DLM_Shortcodes {
11
 
12
  /**
13
+ * Setup the shortcodes
 
 
 
14
  */
15
+ public function setup() {
16
  add_shortcode( 'total_downloads', array( $this, 'total_downloads' ) );
17
  add_shortcode( 'total_files', array( $this, 'total_files' ) );
18
  add_shortcode( 'download', array( $this, 'download' ) );
54
  * download function.
55
  *
56
  * @access public
57
+ *
58
+ * @param array $atts
59
+ *
60
+ * @return string
61
  */
62
  public function download( $atts, $content = '' ) {
63
+ global $dlm_download;
64
 
65
  extract( shortcode_atts( array(
66
  'id' => '',
72
 
73
  $id = apply_filters( 'dlm_shortcode_download_id', $id );
74
 
75
+ if ( empty( $id ) ) {
76
  return;
77
+ }
78
 
79
+ // If we have content, wrap in a link only
80
+ if ( $content ) {
81
 
82
+ $download = new DLM_Download( $id );
83
 
84
+ if ( $download->exists() ) {
85
 
86
+ if ( isset( $version ) && 0 != $version ) {
87
  $version_id = $dlm_download->get_version_id( $version );
88
+ }
89
 
90
+ if ( isset( $version_id ) && 0 != $version_id ) {
91
  $dlm_download->set_version( $version_id );
92
+ }
93
 
94
  return '<a href="' . $download->get_the_download_link() . '">' . $content . '</a>';
95
 
96
  } else {
97
  return '[' . __( 'Download not found', 'download-monitor' ) . ']';
98
  }
99
+ } // If there is no content, get the template part
100
+ else {
 
 
101
 
102
+ ob_start();
103
 
104
  $downloads = new WP_Query( array(
105
+ 'post_type' => 'dlm_download',
106
+ 'posts_per_page' => 1,
107
+ 'no_found_rows' => 1,
108
+ 'post_status' => 'publish',
109
+ 'p' => $id
110
+ ) );
111
 
112
  if ( $downloads->have_posts() ) {
113
 
114
  while ( $downloads->have_posts() ) {
115
  $downloads->the_post();
116
 
117
+ if ( isset( $version ) && 0 != $version ) {
118
  $version_id = $dlm_download->get_version_id( $version );
119
+ }
120
 
121
+ if ( isset( $version_id ) && 0 != $version_id ) {
122
  $dlm_download->set_version( $version_id );
123
+ }
124
+
125
+ // Template handler
126
+ $template_handler = new DLM_Template_Handler();
127
 
128
+ $template_handler->get_template_part( 'content-download', $template );
129
  }
130
 
131
  } else {
134
 
135
  wp_reset_postdata();
136
 
137
+ if ( 'true' === $autop || true === $autop ) {
138
  return wpautop( ob_get_clean() );
139
+ } else {
140
  return ob_get_clean();
141
+ }
142
+ }
143
  }
144
 
145
  /**
146
  * download_data function.
147
  *
148
  * @access public
149
+ *
150
+ * @param array $atts
151
+ *
152
+ * @return mixed
153
  */
154
  public function download_data( $atts ) {
 
155
 
156
  extract( shortcode_atts( array(
157
  'id' => '',
162
 
163
  $id = apply_filters( 'dlm_shortcode_download_id', $id );
164
 
165
+ if ( empty( $id ) || empty( $data ) ) {
166
  return;
167
+ }
168
 
169
  $download = new DLM_Download( $id );
170
 
171
+ if ( isset( $version ) && 0 != $version ) {
172
  $version_id = $download->get_version_id( $version );
173
+ }
174
 
175
+ if ( $version_id ) {
176
  $download->set_version( $version_id );
177
+ }
178
 
179
  switch ( $data ) {
180
 
230
  * downloads function.
231
  *
232
  * @access public
233
+ *
234
  * @param mixed $atts
235
+ *
236
  * @return void
237
  */
238
  public function downloads( $atts ) {
239
+ global $dlm_max_num_pages;
240
 
241
  extract( shortcode_atts( array(
242
  // Query args
286
  break;
287
  default :
288
  $orderby = 'title';
289
+ break;
290
  }
291
 
292
+ $args = array(
293
+ 'post_type' => 'dlm_download',
294
+ 'posts_per_page' => $per_page,
295
+ 'offset' => $paginate ? ( max( 1, get_query_var( 'paged' ) ) - 1 ) * $per_page : $offset,
296
+ 'post_status' => 'publish',
297
+ 'orderby' => $orderby,
298
+ 'order' => $order,
299
+ 'meta_key' => $meta_key,
300
+ 'post__in' => $post__in,
301
+ 'post__not_in' => $post__not_in,
302
+ 'meta_query' => array()
303
+ );
304
+
305
+ if ( $category || $tag ) {
306
+ $args['tax_query'] = array( 'relation' => 'AND' );
307
+
308
+ $categories = array_filter( explode( ',', $category ) );
309
+ $tags = array_filter( explode( ',', $tag ) );
310
+
311
+ if ( ! empty( $categories ) ) {
312
+ $args['tax_query'][] = array(
313
  'taxonomy' => 'dlm_download_category',
314
  'field' => 'slug',
315
  'terms' => $categories,
316
  'include_children' => ( $category_include_children === 'true' || $category_include_children === true )
317
+ );
318
+ }
319
 
320
+ if ( ! empty( $tags ) ) {
321
+ $args['tax_query'][] = array(
322
+ 'taxonomy' => 'dlm_download_tag',
323
  'field' => 'slug',
324
  'terms' => $tags
325
+ );
326
+ }
327
+ }
328
+
329
+ if ( $featured === 'true' || $featured === true ) {
330
+ $args['meta_query'][] = array(
331
+ 'key' => '_featured',
332
+ 'value' => 'yes'
333
+ );
334
+ }
335
+
336
+ if ( $members_only === 'true' || $members_only === true ) {
337
+ $args['meta_query'][] = array(
338
+ 'key' => '_members_only',
339
+ 'value' => 'yes'
340
+ );
341
+ }
342
+
343
+ ob_start();
344
 
345
  $downloads = new WP_Query( $args );
346
  $dlm_max_num_pages = $downloads->max_num_pages;
347
 
348
+ // Template handler
349
+ $template_handler = new DLM_Template_Handler();
350
+
351
  if ( $downloads->have_posts() ) : ?>
352
 
353
  <?php echo html_entity_decode( $loop_start ); ?>
356
 
357
  <?php echo html_entity_decode( $before ); ?>
358
 
359
+ <?php $template_handler->get_template_part( 'content-download', $template ); ?>
360
 
361
  <?php echo html_entity_decode( $after ); ?>
362
 
364
 
365
  <?php echo html_entity_decode( $loop_end ); ?>
366
 
367
+ <?php if ( $paginate ) {
368
+ $template_handler->get_template_part( 'pagination', '' );
369
+ } ?>
370
 
371
  <?php endif;
372
 
373
  wp_reset_postdata();
374
 
375
+ return ob_get_clean();
376
  }
377
+ }
 
 
includes/class-dlm-taxonomy-manager.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
+
7
+ class DLM_Taxonomy_Manager {
8
+
9
+ /**
10
+ * Setup hooks
11
+ */
12
+ public function setup() {
13
+ add_action( 'init', array( $this, 'register' ), 9 );
14
+ }
15
+
16
+ /**
17
+ * Register Taxonomies
18
+ */
19
+ public function register() {
20
+
21
+ // Register Download Category
22
+ register_taxonomy( 'dlm_download_category',
23
+ array( 'dlm_download' ),
24
+ apply_filters( 'dlm_download_category_args', array(
25
+ 'hierarchical' => true,
26
+ 'update_count_callback' => '_update_post_term_count',
27
+ 'label' => __( 'Categories', 'download-monitor' ),
28
+ 'labels' => array(
29
+ 'name' => __( 'Categories', 'download-monitor' ),
30
+ 'singular_name' => __( 'Download Category', 'download-monitor' ),
31
+ 'search_items' => __( 'Search Download Categories', 'download-monitor' ),
32
+ 'all_items' => __( 'All Download Categories', 'download-monitor' ),
33
+ 'parent_item' => __( 'Parent Download Category', 'download-monitor' ),
34
+ 'parent_item_colon' => __( 'Parent Download Category:', 'download-monitor' ),
35
+ 'edit_item' => __( 'Edit Download Category', 'download-monitor' ),
36
+ 'update_item' => __( 'Update Download Category', 'download-monitor' ),
37
+ 'add_new_item' => __( 'Add New Download Category', 'download-monitor' ),
38
+ 'new_item_name' => __( 'New Download Category Name', 'download-monitor' )
39
+ ),
40
+ 'show_ui' => true,
41
+ 'query_var' => true,
42
+ 'capabilities' => array(
43
+ 'manage_terms' => 'manage_downloads',
44
+ 'edit_terms' => 'manage_downloads',
45
+ 'delete_terms' => 'manage_downloads',
46
+ 'assign_terms' => 'manage_downloads',
47
+ ),
48
+ 'rewrite' => false,
49
+ 'show_in_nav_menus' => false
50
+ ) )
51
+ );
52
+
53
+ // Register Download Tag
54
+ register_taxonomy( 'dlm_download_tag',
55
+ array( 'dlm_download' ),
56
+ apply_filters( 'dlm_download_tag_args', array(
57
+ 'hierarchical' => false,
58
+ 'label' => __( 'Tags', 'download-monitor' ),
59
+ 'labels' => array(
60
+ 'name' => __( 'Tags', 'download-monitor' ),
61
+ 'singular_name' => __( 'Download Tag', 'download-monitor' ),
62
+ 'search_items' => __( 'Search Download Tags', 'download-monitor' ),
63
+ 'all_items' => __( 'All Download Tags', 'download-monitor' ),
64
+ 'parent_item' => __( 'Parent Download Tag', 'download-monitor' ),
65
+ 'parent_item_colon' => __( 'Parent Download Tag:', 'download-monitor' ),
66
+ 'edit_item' => __( 'Edit Download Tag', 'download-monitor' ),
67
+ 'update_item' => __( 'Update Download Tag', 'download-monitor' ),
68
+ 'add_new_item' => __( 'Add New Download Tag', 'download-monitor' ),
69
+ 'new_item_name' => __( 'New Download Tag Name', 'download-monitor' )
70
+ ),
71
+ 'show_ui' => true,
72
+ 'query_var' => true,
73
+ 'capabilities' => array(
74
+ 'manage_terms' => 'manage_downloads',
75
+ 'edit_terms' => 'manage_downloads',
76
+ 'delete_terms' => 'manage_downloads',
77
+ 'assign_terms' => 'manage_downloads',
78
+ ),
79
+ 'rewrite' => false,
80
+ 'show_in_nav_menus' => false
81
+ ) )
82
+ );
83
+ }
84
+
85
+ }
includes/class-dlm-template-handler.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
+
7
+ class DLM_Template_Handler {
8
+
9
+ /**
10
+ * get_template_part method.
11
+ *
12
+ * @todo move this to own template loader
13
+ *
14
+ * @access public
15
+ *
16
+ * @param string $slug
17
+ * @param string $name (default: '')
18
+ * @param string $custom_dir
19
+ *
20
+ * @return void
21
+ */
22
+ public function get_template_part( $slug, $name = '', $custom_dir = '' ) {
23
+ $template = '';
24
+
25
+ // The plugin path
26
+ $plugin_path = WP_DLM::get_plugin_path();
27
+
28
+ // Look in yourtheme/slug-name.php and yourtheme/download-monitor/slug-name.php
29
+ if ( $name ) {
30
+ $template = locate_template( array( "{$slug}-{$name}.php", "download-monitor/{$slug}-{$name}.php" ) );
31
+ }
32
+
33
+ // Get default slug-name.php
34
+ if ( ! $template && $name && file_exists( $plugin_path . "/templates/{$slug}-{$name}.php" ) ) {
35
+ $template = $plugin_path . "/templates/{$slug}-{$name}.php";
36
+ }
37
+
38
+ // If a custom path was defined, check that next
39
+ if ( ! $template && $custom_dir && file_exists( trailingslashit( $custom_dir ) . "{$slug}-{$name}.php" ) ) {
40
+ $template = trailingslashit( $custom_dir ) . "{$slug}-{$name}.php";
41
+ }
42
+
43
+ // If template file doesn't exist, look in yourtheme/slug.php and yourtheme/download-monitor/slug.php
44
+ if ( ! $template ) {
45
+ $template = locate_template( array( "{$slug}.php", "download-monitor/{$slug}.php" ) );
46
+ }
47
+
48
+ // If a custom path was defined, check that next
49
+ if ( ! $template && $custom_dir && file_exists( trailingslashit( $custom_dir ) . "{$slug}-{$name}.php" ) ) {
50
+ $template = trailingslashit( $custom_dir ) . "{$slug}.php";
51
+ }
52
+
53
+ // Get default slug-name.php
54
+ if ( ! $template && file_exists( $plugin_path . "/templates/{$slug}.php" ) ) {
55
+ $template = $plugin_path . "/templates/{$slug}.php";
56
+ }
57
+
58
+ // Allow 3rd party plugin filter template file from their plugin
59
+ $template = apply_filters( 'dlm_get_template_part', $template, $slug, $name );
60
+
61
+ // Load template if we've found one
62
+ if ( $template ) {
63
+ load_template( $template, false );
64
+ }
65
+ }
66
+
67
+ }
includes/class-wp-dlm.php ADDED
@@ -0,0 +1,426 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
+
7
+ /**
8
+ * WP_DLM class.
9
+ *
10
+ * Main plugin class
11
+ */
12
+ class WP_DLM {
13
+
14
+ /**
15
+ * Get the plugin file
16
+ *
17
+ * @static
18
+ *
19
+ * @return String
20
+ */
21
+ public static function get_plugin_file() {
22
+ return DLM_PLUGIN_FILE;
23
+ }
24
+
25
+ /**
26
+ * Get plugin path
27
+ *
28
+ * @static
29
+ *
30
+ * @return string
31
+ */
32
+ public static function get_plugin_path() {
33
+ return plugin_dir_path( self::get_plugin_file() );
34
+ }
35
+
36
+ /**
37
+ * Get plugin URL
38
+ *
39
+ * @static
40
+ *
41
+ * @return string
42
+ */
43
+ public static function get_plugin_url() {
44
+ return plugins_url( basename( plugin_dir_path( self::get_plugin_file() ) ), basename( self::get_plugin_file() ) );
45
+ }
46
+
47
+ /**
48
+ * A static method that will setup the autoloader
49
+ */
50
+ private static function setup_autoloader() {
51
+ require_once( plugin_dir_path( self::get_plugin_file() ) . 'includes/class-dlm-autoloader.php' );
52
+ $autoloader = new DLM_Autoloader( plugin_dir_path( self::get_plugin_file() ) . 'includes/' );
53
+ spl_autoload_register( array( $autoloader, 'load' ) );
54
+ }
55
+
56
+ /**
57
+ * __construct function.
58
+ *
59
+ * @access public
60
+ */
61
+ public function __construct() {
62
+ global $wpdb;
63
+
64
+ // Setup autoloader
65
+ self::setup_autoloader();
66
+
67
+ // Load plugin text domain
68
+ load_textdomain( 'download-monitor', WP_LANG_DIR . '/download-monitor/download_monitor-' . get_locale() . '.mo' );
69
+ load_plugin_textdomain( 'download-monitor', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
70
+
71
+ // Table for logs
72
+ $wpdb->download_log = $wpdb->prefix . 'download_log';
73
+
74
+ // Setup admin classes
75
+ if ( is_admin() ) {
76
+
77
+ // Setup admin scripts
78
+ $admin_scripts = new DLM_Admin_Scripts();
79
+ $admin_scripts->setup();
80
+
81
+ // Setup Main Admin Class
82
+ $dlm_admin = new DLM_Admin();
83
+ $dlm_admin->setup();
84
+
85
+ // Customize Admin CPT views
86
+ new DLM_Admin_CPT();
87
+
88
+ // Admin Write Panels
89
+ new DLM_Admin_Writepanels();
90
+
91
+ // Admin Media Browser
92
+ new DLM_Admin_Media_Browser();
93
+
94
+ // Admin Media Insert
95
+ new DLM_Admin_Media_Insert();
96
+ }
97
+
98
+ // Setup AJAX handler if doing AJAX
99
+ if ( defined( 'DOING_AJAX' ) ) {
100
+ new DLM_Ajax_Handler();
101
+ }
102
+
103
+ // Functions
104
+ include_once( 'download-functions.php' );
105
+
106
+ // Deprecated
107
+ include_once( 'deprecated.php' );
108
+
109
+ // Setup DLM Download Handler
110
+ $download_handler = new DLM_Download_Handler();
111
+ $download_handler->setup();
112
+
113
+ // Setup shortcodes
114
+ $dlm_shortcodes = new DLM_Shortcodes();
115
+ $dlm_shortcodes->setup();
116
+
117
+ // Setup Widgets
118
+ $widget_manager = new DLM_Widget_Manager();
119
+ $widget_manager->setup();
120
+
121
+ // Setup Taxonomies
122
+ $taxonomy_manager = new DLM_Taxonomy_Manager();
123
+ $taxonomy_manager->setup();
124
+
125
+ // Setup Post Types
126
+ $post_type_manager = new DLM_Post_Type_Manager();
127
+ $post_type_manager->setup();
128
+
129
+ // Setup actions
130
+ $this->setup_actions();
131
+ }
132
+
133
+ /**
134
+ * Setup actions
135
+ */
136
+ private function setup_actions() {
137
+ add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_links' ) );
138
+ add_action( 'init', array( $this, 'register_globals' ) );
139
+ add_action( 'after_setup_theme', array( $this, 'compatibility' ) );
140
+ add_action( 'the_post', array( $this, 'setup_download_data' ) );
141
+ add_action( 'wp_enqueue_scripts', array( $this, 'frontend_scripts' ) );
142
+ add_action( 'admin_init', array( $this, 'load_extensions' ) );
143
+ }
144
+
145
+ public function load_extensions() {
146
+
147
+ // Load the registered extensions
148
+ $registered_extensions = apply_filters( 'dlm_extensions', array() );
149
+
150
+ // Check if we've got extensions
151
+ if ( count( $registered_extensions ) > 0 ) {
152
+
153
+ // Don't block local requests
154
+ add_filter( 'block_local_requests', '__return_false' );
155
+
156
+ // Load products
157
+ DLM_Product_Manager::get()->load_products( $registered_extensions );
158
+
159
+ }
160
+
161
+ }
162
+
163
+ /**
164
+ * Add Theme Compatibility
165
+ *
166
+ * @access public
167
+ * @return void
168
+ */
169
+ public function compatibility() {
170
+ // Post thumbnail support
171
+ if ( ! current_theme_supports( 'post-thumbnails' ) ) {
172
+ add_theme_support( 'post-thumbnails' );
173
+ remove_post_type_support( 'post', 'thumbnail' );
174
+ remove_post_type_support( 'page', 'thumbnail' );
175
+ } else {
176
+ add_theme_support( 'post-thumbnails', array( 'dlm_download' ) );
177
+ add_post_type_support( 'download', 'thumbnail' );
178
+ }
179
+ }
180
+
181
+ /**
182
+ * Add links to admin plugins page.
183
+ *
184
+ * @param array $links
185
+ *
186
+ * @return array
187
+ */
188
+ public function plugin_links( $links ) {
189
+ $plugin_links = array(
190
+ '<a href="' . admin_url( 'edit.php?post_type=dlm_download&page=download-monitor-settings' ) . '">' . __( 'Settings', 'download-monitor' ) . '</a>',
191
+ '<a href="https://www.download-monitor.com/extensions/">' . __( 'Extensions', 'download-monitor' ) . '</a>',
192
+ '<a href="https://github.com/download-monitor/download-monitor/wiki">' . __( 'Docs', 'download-monitor' ) . '</a>',
193
+ );
194
+
195
+ return array_merge( $plugin_links, $links );
196
+ }
197
+
198
+ /**
199
+ * frontend_scripts function.
200
+ *
201
+ * @access public
202
+ * @return void
203
+ */
204
+ public function frontend_scripts() {
205
+ wp_enqueue_style( 'dlm-frontend', self::get_plugin_url() . '/assets/css/frontend.css' );
206
+ }
207
+
208
+ /**
209
+ * Register environment globals
210
+ *
211
+ * @access private
212
+ * @return void
213
+ */
214
+ public function register_globals() {
215
+ $GLOBALS['dlm_download'] = null;
216
+ }
217
+
218
+ /**
219
+ * When the_post is called, get product data too
220
+ *
221
+ * @access public
222
+ *
223
+ * @param mixed $post
224
+ *
225
+ * @return void
226
+ */
227
+ public function setup_download_data( $post ) {
228
+ if ( is_int( $post ) ) {
229
+ $post = get_post( $post );
230
+ }
231
+
232
+ if ( $post->post_type !== 'dlm_download' ) {
233
+ return;
234
+ }
235
+
236
+ $GLOBALS['dlm_download'] = new DLM_Download( $post->ID );
237
+ }
238
+
239
+ /** Deprecated methods **************************************************/
240
+
241
+ /**
242
+ * get_template_part function.
243
+ *
244
+ * @deprecated 1.6.0
245
+ *
246
+ * @access public
247
+ *
248
+ * @param mixed $slug
249
+ * @param string $name (default: '')
250
+ *
251
+ * @return void
252
+ */
253
+ public function get_template_part( $slug, $name = '', $custom_dir = '' ) {
254
+
255
+ // Deprecated
256
+ DLM_Debug_Logger::deprecated( __METHOD__ );
257
+
258
+ // Load template part
259
+ $template_handler = new DLM_Template_Handler();
260
+ $template_handler->get_template_part( $slug, $name, $custom_dir );
261
+ }
262
+
263
+ /**
264
+ * Get the plugin url
265
+ *
266
+ * @deprecated 1.6.0
267
+ *
268
+ * @access public
269
+ * @return string
270
+ */
271
+ public function plugin_url() {
272
+
273
+ // Deprecated
274
+ DLM_Debug_Logger::deprecated( __METHOD__ );
275
+
276
+ return self::get_plugin_url();
277
+ }
278
+
279
+ /**
280
+ * Get the plugin path
281
+ *
282
+ * @deprecated 1.6.0
283
+ *
284
+ * @access public
285
+ * @return string
286
+ */
287
+ public function plugin_path() {
288
+
289
+ // Deprecated
290
+ DLM_Debug_Logger::deprecated( __METHOD__ );
291
+
292
+ return self::get_plugin_path();
293
+ }
294
+
295
+ /**
296
+ * Returns a listing of all files in the specified folder and all subdirectories up to 100 levels deep.
297
+ * The depth of the recursiveness can be controlled by the $levels param.
298
+ *
299
+ * @deprecated 1.6.0
300
+ *
301
+ * @access public
302
+ *
303
+ * @param string $folder (default: '')
304
+ *
305
+ * @return void
306
+ */
307
+ public function list_files( $folder = '' ) {
308
+
309
+ // Deprecated
310
+ DLM_Debug_Logger::deprecated( __METHOD__ );
311
+
312
+ // File Manger
313
+ $file_manager = new DLM_File_Manager();
314
+
315
+ // Return files
316
+ return $file_manager->list_files( $folder );
317
+ }
318
+
319
+ /**
320
+ * Parse a file path and return the new path and whether or not it's remote
321
+ *
322
+ * @deprecated 1.6.0
323
+ *
324
+ * @param string $file_path
325
+ *
326
+ * @return array
327
+ */
328
+ public function parse_file_path( $file_path ) {
329
+
330
+ // Deprecated
331
+ DLM_Debug_Logger::deprecated( __METHOD__ );
332
+
333
+ // File Manger
334
+ $file_manager = new DLM_File_Manager();
335
+
336
+ // Return files
337
+ return $file_manager->parse_file_path( $file_path );
338
+ }
339
+
340
+ /**
341
+ * Gets the filesize of a path or URL.
342
+ *
343
+ * @deprecated 1.6.0
344
+ *
345
+ * @param string $file_path
346
+ *
347
+ * @access public
348
+ * @return string size on success, -1 on failure
349
+ */
350
+ public function get_filesize( $file_path ) {
351
+
352
+ // Deprecated
353
+ DLM_Debug_Logger::deprecated( __METHOD__ );
354
+
355
+ // File Manger
356
+ $file_manager = new DLM_File_Manager();
357
+
358
+ // Return files
359
+ return $file_manager->get_file_size( $file_path );
360
+ }
361
+
362
+ /**
363
+ * Gets md5, sha1 and crc32 hashes for a file and store it.
364
+ *
365
+ * @deprecated 1.6.0
366
+ *
367
+ * @string $file_path
368
+ *
369
+ * @access public
370
+ * @return array of sizes
371
+ */
372
+ public function get_file_hashes( $file_path ) {
373
+
374
+ // Deprecated
375
+ DLM_Debug_Logger::deprecated( __METHOD__ );
376
+
377
+ // File Manger
378
+ $file_manager = new DLM_File_Manager();
379
+
380
+ // Return files
381
+ return $file_manager->get_file_hashes( $file_path );
382
+ }
383
+
384
+ /**
385
+ * Encode files for storage
386
+ *
387
+ * @deprecated 1.6.0
388
+ *
389
+ * @param array $files
390
+ *
391
+ * @return string
392
+ */
393
+ public function json_encode_files( $files ) {
394
+
395
+ // Deprecated
396
+ DLM_Debug_Logger::deprecated( __METHOD__ );
397
+
398
+ // File Manger
399
+ $file_manager = new DLM_File_Manager();
400
+
401
+ // Return files
402
+ return $file_manager->json_encode_files( $files );
403
+ }
404
+
405
+ /**
406
+ * Fallback for PHP < 5.4 where JSON_UNESCAPED_UNICODE does not exist.
407
+ *
408
+ * @deprecated 1.6.0
409
+ *
410
+ * @param array $matches
411
+ *
412
+ * @return string
413
+ */
414
+ public function json_unscaped_unicode_fallback( $matches ) {
415
+
416
+ // Deprecated
417
+ DLM_Debug_Logger::deprecated( __METHOD__ );
418
+
419
+ // File Manger
420
+ $file_manager = new DLM_File_Manager();
421
+
422
+ // Return files
423
+ return $file_manager->json_unscaped_unicode_fallback( $matches );
424
+ }
425
+
426
+ }
includes/deprecated.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Deprecated code, avoid using anything that's in this file
4
+ */
5
+
6
+ /**
7
+ * dlm_create_log function.
8
+ *
9
+ * @access public
10
+ *
11
+ * @deprecated 1.6.0
12
+ *
13
+ * @param string $type (default: '')
14
+ * @param string $status (default: '')
15
+ * @param string $message (default: '')
16
+ * @param mixed $download
17
+ * @param mixed $version
18
+ *
19
+ * @return void
20
+ */
21
+ function dlm_create_log( $type = '', $status = '', $message = '', $download, $version ) {
22
+
23
+ // Deprecated notice
24
+ _deprecated_function( __FUNCTION__, '1.6.0', 'DLM_Logging->create_log()' );
25
+
26
+ // Logging object
27
+ $logging = new DLM_Logging();
28
+
29
+ // Check if logging is enabled
30
+ if( $logging->is_logging_enabled() ) {
31
+
32
+ // Create log
33
+ $logging->create_log( $type, $status, $message, $download, $version );
34
+
35
+ }
36
+
37
+ }
includes/download-functions.php CHANGED
@@ -7,8 +7,9 @@
7
  function dlm_get_default_download_template() {
8
  $default = get_option( 'dlm_default_template' );
9
 
10
- if ( $default == 'custom' )
11
  $default = get_option( 'dlm_custom_template' );
 
12
 
13
  return $default;
14
  }
7
  function dlm_get_default_download_template() {
8
  $default = get_option( 'dlm_default_template' );
9
 
10
+ if ( $default == 'custom' ) {
11
  $default = get_option( 'dlm_custom_template' );
12
+ }
13
 
14
  return $default;
15
  }
includes/product/class-dlm-product-license.php ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class DLM_Product_License {
4
+
5
+ /**
6
+ * @var String
7
+ */
8
+ private $product_id;
9
+
10
+ /**
11
+ * @var String
12
+ */
13
+ private $key;
14
+
15
+ /**
16
+ * @var String
17
+ */
18
+ private $email;
19
+
20
+ /**
21
+ * @var String (active or inactive)
22
+ */
23
+ private $status;
24
+
25
+ /**
26
+ * Constructor
27
+ *
28
+ * @param String $product_id
29
+ */
30
+ public function __construct( $product_id ) {
31
+
32
+ // Set Product ID
33
+ $this->product_id = $product_id;
34
+
35
+ // Load license data from DB
36
+ $db_license = wp_parse_args( get_option( $this->product_id . '-license', array() ), array(
37
+ 'key' => '',
38
+ 'email' => get_option( 'admin_email', '' ),
39
+ 'status' => 'inactive'
40
+ ) );
41
+
42
+ // Set properties
43
+ $this->key = $db_license['key'];
44
+ $this->email = $db_license['email'];
45
+ $this->status = $db_license['status'];
46
+ }
47
+
48
+ /**
49
+ * @return String
50
+ */
51
+ public function get_key() {
52
+ return $this->key;
53
+ }
54
+
55
+ /**
56
+ * @param String $key
57
+ */
58
+ public function set_key( $key ) {
59
+ $this->key = $key;
60
+ }
61
+
62
+ /**
63
+ * @return String
64
+ */
65
+ public function get_email() {
66
+ return $this->email;
67
+ }
68
+
69
+ /**
70
+ * @param String $email
71
+ */
72
+ public function set_email( $email ) {
73
+ $this->email = $email;
74
+ }
75
+
76
+ /**
77
+ * @return String
78
+ */
79
+ public function get_status() {
80
+ return $this->status;
81
+ }
82
+
83
+ /**
84
+ * @param String $status
85
+ */
86
+ public function set_status( $status ) {
87
+ $this->status = $status;
88
+ }
89
+
90
+ /**
91
+ * Return if license is active
92
+ *
93
+ * @return bool
94
+ */
95
+ public function is_active() {
96
+ return ( 'active' === $this->status );
97
+ }
98
+
99
+ /**
100
+ * Store license data in DB
101
+ */
102
+ public function store() {
103
+ update_option( $this->product_id . '-license', array(
104
+ 'key' => $this->get_key(),
105
+ 'email' => $this->get_email(),
106
+ 'status' => $this->get_status()
107
+ ) );
108
+ }
109
+
110
+ }
includes/product/class-dlm-product-manager.php ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Exit if accessed directly
4
+ if ( ! defined( 'ABSPATH' ) ) {
5
+ exit;
6
+ }
7
+
8
+ class DLM_Product_Manager {
9
+
10
+ /**
11
+ * @var DLM_Product_Manager
12
+ */
13
+ private static $instance = null;
14
+
15
+ /**
16
+ * @var array<DLM_Product>
17
+ */
18
+ private $products;
19
+
20
+ /**
21
+ * Private constructor
22
+ */
23
+ private function __construct() {
24
+ }
25
+
26
+ /**
27
+ * Singleton get method
28
+ *
29
+ * @since 1.0.0
30
+ * @access public
31
+ *
32
+ * @return DLM_Product_Manager
33
+ */
34
+ public static function get() {
35
+ if ( null == self::$instance ) {
36
+ self::$instance = new self();
37
+ }
38
+
39
+ return self::$instance;
40
+ }
41
+
42
+ /**
43
+ * Load Products
44
+ *
45
+ * @param array $extensions
46
+ */
47
+ public function load_products( $extensions ) {
48
+
49
+ // Check
50
+ if ( count( $extensions ) > 0 ) {
51
+
52
+ // Loop
53
+ foreach ( $extensions as $extension ) {
54
+
55
+ // Setup new Product
56
+ $product = new DLM_Product( $extension );
57
+
58
+ // Setup plugin actions and filters
59
+ add_action( 'pre_set_site_transient_update_plugins', array( $product, 'check_for_updates' ) );
60
+ add_filter( 'plugins_api', array( $product, 'plugins_api' ), 10, 3 );
61
+
62
+ // Add product to products property
63
+ $this->products[ $extension ] = $product;
64
+ }
65
+
66
+ }
67
+
68
+ }
69
+
70
+ /**
71
+ * Get products
72
+ *
73
+ * @return array<DLM_Product>
74
+ */
75
+ public function get_products() {
76
+ return $this->products;
77
+ }
78
+
79
+
80
+ /**
81
+ * Handle errors from the API
82
+ *
83
+ * @param array $errors
84
+ */
85
+ /*
86
+ public function handle_errors( $errors ) {
87
+
88
+ if ( ! empty( $errors['no_key'] ) ) {
89
+ $this->add_error( sprintf( 'A licence key for %s could not be found. Maybe you forgot to enter a licence key when setting up %s.', esc_html( $this->plugin_data['Name'] ), esc_html( $this->plugin_data['Name'] ) ) );
90
+ } elseif ( ! empty( $errors['invalid_request'] ) ) {
91
+ $this->add_error( 'Invalid update request' );
92
+ } elseif ( ! empty( $errors['invalid_key'] ) ) {
93
+ $this->add_error( $errors['invalid_key'], 'invalid_key' );
94
+ } elseif ( ! empty( $errors['no_activation'] ) ) {
95
+
96
+ // Deactivate license
97
+ RP4WP_Updater_Key_API::deactivate( array(
98
+ 'api_product_id' => $this->plugin_slug,
99
+ 'licence_key' => $this->api_key,
100
+ ) );
101
+
102
+ $this->add_error( $errors['no_activation'] );
103
+ }
104
+
105
+ }
106
+ */
107
+ }
includes/product/class-dlm-product.php ADDED
@@ -0,0 +1,346 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class DLM_Product
5
+ * The base class for all Download Monitor Extensions
6
+ */
7
+ class DLM_Product {
8
+
9
+ /**
10
+ * The store URL
11
+ */
12
+ const STORE_URL = 'https://www.download-monitor.com/?wc-api=';
13
+
14
+ /**
15
+ * Activation endpoint
16
+ */
17
+ const ENDPOINT_ACTIVATION = 'wp_plugin_licencing_activation_api';
18
+
19
+ /**
20
+ * Update endpoint
21
+ */
22
+ const ENDPOINT_UPDATE = 'wp_plugin_licencing_update_api';
23
+
24
+ /**
25
+ * @var String
26
+ */
27
+ private $product_id;
28
+
29
+ /**
30
+ * @var String
31
+ */
32
+ private $plugin_name;
33
+
34
+ /**
35
+ * @var DLM_Product_License
36
+ */
37
+ private $license = null;
38
+
39
+ /**
40
+ * Constructor
41
+ *
42
+ * @param String $product_id
43
+ */
44
+ function __construct( $product_id ) {
45
+ $this->product_id = $product_id;
46
+
47
+ // The plugin file name
48
+ $this->plugin_name = $this->product_id . '/' . $this->product_id . '.php';
49
+ }
50
+
51
+ /**
52
+ * @return String
53
+ */
54
+ public function get_product_id() {
55
+ return $this->product_id;
56
+ }
57
+
58
+ /**
59
+ * @param String $product_id
60
+ */
61
+ public function set_product_id( $product_id ) {
62
+ $this->product_id = $product_id;
63
+ }
64
+
65
+ /**
66
+ * @return String
67
+ */
68
+ public function get_plugin_name() {
69
+ return $this->plugin_name;
70
+ }
71
+
72
+ /**
73
+ * @param String $plugin_name
74
+ */
75
+ public function set_plugin_name( $plugin_name ) {
76
+ $this->plugin_name = $plugin_name;
77
+ }
78
+
79
+ /**
80
+ * Get the license, license will be automatically loaded if not set yet.
81
+ *
82
+ * @return DLM_Product_License
83
+ */
84
+ public function get_license() {
85
+ if ( null === $this->license ) {
86
+ $this->license = new DLM_Product_License( $this->product_id );
87
+ }
88
+
89
+ return $this->license;
90
+ }
91
+
92
+ /**
93
+ * Set the license
94
+ *
95
+ * @param DLM_Product_License $license
96
+ */
97
+ public function set_license( $license ) {
98
+ $this->license = $license;
99
+ $this->license->store();
100
+ }
101
+
102
+ /**
103
+ * Attempt to activate a plugin licence
104
+ *
105
+ * @return String
106
+ */
107
+ public function activate() {
108
+
109
+ // Get License
110
+ $license = $this->get_license();
111
+
112
+ try {
113
+
114
+ // Check License key
115
+ if ( '' === $license->get_key() ) {
116
+ throw new Exception( 'Please enter your license key.' );
117
+ }
118
+
119
+ // Check license email
120
+ if ( '' === $license->get_email() ) {
121
+ throw new Exception( 'Please enter the email address associated with your license.' );
122
+ }
123
+
124
+ // Do activate request
125
+ $request = wp_remote_get( self::STORE_URL . self::ENDPOINT_ACTIVATION . '&' . http_build_query( array(
126
+ 'email' => $license->get_email(),
127
+ 'licence_key' => $license->get_key(),
128
+ 'api_product_id' => $this->product_id,
129
+ 'request' => 'activate',
130
+ 'instance' => site_url()
131
+ ), '', '&' ) );
132
+
133
+ // Check request
134
+ if ( is_wp_error( $request ) || wp_remote_retrieve_response_code( $request ) != 200 ) {
135
+ throw new Exception( 'Connection failed to the Licence Key API server. Try again later.' );
136
+ }
137
+
138
+ // Get activation result
139
+ $activate_results = json_decode( wp_remote_retrieve_body( $request ), true );
140
+
141
+ // Check if response is correct
142
+ if ( ! empty( $activate_results['activated'] ) ) {
143
+
144
+ // Set local activation status to true
145
+ $license->set_status( 'active' );
146
+ $this->set_license( $license );
147
+
148
+ // Return Message
149
+ return array( 'result' => 'success', 'message' => __( 'License successfully activated.', 'download-monitor' ) );
150
+
151
+ } elseif ( $activate_results === false ) {
152
+ throw new Exception( 'Connection failed to the Licence Key API server. Try again later.' );
153
+ } elseif ( isset( $activate_results['error_code'] ) ) {
154
+ throw new Exception( $activate_results['error'] );
155
+ }
156
+
157
+
158
+ } catch ( Exception $e ) {
159
+
160
+ // Set local activation status to false
161
+ $license->set_status( 'inactivate' );
162
+ $this->set_license( $license );
163
+
164
+ // Return error message
165
+ return array( 'result' => 'failed', 'message' => $e->getMessage() );
166
+ }
167
+ }
168
+
169
+ /**
170
+ * Attempt to deactivate a licence
171
+ */
172
+ public function deactivate() {
173
+
174
+ // Get License
175
+ $license = $this->get_license();
176
+
177
+ try {
178
+
179
+ // Check License key
180
+ if ( '' === $license->get_key() ) {
181
+ throw new Exception( "Can't deactivate license without a license key." );
182
+ }
183
+
184
+ // The Request
185
+ $request = wp_remote_get( self::STORE_URL . self::ENDPOINT_ACTIVATION . '&' . http_build_query( array(
186
+ 'api_product_id' => $this->product_id,
187
+ 'licence_key' => $license->get_key(),
188
+ 'request' => 'deactivate',
189
+ 'instance' => site_url(),
190
+ ), '', '&' ) );
191
+
192
+ // Check request
193
+ if ( is_wp_error( $request ) || wp_remote_retrieve_response_code( $request ) != 200 ) {
194
+ throw new Exception( 'Connection failed to the Licence Key API server. Try again later.' );
195
+ }
196
+
197
+ // Get result
198
+ $result = json_decode( wp_remote_retrieve_body( $request ), true );
199
+
200
+ /** @todo check result * */
201
+
202
+ // Set new license status
203
+ $license->set_status( 'inactive' );
204
+ $this->set_license( $license );
205
+
206
+ return array( 'result' => 'success' );
207
+
208
+ } catch ( Exception $e ) {
209
+
210
+ // Return error message
211
+ return array( 'result' => 'failed', 'message' => $e->getMessage() );
212
+ }
213
+
214
+ }
215
+
216
+ /**
217
+ * Check for plugin updates
218
+ *
219
+ * @var $check_for_updates_data
220
+ */
221
+ public function check_for_updates( $check_for_updates_data ) {
222
+
223
+ // Get license
224
+ $license = $this->get_license();
225
+
226
+ // Check if checked is set
227
+ if ( empty( $check_for_updates_data->checked ) ) {
228
+ return $check_for_updates_data;
229
+ }
230
+
231
+ // Only check for data if license is activated
232
+ if ( true !== $license->is_active() ) {
233
+ return $check_for_updates_data;
234
+ }
235
+
236
+ // Get current version
237
+ $current_ver = $check_for_updates_data->checked[ $this->plugin_name ];
238
+
239
+ // The request
240
+ $request = wp_remote_get( self::STORE_URL . self::ENDPOINT_UPDATE . '&' . http_build_query( array(
241
+ 'request' => 'pluginupdatecheck',
242
+ 'plugin_name' => $this->plugin_name,
243
+ 'version' => $current_ver,
244
+ 'api_product_id' => $this->product_id,
245
+ 'licence_key' => $license->get_key(),
246
+ 'email' => $license->get_email(),
247
+ 'instance' => site_url()
248
+ ), '', '&' ) );
249
+
250
+ // Check if request is correct
251
+ if ( is_wp_error( $request ) || wp_remote_retrieve_response_code( $request ) != 200 ) {
252
+ return $check_for_updates_data;
253
+ }
254
+
255
+ // Check for a plugin update
256
+ $response = maybe_unserialize( wp_remote_retrieve_body( $request ) );
257
+
258
+ // $response must be an object
259
+ if ( ! is_object( $response ) ) {
260
+ return $check_for_updates_data;
261
+ }
262
+
263
+ if ( isset( $response->errors ) ) {
264
+ // $this->handle_errors( $response->errors );
265
+ /** @todo handle errors */
266
+ return $check_for_updates_data;
267
+ }
268
+
269
+ // Set version variables
270
+ if ( is_object( $response ) && false !== $response && isset( $response->new_version ) ) {
271
+
272
+ // Check if there's a new version
273
+ if ( version_compare( $response->new_version, $current_ver, '>' ) ) {
274
+ $check_for_updates_data->response[ $this->plugin_name ] = $response;
275
+ }
276
+
277
+ }
278
+
279
+ return $check_for_updates_data;
280
+ }
281
+
282
+ /**
283
+ * Plugins API
284
+ *
285
+ * @param bool $false
286
+ * @param string $action
287
+ * @param array $args
288
+ *
289
+ * @return mixed
290
+ */
291
+ public function plugins_api( $false, $action, $args ) {
292
+
293
+ // License
294
+ $license = $this->get_license();
295
+
296
+ // Only take over plugin info screen if license is activated
297
+ if ( true !== $license->is_active() ) {
298
+ return $false;
299
+ }
300
+
301
+ // Check if this request if for this product
302
+ if ( ! isset( $args->slug ) || ( $args->slug !== $this->plugin_name ) ) {
303
+ return $false;
304
+ }
305
+
306
+ // Get the current version
307
+ $plugin_info = get_site_transient( 'update_plugins' );
308
+ $current_ver = isset( $plugin_info->checked[ $this->plugin_name ] ) ? $plugin_info->checked[ $this->plugin_name ] : '';
309
+
310
+ $request = wp_remote_get( self::STORE_URL . self::ENDPOINT_UPDATE . '&' . http_build_query( array(
311
+ 'request' => 'plugininformation',
312
+ 'plugin_name' => $this->plugin_name,
313
+ 'version' => $current_ver,
314
+ 'api_product_id' => $this->product_id,
315
+ 'licence_key' => $license->get_key(),
316
+ 'email' => $license->get_email(),
317
+ 'instance' => site_url()
318
+ ), '', '&' ) );
319
+
320
+ // Check if request is correct
321
+ if ( is_wp_error( $request ) || wp_remote_retrieve_response_code( $request ) != 200 ) {
322
+ return $false;
323
+ }
324
+
325
+ // Check for a plugin update
326
+ $response = maybe_unserialize( wp_remote_retrieve_body( $request ) );
327
+
328
+ // $response must be an object
329
+ if ( ! is_object( $response ) ) {
330
+ return $false;
331
+ }
332
+
333
+ // Handle errors
334
+ if ( isset( $response->errors ) ) {
335
+ /** @todo handle errors */
336
+ //$this->handle_errors( $response->errors );
337
+ return $false;
338
+ }
339
+
340
+ // If everything is okay return the $response
341
+ if ( isset( $response ) && is_object( $response ) && false !== $response ) {
342
+ return $response;
343
+ }
344
+ }
345
+
346
+ }
includes/widgets/class-dlm-widget-downloads.php CHANGED
@@ -1,6 +1,8 @@
1
  <?php
2
 
3
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
4
 
5
  /**
6
  * DLM_Widget_Downloads class.
@@ -40,13 +42,15 @@ class DLM_Widget_Downloads extends WP_Widget {
40
  *
41
  * @see WP_Widget
42
  * @access public
 
43
  * @param array $args
44
  * @param array $instance
 
45
  * @return void
46
  */
47
  function widget( $args, $instance ) {
48
- global $download_monitor;
49
 
 
50
  extract( $args );
51
 
52
  $title = isset( $instance['title'] ) ? apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) : __( 'Featured Downloads', 'download-monitor' );
@@ -57,35 +61,35 @@ class DLM_Widget_Downloads extends WP_Widget {
57
  $featured = isset( $instance['featured'] ) ? $instance['featured'] : 'no';
58
  $members_only = isset( $instance['members_only'] ) ? $instance['members_only'] : 'no';
59
 
60
- $args = array(
61
- 'post_status' => 'publish',
62
- 'post_type' => 'dlm_download',
63
- 'no_found_rows' => 1,
64
- 'posts_per_page' => $posts_per_page,
65
- 'orderby' => $orderby,
66
- 'order' => $order,
67
- 'meta_query' => array(),
68
- 'tax_query' => array()
69
- );
70
-
71
- if ( $orderby == 'download_count' ) {
72
- $args['orderby'] = 'meta_value_num';
73
  $args['meta_key'] = '_download_count';
74
- }
75
-
76
- if ( $featured == 'yes' ) {
77
- $args['meta_query'][] = array(
78
- 'key' => '_featured',
79
- 'value' => 'yes'
80
- );
81
- }
82
-
83
- if ( $members_only == 'yes' ) {
84
- $args['meta_query'][] = array(
85
- 'key' => '_members_only',
86
- 'value' => 'yes'
87
- );
88
- }
89
 
90
  $r = new WP_Query( $args );
91
 
@@ -93,17 +97,21 @@ class DLM_Widget_Downloads extends WP_Widget {
93
 
94
  echo $before_widget;
95
 
96
- if ( $title )
97
  echo $before_title . $title . $after_title;
 
98
 
99
  echo apply_filters( 'dlm_widget_downloads_list_start', '<ul class="dlm-downloads">' );
100
 
101
- while ( $r->have_posts()) {
 
 
 
102
  $r->the_post();
103
 
104
  echo apply_filters( 'dlm_widget_downloads_list_item_start', '<li>' );
105
 
106
- $download_monitor->get_template_part( 'content-download', $format );
107
 
108
  echo apply_filters( 'dlm_widget_downloads_list_item_end', '</li>' );
109
  }
@@ -119,8 +127,10 @@ class DLM_Widget_Downloads extends WP_Widget {
119
  *
120
  * @see WP_Widget->update
121
  * @access public
 
122
  * @param array $new_instance
123
  * @param array $old_instance
 
124
  * @return array
125
  */
126
  function update( $new_instance, $old_instance ) {
@@ -141,12 +151,14 @@ class DLM_Widget_Downloads extends WP_Widget {
141
  *
142
  * @see WP_Widget->form
143
  * @access public
 
144
  * @param array $instance
 
145
  * @return void
146
  */
147
  function form( $instance ) {
148
  $title = isset( $instance['title'] ) ? $instance['title'] : __( 'Featured Downloads', 'download-monitor' );
149
- $posts_per_page = isset( $instance['posts_per_page'] ) ? absint( $instance['posts_per_page'] ) : 10;
150
  $format = isset( $instance['format'] ) ? sanitize_title( $instance['format'] ) : '';
151
  $orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : 'title';
152
  $order = isset( $instance['order'] ) ? $instance['order'] : 'ASC';
@@ -154,43 +166,71 @@ class DLM_Widget_Downloads extends WP_Widget {
154
  $members_only = isset( $instance['members_only'] ) ? $instance['members_only'] : 'no';
155
  ?>
156
  <p>
157
- <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'download-monitor' ); ?></label>
158
- <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
 
 
 
159
  </p>
160
  <p>
161
- <label for="<?php echo $this->get_field_id( 'posts_per_page' ); ?>"><?php _e( 'Limit:', 'download-monitor' ); ?></label>
162
- <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'posts_per_page' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'posts_per_page' ) ); ?>" type="text" value="<?php echo esc_attr( $posts_per_page ); ?>" size="3" />
 
 
 
163
  </p>
164
  <p>
165
- <label for="<?php echo $this->get_field_id( 'format' ); ?>"><?php _e( 'Output template:', 'download-monitor' ); ?></label>
166
- <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'format' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'format' ) ); ?>" type="text" value="<?php echo esc_attr( $format ); ?>" placeholder="<?php _e( 'Default template', 'download-monitor' ); ?>" />
 
 
 
 
167
  </p>
168
  <p>
169
- <label for="<?php echo $this->get_field_id( 'orderby' ); ?>"><?php _e( 'Order by:', 'download-monitor' ); ?></label>
170
- <select class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'orderby' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'orderby' ) ); ?>" type="text">
171
- <option value="title" <?php selected( $orderby, 'title' ); ?>><?php _e( 'Title', 'download-monitor' ); ?></option>
172
- <option value="rand" <?php selected( $orderby, 'rand' ); ?>><?php _e( 'Random', 'download-monitor' ); ?></option>
173
- <option value="ID" <?php selected( $orderby, 'ID' ); ?>><?php _e( 'ID', 'download-monitor' ); ?></option>
174
- <option value="date" <?php selected( $orderby, 'date' ); ?>><?php _e( 'Date added', 'download-monitor' ); ?></option>
175
- <option value="modified" <?php selected( $orderby, 'modified' ); ?>><?php _e( 'Date modified', 'download-monitor' ); ?></option>
176
- <option value="download_count" <?php selected( $orderby, 'download_count' ); ?>><?php _e( 'Download count', 'download-monitor' ); ?></option>
 
 
 
 
 
 
 
 
177
  </select>
178
  </p>
179
  <p>
180
- <label for="<?php echo $this->get_field_id( 'order' ); ?>"><?php _e( 'Order:', 'download-monitor' ); ?></label>
181
- <select class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'order' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'order' ) ); ?>" type="text">
182
- <option value="ASC" <?php selected( $order, 'ASC' ); ?>><?php _e( 'ASC', 'download-monitor' ); ?></option>
183
- <option value="DESC" <?php selected( $order, 'DESC' ); ?>><?php _e( 'DESC', 'download-monitor' ); ?></option>
 
 
 
 
184
  </select>
185
  </p>
186
  <p>
187
- <input id="<?php echo esc_attr( $this->get_field_id( 'featured' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'featured' ) ); ?>" type="checkbox" <?php checked( $featured, 'yes' ); ?> />
188
- <label for="<?php echo $this->get_field_id( 'featured' ); ?>"><?php _e( 'Show only featured downloads', 'download-monitor' ); ?></label>
 
 
 
189
  </p>
190
  <p>
191
- <input id="<?php echo esc_attr( $this->get_field_id( 'members_only' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'members_only' ) ); ?>" type="checkbox" <?php checked( $members_only, 'yes' ); ?> />
192
- <label for="<?php echo $this->get_field_id( 'members_only' ); ?>"><?php _e( 'Show only members only downloads', 'download-monitor' ); ?></label>
 
 
 
193
  </p>
194
- <?php
195
  }
196
  }
1
  <?php
2
 
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
 
7
  /**
8
  * DLM_Widget_Downloads class.
42
  *
43
  * @see WP_Widget
44
  * @access public
45
+ *
46
  * @param array $args
47
  * @param array $instance
48
+ *
49
  * @return void
50
  */
51
  function widget( $args, $instance ) {
 
52
 
53
+ // Extract the arguments
54
  extract( $args );
55
 
56
  $title = isset( $instance['title'] ) ? apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) : __( 'Featured Downloads', 'download-monitor' );
61
  $featured = isset( $instance['featured'] ) ? $instance['featured'] : 'no';
62
  $members_only = isset( $instance['members_only'] ) ? $instance['members_only'] : 'no';
63
 
64
+ $args = array(
65
+ 'post_status' => 'publish',
66
+ 'post_type' => 'dlm_download',
67
+ 'no_found_rows' => 1,
68
+ 'posts_per_page' => $posts_per_page,
69
+ 'orderby' => $orderby,
70
+ 'order' => $order,
71
+ 'meta_query' => array(),
72
+ 'tax_query' => array()
73
+ );
74
+
75
+ if ( $orderby == 'download_count' ) {
76
+ $args['orderby'] = 'meta_value_num';
77
  $args['meta_key'] = '_download_count';
78
+ }
79
+
80
+ if ( $featured == 'yes' ) {
81
+ $args['meta_query'][] = array(
82
+ 'key' => '_featured',
83
+ 'value' => 'yes'
84
+ );
85
+ }
86
+
87
+ if ( $members_only == 'yes' ) {
88
+ $args['meta_query'][] = array(
89
+ 'key' => '_members_only',
90
+ 'value' => 'yes'
91
+ );
92
+ }
93
 
94
  $r = new WP_Query( $args );
95
 
97
 
98
  echo $before_widget;
99
 
100
+ if ( $title ) {
101
  echo $before_title . $title . $after_title;
102
+ }
103
 
104
  echo apply_filters( 'dlm_widget_downloads_list_start', '<ul class="dlm-downloads">' );
105
 
106
+ // Template handler
107
+ $template_handler = new DLM_Template_Handler();
108
+
109
+ while ( $r->have_posts() ) {
110
  $r->the_post();
111
 
112
  echo apply_filters( 'dlm_widget_downloads_list_item_start', '<li>' );
113
 
114
+ $template_handler->get_template_part( 'content-download', $format );
115
 
116
  echo apply_filters( 'dlm_widget_downloads_list_item_end', '</li>' );
117
  }
127
  *
128
  * @see WP_Widget->update
129
  * @access public
130
+ *
131
  * @param array $new_instance
132
  * @param array $old_instance
133
+ *
134
  * @return array
135
  */
136
  function update( $new_instance, $old_instance ) {
151
  *
152
  * @see WP_Widget->form
153
  * @access public
154
+ *
155
  * @param array $instance
156
+ *
157
  * @return void
158
  */
159
  function form( $instance ) {
160
  $title = isset( $instance['title'] ) ? $instance['title'] : __( 'Featured Downloads', 'download-monitor' );
161
+ $posts_per_page = isset( $instance['posts_per_page'] ) ? absint( $instance['posts_per_page'] ) : 10;
162
  $format = isset( $instance['format'] ) ? sanitize_title( $instance['format'] ) : '';
163
  $orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : 'title';
164
  $order = isset( $instance['order'] ) ? $instance['order'] : 'ASC';
166
  $members_only = isset( $instance['members_only'] ) ? $instance['members_only'] : 'no';
167
  ?>
168
  <p>
169
+ <label
170
+ for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'download-monitor' ); ?></label>
171
+ <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"
172
+ name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text"
173
+ value="<?php echo esc_attr( $title ); ?>"/>
174
  </p>
175
  <p>
176
+ <label
177
+ for="<?php echo $this->get_field_id( 'posts_per_page' ); ?>"><?php _e( 'Limit:', 'download-monitor' ); ?></label>
178
+ <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'posts_per_page' ) ); ?>"
179
+ name="<?php echo esc_attr( $this->get_field_name( 'posts_per_page' ) ); ?>" type="text"
180
+ value="<?php echo esc_attr( $posts_per_page ); ?>" size="3"/>
181
  </p>
182
  <p>
183
+ <label
184
+ for="<?php echo $this->get_field_id( 'format' ); ?>"><?php _e( 'Output template:', 'download-monitor' ); ?></label>
185
+ <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'format' ) ); ?>"
186
+ name="<?php echo esc_attr( $this->get_field_name( 'format' ) ); ?>" type="text"
187
+ value="<?php echo esc_attr( $format ); ?>"
188
+ placeholder="<?php _e( 'Default template', 'download-monitor' ); ?>"/>
189
  </p>
190
  <p>
191
+ <label
192
+ for="<?php echo $this->get_field_id( 'orderby' ); ?>"><?php _e( 'Order by:', 'download-monitor' ); ?></label>
193
+ <select class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'orderby' ) ); ?>"
194
+ name="<?php echo esc_attr( $this->get_field_name( 'orderby' ) ); ?>" type="text">
195
+ <option
196
+ value="title" <?php selected( $orderby, 'title' ); ?>><?php _e( 'Title', 'download-monitor' ); ?></option>
197
+ <option
198
+ value="rand" <?php selected( $orderby, 'rand' ); ?>><?php _e( 'Random', 'download-monitor' ); ?></option>
199
+ <option
200
+ value="ID" <?php selected( $orderby, 'ID' ); ?>><?php _e( 'ID', 'download-monitor' ); ?></option>
201
+ <option
202
+ value="date" <?php selected( $orderby, 'date' ); ?>><?php _e( 'Date added', 'download-monitor' ); ?></option>
203
+ <option
204
+ value="modified" <?php selected( $orderby, 'modified' ); ?>><?php _e( 'Date modified', 'download-monitor' ); ?></option>
205
+ <option
206
+ value="download_count" <?php selected( $orderby, 'download_count' ); ?>><?php _e( 'Download count', 'download-monitor' ); ?></option>
207
  </select>
208
  </p>
209
  <p>
210
+ <label
211
+ for="<?php echo $this->get_field_id( 'order' ); ?>"><?php _e( 'Order:', 'download-monitor' ); ?></label>
212
+ <select class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'order' ) ); ?>"
213
+ name="<?php echo esc_attr( $this->get_field_name( 'order' ) ); ?>" type="text">
214
+ <option
215
+ value="ASC" <?php selected( $order, 'ASC' ); ?>><?php _e( 'ASC', 'download-monitor' ); ?></option>
216
+ <option
217
+ value="DESC" <?php selected( $order, 'DESC' ); ?>><?php _e( 'DESC', 'download-monitor' ); ?></option>
218
  </select>
219
  </p>
220
  <p>
221
+ <input id="<?php echo esc_attr( $this->get_field_id( 'featured' ) ); ?>"
222
+ name="<?php echo esc_attr( $this->get_field_name( 'featured' ) ); ?>"
223
+ type="checkbox" <?php checked( $featured, 'yes' ); ?> />
224
+ <label
225
+ for="<?php echo $this->get_field_id( 'featured' ); ?>"><?php _e( 'Show only featured downloads', 'download-monitor' ); ?></label>
226
  </p>
227
  <p>
228
+ <input id="<?php echo esc_attr( $this->get_field_id( 'members_only' ) ); ?>"
229
+ name="<?php echo esc_attr( $this->get_field_name( 'members_only' ) ); ?>"
230
+ type="checkbox" <?php checked( $members_only, 'yes' ); ?> />
231
+ <label
232
+ for="<?php echo $this->get_field_id( 'members_only' ); ?>"><?php _e( 'Show only members only downloads', 'download-monitor' ); ?></label>
233
  </p>
234
+ <?php
235
  }
236
  }
includes/widgets/class-dlm-widget-manager.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
+
7
+ class DLM_Widget_Manager {
8
+
9
+ /**
10
+ * Setup the actions
11
+ */
12
+ public function setup() {
13
+ add_action( 'widgets_init', array( $this, 'register_widgets' ) );
14
+ }
15
+
16
+ /**
17
+ * Register the widgets
18
+ */
19
+ public function register_widgets() {
20
+ register_widget( 'DLM_Widget_Downloads' );
21
+ }
22
+
23
+ }
languages/download-monitor-de_DE.mo CHANGED
Binary file
languages/download-monitor-de_DE.po CHANGED
@@ -6,14 +6,16 @@ msgstr ""
6
  "Project-Id-Version: Download Monitor\n"
7
  "Report-Msgid-Bugs-To: http://wordpress.org/tag/download-monitor\n"
8
  "POT-Creation-Date: 2014-06-28 19:28:54+00:00\n"
9
- "PO-Revision-Date: 2014-06-29 09:07+0000\n"
10
- "Last-Translator: Mike Jolley <mike.jolley@me.com>\n"
11
- "Language-Team: German (Germany) (http://www.transifex.com/projects/p/download-monitor/language/de_DE/)\n"
 
12
  "MIME-Version: 1.0\n"
13
  "Content-Type: text/plain; charset=UTF-8\n"
14
  "Content-Transfer-Encoding: 8bit\n"
15
  "Language: de_DE\n"
16
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
 
17
 
18
  #: download-monitor.php:92 includes/admin/class-dlm-admin.php:281
19
  msgid "Settings"
@@ -21,7 +23,7 @@ msgstr "Einstellungen"
21
 
22
  #: download-monitor.php:93 includes/admin/class-dlm-admin.php:284
23
  msgid "Add-ons"
24
- msgstr ""
25
 
26
  #: download-monitor.php:94
27
  msgid "Docs"
@@ -34,7 +36,7 @@ msgstr "Kategorien"
34
 
35
  #: download-monitor.php:244
36
  msgid "Download Category"
37
- msgstr "Download Kategorie"
38
 
39
  #: download-monitor.php:245
40
  msgid "Search Download Categories"
@@ -42,7 +44,7 @@ msgstr "Kategorien durchsuchen"
42
 
43
  #: download-monitor.php:246
44
  msgid "All Download Categories"
45
- msgstr "Alle Download Kategorien"
46
 
47
  #: download-monitor.php:247
48
  msgid "Parent Download Category"
@@ -71,56 +73,56 @@ msgstr "Neuer Name für Download-Kategorie"
71
  #: download-monitor.php:271 download-monitor.php:273
72
  #: includes/admin/class-dlm-admin-cpt.php:173
73
  msgid "Tags"
74
- msgstr ""
75
 
76
  #: download-monitor.php:274
77
  msgid "Download Tag"
78
- msgstr ""
79
 
80
  #: download-monitor.php:275
81
  msgid "Search Download Tags"
82
- msgstr "Download Tags durchsuchen"
83
 
84
  #: download-monitor.php:276
85
  msgid "All Download Tags"
86
- msgstr "Alle Download Tags"
87
 
88
  #: download-monitor.php:277
89
  msgid "Parent Download Tag"
90
- msgstr "Übergeordneter Download Tag"
91
 
92
  #: download-monitor.php:278
93
  msgid "Parent Download Tag:"
94
- msgstr "Übergeordneter Download Tag:"
95
 
96
  #: download-monitor.php:279
97
  msgid "Edit Download Tag"
98
- msgstr "Download Tag bearbeiten"
99
 
100
  #: download-monitor.php:280
101
  msgid "Update Download Tag"
102
- msgstr "Download Tag aktualisieren"
103
 
104
  #: download-monitor.php:281
105
  msgid "Add New Download Tag"
106
- msgstr "Download Tag hinzufügen"
107
 
108
  #: download-monitor.php:282
109
  msgid "New Download Tag Name"
110
- msgstr "Neuer Name für Download Tag"
111
 
112
  #: download-monitor.php:303
113
  msgid "All Downloads"
114
- msgstr ""
115
 
116
  #: download-monitor.php:304
117
  msgid "Downloads"
118
- msgstr ""
119
 
120
  #: download-monitor.php:305 includes/admin/class-dlm-admin-dashboard.php:69
121
  #: includes/admin/class-dlm-logging-list-table.php:123
122
  msgid "Download"
123
- msgstr ""
124
 
125
  #: download-monitor.php:306
126
  msgid "Add New"
@@ -140,7 +142,7 @@ msgstr "Download bearbeiten"
140
 
141
  #: download-monitor.php:310
142
  msgid "New Download"
143
- msgstr "Neue Download-Eintrag"
144
 
145
  #: download-monitor.php:311 download-monitor.php:312
146
  msgid "View Download"
@@ -169,7 +171,7 @@ msgstr "Hier können sie die Downloads für ihre Seite verwalten"
169
  #: includes/admin/class-dlm-addons.php:50
170
  #: includes/admin/class-dlm-admin.php:284
171
  msgid "Download Monitor Add-ons"
172
- msgstr ""
173
 
174
  #: includes/admin/class-dlm-admin-cpt.php:64
175
  msgid "Select a category"
@@ -194,7 +196,7 @@ msgstr "Sonderfeld gelöscht."
194
 
195
  #: includes/admin/class-dlm-admin-cpt.php:144
196
  msgid "Download restored to revision from %s"
197
- msgstr "Download Version von Datum %s wiederhergestellt."
198
 
199
  #: includes/admin/class-dlm-admin-cpt.php:145
200
  msgid "Download published."
@@ -214,11 +216,11 @@ msgstr "Download geplant für: <strong>%1$s</strong>."
214
 
215
  #: includes/admin/class-dlm-admin-cpt.php:149
216
  msgid "M j, Y @ G:i"
217
- msgstr ""
218
 
219
  #: includes/admin/class-dlm-admin-cpt.php:150
220
  msgid "Download draft updated."
221
- msgstr "Download Entwurf aktualisiert."
222
 
223
  #: includes/admin/class-dlm-admin-cpt.php:167
224
  msgid "Image"
@@ -232,7 +234,7 @@ msgstr "Titel"
232
  #: includes/admin/class-dlm-admin-cpt.php:169
233
  #: includes/widgets/class-dlm-widget-downloads.php:173
234
  msgid "ID"
235
- msgstr ""
236
 
237
  #: includes/admin/class-dlm-admin-cpt.php:170
238
  #: includes/admin/class-dlm-logging-list-table.php:124
@@ -243,7 +245,7 @@ msgstr "Datei"
243
  #: includes/admin/class-dlm-admin-insert.php:231
244
  #: includes/admin/html-downloadable-file-version.php:16
245
  msgid "Version"
246
- msgstr ""
247
 
248
  #: includes/admin/class-dlm-admin-cpt.php:174
249
  #: includes/admin/class-dlm-admin-dashboard.php:70
@@ -254,7 +256,7 @@ msgstr "Download-Anzahl"
254
 
255
  #: includes/admin/class-dlm-admin-cpt.php:175
256
  msgid "Featured"
257
- msgstr "Hervorgehobene Artikel"
258
 
259
  #: includes/admin/class-dlm-admin-cpt.php:176
260
  #: includes/admin/class-dlm-admin-writepanels.php:63
@@ -263,7 +265,7 @@ msgstr "Nur für Mitglieder"
263
 
264
  #: includes/admin/class-dlm-admin-cpt.php:177
265
  msgid "Redirect only"
266
- msgstr ""
267
 
268
  #: includes/admin/class-dlm-admin-cpt.php:178
269
  msgid "Date posted"
@@ -273,7 +275,7 @@ msgstr "Veröffentlichungs-Datum"
273
  #: includes/admin/class-dlm-admin-cpt.php:220
274
  #: includes/admin/class-dlm-admin-cpt.php:228
275
  msgid "Yes"
276
- msgstr ""
277
 
278
  #: includes/admin/class-dlm-admin-dashboard.php:21
279
  msgid "Popular Downloads"
@@ -325,9 +327,12 @@ msgstr "Name der Vorlage"
325
  #: includes/admin/class-dlm-admin-insert.php:199
326
  msgid ""
327
  "Leaving this blank will use the default <code>content-download.php</code> "
328
- "template file. If you enter, for example, <code>image</code>, the <code"
329
- ">content-download-image.php</code> template will be used instead."
330
- msgstr "Wenn sie dieses Feld freilassen wird die Vorlage <code>content-download.php</code> verwendet. Wenn sie zum Beispiel <code>image</code> eingeben, wird die Vorlage <code>content-download-image.php</code> verwendet."
 
 
 
331
 
332
  #: includes/admin/class-dlm-admin-insert.php:214
333
  msgid "Drop file here"
@@ -336,7 +341,7 @@ msgstr "Datei hier ablegen"
336
  #: includes/admin/class-dlm-admin-insert.php:215
337
  msgctxt "Drop file here *or* select file"
338
  msgid "or"
339
- msgstr ""
340
 
341
  #: includes/admin/class-dlm-admin-insert.php:216
342
  msgid "Select File"
@@ -348,7 +353,7 @@ msgstr "URL selbst eintragen"
348
 
349
  #: includes/admin/class-dlm-admin-insert.php:223
350
  msgid "Download URL"
351
- msgstr "URL herunterladen"
352
 
353
  #: includes/admin/class-dlm-admin-insert.php:224
354
  msgid "Required URL"
@@ -372,7 +377,7 @@ msgstr "Download speichern"
372
 
373
  #: includes/admin/class-dlm-admin-insert.php:291
374
  msgid "Allowed Files"
375
- msgstr ""
376
 
377
  #: includes/admin/class-dlm-admin-insert.php:341
378
  msgid "Please wait..."
@@ -389,55 +394,61 @@ msgstr "Keine Dateien gefunden"
389
 
390
  #: includes/admin/class-dlm-admin-writepanels.php:29
391
  msgid "Download Options"
392
- msgstr "Download Optionen"
393
 
394
  #: includes/admin/class-dlm-admin-writepanels.php:30
395
  msgid "Downloadable Files/Versions"
396
- msgstr ""
397
 
398
  #: includes/admin/class-dlm-admin-writepanels.php:35
399
  msgid "Short Description"
400
- msgstr "Kurze Beschreibung"
401
 
402
  #: includes/admin/class-dlm-admin-writepanels.php:57
403
  msgid "Featured download"
404
- msgstr "Hervorgehobene Download"
405
 
406
  #: includes/admin/class-dlm-admin-writepanels.php:58
407
  msgid "Mark this download as featured. Used by shortcodes and widgets."
408
- msgstr "Download als hervorgehoben markieren. Die Hervorhebung wird in shortcodes und widgets verwendet."
 
 
409
 
410
  #: includes/admin/class-dlm-admin-writepanels.php:64
411
  msgid ""
412
  "Only logged in users will be able to access the file via a download link if "
413
  "this is enabled."
414
- msgstr "Nur angemeldete Benutzer haben Zugriff auf die Datei, wenn dies ausgewählt ist."
 
 
415
 
416
  #: includes/admin/class-dlm-admin-writepanels.php:69
417
  msgid "Redirect to file"
418
- msgstr ""
419
 
420
  #: includes/admin/class-dlm-admin-writepanels.php:70
421
  msgid ""
422
- "Don't force download. If the <code>dlm_upload</code> folder is protected you"
423
- " may need to move your file."
424
  msgstr ""
 
 
425
 
426
  #: includes/admin/class-dlm-admin-writepanels.php:94
427
  msgid "Add file"
428
- msgstr ""
429
 
430
  #: includes/admin/class-dlm-admin-writepanels.php:95
431
  msgid "Close all"
432
- msgstr "Alle schließen"
433
 
434
  #: includes/admin/class-dlm-admin-writepanels.php:95
435
  msgid "Expand all"
436
- msgstr "Alles expandieren"
437
 
438
  #: includes/admin/class-dlm-admin-writepanels.php:228
439
  msgid "Are you sure you want to delete this file?"
440
- msgstr "Sind sie sicher dass sie dides Datei löschen möchten?"
441
 
442
  #: includes/admin/class-dlm-admin.php:95
443
  msgid "General"
@@ -451,77 +462,88 @@ msgstr "Standard-Vorlage"
451
  msgid ""
452
  "Choose which template is used for <code>[download]</code> shortcodes by "
453
  "default (this can be overridden by the <code>format</code> argument)."
454
- msgstr "Vorlage auswählen für <code>[download]</code> shortcodes (kann mit dem <code>format</code> Argument überschrieben werden)."
 
 
455
 
456
  #: includes/admin/class-dlm-admin.php:104
457
  msgid "Default - Title and count"
458
- msgstr ""
459
 
460
  #: includes/admin/class-dlm-admin.php:105
461
  msgid "Button - CSS styled button showing title and count"
462
- msgstr ""
463
 
464
  #: includes/admin/class-dlm-admin.php:106
465
  msgid "Box - Box showing thumbnail, title, count, filename and filesize."
466
  msgstr ""
 
 
467
 
468
  #: includes/admin/class-dlm-admin.php:107
469
  msgid "Filename - Filename and download count"
470
- msgstr ""
471
 
472
  #: includes/admin/class-dlm-admin.php:108
473
  msgid "Title - Shows download title only"
474
- msgstr ""
475
 
476
  #: includes/admin/class-dlm-admin.php:109
477
  msgid "Version list - Lists all download versions in an unordered list"
478
  msgstr ""
 
479
 
480
  #: includes/admin/class-dlm-admin.php:110
481
  msgid "Custom template"
482
- msgstr ""
483
 
484
  #: includes/admin/class-dlm-admin.php:116
485
  msgid "Custom Template"
486
- msgstr ""
487
 
488
  #: includes/admin/class-dlm-admin.php:117
489
  msgid ""
490
  "Leaving this blank will use the default <code>content-download.php</code> "
491
- "template file. If you enter, for example, <code>image</code>, the <code"
492
- ">content-download-image.php</code> template will be used instead. You can "
493
- "add custom templates inside your theme folder."
494
  msgstr ""
 
 
 
 
495
 
496
  #: includes/admin/class-dlm-admin.php:122
497
  msgid "MD5 hashes"
498
- msgstr ""
499
 
500
  #: includes/admin/class-dlm-admin.php:123
501
  msgid "Generate MD5 hash for uploaded files"
502
- msgstr ""
503
 
504
  #: includes/admin/class-dlm-admin.php:130
505
  msgid "SHA1 hashes"
506
- msgstr ""
507
 
508
  #: includes/admin/class-dlm-admin.php:131
509
  msgid "Generate SHA1 hash for uploaded files"
510
- msgstr ""
511
 
512
  #: includes/admin/class-dlm-admin.php:138
513
  msgid "CRC32B hashes"
514
- msgstr ""
515
 
516
  #: includes/admin/class-dlm-admin.php:139
517
  msgid "Generate CRC32B hash for uploaded files"
518
- msgstr ""
519
 
520
  #: includes/admin/class-dlm-admin.php:140
521
  msgid ""
522
  "Hashes can optionally be output via shortcodes, but may cause performance "
523
  "issues with large files."
524
  msgstr ""
 
 
525
 
526
  #: includes/admin/class-dlm-admin.php:146
527
  msgid "Endpoint"
@@ -533,72 +555,81 @@ msgstr "Download"
533
 
534
  #: includes/admin/class-dlm-admin.php:152
535
  msgid "Download Endpoint"
536
- msgstr "Download Endpunkt"
537
 
538
  #: includes/admin/class-dlm-admin.php:153
539
  msgid ""
540
- "Define what endpoint should be used for download links. By default this will"
541
- " be <code>%s</code>."
542
- msgstr "Bestimme den Endpunkt für Download-Links. Standardmäßig: <code>%s</code>."
 
543
 
544
  #: includes/admin/class-dlm-admin.php:158
545
  msgid "Endpoint Value"
546
- msgstr "Endpunkt Werte"
547
 
548
  #: includes/admin/class-dlm-admin.php:159
549
  msgid ""
550
  "Define what unique value should be used on the end of your endpoint to "
551
- "identify the downloadable file. e.g. ID would give a link like "
 
 
 
 
552
  "<code>%s</code>"
553
- msgstr "Bestimme welche Werte am Ende ihres Endpunkts stehen sollen zur Identifikation ihrer Download-Datei. Zum Beispiel: ID ergibt den folgenden Link <code>%s</code>"
554
 
555
  #: includes/admin/class-dlm-admin.php:162
556
  #: includes/admin/class-dlm-admin.php:484
557
  msgid "Download ID"
558
- msgstr ""
559
 
560
  #: includes/admin/class-dlm-admin.php:163
561
  msgid "Download slug"
562
- msgstr "Download Slug"
563
 
564
  #: includes/admin/class-dlm-admin.php:169
565
  msgid "X-Accel-Redirect / X-Sendfile"
566
- msgstr ""
567
 
568
  #: includes/admin/class-dlm-admin.php:170
569
  #: includes/admin/class-dlm-admin.php:178
570
  #: includes/admin/class-dlm-admin.php:189
571
  msgid "Enable"
572
- msgstr "Anschalten"
573
 
574
  #: includes/admin/class-dlm-admin.php:171
575
  msgid ""
576
- "If supported, <code>X-Accel-Redirect</code> / <code>X-Sendfile</code> can be"
577
- " used to serve downloads instead of PHP (server requires "
578
- "<code>mod_xsendfile</code>)."
579
- msgstr "Falls unterstützt, können <code>X-Accel-Redirect</code> / <code>X-Sendfile</code> genutzt werden, anstelle von PHP (Server braucht <code>mod_xsendfile</code>)."
 
 
 
580
 
581
  #: includes/admin/class-dlm-admin.php:177
582
  msgid "Prevent hotlinking"
583
- msgstr ""
584
 
585
  #: includes/admin/class-dlm-admin.php:179
586
  msgid ""
587
  "If enabled, the download handler will check the PHP referer to see if it "
588
  "originated from your site and if not, redirect them to the homepage."
589
  msgstr ""
 
 
590
 
591
  #: includes/admin/class-dlm-admin.php:185
592
  msgid "Logging"
593
- msgstr "Log Aufzeichung"
594
 
595
  #: includes/admin/class-dlm-admin.php:191
596
  msgid "Download Log"
597
- msgstr ""
598
 
599
  #: includes/admin/class-dlm-admin.php:192
600
  msgid "Log download attempts, IP addresses and more."
601
- msgstr "Download Versuche, IP Adressen und anderes aufzeichnen."
602
 
603
  #: includes/admin/class-dlm-admin.php:198
604
  msgid "Blacklist IPs"
@@ -608,19 +639,21 @@ msgstr "IPs sperren (Blacklist)"
608
  msgid ""
609
  "List IP Addresses to blacklist, 1 per line. Use <code>*</code> for a "
610
  "wildcard."
611
- msgstr "IP Adressen auf Blackliste setzen, 1 pro Linie. Code <code>*</code> als Wildcard."
 
 
612
 
613
  #: includes/admin/class-dlm-admin.php:206
614
  msgid "Blacklist user agents"
615
- msgstr "User Agents sperren"
616
 
617
  #: includes/admin/class-dlm-admin.php:207
618
  msgid "List browser user agents to blacklist, 1 per line."
619
- msgstr "User Agents für Sperrung auflisten, einer pro Linie."
620
 
621
  #: includes/admin/class-dlm-admin.php:279
622
  msgid "Logs"
623
- msgstr ""
624
 
625
  #: includes/admin/class-dlm-admin.php:323
626
  msgid "Settings successfully saved"
@@ -640,7 +673,7 @@ msgstr "CSV exportieren"
640
 
641
  #: includes/admin/class-dlm-admin.php:434
642
  msgid "Delete Logs"
643
- msgstr ""
644
 
645
  #: includes/admin/class-dlm-admin.php:485
646
  msgid "Version ID"
@@ -648,28 +681,28 @@ msgstr "Versions-ID"
648
 
649
  #: includes/admin/class-dlm-admin.php:486
650
  msgid "Filename"
651
- msgstr ""
652
 
653
  #: includes/admin/class-dlm-admin.php:487
654
  msgid "User ID"
655
- msgstr ""
656
 
657
  #: includes/admin/class-dlm-admin.php:488
658
  msgid "User Login"
659
- msgstr ""
660
 
661
  #: includes/admin/class-dlm-admin.php:489
662
  msgid "User Email"
663
- msgstr ""
664
 
665
  #: includes/admin/class-dlm-admin.php:490
666
  msgid "User IP"
667
- msgstr ""
668
 
669
  #: includes/admin/class-dlm-admin.php:491
670
  #: includes/admin/class-dlm-logging-list-table.php:127
671
  msgid "User Agent"
672
- msgstr ""
673
 
674
  #: includes/admin/class-dlm-admin.php:492
675
  #: includes/admin/class-dlm-logging-list-table.php:128
@@ -678,7 +711,7 @@ msgstr "Datum"
678
 
679
  #: includes/admin/class-dlm-admin.php:493
680
  msgid "Status"
681
- msgstr ""
682
 
683
  #: includes/admin/class-dlm-logging-list-table.php:50
684
  msgid "Download Complete"
@@ -694,7 +727,7 @@ msgstr "Download #%d (existiert nicht mehr)"
694
 
695
  #: includes/admin/class-dlm-logging-list-table.php:72
696
  msgid "v%s"
697
- msgstr ""
698
 
699
  #: includes/admin/class-dlm-logging-list-table.php:92
700
  msgid "Non-member"
@@ -710,51 +743,51 @@ msgstr "IP Addresse"
710
 
711
  #: includes/admin/class-dlm-logging-list-table.php:142
712
  msgid "Any status"
713
- msgstr ""
714
 
715
  #: includes/admin/class-dlm-logging-list-table.php:143
716
  msgid "Failed"
717
- msgstr ""
718
 
719
  #: includes/admin/class-dlm-logging-list-table.php:144
720
  msgid "Redirected"
721
- msgstr ""
722
 
723
  #: includes/admin/class-dlm-logging-list-table.php:145
724
  msgid "Completed"
725
- msgstr ""
726
 
727
  #: includes/admin/class-dlm-logging-list-table.php:164
728
  msgid "Show all dates"
729
- msgstr ""
730
 
731
  #: includes/admin/class-dlm-logging-list-table.php:177
732
  msgid "%1$s %2$d"
733
- msgstr ""
734
 
735
  #: includes/admin/class-dlm-logging-list-table.php:185
736
  msgid "25 per page"
737
- msgstr ""
738
 
739
  #: includes/admin/class-dlm-logging-list-table.php:186
740
  msgid "50 per page"
741
- msgstr ""
742
 
743
  #: includes/admin/class-dlm-logging-list-table.php:187
744
  msgid "100 per page"
745
- msgstr ""
746
 
747
  #: includes/admin/class-dlm-logging-list-table.php:188
748
  msgid "200 per page"
749
- msgstr ""
750
 
751
  #: includes/admin/class-dlm-logging-list-table.php:189
752
  msgid "Show All"
753
- msgstr ""
754
 
755
  #: includes/admin/class-dlm-logging-list-table.php:193
756
  msgid "Filter"
757
- msgstr ""
758
 
759
  #: includes/admin/html-downloadable-file-version.php:3
760
  msgid "Remove"
@@ -766,7 +799,7 @@ msgstr "Zum Umschalten klicken"
766
 
767
  #: includes/admin/html-downloadable-file-version.php:5
768
  msgid "Version <span class=\"version\">%s</span> (%s)"
769
- msgstr ""
770
 
771
  #: includes/admin/html-downloadable-file-version.php:5
772
  #: includes/admin/html-downloadable-file-version.php:17
@@ -776,30 +809,32 @@ msgstr "nicht verfügbar"
776
  #: includes/admin/html-downloadable-file-version.php:5
777
  msgid "Downloaded %s time"
778
  msgid_plural "Downloaded %s times"
779
- msgstr[0] "%s-mal heruntergeladen"
780
  msgstr[1] "%s-mal heruntergeladen"
781
 
782
  #: includes/admin/html-downloadable-file-version.php:21
783
  msgid "File URL(s)"
784
- msgstr "Datei URL(s)"
785
 
786
  #: includes/admin/html-downloadable-file-version.php:22
787
  msgid ""
788
  "Enter one file path/URL per line - multiple files will be used as mirrors "
789
  "(chosen at random)."
790
- msgstr "Einen Pfad)Url pro Zeile - mehrere werden als file mirrors genutzt (zufällige Auswahl)."
 
 
791
 
792
  #: includes/admin/html-downloadable-file-version.php:27
793
  msgid "Upload file"
794
- msgstr "Datei auf den Server laden"
795
 
796
  #: includes/admin/html-downloadable-file-version.php:29
797
  msgid "Choose a file"
798
- msgstr ""
799
 
800
  #: includes/admin/html-downloadable-file-version.php:30
801
  msgid "Insert file URL"
802
- msgstr ""
803
 
804
  #: includes/admin/html-downloadable-file-version.php:34
805
  msgid "Browse for file"
@@ -811,15 +846,15 @@ msgstr "Datei-Erstellungsdatum"
811
 
812
  #: includes/admin/html-downloadable-file-version.php:59
813
  msgid "h"
814
- msgstr ""
815
 
816
  #: includes/admin/html-downloadable-file-version.php:59
817
  msgid "m"
818
- msgstr ""
819
 
820
  #: includes/class-dlm-download-handler.php:140
821
  msgid "Password Required"
822
- msgstr ""
823
 
824
  #: includes/class-dlm-download-handler.php:150
825
  msgid "Download does not exist."
@@ -848,7 +883,9 @@ msgstr "Dateipfad nicht definiert."
848
 
849
  #: includes/class-dlm-download-handler.php:194
850
  msgid "You do not have permission to access this download."
851
- msgstr "Sie besitzen nicht die nötige Berechtigung, um auf diese Download-Datei zuzugreifen."
 
 
852
 
853
  #: includes/class-dlm-download-handler.php:212
854
  #: includes/class-dlm-download-handler.php:228
@@ -859,7 +896,7 @@ msgstr "Weitergeleitet zu Datei"
859
 
860
  #: includes/class-dlm-download-handler.php:281
861
  msgid "Redirected to remote file."
862
- msgstr "Weitergeleitet zu Datei auf anderem Server"
863
 
864
  #: includes/class-dlm-download-handler.php:286
865
  msgid "File not found"
@@ -871,7 +908,7 @@ msgstr "Datei nicht gefunden."
871
 
872
  #: includes/class-dlm-shortcodes.php:93 includes/class-dlm-shortcodes.php:125
873
  msgid "Download not found"
874
- msgstr "Download Eintrag nicht gefunden."
875
 
876
  #: includes/widgets/class-dlm-widget-downloads.php:27
877
  msgid "Display a list of your downloads."
@@ -892,7 +929,7 @@ msgstr "Titel:"
892
 
893
  #: includes/widgets/class-dlm-widget-downloads.php:161
894
  msgid "Limit:"
895
- msgstr ""
896
 
897
  #: includes/widgets/class-dlm-widget-downloads.php:165
898
  msgid "Output template:"
@@ -936,7 +973,7 @@ msgstr "Nur hervorgehobene Downloads anzeigen"
936
 
937
  #: includes/widgets/class-dlm-widget-downloads.php:192
938
  msgid "Show only members only downloads"
939
- msgstr "Downloads nur Mitgliedern anzeigen"
940
 
941
  #: templates/content-download-box.php:12
942
  #: templates/content-download-filename.php:9 templates/content-download.php:9
@@ -949,7 +986,7 @@ msgstr[1] "%d Downloads"
949
  #: templates/content-download-filename.php:8
950
  #: templates/content-download-title.php:8 templates/content-download.php:8
951
  msgid "Version %s"
952
- msgstr ""
953
 
954
  #: templates/content-download-box.php:21
955
  msgid "Download File"
@@ -957,7 +994,7 @@ msgstr "Datei herunterladen"
957
 
958
  #: templates/content-download-button.php:9
959
  msgid "Download &ldquo;%s&rdquo;"
960
- msgstr ""
961
 
962
  #: templates/content-download-button.php:10
963
  #: templates/content-download-version-list.php:17
@@ -968,11 +1005,11 @@ msgstr[1] "%d-mal heruntergeladen"
968
 
969
  #. Plugin Name of the plugin/theme
970
  msgid "Download Monitor"
971
- msgstr ""
972
 
973
  #. Plugin URI of the plugin/theme
974
  msgid "http://mikejolley.com/projects/download-monitor/"
975
- msgstr ""
976
 
977
  #. Description of the plugin/theme
978
  msgid ""
@@ -980,11 +1017,14 @@ msgid ""
980
  "outputting download links and file information on your WordPress powered "
981
  "site."
982
  msgstr ""
 
 
 
983
 
984
  #. Author of the plugin/theme
985
  msgid "Mike Jolley"
986
- msgstr ""
987
 
988
  #. Author URI of the plugin/theme
989
  msgid "http://mikejolley.com"
990
- msgstr ""
6
  "Project-Id-Version: Download Monitor\n"
7
  "Report-Msgid-Bugs-To: http://wordpress.org/tag/download-monitor\n"
8
  "POT-Creation-Date: 2014-06-28 19:28:54+00:00\n"
9
+ "PO-Revision-Date: 2014-09-24 20:11+0100\n"
10
+ "Last-Translator: Sebastian Herrmann <sebastian@herrherrmann.net>\n"
11
+ "Language-Team: German (Germany) (http://www.transifex.com/projects/p/"
12
+ "download-monitor/language/de_DE/)\n"
13
  "MIME-Version: 1.0\n"
14
  "Content-Type: text/plain; charset=UTF-8\n"
15
  "Content-Transfer-Encoding: 8bit\n"
16
  "Language: de_DE\n"
17
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
18
+ "X-Generator: Poedit 1.6.9\n"
19
 
20
  #: download-monitor.php:92 includes/admin/class-dlm-admin.php:281
21
  msgid "Settings"
23
 
24
  #: download-monitor.php:93 includes/admin/class-dlm-admin.php:284
25
  msgid "Add-ons"
26
+ msgstr "Add-ons"
27
 
28
  #: download-monitor.php:94
29
  msgid "Docs"
36
 
37
  #: download-monitor.php:244
38
  msgid "Download Category"
39
+ msgstr "Download-Kategorie"
40
 
41
  #: download-monitor.php:245
42
  msgid "Search Download Categories"
44
 
45
  #: download-monitor.php:246
46
  msgid "All Download Categories"
47
+ msgstr "Alle Download-Kategorien"
48
 
49
  #: download-monitor.php:247
50
  msgid "Parent Download Category"
73
  #: download-monitor.php:271 download-monitor.php:273
74
  #: includes/admin/class-dlm-admin-cpt.php:173
75
  msgid "Tags"
76
+ msgstr "Tags"
77
 
78
  #: download-monitor.php:274
79
  msgid "Download Tag"
80
+ msgstr "Download-Tag"
81
 
82
  #: download-monitor.php:275
83
  msgid "Search Download Tags"
84
+ msgstr "Download-Tags durchsuchen"
85
 
86
  #: download-monitor.php:276
87
  msgid "All Download Tags"
88
+ msgstr "Alle Download-Tags"
89
 
90
  #: download-monitor.php:277
91
  msgid "Parent Download Tag"
92
+ msgstr "Übergeordneter Download-Tag"
93
 
94
  #: download-monitor.php:278
95
  msgid "Parent Download Tag:"
96
+ msgstr "Übergeordneter Download-Tag:"
97
 
98
  #: download-monitor.php:279
99
  msgid "Edit Download Tag"
100
+ msgstr "Download-Tag bearbeiten"
101
 
102
  #: download-monitor.php:280
103
  msgid "Update Download Tag"
104
+ msgstr "Download-Tag aktualisieren"
105
 
106
  #: download-monitor.php:281
107
  msgid "Add New Download Tag"
108
+ msgstr "Download-Tag hinzufügen"
109
 
110
  #: download-monitor.php:282
111
  msgid "New Download Tag Name"
112
+ msgstr "Neuer Name für Download-Tag"
113
 
114
  #: download-monitor.php:303
115
  msgid "All Downloads"
116
+ msgstr "Alle Downloads"
117
 
118
  #: download-monitor.php:304
119
  msgid "Downloads"
120
+ msgstr "Downloads"
121
 
122
  #: download-monitor.php:305 includes/admin/class-dlm-admin-dashboard.php:69
123
  #: includes/admin/class-dlm-logging-list-table.php:123
124
  msgid "Download"
125
+ msgstr "Download"
126
 
127
  #: download-monitor.php:306
128
  msgid "Add New"
142
 
143
  #: download-monitor.php:310
144
  msgid "New Download"
145
+ msgstr "Neuer Download"
146
 
147
  #: download-monitor.php:311 download-monitor.php:312
148
  msgid "View Download"
171
  #: includes/admin/class-dlm-addons.php:50
172
  #: includes/admin/class-dlm-admin.php:284
173
  msgid "Download Monitor Add-ons"
174
+ msgstr "Download Monitor Add-ons"
175
 
176
  #: includes/admin/class-dlm-admin-cpt.php:64
177
  msgid "Select a category"
196
 
197
  #: includes/admin/class-dlm-admin-cpt.php:144
198
  msgid "Download restored to revision from %s"
199
+ msgstr "Download-Version von Datum %s wiederhergestellt."
200
 
201
  #: includes/admin/class-dlm-admin-cpt.php:145
202
  msgid "Download published."
216
 
217
  #: includes/admin/class-dlm-admin-cpt.php:149
218
  msgid "M j, Y @ G:i"
219
+ msgstr "j.m.Y @ G:i"
220
 
221
  #: includes/admin/class-dlm-admin-cpt.php:150
222
  msgid "Download draft updated."
223
+ msgstr "Download-Entwurf aktualisiert."
224
 
225
  #: includes/admin/class-dlm-admin-cpt.php:167
226
  msgid "Image"
234
  #: includes/admin/class-dlm-admin-cpt.php:169
235
  #: includes/widgets/class-dlm-widget-downloads.php:173
236
  msgid "ID"
237
+ msgstr "ID"
238
 
239
  #: includes/admin/class-dlm-admin-cpt.php:170
240
  #: includes/admin/class-dlm-logging-list-table.php:124
245
  #: includes/admin/class-dlm-admin-insert.php:231
246
  #: includes/admin/html-downloadable-file-version.php:16
247
  msgid "Version"
248
+ msgstr "Version"
249
 
250
  #: includes/admin/class-dlm-admin-cpt.php:174
251
  #: includes/admin/class-dlm-admin-dashboard.php:70
256
 
257
  #: includes/admin/class-dlm-admin-cpt.php:175
258
  msgid "Featured"
259
+ msgstr "Hervorgehoben"
260
 
261
  #: includes/admin/class-dlm-admin-cpt.php:176
262
  #: includes/admin/class-dlm-admin-writepanels.php:63
265
 
266
  #: includes/admin/class-dlm-admin-cpt.php:177
267
  msgid "Redirect only"
268
+ msgstr "Nur weiterleiten"
269
 
270
  #: includes/admin/class-dlm-admin-cpt.php:178
271
  msgid "Date posted"
275
  #: includes/admin/class-dlm-admin-cpt.php:220
276
  #: includes/admin/class-dlm-admin-cpt.php:228
277
  msgid "Yes"
278
+ msgstr "Ja"
279
 
280
  #: includes/admin/class-dlm-admin-dashboard.php:21
281
  msgid "Popular Downloads"
327
  #: includes/admin/class-dlm-admin-insert.php:199
328
  msgid ""
329
  "Leaving this blank will use the default <code>content-download.php</code> "
330
+ "template file. If you enter, for example, <code>image</code>, the "
331
+ "<code>content-download-image.php</code> template will be used instead."
332
+ msgstr ""
333
+ "Wenn Sie dieses Feld freilassen, wird die Vorlage <code>content-download."
334
+ "php</code> verwendet. Wenn Sie zum Beispiel <code>image</code> eingeben, "
335
+ "wird die Vorlage <code>content-download-image.php</code> verwendet."
336
 
337
  #: includes/admin/class-dlm-admin-insert.php:214
338
  msgid "Drop file here"
341
  #: includes/admin/class-dlm-admin-insert.php:215
342
  msgctxt "Drop file here *or* select file"
343
  msgid "or"
344
+ msgstr "oder"
345
 
346
  #: includes/admin/class-dlm-admin-insert.php:216
347
  msgid "Select File"
353
 
354
  #: includes/admin/class-dlm-admin-insert.php:223
355
  msgid "Download URL"
356
+ msgstr "Download-URL"
357
 
358
  #: includes/admin/class-dlm-admin-insert.php:224
359
  msgid "Required URL"
377
 
378
  #: includes/admin/class-dlm-admin-insert.php:291
379
  msgid "Allowed Files"
380
+ msgstr "Erlaubte Dateitypen"
381
 
382
  #: includes/admin/class-dlm-admin-insert.php:341
383
  msgid "Please wait..."
394
 
395
  #: includes/admin/class-dlm-admin-writepanels.php:29
396
  msgid "Download Options"
397
+ msgstr "Download-Optionen"
398
 
399
  #: includes/admin/class-dlm-admin-writepanels.php:30
400
  msgid "Downloadable Files/Versions"
401
+ msgstr "Dateien/Versionen"
402
 
403
  #: includes/admin/class-dlm-admin-writepanels.php:35
404
  msgid "Short Description"
405
+ msgstr "Kurzbeschreibung"
406
 
407
  #: includes/admin/class-dlm-admin-writepanels.php:57
408
  msgid "Featured download"
409
+ msgstr "Hervorgehobener Download"
410
 
411
  #: includes/admin/class-dlm-admin-writepanels.php:58
412
  msgid "Mark this download as featured. Used by shortcodes and widgets."
413
+ msgstr ""
414
+ "Download als hervorgehoben markieren. Die Hervorhebung wird in shortcodes "
415
+ "und widgets verwendet."
416
 
417
  #: includes/admin/class-dlm-admin-writepanels.php:64
418
  msgid ""
419
  "Only logged in users will be able to access the file via a download link if "
420
  "this is enabled."
421
+ msgstr ""
422
+ "Nur angemeldete Benutzer haben Zugriff auf die Datei, wenn dies ausgewählt "
423
+ "ist."
424
 
425
  #: includes/admin/class-dlm-admin-writepanels.php:69
426
  msgid "Redirect to file"
427
+ msgstr "Zur Datei weiterleiten"
428
 
429
  #: includes/admin/class-dlm-admin-writepanels.php:70
430
  msgid ""
431
+ "Don't force download. If the <code>dlm_upload</code> folder is protected you "
432
+ "may need to move your file."
433
  msgstr ""
434
+ "Download nicht erzwingen. Falls das Verzeichnis <code>dlm_upload</code> "
435
+ "geschützt ist, muss die Datei ggf. verschoben werden."
436
 
437
  #: includes/admin/class-dlm-admin-writepanels.php:94
438
  msgid "Add file"
439
+ msgstr "Download hinzufügen"
440
 
441
  #: includes/admin/class-dlm-admin-writepanels.php:95
442
  msgid "Close all"
443
+ msgstr "Alle minimieren"
444
 
445
  #: includes/admin/class-dlm-admin-writepanels.php:95
446
  msgid "Expand all"
447
+ msgstr "Alle expandieren"
448
 
449
  #: includes/admin/class-dlm-admin-writepanels.php:228
450
  msgid "Are you sure you want to delete this file?"
451
+ msgstr "Sind Sie sicher, dass Sie diese Datei löschen möchten?"
452
 
453
  #: includes/admin/class-dlm-admin.php:95
454
  msgid "General"
462
  msgid ""
463
  "Choose which template is used for <code>[download]</code> shortcodes by "
464
  "default (this can be overridden by the <code>format</code> argument)."
465
+ msgstr ""
466
+ "Standard-Vorlage für <code>[download]</code> Shortcodes auswählen (kann mit "
467
+ "dem <code>format</code> Parameter überschrieben werden)."
468
 
469
  #: includes/admin/class-dlm-admin.php:104
470
  msgid "Default - Title and count"
471
+ msgstr "Default - Titel und Download-Anzahl."
472
 
473
  #: includes/admin/class-dlm-admin.php:105
474
  msgid "Button - CSS styled button showing title and count"
475
+ msgstr "Button - CSS-Button mit Titel und Download-Anzahl."
476
 
477
  #: includes/admin/class-dlm-admin.php:106
478
  msgid "Box - Box showing thumbnail, title, count, filename and filesize."
479
  msgstr ""
480
+ "Box - Eine Box mit Vorschaubild, Titel, Download-Anzahl, Dateiname und -"
481
+ "größe."
482
 
483
  #: includes/admin/class-dlm-admin.php:107
484
  msgid "Filename - Filename and download count"
485
+ msgstr "Filename - Dateiname und Download-Anzahl."
486
 
487
  #: includes/admin/class-dlm-admin.php:108
488
  msgid "Title - Shows download title only"
489
+ msgstr "Title - Zeigt nur den Titel des Downloads."
490
 
491
  #: includes/admin/class-dlm-admin.php:109
492
  msgid "Version list - Lists all download versions in an unordered list"
493
  msgstr ""
494
+ "Version list - Zeigt alle Download-Versionen in einer ungeordneten Liste."
495
 
496
  #: includes/admin/class-dlm-admin.php:110
497
  msgid "Custom template"
498
+ msgstr "Eigene Vorlage"
499
 
500
  #: includes/admin/class-dlm-admin.php:116
501
  msgid "Custom Template"
502
+ msgstr "Eigene Vorlage"
503
 
504
  #: includes/admin/class-dlm-admin.php:117
505
  msgid ""
506
  "Leaving this blank will use the default <code>content-download.php</code> "
507
+ "template file. If you enter, for example, <code>image</code>, the "
508
+ "<code>content-download-image.php</code> template will be used instead. You "
509
+ "can add custom templates inside your theme folder."
510
  msgstr ""
511
+ "Wenn Sie dieses Feld freilassen, wird die Vorlage <code>content-download."
512
+ "php</code> verwendet. Wenn Sie zum Beispiel <code>image</code> eingeben, "
513
+ "wird die Vorlage <code>content-download-image.php</code> verwendet. Eigene "
514
+ "Vorlagen können im Theme-Verzeichnis abgelegt werden."
515
 
516
  #: includes/admin/class-dlm-admin.php:122
517
  msgid "MD5 hashes"
518
+ msgstr "MD5-Hashwerte"
519
 
520
  #: includes/admin/class-dlm-admin.php:123
521
  msgid "Generate MD5 hash for uploaded files"
522
+ msgstr "MD5-Hash für hochgeladene Dateien erstellen"
523
 
524
  #: includes/admin/class-dlm-admin.php:130
525
  msgid "SHA1 hashes"
526
+ msgstr "SHA1-Hashwerte"
527
 
528
  #: includes/admin/class-dlm-admin.php:131
529
  msgid "Generate SHA1 hash for uploaded files"
530
+ msgstr "SHA1-Hash für hochgeladene Dateien erstellen"
531
 
532
  #: includes/admin/class-dlm-admin.php:138
533
  msgid "CRC32B hashes"
534
+ msgstr "CRC32B-Hashwerte"
535
 
536
  #: includes/admin/class-dlm-admin.php:139
537
  msgid "Generate CRC32B hash for uploaded files"
538
+ msgstr "CRC32B-Hash für hochgeladene Dateien erstellen"
539
 
540
  #: includes/admin/class-dlm-admin.php:140
541
  msgid ""
542
  "Hashes can optionally be output via shortcodes, but may cause performance "
543
  "issues with large files."
544
  msgstr ""
545
+ "Hashwerte können auch über Shortcodes ausgegeben werden, dies kann bei "
546
+ "großen Dateien jedoch zu Performanceproblemen führen."
547
 
548
  #: includes/admin/class-dlm-admin.php:146
549
  msgid "Endpoint"
555
 
556
  #: includes/admin/class-dlm-admin.php:152
557
  msgid "Download Endpoint"
558
+ msgstr "Download-Endpunkt"
559
 
560
  #: includes/admin/class-dlm-admin.php:153
561
  msgid ""
562
+ "Define what endpoint should be used for download links. By default this will "
563
+ "be <code>%s</code>."
564
+ msgstr ""
565
+ "Bestimme den Endpunkt für Download-Links. Standardmäßig: <code>%s</code>."
566
 
567
  #: includes/admin/class-dlm-admin.php:158
568
  msgid "Endpoint Value"
569
+ msgstr "Endpunkt-Wert"
570
 
571
  #: includes/admin/class-dlm-admin.php:159
572
  msgid ""
573
  "Define what unique value should be used on the end of your endpoint to "
574
+ "identify the downloadable file. e.g. ID would give a link like <code>%s</"
575
+ "code>"
576
+ msgstr ""
577
+ "Bestimme, welche Werte am Ende ihres Endpunkts zur Identifikation ihrer "
578
+ "Download-Datei stehen sollen. Zum Beispiel: ID ergibt den folgenden Link "
579
  "<code>%s</code>"
 
580
 
581
  #: includes/admin/class-dlm-admin.php:162
582
  #: includes/admin/class-dlm-admin.php:484
583
  msgid "Download ID"
584
+ msgstr "Download-ID"
585
 
586
  #: includes/admin/class-dlm-admin.php:163
587
  msgid "Download slug"
588
+ msgstr "Download-Slug"
589
 
590
  #: includes/admin/class-dlm-admin.php:169
591
  msgid "X-Accel-Redirect / X-Sendfile"
592
+ msgstr "X-Accel-Redirect / X-Sendfile"
593
 
594
  #: includes/admin/class-dlm-admin.php:170
595
  #: includes/admin/class-dlm-admin.php:178
596
  #: includes/admin/class-dlm-admin.php:189
597
  msgid "Enable"
598
+ msgstr "Aktivieren"
599
 
600
  #: includes/admin/class-dlm-admin.php:171
601
  msgid ""
602
+ "If supported, <code>X-Accel-Redirect</code> / <code>X-Sendfile</code> can be "
603
+ "used to serve downloads instead of PHP (server requires <code>mod_xsendfile</"
604
+ "code>)."
605
+ msgstr ""
606
+ "Falls unterstützt, können <code>X-Accel-Redirect</code> / <code>X-Sendfile</"
607
+ "code> genutzt werden, anstelle von PHP (Server benötigt <code>mod_xsendfile</"
608
+ "code>)."
609
 
610
  #: includes/admin/class-dlm-admin.php:177
611
  msgid "Prevent hotlinking"
612
+ msgstr "Querverweise verhindern"
613
 
614
  #: includes/admin/class-dlm-admin.php:179
615
  msgid ""
616
  "If enabled, the download handler will check the PHP referer to see if it "
617
  "originated from your site and if not, redirect them to the homepage."
618
  msgstr ""
619
+ "Wenn dies aktiviert ist, leitet der Download-Handler alle Nutzeranfragen von "
620
+ "externen Seiten auf die Startseite um."
621
 
622
  #: includes/admin/class-dlm-admin.php:185
623
  msgid "Logging"
624
+ msgstr "Log-Aufzeichung"
625
 
626
  #: includes/admin/class-dlm-admin.php:191
627
  msgid "Download Log"
628
+ msgstr "Download-Log"
629
 
630
  #: includes/admin/class-dlm-admin.php:192
631
  msgid "Log download attempts, IP addresses and more."
632
+ msgstr "Download-Versuche, IP-Adressen und anderes aufzeichnen."
633
 
634
  #: includes/admin/class-dlm-admin.php:198
635
  msgid "Blacklist IPs"
639
  msgid ""
640
  "List IP Addresses to blacklist, 1 per line. Use <code>*</code> for a "
641
  "wildcard."
642
+ msgstr ""
643
+ "IP-Adressen auf Blackliste setzen, 1 pro Zeile. Das Zeichen <code>*</code> "
644
+ "dient als Wildcard."
645
 
646
  #: includes/admin/class-dlm-admin.php:206
647
  msgid "Blacklist user agents"
648
+ msgstr "Benutzer-Umgebungen sperren"
649
 
650
  #: includes/admin/class-dlm-admin.php:207
651
  msgid "List browser user agents to blacklist, 1 per line."
652
+ msgstr "Benutzer-Umgebungen für Sperrung auflisten, einer pro Linie."
653
 
654
  #: includes/admin/class-dlm-admin.php:279
655
  msgid "Logs"
656
+ msgstr "Logs"
657
 
658
  #: includes/admin/class-dlm-admin.php:323
659
  msgid "Settings successfully saved"
673
 
674
  #: includes/admin/class-dlm-admin.php:434
675
  msgid "Delete Logs"
676
+ msgstr "Logs leeren"
677
 
678
  #: includes/admin/class-dlm-admin.php:485
679
  msgid "Version ID"
681
 
682
  #: includes/admin/class-dlm-admin.php:486
683
  msgid "Filename"
684
+ msgstr "Dateiname"
685
 
686
  #: includes/admin/class-dlm-admin.php:487
687
  msgid "User ID"
688
+ msgstr "Benutzer-ID"
689
 
690
  #: includes/admin/class-dlm-admin.php:488
691
  msgid "User Login"
692
+ msgstr "Benutzer-Login"
693
 
694
  #: includes/admin/class-dlm-admin.php:489
695
  msgid "User Email"
696
+ msgstr "Benutzer-E-Mail-Adresse"
697
 
698
  #: includes/admin/class-dlm-admin.php:490
699
  msgid "User IP"
700
+ msgstr "Benutzer-IP"
701
 
702
  #: includes/admin/class-dlm-admin.php:491
703
  #: includes/admin/class-dlm-logging-list-table.php:127
704
  msgid "User Agent"
705
+ msgstr "Benutzer-Umgebung"
706
 
707
  #: includes/admin/class-dlm-admin.php:492
708
  #: includes/admin/class-dlm-logging-list-table.php:128
711
 
712
  #: includes/admin/class-dlm-admin.php:493
713
  msgid "Status"
714
+ msgstr "Status"
715
 
716
  #: includes/admin/class-dlm-logging-list-table.php:50
717
  msgid "Download Complete"
727
 
728
  #: includes/admin/class-dlm-logging-list-table.php:72
729
  msgid "v%s"
730
+ msgstr "v%s"
731
 
732
  #: includes/admin/class-dlm-logging-list-table.php:92
733
  msgid "Non-member"
743
 
744
  #: includes/admin/class-dlm-logging-list-table.php:142
745
  msgid "Any status"
746
+ msgstr "Jeder Status"
747
 
748
  #: includes/admin/class-dlm-logging-list-table.php:143
749
  msgid "Failed"
750
+ msgstr "Fehlgeschlagen"
751
 
752
  #: includes/admin/class-dlm-logging-list-table.php:144
753
  msgid "Redirected"
754
+ msgstr "Umgeleitet"
755
 
756
  #: includes/admin/class-dlm-logging-list-table.php:145
757
  msgid "Completed"
758
+ msgstr "Abgeschlossen"
759
 
760
  #: includes/admin/class-dlm-logging-list-table.php:164
761
  msgid "Show all dates"
762
+ msgstr "Alle Zeiträume zeigen"
763
 
764
  #: includes/admin/class-dlm-logging-list-table.php:177
765
  msgid "%1$s %2$d"
766
+ msgstr "%1$s %2$d"
767
 
768
  #: includes/admin/class-dlm-logging-list-table.php:185
769
  msgid "25 per page"
770
+ msgstr "25 pro Seite"
771
 
772
  #: includes/admin/class-dlm-logging-list-table.php:186
773
  msgid "50 per page"
774
+ msgstr "50 pro Seite"
775
 
776
  #: includes/admin/class-dlm-logging-list-table.php:187
777
  msgid "100 per page"
778
+ msgstr "100 pro Seite"
779
 
780
  #: includes/admin/class-dlm-logging-list-table.php:188
781
  msgid "200 per page"
782
+ msgstr "200 pro Seite"
783
 
784
  #: includes/admin/class-dlm-logging-list-table.php:189
785
  msgid "Show All"
786
+ msgstr "Alle zeigen"
787
 
788
  #: includes/admin/class-dlm-logging-list-table.php:193
789
  msgid "Filter"
790
+ msgstr "Filter"
791
 
792
  #: includes/admin/html-downloadable-file-version.php:3
793
  msgid "Remove"
799
 
800
  #: includes/admin/html-downloadable-file-version.php:5
801
  msgid "Version <span class=\"version\">%s</span> (%s)"
802
+ msgstr "Version <span class=\"version\">%s</span> (%s)"
803
 
804
  #: includes/admin/html-downloadable-file-version.php:5
805
  #: includes/admin/html-downloadable-file-version.php:17
809
  #: includes/admin/html-downloadable-file-version.php:5
810
  msgid "Downloaded %s time"
811
  msgid_plural "Downloaded %s times"
812
+ msgstr[0] "Einmal heruntergeladen"
813
  msgstr[1] "%s-mal heruntergeladen"
814
 
815
  #: includes/admin/html-downloadable-file-version.php:21
816
  msgid "File URL(s)"
817
+ msgstr "Datei-URL(s)"
818
 
819
  #: includes/admin/html-downloadable-file-version.php:22
820
  msgid ""
821
  "Enter one file path/URL per line - multiple files will be used as mirrors "
822
  "(chosen at random)."
823
+ msgstr ""
824
+ "Einen Pfad/URL pro Zeile eingeben - mehrere werden als Datei-Mirrors genutzt "
825
+ "(zufällig ausgewählt)."
826
 
827
  #: includes/admin/html-downloadable-file-version.php:27
828
  msgid "Upload file"
829
+ msgstr "Datei hochladen"
830
 
831
  #: includes/admin/html-downloadable-file-version.php:29
832
  msgid "Choose a file"
833
+ msgstr "Datei auswählen"
834
 
835
  #: includes/admin/html-downloadable-file-version.php:30
836
  msgid "Insert file URL"
837
+ msgstr "Datei-URL angeben"
838
 
839
  #: includes/admin/html-downloadable-file-version.php:34
840
  msgid "Browse for file"
846
 
847
  #: includes/admin/html-downloadable-file-version.php:59
848
  msgid "h"
849
+ msgstr "h"
850
 
851
  #: includes/admin/html-downloadable-file-version.php:59
852
  msgid "m"
853
+ msgstr "min"
854
 
855
  #: includes/class-dlm-download-handler.php:140
856
  msgid "Password Required"
857
+ msgstr "Passwort benötigt"
858
 
859
  #: includes/class-dlm-download-handler.php:150
860
  msgid "Download does not exist."
883
 
884
  #: includes/class-dlm-download-handler.php:194
885
  msgid "You do not have permission to access this download."
886
+ msgstr ""
887
+ "Sie besitzen nicht die nötige Berechtigung, um auf diesen Download "
888
+ "zuzugreifen."
889
 
890
  #: includes/class-dlm-download-handler.php:212
891
  #: includes/class-dlm-download-handler.php:228
896
 
897
  #: includes/class-dlm-download-handler.php:281
898
  msgid "Redirected to remote file."
899
+ msgstr "Weitergeleitet zu Datei auf anderem Server."
900
 
901
  #: includes/class-dlm-download-handler.php:286
902
  msgid "File not found"
908
 
909
  #: includes/class-dlm-shortcodes.php:93 includes/class-dlm-shortcodes.php:125
910
  msgid "Download not found"
911
+ msgstr "Download nicht gefunden."
912
 
913
  #: includes/widgets/class-dlm-widget-downloads.php:27
914
  msgid "Display a list of your downloads."
929
 
930
  #: includes/widgets/class-dlm-widget-downloads.php:161
931
  msgid "Limit:"
932
+ msgstr "Downloadlimit:"
933
 
934
  #: includes/widgets/class-dlm-widget-downloads.php:165
935
  msgid "Output template:"
973
 
974
  #: includes/widgets/class-dlm-widget-downloads.php:192
975
  msgid "Show only members only downloads"
976
+ msgstr "Nur Downloads für Mitglieder zeigen"
977
 
978
  #: templates/content-download-box.php:12
979
  #: templates/content-download-filename.php:9 templates/content-download.php:9
986
  #: templates/content-download-filename.php:8
987
  #: templates/content-download-title.php:8 templates/content-download.php:8
988
  msgid "Version %s"
989
+ msgstr "Version %s"
990
 
991
  #: templates/content-download-box.php:21
992
  msgid "Download File"
994
 
995
  #: templates/content-download-button.php:9
996
  msgid "Download &ldquo;%s&rdquo;"
997
+ msgstr "Download &ldquo;%s&rdquo;"
998
 
999
  #: templates/content-download-button.php:10
1000
  #: templates/content-download-version-list.php:17
1005
 
1006
  #. Plugin Name of the plugin/theme
1007
  msgid "Download Monitor"
1008
+ msgstr "Download Monitor"
1009
 
1010
  #. Plugin URI of the plugin/theme
1011
  msgid "http://mikejolley.com/projects/download-monitor/"
1012
+ msgstr "http://mikejolley.com/projects/download-monitor/"
1013
 
1014
  #. Description of the plugin/theme
1015
  msgid ""
1017
  "outputting download links and file information on your WordPress powered "
1018
  "site."
1019
  msgstr ""
1020
+ "Eine komplette Lösung für die Verwaltung von Downloads. Stellt ein "
1021
+ "Monitoring für die Downloads bereit und bietet die Möglichkeit, Download-"
1022
+ "Links und -Informationen auf der WordPress-Seite auszugeben."
1023
 
1024
  #. Author of the plugin/theme
1025
  msgid "Mike Jolley"
1026
+ msgstr "Mike Jolley"
1027
 
1028
  #. Author URI of the plugin/theme
1029
  msgid "http://mikejolley.com"
1030
+ msgstr "http://mikejolley.com"
package.json DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "name": "download-monitor",
3
- "title": "Download Monitor",
4
- "version": "",
5
- "homepage": "",
6
- "main": "Gruntfile.js",
7
- "devDependencies": {
8
- "grunt": "~0.4.4",
9
- "grunt-contrib-uglify": "~0.4.0",
10
- "grunt-contrib-less": "~0.11.0",
11
- "grunt-contrib-cssmin": "~0.7.0",
12
- "grunt-shell": "~0.6.4",
13
- "grunt-contrib-watch": "~0.5.3"
14
- },
15
- "engines": {
16
- "node": ">=0.8.0",
17
- "npm": ">=1.1.0"
18
- }
19
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Download Monitor ===
2
- Contributors: mikejolley
3
- Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=mike.jolley@me.com&item_name=Donation+for+Download+Monitor
4
  Tags: download, downloads, monitor, hits, download monitor, tracking, admin, count, counter, files, versions, download count, logging
5
  Requires at least: 3.8
6
- Tested up to: 4.0
7
- Stable tag: 1.5.1
8
  License: GPLv3
9
 
10
  Download Monitor is a plugin for uploading and managing downloads, tracking downloads, and displaying links.
@@ -26,25 +26,25 @@ Download Monitor provides an interface for uploading and managing downloadable f
26
  * Member only downloads.
27
  * Customisable endpoints for showing pretty download links.
28
 
29
- [Read more about Download Monitor](http://mikejolley.com/projects/download-monitor/).
30
 
31
  = Documentation =
32
 
33
- Documentation will be maintained on the [GitHub Wiki here](https://github.com/mikejolley/download-monitor/wiki).
34
 
35
- = Add-ons =
36
 
37
- Add-ons, such as the __legacy importer__ and __page addon__ can be [found here](http://mikejolley.com/projects/download-monitor/add-ons/). Take a look!
38
 
39
  = Contributing and reporting bugs =
40
 
41
- You can contribute code to this plugin via GitHub: [https://github.com/mikejolley/download-monitor](https://github.com/mikejolley/download-monitor)
42
 
43
  You can contribute localizations via Transifex [https://www.transifex.com/projects/p/download-monitor/](https://www.transifex.com/projects/p/download-monitor/)
44
 
45
  = Support =
46
 
47
- Use the WordPress.org forums for community support - I cannot offer support directly for free. If you spot a bug, you can of course log it on [Github](https://github.com/mikejolley/download-monitor) instead where I can act upon it more efficiently.
48
 
49
  If you want help with a customisation, hire a developer!
50
 
@@ -68,7 +68,7 @@ The manual installation method involves downloading the plugin and uploading it
68
 
69
  = I used this before, so why is this version 1? =
70
 
71
- Version 1.0.0 is a fresh start/complete rewrite of the legacy 3.0 version using modern best-practices such as custom post types and endpoints. Because of this, data from the legacy plugin won't work without migration using [the legacy importer](http://mikejolley.com/projects/download-monitor/add-ons/legacy-importer/). Since this upgrade process isn't straightforward nor automated I've reverted the version to 1.0.0 to prevent automatic updates.
72
 
73
  Legacy versions can still be [found here](http://wordpress.org/plugins/download-monitor/developers/).
74
 
@@ -76,7 +76,7 @@ Legacy versions can still be [found here](http://wordpress.org/plugins/download-
76
 
77
  The rewrite has trimmed the fat and only kept the best, most useful features. If something is missing, you can always code it yourself - the new system is very flexible and its easy to query files using [get_posts](http://codex.wordpress.org/Template_Tags/get_posts).
78
 
79
- If you are missing the "Page Addon", this is now a separate plugin found here: [Download Monitor Page Addon](http://mikejolley.com/projects/download-monitor/add-ons/page-addon/).
80
 
81
  = Can I upload .xxx filetype using the uploader? =
82
 
@@ -110,6 +110,26 @@ Admin hits are not counted, log out and try!
110
 
111
  == Changelog ==
112
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  = 1.5.1 =
114
  * Fallback for JSON_UNESCAPED_UNICODE to fix accented characters on < PHP 5.4.
115
  * Changed default orderby for downloads shortcode to date, desc.
@@ -125,7 +145,7 @@ Admin hits are not counted, log out and try!
125
  * Added Grunt.
126
  * Added options to generate file hashes DISABLED BY DEFAULT as they can cause performance issues with large files.
127
 
128
- = 1.4.4 =
129
  * Use home_dir instead of site_dir - fixes hot-linking protections against own site (when not in root dir)
130
  * Replace hardcoded WP_CONTENT_DIR and WP_CONTENT_URL with wp_upload_dir to work when UPLOADS and UPLOADS_URL constants are set.
131
  * Added some filters for hotlink protection customisation.
@@ -143,7 +163,7 @@ Admin hits are not counted, log out and try!
143
  * Disable remote file hash generation, but can be enabled with filter dlm_allow_remote_hash_file
144
  * Radio buttons instead of select (with pagination) in popup to improve performance.
145
 
146
- = 1.4.2 =
147
  * Fix for site_url -> abspath
148
  * Check if hash functions are supported before use.
149
 
@@ -238,4 +258,9 @@ Admin hits are not counted, log out and try!
238
  * Workaround root relative URLS
239
 
240
  = 1.0.0 =
241
- * Complete rewrite of the plugin making use of custom post types and other best practices. Fresh start version '1' to prevent auto-updates (legacy importer needs to be used to migrate from old versions).
 
 
 
 
 
1
  === Download Monitor ===
2
+ Contributors: barrykooij, mikejolley
3
+ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=barry@cageworks.nl&item_name=Donation+for+Download+Monitor
4
  Tags: download, downloads, monitor, hits, download monitor, tracking, admin, count, counter, files, versions, download count, logging
5
  Requires at least: 3.8
6
+ Tested up to: 4.1
7
+ Stable tag: 1.6.0
8
  License: GPLv3
9
 
10
  Download Monitor is a plugin for uploading and managing downloads, tracking downloads, and displaying links.
26
  * Member only downloads.
27
  * Customisable endpoints for showing pretty download links.
28
 
29
+ [Read more about Download Monitor](https://www.download-monitor.com).
30
 
31
  = Documentation =
32
 
33
+ Documentation will be maintained on the [GitHub Wiki here](https://github.com/download-monitor/download-monitor/wiki).
34
 
35
+ = Extensions =
36
 
37
+ Extensions, such as the __legacy importer__ and __page addon__ can be [found here](https://www.download-monitor.com/extensions/). Take a look!
38
 
39
  = Contributing and reporting bugs =
40
 
41
+ You can contribute code to this plugin via GitHub: [https://github.com/download-monitor/download-monitor](https://github.com/download-monitor/download-monitor)
42
 
43
  You can contribute localizations via Transifex [https://www.transifex.com/projects/p/download-monitor/](https://www.transifex.com/projects/p/download-monitor/)
44
 
45
  = Support =
46
 
47
+ Use the WordPress.org forums for community support. If you spot a bug, you can of course log it on [Github](https://github.com/download-monitor/download-monitor) instead where we can act upon it more efficiently.
48
 
49
  If you want help with a customisation, hire a developer!
50
 
68
 
69
  = I used this before, so why is this version 1? =
70
 
71
+ Version 1.0.0 is a fresh start/complete rewrite of the legacy 3.0 version using modern best-practices such as custom post types and endpoints. Because of this, data from the legacy plugin won't work without migration using [the legacy importer](https://www.download-monitor.com/extensions/dlm-legacy-importer/). Since this upgrade process isn't straightforward nor automated I've reverted the version to 1.0.0 to prevent automatic updates.
72
 
73
  Legacy versions can still be [found here](http://wordpress.org/plugins/download-monitor/developers/).
74
 
76
 
77
  The rewrite has trimmed the fat and only kept the best, most useful features. If something is missing, you can always code it yourself - the new system is very flexible and its easy to query files using [get_posts](http://codex.wordpress.org/Template_Tags/get_posts).
78
 
79
+ If you are missing the "Page Addon", this is now a separate plugin found here: [Download Monitor Page Addon](https://www.download-monitor.com/extensions/page-addon/).
80
 
81
  = Can I upload .xxx filetype using the uploader? =
82
 
110
 
111
  == Changelog ==
112
 
113
+ = 1.6.0 =
114
+ * Plugin is now initiated at plugins_loaded.
115
+ * Implemented auto loader.
116
+ * Classes are no longer initiated at bottom of class file but whenever an object is needed.
117
+ * Code standards corrections.
118
+ * Introduced Template_Handler. Loading of template parts should be done through this class.
119
+ * Removed $GLOBALS['dlm_logging'] global.
120
+ * Removed $GLOBALS['DLM_Download_Handler'] global.
121
+ * Removed internal use of $download_monitor global.
122
+ # Moved all inline JavaScript to separate JavaScript files.
123
+ * Moved all install related code to installer class.
124
+ * Moved main plugin class to it's own file.
125
+ * Deprecated 'dlm_create_log' function.
126
+ * Redone extensions page.
127
+ * Fixed a bug in shortcode download where orderby=download_count wasn't working.
128
+ * Fixed a bug where downloads didn't work with default WP permalink structure.
129
+ * Delete dlm_file_version_ids_ transient on save.
130
+ * Added dlm_download_headers filter.
131
+ * Added dlm_get_template_part filter.
132
+
133
  = 1.5.1 =
134
  * Fallback for JSON_UNESCAPED_UNICODE to fix accented characters on < PHP 5.4.
135
  * Changed default orderby for downloads shortcode to date, desc.
145
  * Added Grunt.
146
  * Added options to generate file hashes DISABLED BY DEFAULT as they can cause performance issues with large files.
147
 
148
+ = 1.4.4 =
149
  * Use home_dir instead of site_dir - fixes hot-linking protections against own site (when not in root dir)
150
  * Replace hardcoded WP_CONTENT_DIR and WP_CONTENT_URL with wp_upload_dir to work when UPLOADS and UPLOADS_URL constants are set.
151
  * Added some filters for hotlink protection customisation.
163
  * Disable remote file hash generation, but can be enabled with filter dlm_allow_remote_hash_file
164
  * Radio buttons instead of select (with pagination) in popup to improve performance.
165
 
166
+ = 1.4.2 =
167
  * Fix for site_url -> abspath
168
  * Check if hash functions are supported before use.
169
 
258
  * Workaround root relative URLS
259
 
260
  = 1.0.0 =
261
+ * Complete rewrite of the plugin making use of custom post types and other best practices. Fresh start version '1' to prevent auto-updates (legacy importer needs to be used to migrate from old versions).
262
+
263
+ == Upgrade Notice ==
264
+
265
+ = 1.6.0 =
266
+ If you're using the Page Addon or Amazon S3 extension you must update these extensions too. Visit https://www.download-monitor.com/ for more information.
templates/content-download-box.php CHANGED
@@ -9,7 +9,8 @@ global $dlm_download;
9
 
10
  <?php $dlm_download->the_image(); ?>
11
 
12
- <div class="download-count"><?php printf( _n( '1 download', '%d downloads', $dlm_download->get_the_download_count(), 'download-monitor' ), $dlm_download->get_the_download_count() ) ?></div>
 
13
 
14
  <div class="download-box-content">
15
 
@@ -17,7 +18,9 @@ global $dlm_download;
17
 
18
  <?php $dlm_download->the_short_description(); ?>
19
 
20
- <a class="download-button" title="<?php if ( $dlm_download->has_version_number() ) printf( __( 'Version %s', 'download-monitor' ), $dlm_download->get_the_version_number() ); ?>" href="<?php $dlm_download->the_download_link(); ?>" rel="nofollow">
 
 
21
  <?php _e( 'Download File', 'download-monitor' ); ?>
22
  <small><?php $dlm_download->the_filename(); ?> &ndash; <?php $dlm_download->the_filesize(); ?></small>
23
  </a>
9
 
10
  <?php $dlm_download->the_image(); ?>
11
 
12
+ <div
13
+ class="download-count"><?php printf( _n( '1 download', '%d downloads', $dlm_download->get_the_download_count(), 'download-monitor' ), $dlm_download->get_the_download_count() ) ?></div>
14
 
15
  <div class="download-box-content">
16
 
18
 
19
  <?php $dlm_download->the_short_description(); ?>
20
 
21
+ <a class="download-button" title="<?php if ( $dlm_download->has_version_number() ) {
22
+ printf( __( 'Version %s', 'download-monitor' ), $dlm_download->get_the_version_number() );
23
+ } ?>" href="<?php $dlm_download->the_download_link(); ?>" rel="nofollow">
24
  <?php _e( 'Download File', 'download-monitor' ); ?>
25
  <small><?php $dlm_download->the_filename(); ?> &ndash; <?php $dlm_download->the_filesize(); ?></small>
26
  </a>
templates/content-download-button.php CHANGED
@@ -3,9 +3,9 @@
3
  * Download button
4
  */
5
 
6
- global $dlm_download, $download_monitor;
7
  ?>
8
  <p><a class="aligncenter download-button" href="<?php $dlm_download->the_download_link(); ?>" rel="nofollow">
9
- <?php printf( __( 'Download &ldquo;%s&rdquo;', 'download-monitor' ), $dlm_download->get_the_title() ); ?>
10
- <small><?php $dlm_download->the_filename(); ?> &ndash; <?php printf( _n( 'Downloaded 1 time', 'Downloaded %d times', $dlm_download->get_the_download_count(), 'download-monitor' ), $dlm_download->get_the_download_count() ) ?> &ndash; <?php $dlm_download->the_filesize(); ?></small>
11
- </a></p>
3
  * Download button
4
  */
5
 
6
+ global $dlm_download;
7
  ?>
8
  <p><a class="aligncenter download-button" href="<?php $dlm_download->the_download_link(); ?>" rel="nofollow">
9
+ <?php printf( __( 'Download &ldquo;%s&rdquo;', 'download-monitor' ), $dlm_download->get_the_title() ); ?>
10
+ <small><?php $dlm_download->the_filename(); ?> &ndash; <?php printf( _n( 'Downloaded 1 time', 'Downloaded %d times', $dlm_download->get_the_download_count(), 'download-monitor' ), $dlm_download->get_the_download_count() ) ?> &ndash; <?php $dlm_download->the_filesize(); ?></small>
11
+ </a></p>
templates/content-download-filename.php CHANGED
@@ -5,6 +5,11 @@
5
 
6
  global $dlm_download;
7
  ?>
8
- <a class="download-link filetype-icon <?php echo 'filetype-' . $dlm_download->get_the_filetype(); ?>" title="<?php if ( $dlm_download->has_version_number() ) printf( __( 'Version %s', 'download-monitor' ), $dlm_download->get_the_version_number() ); ?>" href="<?php $dlm_download->the_download_link(); ?>" rel="nofollow">
9
- <?php $dlm_download->the_filename(); ?> (<?php printf( _n( '1 download', '%d downloads', $dlm_download->get_the_download_count(), 'download-monitor' ), $dlm_download->get_the_download_count() ) ?>)
 
 
 
 
 
10
  </a>
5
 
6
  global $dlm_download;
7
  ?>
8
+ <a class="download-link filetype-icon <?php echo 'filetype-' . $dlm_download->get_the_filetype(); ?>"
9
+ title="<?php if ( $dlm_download->has_version_number() ) {
10
+ printf( __( 'Version %s', 'download-monitor' ), $dlm_download->get_the_version_number() );
11
+ } ?>" href="<?php $dlm_download->the_download_link(); ?>" rel="nofollow">
12
+ <?php $dlm_download->the_filename(); ?>
13
+ (<?php printf( _n( '1 download', '%d downloads', $dlm_download->get_the_download_count(), 'download-monitor' ), $dlm_download->get_the_download_count() ) ?>
14
+ )
15
  </a>
templates/content-download-title.php CHANGED
@@ -5,6 +5,8 @@
5
 
6
  global $dlm_download;
7
  ?>
8
- <a class="download-link" title="<?php if ( $dlm_download->has_version_number() ) printf( __( 'Version %s', 'download-monitor' ), $dlm_download->get_the_version_number() ); ?>" href="<?php $dlm_download->the_download_link(); ?>" rel="nofollow">
 
 
9
  <?php $dlm_download->the_title(); ?>
10
  </a>
5
 
6
  global $dlm_download;
7
  ?>
8
+ <a class="download-link" title="<?php if ( $dlm_download->has_version_number() ) {
9
+ printf( __( 'Version %s', 'download-monitor' ), $dlm_download->get_the_version_number() );
10
+ } ?>" href="<?php $dlm_download->the_download_link(); ?>" rel="nofollow">
11
  <?php $dlm_download->the_title(); ?>
12
  </a>
templates/content-download-version-list.php CHANGED
@@ -10,15 +10,19 @@ $versions = $dlm_download->get_file_versions();
10
  if ( $versions ) : ?>
11
  <ul class="download-versions">
12
  <?php
13
- foreach ( $versions as $version ) {
14
- $dlm_download->set_version( $version->id );
15
- $version_post = get_post( $version->id );
16
- ?>
17
- <li><a class="download-link" title="<?php printf( _n( 'Downloaded 1 time', 'Downloaded %d times', $dlm_download->get_the_download_count(), 'download-monitor' ), $dlm_download->get_the_download_count() ) ?>" href="<?php $dlm_download->the_download_link(); ?>" rel="nofollow">
18
- <?php $dlm_download->the_filename(); ?> <?php if ( $dlm_download->has_version_number() ) echo '- ' . $dlm_download->get_the_version_number(); ?>
 
 
 
 
19
  </a></li>
20
- <?php
21
- }
22
  ?>
23
  </ul>
24
  <?php endif; ?>
10
  if ( $versions ) : ?>
11
  <ul class="download-versions">
12
  <?php
13
+ foreach ( $versions as $version ) {
14
+ $dlm_download->set_version( $version->id );
15
+ $version_post = get_post( $version->id );
16
+ ?>
17
+ <li><a class="download-link"
18
+ title="<?php printf( _n( 'Downloaded 1 time', 'Downloaded %d times', $dlm_download->get_the_download_count(), 'download-monitor' ), $dlm_download->get_the_download_count() ) ?>"
19
+ href="<?php $dlm_download->the_download_link(); ?>" rel="nofollow">
20
+ <?php $dlm_download->the_filename(); ?> <?php if ( $dlm_download->has_version_number() ) {
21
+ echo '- ' . $dlm_download->get_the_version_number();
22
+ } ?>
23
  </a></li>
24
+ <?php
25
+ }
26
  ?>
27
  </ul>
28
  <?php endif; ?>
templates/content-download.php CHANGED
@@ -5,6 +5,10 @@
5
 
6
  global $dlm_download;
7
  ?>
8
- <a class="download-link" title="<?php if ( $dlm_download->has_version_number() ) printf( __( 'Version %s', 'download-monitor' ), $dlm_download->get_the_version_number() ); ?>" href="<?php $dlm_download->the_download_link(); ?>" rel="nofollow">
9
- <?php $dlm_download->the_title(); ?> (<?php printf( _n( '1 download', '%d downloads', $dlm_download->get_the_download_count(), 'download-monitor' ), $dlm_download->get_the_download_count() ) ?>)
 
 
 
 
10
  </a>
5
 
6
  global $dlm_download;
7
  ?>
8
+ <a class="download-link" title="<?php if ( $dlm_download->has_version_number() ) {
9
+ printf( __( 'Version %s', 'download-monitor' ), $dlm_download->get_the_version_number() );
10
+ } ?>" href="<?php $dlm_download->the_download_link(); ?>" rel="nofollow">
11
+ <?php $dlm_download->the_title(); ?>
12
+ (<?php printf( _n( '1 download', '%d downloads', $dlm_download->get_the_download_count(), 'download-monitor' ), $dlm_download->get_the_download_count() ) ?>
13
+ )
14
  </a>
templates/pagination.php CHANGED
@@ -2,25 +2,28 @@
2
  /**
3
  * Pagination - Show numbered pagination.
4
  */
5
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
6
 
7
  global $dlm_max_num_pages;
8
 
9
- if ( $dlm_max_num_pages <= 1 )
10
  return;
 
11
  ?>
12
  <nav class="download-monitor-pagination">
13
  <?php
14
- echo paginate_links( apply_filters( 'download_monitor_pagination_args', array(
15
- 'base' => str_replace( 999999999, '%#%', get_pagenum_link( 999999999 ) ),
16
- 'format' => '',
17
- 'current' => max( 1, get_query_var('paged') ),
18
- 'total' => $dlm_max_num_pages,
19
- 'prev_text' => '&larr;',
20
- 'next_text' => '&rarr;',
21
- 'type' => 'list',
22
- 'end_size' => 3,
23
- 'mid_size' => 3
24
- ) ) );
25
  ?>
26
  </nav>
2
  /**
3
  * Pagination - Show numbered pagination.
4
  */
5
+ if ( ! defined( 'ABSPATH' ) ) {
6
+ exit;
7
+ } // Exit if accessed directly
8
 
9
  global $dlm_max_num_pages;
10
 
11
+ if ( $dlm_max_num_pages <= 1 ) {
12
  return;
13
+ }
14
  ?>
15
  <nav class="download-monitor-pagination">
16
  <?php
17
+ echo paginate_links( apply_filters( 'download_monitor_pagination_args', array(
18
+ 'base' => str_replace( 999999999, '%#%', get_pagenum_link( 999999999 ) ),
19
+ 'format' => '',
20
+ 'current' => max( 1, get_query_var( 'paged' ) ),
21
+ 'total' => $dlm_max_num_pages,
22
+ 'prev_text' => '&larr;',
23
+ 'next_text' => '&rarr;',
24
+ 'type' => 'list',
25
+ 'end_size' => 3,
26
+ 'mid_size' => 3
27
+ ) ) );
28
  ?>
29
  </nav>