Download Monitor - Version 4.7.2

Version Description

  • 24.10.2022 = Fixed: Possible overload of server on the Reports page ( #1102 ) Changed: Plugin Logo ( #1101 ) Fixed: Log query strings for download location ( #1099 ) Fixed: Version's number of downloads wrong ( #1097 ) Added: Protection functionality for Media Library files ( #1096 ) Fixed: Redirect to file when unicode chars are present ( #1095 ) Fixed: Front-end CSS was not enqueued for Gutenberg blocks ( #1094 )
Download this release

Release Info

Developer raldea89
Plugin Icon 128x128 Download Monitor
Version 4.7.2
Comparing to
See all releases

Code changes from version 4.7.1 to 4.7.2

assets/css/menu.css DELETED
@@ -1,85 +0,0 @@
1
- /* Menu */
2
- #adminmenu #menu-posts-dlm_download {
3
- /* .wp-menu-image:before {
4
- content: "\f316";
5
- font-family: "dashicons" !important;
6
- font-style: normal;
7
- font-weight: normal;
8
- speak: none;
9
-
10
- display: inline-block;
11
- text-decoration: inherit;
12
- width: 1em;
13
- text-align: center;
14
-
15
- !* For safety - reset parent styles, that can break glyph codes*!
16
- font-variant: normal;
17
- text-transform: none;
18
-
19
- !* fix buttons height, for twitter bootstrap *!
20
- line-height: 1em;
21
- }*/
22
- }
23
- #adminmenu #menu-posts-dlm_download .wp-menu-image.svg {
24
- background-size: 40px auto;
25
- }
26
- #adminmenu #menu-posts-dlm_download ul.wp-submenu li > a {
27
- padding: 7px 12px;
28
- }
29
- #adminmenu #menu-posts-dlm_download ul.wp-submenu li a[href$="dlm-lite-vs-pro"] {
30
- color: gold;
31
- }
32
- #adminmenu #menu-posts-dlm_download ul.wp-submenu li a[href$="edit-tags.php?taxonomy=dlm_download_tag&post_type=dlm_download"],
33
- #adminmenu #menu-posts-dlm_download ul.wp-submenu li a[href$="edit.php?post_type=dlm_download&page=download-monitor-settings"],
34
- #adminmenu #menu-posts-dlm_download ul.wp-submenu li a[href$="edit.php?post_type=dlm_download&page=download-monitor-reports"] {
35
- border-bottom: 1px solid hsla(0, 0%, 100%, 0.2);
36
- }
37
- /* LU upgrade notice */
38
- .dlm-lu-upgrade-notice {
39
- position: relative;
40
- padding: 1em;
41
- margin: 3em 1em 1em 0;
42
- color: #fff;
43
- background: #419ccb;
44
- box-shadow: 2px 2px 1px grey;
45
- }
46
- .dlm-lu-upgrade-notice h3,
47
- .dlm-lu-upgrade-notice a {
48
- color: #fff;
49
- }
50
- .dlm-lu-upgrade-notice h3 {
51
- margin-top: 0;
52
- }
53
- .dlm-lu-upgrade-notice p {
54
- font-size: 1.05em;
55
- }
56
- .dlm-lu-upgrade-notice p a {
57
- font-weight: bold;
58
- }
59
- .dlm-lu-upgrade-notice a.dlm-lu-upgrade-notice-hide {
60
- position: absolute;
61
- top: 10px;
62
- right: 10px;
63
- text-decoration: none;
64
- font-size: 0.95em;
65
- }
66
- .dlm-onboarding-notice {
67
- border-left-color: #419ccb;
68
- }
69
- .dlm-onboarding-notice:before {
70
- display: inline-block;
71
- position: absolute;
72
- top: 0;
73
- left: 0;
74
- width: 35px;
75
- height: 100%;
76
- content: "";
77
- background-color: #419ccb;
78
- background-image: url('../images/logo.png');
79
- background-size: 29px 28px;
80
- background-position: 1px center;
81
- background-repeat: no-repeat;
82
- }
83
- .dlm-onboarding-notice p {
84
- padding-left: 33px;
85
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/css/menu.less DELETED
@@ -1,101 +0,0 @@
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
- .wp-menu-image.svg {
25
- background-size: 40px auto;
26
- }
27
-
28
- ul.wp-submenu {
29
-
30
- li {
31
-
32
- & > a {
33
- padding:7px 12px;
34
- }
35
- // Lite vs PRO menu link
36
- a[href$="dlm-lite-vs-pro"] {
37
- color: gold;
38
- }
39
-
40
- a[href$="edit-tags.php?taxonomy=dlm_download_tag&post_type=dlm_download"],
41
- a[href$="edit.php?post_type=dlm_download&page=download-monitor-settings"],
42
- a[href$="edit.php?post_type=dlm_download&page=download-monitor-reports"]{
43
- border-bottom: 1px solid hsla(0,0%,100%,.2);
44
- }
45
- }
46
- }
47
- }
48
- }
49
-
50
- /* LU upgrade notice */
51
- .dlm-lu-upgrade-notice {
52
- position: relative;
53
- padding: 1em;
54
- margin: 3em 1em 1em 0;
55
- color: #fff;
56
- background: #419ccb;
57
- box-shadow: 2px 2px 1px grey;
58
-
59
- h3, a {
60
- color: #fff;
61
- }
62
- h3 {
63
- margin-top: 0;
64
- }
65
-
66
- p {
67
- font-size: 1.05em;
68
- a {
69
- font-weight: bold;
70
- }
71
- }
72
- a.dlm-lu-upgrade-notice-hide {
73
- position: absolute;
74
- top: 10px;
75
- right: 10px;
76
- text-decoration: none;
77
- font-size: 0.95em;
78
- }
79
- }
80
-
81
- .dlm-onboarding-notice {
82
- border-left-color: #419ccb;
83
-
84
- &:before {
85
- display: inline-block;
86
- position:absolute;
87
- top:0;
88
- left:0;
89
- width: 35px;
90
- height: 100%;
91
- content:"";
92
- background-color: #419ccb;
93
- background-image: url('../images/logo.png');
94
- background-size: 29px 28px;
95
- background-position: 1px center;
96
- background-repeat: no-repeat;
97
- }
98
- p {
99
- padding-left: 33px;
100
- }
101
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/css/menu.min.css DELETED
@@ -1 +0,0 @@
1
- #adminmenu #menu-posts-dlm_download .wp-menu-image.svg{background-size:40px auto}#adminmenu #menu-posts-dlm_download ul.wp-submenu li>a{padding:7px 12px}#adminmenu #menu-posts-dlm_download ul.wp-submenu li a[href$=dlm-lite-vs-pro]{color:gold}#adminmenu #menu-posts-dlm_download ul.wp-submenu li a[href$="edit-tags.php?taxonomy=dlm_download_tag&post_type=dlm_download"],#adminmenu #menu-posts-dlm_download ul.wp-submenu li a[href$="edit.php?post_type=dlm_download&page=download-monitor-reports"],#adminmenu #menu-posts-dlm_download ul.wp-submenu li a[href$="edit.php?post_type=dlm_download&page=download-monitor-settings"]{border-bottom:1px solid hsla(0,0%,100%,.2)}.dlm-lu-upgrade-notice{position:relative;padding:1em;margin:3em 1em 1em 0;color:#fff;background:#419ccb;box-shadow:2px 2px 1px grey}.dlm-lu-upgrade-notice a,.dlm-lu-upgrade-notice h3{color:#fff}.dlm-lu-upgrade-notice h3{margin-top:0}.dlm-lu-upgrade-notice p{font-size:1.05em}.dlm-lu-upgrade-notice p a{font-weight:700}.dlm-lu-upgrade-notice a.dlm-lu-upgrade-notice-hide{position:absolute;top:10px;right:10px;text-decoration:none;font-size:.95em}.dlm-onboarding-notice{border-left-color:#419ccb}.dlm-onboarding-notice:before{display:inline-block;position:absolute;top:0;left:0;width:35px;height:100%;content:"";background-color:#419ccb;background-image:url('../images/logo.png');background-size:29px 28px;background-position:1px center;background-repeat:no-repeat}.dlm-onboarding-notice p{padding-left:33px}
 
assets/css/others.css ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Menu */
2
+ #adminmenu #menu-posts-dlm_download ul.wp-submenu li > a {
3
+ padding: 7px 12px;
4
+ }
5
+ #adminmenu #menu-posts-dlm_download ul.wp-submenu li a[href$="dlm-lite-vs-pro"] {
6
+ color: gold;
7
+ }
8
+ #adminmenu #menu-posts-dlm_download ul.wp-submenu li a[href$="edit-tags.php?taxonomy=dlm_download_tag&post_type=dlm_download"],
9
+ #adminmenu #menu-posts-dlm_download ul.wp-submenu li a[href$="edit.php?post_type=dlm_download&page=download-monitor-settings"],
10
+ #adminmenu #menu-posts-dlm_download ul.wp-submenu li a[href$="edit.php?post_type=dlm_download&page=download-monitor-reports"] {
11
+ border-bottom: 1px solid hsla(0, 0%, 100%, 0.2);
12
+ }
13
+ /* LU upgrade notice */
14
+ .dlm-lu-upgrade-notice {
15
+ position: relative;
16
+ padding: 1em;
17
+ margin: 3em 1em 1em 0;
18
+ color: #fff;
19
+ background: #419ccb;
20
+ box-shadow: 2px 2px 1px grey;
21
+ }
22
+ .dlm-lu-upgrade-notice h3,
23
+ .dlm-lu-upgrade-notice a {
24
+ color: #fff;
25
+ }
26
+ .dlm-lu-upgrade-notice h3 {
27
+ margin-top: 0;
28
+ }
29
+ .dlm-lu-upgrade-notice p {
30
+ font-size: 1.05em;
31
+ }
32
+ .dlm-lu-upgrade-notice p a {
33
+ font-weight: bold;
34
+ }
35
+ .dlm-lu-upgrade-notice a.dlm-lu-upgrade-notice-hide {
36
+ position: absolute;
37
+ top: 10px;
38
+ right: 10px;
39
+ text-decoration: none;
40
+ font-size: 0.95em;
41
+ }
42
+ .dlm-onboarding-notice {
43
+ border-left-color: #419ccb;
44
+ }
45
+ .dlm-onboarding-notice:before {
46
+ display: inline-block;
47
+ position: absolute;
48
+ top: 0;
49
+ left: 0;
50
+ width: 35px;
51
+ height: 100%;
52
+ content: "";
53
+ background-color: #419ccb;
54
+ background-image: url('../images/logo.png');
55
+ background-size: 29px 28px;
56
+ background-position: 1px center;
57
+ background-repeat: no-repeat;
58
+ }
59
+ .dlm-onboarding-notice p {
60
+ padding-left: 33px;
61
+ }
62
+ /**
63
+ * Media Library visual indicator that a file is protected by DLM
64
+ */
65
+ .dlm-ml-protected-file .thumbnail {
66
+ box-shadow: 0 0 0.5rem rgba(0, 0, 255, 0.45);
67
+ }
68
+ .dlm-ml-protected-file:after {
69
+ content: "";
70
+ background: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjgiIGhlaWdodD0iMjgiIHZpZXdCb3g9IjAgMCAyOCAyOCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTI4IDE0QzI4IDYuMjY4MDEgMjEuNzMyIDAgMTQgMEM2LjI2ODAxIDAgMCA2LjI2ODAxIDAgMTRDMCAyMS43MzIgNi4yNjgwMSAyOCAxNCAyOEMyMS43MzIgMjggMjggMjEuNzMyIDI4IDE0WiIgZmlsbD0idXJsKCNwYWludDBfbGluZWFyXzM2XzM5KSIvPgo8cGF0aCBkPSJNMTcuNjE1NCAxMi41NjI1SDE3LjM3NVY5LjUxNTYyQzE3LjM3NSA4LjU4MzIyIDE2Ljk5NTEgNy42ODkwMSAxNi4zMTg5IDcuMDI5N0MxNS42NDI3IDYuMzcwNCAxNC43MjU1IDYgMTMuNzY5MiA2QzEyLjgxMjkgNiAxMS44OTU4IDYuMzcwNCAxMS4yMTk2IDcuMDI5N0MxMC41NDM0IDcuNjg5MDEgMTAuMTYzNSA4LjU4MzIyIDEwLjE2MzUgOS41MTU2MlYxMi41NjI1SDkuOTIzMDhDOS40MTMwNSAxMi41NjI1IDguOTIzOSAxMi43NiA4LjU2MzI2IDEzLjExMTdDOC4yMDI2MSAxMy40NjMzIDggMTMuOTQwMiA4IDE0LjQzNzVWMTkuMTI1QzggMTkuNjIyMyA4LjIwMjYxIDIwLjA5OTIgOC41NjMyNiAy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uMTQwNiAxNC4wMTkgMTUuMTkgMTQuMTA5MiAxNS4yNzc5QzE0LjE5OTMgMTUuMzY1OCAxNC4yNSAxNS40ODUxIDE0LjI1IDE1LjYwOTRWMTcuOTUzMVoiIGZpbGw9IndoaXRlIi8+CjxkZWZzPgo8bGluZWFyR3JhZGllbnQgaWQ9InBhaW50MF9saW5lYXJfMzZfMzkiIHgxPSItNy41NDY4NyIgeTE9Ii00LjM3NSIgeDI9IjI1LjU5MzciIHkyPSIyOC43NjU2IiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+CjxzdG9wIG9mZnNldD0iMC4xMTAxMTMiIHN0b3AtY29sb3I9IiM1RERFRkIiLz4KPHN0b3Agb2Zmc2V0PSIwLjQ0MzU2OCIgc3RvcC1jb2xvcj0iIzQxOUJDQSIvPgo8c3RvcCBvZmZzZXQ9IjAuNjM2MTIyIiBzdG9wLWNvbG9yPSIjMDA4Q0Q1Ii8+CjxzdG9wIG9mZnNldD0iMSIgc3RvcC1jb2xvcj0iIzAyNUVBMCIvPgo8L2xpbmVhckdyYWRpZW50Pgo8L2RlZnM+Cjwvc3ZnPgo=");
71
+ display: block;
72
+ width: 20px;
73
+ height: 20px;
74
+ z-index: 999;
75
+ position: absolute;
76
+ top: 15px;
77
+ right: 15px;
78
+ background-size: contain;
79
+ }
assets/css/others.less ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Menu */
2
+ #adminmenu {
3
+ #menu-posts-dlm_download {
4
+
5
+ ul.wp-submenu {
6
+
7
+ li {
8
+
9
+ & > a {
10
+ padding:7px 12px;
11
+ }
12
+ // Lite vs PRO menu link
13
+ a[href$="dlm-lite-vs-pro"] {
14
+ color: gold;
15
+ }
16
+
17
+ a[href$="edit-tags.php?taxonomy=dlm_download_tag&post_type=dlm_download"],
18
+ a[href$="edit.php?post_type=dlm_download&page=download-monitor-settings"],
19
+ a[href$="edit.php?post_type=dlm_download&page=download-monitor-reports"]{
20
+ border-bottom: 1px solid hsla(0,0%,100%,.2);
21
+ }
22
+ }
23
+ }
24
+ }
25
+ }
26
+
27
+ /* LU upgrade notice */
28
+ .dlm-lu-upgrade-notice {
29
+ position: relative;
30
+ padding: 1em;
31
+ margin: 3em 1em 1em 0;
32
+ color: #fff;
33
+ background: #419ccb;
34
+ box-shadow: 2px 2px 1px grey;
35
+
36
+ h3, a {
37
+ color: #fff;
38
+ }
39
+ h3 {
40
+ margin-top: 0;
41
+ }
42
+
43
+ p {
44
+ font-size: 1.05em;
45
+ a {
46
+ font-weight: bold;
47
+ }
48
+ }
49
+ a.dlm-lu-upgrade-notice-hide {
50
+ position: absolute;
51
+ top: 10px;
52
+ right: 10px;
53
+ text-decoration: none;
54
+ font-size: 0.95em;
55
+ }
56
+ }
57
+
58
+ .dlm-onboarding-notice {
59
+ border-left-color: #419ccb;
60
+
61
+ &:before {
62
+ display: inline-block;
63
+ position:absolute;
64
+ top:0;
65
+ left:0;
66
+ width: 35px;
67
+ height: 100%;
68
+ content:"";
69
+ background-color: #419ccb;
70
+ background-image: url('../images/logo.png');
71
+ background-size: 29px 28px;
72
+ background-position: 1px center;
73
+ background-repeat: no-repeat;
74
+ }
75
+ p {
76
+ padding-left: 33px;
77
+ }
78
+ }
79
+
80
+ /**
81
+ * Media Library visual indicator that a file is protected by DLM
82
+ */
83
+
84
+ .dlm-ml-protected-file {
85
+ .thumbnail {
86
+ box-shadow: 0 0 .5rem rgba(0,0,255,.45);
87
+ }
88
+ &:after{
89
+ content:"";
90
+ background:url( "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjgiIGhlaWdodD0iMjgiIHZpZ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2VPblVzZSI+CjxzdG9wIG9mZnNldD0iMC4xMTAxMTMiIHN0b3AtY29sb3I9IiM1RERFRkIiLz4KPHN0b3Agb2Zmc2V0PSIwLjQ0MzU2OCIgc3RvcC1jb2xvcj0iIzQxOUJDQSIvPgo8c3RvcCBvZmZzZXQ9IjAuNjM2MTIyIiBzdG9wLWNvbG9yPSIjMDA4Q0Q1Ii8+CjxzdG9wIG9mZnNldD0iMSIgc3RvcC1jb2xvcj0iIzAyNUVBMCIvPgo8L2xpbmVhckdyYWRpZW50Pgo8L2RlZnM+Cjwvc3ZnPgo=" );
91
+ display:block;
92
+ width:20px;
93
+ height:20px;
94
+ z-index:999;
95
+ position: absolute;
96
+ top:15px;
97
+ right:15px;
98
+ background-size:contain;
99
+ }
100
+ }
assets/css/others.min.css ADDED
@@ -0,0 +1 @@
 
1
+ #adminmenu #menu-posts-dlm_download ul.wp-submenu li>a{padding:7px 12px}#adminmenu #menu-posts-dlm_download ul.wp-submenu li a[href$=dlm-lite-vs-pro]{color:gold}#adminmenu #menu-posts-dlm_download ul.wp-submenu li a[href$="edit-tags.php?taxonomy=dlm_download_tag&post_type=dlm_download"],#adminmenu #menu-posts-dlm_download ul.wp-submenu li a[href$="edit.php?post_type=dlm_download&page=download-monitor-reports"],#adminmenu #menu-posts-dlm_download ul.wp-submenu li a[href$="edit.php?post_type=dlm_download&page=download-monitor-settings"]{border-bottom:1px solid hsla(0,0%,100%,.2)}.dlm-lu-upgrade-notice{position:relative;padding:1em;margin:3em 1em 1em 0;color:#fff;background:#419ccb;box-shadow:2px 2px 1px grey}.dlm-lu-upgrade-notice a,.dlm-lu-upgrade-notice h3{color:#fff}.dlm-lu-upgrade-notice h3{margin-top:0}.dlm-lu-upgrade-notice p{font-size:1.05em}.dlm-lu-upgrade-notice p a{font-weight:700}.dlm-lu-upgrade-notice a.dlm-lu-upgrade-notice-hide{position:absolute;top:10px;right:10px;text-decoration:none;font-size:.95em}.dlm-onboarding-notice{border-left-color:#419ccb}.dlm-onboarding-notice:before{display:inline-block;position:absolute;top:0;left:0;width:35px;height:100%;content:"";background-color:#419ccb;background-image:url('../images/logo.png');background-size:29px 28px;background-position:1px center;background-repeat:no-repeat}.dlm-onboarding-notice p{padding-left:33px}.dlm-ml-protected-file .thumbnail{box-shadow:0 0 .5rem rgba(0,0,255,.45)}.dlm-ml-protected-file:after{content:"";background:url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjgiIGhlaWdodD0iMjgiIHZpZXdCb3g9IjAgMCAyOCAyOCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTI4IDE0QzI4IDYuMjY4MDEgMjEuNzMyIDAgMTQgMEM2LjI2ODAxIDAgMCA2LjI2ODAxIDAgMTRDMCAyMS43MzIgNi4yNjgwMSAyOCAxNCAyOEMyMS43MzIgMjggMjggMjEuNzMyIDI4IDE0WiIgZmlsbD0idXJsKCNwYWludDBfbGluZWFyXzM2XzM5KSIvPgo8cGF0aCBkPSJNMTcuNjE1NCAxMi41NjI1SDE3LjM3NVY5LjUxNTYyQzE3LjM3NSA4LjU4MzIyIDE2Ljk5NTEgNy42ODkwMSAxNi4zMTg5IDcuMDI5N0MxNS42NDI3IDYuMzcwNCAxNC43MjU1IDYgMTMuNzY5MiA2QzEyLjgxMjkgNiAxMS44OTU4IDYuMzcwNCAxMS4yMTk2IDcuMDI5N0MxMC41NDM0IDcuNjg5MDEgMTAuMTYzNSA4LjU4MzIyIDEwLjE2MzUgOS41MTU2MlYxMi41NjI1SDkuOTIzMDhDOS40MTMwNSAxMi41NjI1IDguOTIzOSAxMi43NiA4LjU2MzI2IDEzLjExMTdDOC4yMDI2MSAxMy40NjMzIDggMTMuOTQwMiA4IDE0LjQzNzVWMTkuMTI1QzggMTkuNjIyMyA4LjIwMjYxIDIwLjA5OTIgOC41NjMyNiAyMC40NTA4QzguOTIzOSAyMC44MDI1IDkuNDEzMDUgMjEgOS45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5QzE0LjE5OTMgMTUuMzY1OCAxNC4yNSAxNS40ODUxIDE0LjI1IDE1LjYwOTRWMTcuOTUzMVoiIGZpbGw9IndoaXRlIi8+CjxkZWZzPgo8bGluZWFyR3JhZGllbnQgaWQ9InBhaW50MF9saW5lYXJfMzZfMzkiIHgxPSItNy41NDY4NyIgeTE9Ii00LjM3NSIgeDI9IjI1LjU5MzciIHkyPSIyOC43NjU2IiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+CjxzdG9wIG9mZnNldD0iMC4xMTAxMTMiIHN0b3AtY29sb3I9IiM1RERFRkIiLz4KPHN0b3Agb2Zmc2V0PSIwLjQ0MzU2OCIgc3RvcC1jb2xvcj0iIzQxOUJDQSIvPgo8c3RvcCBvZmZzZXQ9IjAuNjM2MTIyIiBzdG9wLWNvbG9yPSIjMDA4Q0Q1Ii8+CjxzdG9wIG9mZnNldD0iMSIgc3RvcC1jb2xvcj0iIzAyNUVBMCIvPgo8L2xpbmVhckdyYWRpZW50Pgo8L2RlZnM+Cjwvc3ZnPgo=");display:block;width:20px;height:20px;z-index:999;position:absolute;top:15px;right:15px;background-size:contain}
assets/js/download-operations.js ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery( function ($) {
2
+ // Browse for file
3
+ jQuery( 'body' ).on( 'click', 'a.dlm_insert_download', function () {
4
+
5
+ tb_show( dlm_id_strings.insert_download, 'media-upload.php?type=add_download&from=wpdlm01&TB_iframe=true&height=200' );
6
+
7
+ return false;
8
+ } );
9
+
10
+ $(document).on('click', '#dlm-protect-file', function (e) {
11
+ // Prevent default for form submission
12
+ e.preventDefault();
13
+
14
+ const objectData = $(this).data(),
15
+ button = $(this),
16
+ buttonText = button.text(),
17
+ data = {
18
+ action : ('protect_file' === objectData.action) ? 'dlm_protect_file' : 'dlm_unprotect_file',
19
+ title : objectData.title,
20
+ _ajax_nonce : objectData.nonce,
21
+ user_id : objectData.user_id,
22
+ file : objectData.file,
23
+ attachment_id: objectData.post_id
24
+ }
25
+ button.attr('disabled', 'disabled');
26
+ button.text('Please wait...');
27
+
28
+ $.post(ajaxurl, data, function (response) {
29
+ if (response.success) {
30
+ button.text(response.data.text);
31
+ if (response.data.url) {
32
+ button.parents('.attachment-info').find('#attachment-details-two-column-copy-link').val(response.data.url);
33
+ jQuery('#attachment_url').val(response.data.url);
34
+ }
35
+ const nextAction = ('protect_file' === objectData.action) ? 'unprotect_file' : 'protect_file';
36
+ button.data('action', nextAction);
37
+
38
+ setTimeout(function () {
39
+ const nextButtonText = ('protect_file' === nextAction) ? 'Protect File' : 'Unprotect File';
40
+ button.text(nextButtonText);
41
+ button.removeAttr('disabled');
42
+ }, 3000);
43
+ } else {
44
+ button.text(response.data);
45
+ setTimeout(function () {
46
+ button.text(buttonText);
47
+ button.removeAttr('disabled');
48
+ }, 3000);
49
+ }
50
+ });
51
+ });
52
+ });
assets/js/download-operations.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(function(n){jQuery("body").on("click","a.dlm_insert_download",function(){return tb_show(dlm_id_strings.insert_download,"media-upload.php?type=add_download&from=wpdlm01&TB_iframe=true&height=200"),!1}),n(document).on("click","#dlm-protect-file",function(t){t.preventDefault();const a=n(this).data(),i=n(this),o=i.text(),e={action:"protect_file"===a.action?"dlm_protect_file":"dlm_unprotect_file",title:a.title,_ajax_nonce:a.nonce,user_id:a.user_id,file:a.file,attachment_id:a.post_id};i.attr("disabled","disabled"),i.text("Please wait..."),n.post(ajaxurl,e,function(t){if(t.success){i.text(t.data.text),t.data.url&&(i.parents(".attachment-info").find("#attachment-details-two-column-copy-link").val(t.data.url),jQuery("#attachment_url").val(t.data.url));const e="protect_file"===a.action?"unprotect_file":"protect_file";i.data("action",e),setTimeout(function(){var t="protect_file"==e?"Protect File":"Unprotect File";i.text(t),i.removeAttr("disabled")},3e3)}else i.text(t.data),setTimeout(function(){i.text(o),i.removeAttr("disabled")},3e3)})})});
assets/js/edit-download.js CHANGED
@@ -54,7 +54,8 @@ jQuery(function ($) {
54
  * @param {*} file
55
  */
56
  dlmAddFileToPath: function (up, file) {
57
- const fileUrl = file.attachment.attributes.url;
 
58
  // Check if is subjective upload or general one
59
  if ('plupload-browse-button' !== jQuery(up.settings.browse_button).attr('id')) {
60
  const fileURLs = jQuery(up.settings.browse_button).parents('.dlm-file-version__row').find('textarea');
@@ -63,7 +64,7 @@ jQuery(function ($) {
63
  let filePaths = fileURLs.val();
64
  filePaths = filePaths ? filePaths + "\n" + fileUrl : fileUrl;
65
  fileURLs.val(filePaths);
66
- dlmEditInstance.afterAddFile(fileURLs);
67
  } else {
68
  // It's a general update so we need to create a new File Version
69
  dlmEditInstance.addNewFile();
@@ -81,7 +82,7 @@ jQuery(function ($) {
81
  if (null !== version) {
82
  versionInpout.val(version);
83
  }
84
- dlmEditInstance.afterAddFile(fileURLs);
85
  // Unbind event
86
  object.off(e);
87
  });
@@ -710,9 +711,28 @@ jQuery(function ($) {
710
  *
711
  * @param $element
712
  */
713
- afterAddFile($element) {
714
  $element.parents('.dlm-file-version__row').find('.dlm-file-version__drag_and_drop').addClass('hidden');
715
  $element.parents('.dlm-file-version__row').find('.dlm-file-version__file_present').removeClass('hidden');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
716
  }
717
  }
718
 
54
  * @param {*} file
55
  */
56
  dlmAddFileToPath: function (up, file) {
57
+ const fileUrl = file.attachment.attributes.url;
58
+
59
  // Check if is subjective upload or general one
60
  if ('plupload-browse-button' !== jQuery(up.settings.browse_button).attr('id')) {
61
  const fileURLs = jQuery(up.settings.browse_button).parents('.dlm-file-version__row').find('textarea');
64
  let filePaths = fileURLs.val();
65
  filePaths = filePaths ? filePaths + "\n" + fileUrl : fileUrl;
66
  fileURLs.val(filePaths);
67
+ dlmEditInstance.afterAddFile(fileURLs, file, up);
68
  } else {
69
  // It's a general update so we need to create a new File Version
70
  dlmEditInstance.addNewFile();
82
  if (null !== version) {
83
  versionInpout.val(version);
84
  }
85
+ dlmEditInstance.afterAddFile(fileURLs, file, up);
86
  // Unbind event
87
  object.off(e);
88
  });
711
  *
712
  * @param $element
713
  */
714
+ afterAddFile($element, file = null, up = null) {
715
  $element.parents('.dlm-file-version__row').find('.dlm-file-version__drag_and_drop').addClass('hidden');
716
  $element.parents('.dlm-file-version__row').find('.dlm-file-version__file_present').removeClass('hidden');
717
+ if ( null !== file && null !== up ) {
718
+ const file_id = file.attachment.id,
719
+ nonce = $('#dlm-ajax-nonce-add-file').val(),
720
+ download_id = parseInt(jQuery('input#post_ID').val()),
721
+ version_id = $element.parents('.downloadable_files').find( '.downloadable_file' ).first().data('file'),
722
+ data = {
723
+ action : 'dlm_update_file_meta',
724
+ file_id : file_id,
725
+ version_id : version_id,
726
+ download_id: download_id,
727
+ nonce : nonce
728
+ };
729
+
730
+ jQuery.post(ajaxurl, data, function (response) {
731
+ if (!response.success) {
732
+ console.log('Error saving attachment meta');
733
+ }
734
+ });
735
+ }
736
  }
737
  }
738
 
assets/js/edit-download.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(function(d){var t=[],i={};function o(){jQuery(".downloadable_files .downloadable_file").each(function(e,n){jQuery(".file_menu_order",n).val(parseInt(jQuery(n).index(".downloadable_files .downloadable_file")))})}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(e,n){n.item.css("background-color","#f6f6f6")},stop:function(e,n){n.item.removeAttr("style"),o()}}),window.send_to_browse_file_url=function(e){e&&((old=jQuery.trim(jQuery(downloadable_files_field).val()))&&(old+="\n"),jQuery(downloadable_files_field).val(old+e)),tb_remove(),window.send_to_editor=window.send_to_editor_default},new class{constructor(){(dlmEditInstance=this).init()}init(){this.createUploaders(),this.initUploaders(),this.newFileAction(),this.removeFileAction(),this.clickActions()}createUploaders(){var e=Backbone.Model.extend({initialize:function(e){this.uploaderOptions=e,dlmUploaderInstance=this;const n=new wp.Uploader(dlmUploaderInstance.uploaderOptions),o=n.dropzone;o.on("dropzone:enter",dlmUploaderInstance.show),o.on("dropzone:leave",dlmUploaderInstance.hide),n.uploader.bind("FilesAdded",dlmUploaderInstance.dlmFileAdded),n.uploader.bind("FileUploaded",dlmUploaderInstance.dlmAddFileToPath),n.uploader.bind("Error",dlmUploaderInstance.dlmUploadError),n.uploader.bind("UploadProgress",dlmUploaderInstance.uploadProgress)},dlmAddFileToPath:function(i,r){const a=r.attachment.attributes.url;if("plupload-browse-button"!==jQuery(i.settings.browse_button).attr("id")){const n=jQuery(i.settings.browse_button).parents(".dlm-file-version__row").find("textarea");dlmUploaderInstance.endUploadProgress(n.parents(".dlm-file-version__row"));let e=n.val();e=e?e+"\n"+a:a,n.val(e),dlmEditInstance.afterAddFile(n)}else dlmEditInstance.addNewFile(),jQuery(document).on("dlm_new_file_added",function(e){const n=jQuery(this),o=jQuery(".dlm-metaboxes.downloadable_files").find(".downloadable_file").first(),l=o.find("textarea"),t=dlmUploaderInstance.retrieveVersion(r),d=o.find('input[name*="downloadable_file_version"]');dlmUploaderInstance.endUploadProgress(jQuery(i.settings.container).parents("#dlm-new-upload")),l.val(a),null!==t&&d.val(t),dlmEditInstance.afterAddFile(l),n.off(e)})},dlmFileAdded:function(e,n){if("plupload-browse-button"!==jQuery(e.settings.browse_button).attr("id")){const o=jQuery(e.settings.browse_button).parents(".dlm-file-version__row").find("textarea");dlmUploaderInstance.startUploadProgress(o.parents(".dlm-file-version__row"))}else dlmUploaderInstance.startUploadProgress(jQuery(e.settings.container).parents("#dlm-new-upload"))},dlmUploadError:function(e,n){jQuery(e.settings.browse_button).parent().append('<p class="error description" style="color:red;">'+n.message+"</p>"),setTimeout(function(){jQuery(e.settings.browse_button).parent().find(".error.description").remove()},3500)},uploadProgress:function(e,n){jQuery(e.settings.container).parent().parent().find(".dlm-uploading-file label span").html(e.total.percent+"%"),jQuery(e.settings.container).parent().parent().find(".dlm-uploading-file .dlm-uploading-progress-bar").css({width:e.total.percent+"%"})},retrieveVersion:function(e){const n=e.name;if(n.indexOf("-")<0)return null;let o=n.split("-")[1],l=o.split(".");return l=l.pop(),(o=o.slice(0,-(l.length+1))).length?o:null},startUploadProgress:function(e){e.find(".dlm-uploading-file").removeClass("hidden")},endUploadProgress:function(e){e.find(".dlm-uploading-file label").toggleClass("hidden"),setTimeout(function(){e.find(".dlm-uploading-file").addClass("hidden"),e.find(".dlm-uploading-file label").toggleClass("hidden")},1500)}}),n=Backbone.View.extend({tagName:"div",className:"dlm-uploader-editor",template:wp.template("uploader-editor"),localDrag:!1,overContainer:!1,overDropzone:!1,draggingFile:null,args:{},elementContainer:null,initialize:function(e){return this.initialized=!1,this.args=e,this.elementContainer=jQuery(this.args.container[0]).attr("id"),window.tinyMCEPreInit&&window.tinyMCEPreInit.dragDropUpload&&this.browserSupport()&&(this.$document=d(document),this.dropzone=null,this.files=[],this.$document.on("drop","#"+this.elementContainer+" .dlm-uploader-editor",_.bind(this.drop,this)),this.$document.on("click","#"+this.elementContainer+" .dlm-uploader-editor",_.bind(this.click,this)),this.$document.on("dragover","#"+this.elementContainer+" .dlm-uploader-editor",_.bind(this.dropzoneDragover,this)),this.$document.on("dragleave","#"+this.elementContainer+" .dlm-uploader-editor",_.bind(this.dropzoneDragleave,this)),this.$document.on("dragover",_.bind(this.containerDragover,this)),this.$document.on("dragleave",_.bind(this.containerDragleave,this)),this.$document.on("dragstart dragend drop",_.bind(function(e){this.localDrag="dragstart"===e.type,"drop"===e.type&&this.containerDragleave()},this)),this.initialized=!0),this},browserSupport:function(){var e=document.createElement("div");return("draggable"in e||"ondragstart"in e&&"ondrop"in e)&&!!(window.File&&window.FileList&&window.FileReader)},isDraggingFile:function(e){return null!==this.draggingFile?this.draggingFile:!_.isUndefined(e.originalEvent)&&!_.isUndefined(e.originalEvent.dataTransfer)&&(this.draggingFile=-1<_.indexOf(e.originalEvent.dataTransfer.types,"Files")&&-1===_.indexOf(e.originalEvent.dataTransfer.types,"text/plain"),this.draggingFile)},refresh:function(e){return this.dropzone.toggle(this.overContainer||this.overDropzone),_.isUndefined(e)||d(e.target).closest(".dlm-uploader-editor").toggleClass("droppable",this.overDropzone),this.overContainer||this.overDropzone||(this.draggingFile=null),this},render:function(){return this.initialized&&(this.$el.html(this.template()),jQuery("#"+this.elementContainer).append(this.$el),this.dropzone=this.$el),this},containerDragover:function(e){!this.localDrag&&this.isDraggingFile(e)&&(this.overContainer=!0,this.refresh())},containerDragleave:function(){this.overContainer=!1,_.delay(_.bind(this.refresh,this),50)},dropzoneDragover:function(e){if(!this.localDrag&&this.isDraggingFile(e))return this.overDropzone=!0,this.refresh(e),!1},dropzoneDragleave:function(e){this.overDropzone=!1,_.delay(_.bind(this.refresh,this,e),50)},drop:function(e){return this.containerDragleave(e),this.dropzoneDragleave(e),!1},click:function(e){this.containerDragleave(e),this.dropzoneDragleave(e),this.localDrag=!1}});i.uploadHandlerModel=e,i.uploadHandlerView=n}initUploaders(){var e={browser:jQuery("#plupload-browse-button"),plupload:{multi_selection:!1},params:{type:"dlm_download"},container:jQuery("#drag-drop-area"),dropzone:jQuery("#drag-drop-area")};new i.uploadHandlerModel(e);const n=new i.uploadHandlerView(e);n.render(),t.push(jQuery("#plupload-browse-button")),d(".dlm_upload_file:not(#plupload-browse-button)").each((e,n)=>{t.push(d(n));const o={browser:d(n),plupload:{multi_selection:!1},params:{type:"dlm_download"},container:d(n).parents("div.dlm-uploader-container"),dropzone:d(n).parents("div.dlm-uploader-container")},l=(new i.uploadHandlerModel(o),new i.uploadHandlerView(o));l.render()})}newFileAction(){d(document).on("dlm_new_file_added",()=>{d(".dlm_upload_file:not(#plupload-browse-button)").each((e,n)=>{if(t.includes(d(n)))return!0;t.push(d(n));const o={browser:d(n),plupload:{multi_selection:!1},params:{type:"dlm_download"},container:d(n).parents("div.dlm-uploader-container"),dropzone:d(n).parents("div.dlm-uploader-container")},l=(new i.uploadHandlerModel(o),new i.uploadHandlerView(o));l.render()}),jQuery("#dlm-new-upload").hide();var e=jQuery(".downloadable_file");0!==e.length&&(jQuery(".dlm-versions-tab").show(),jQuery(".dlm-versions-tab .dlm-versions-number").html("("+e.length+")"))})}removeFileAction(){d(document).on("dlm_remove_file",()=>{0===jQuery(".downloadable_files").find(".dlm-metabox.downloadable_file").length&&jQuery("#dlm-new-upload").show()})}clickActions(){const t=this;jQuery(".dlm-metaboxes-wrapper").on("click",".dlm-metabox h3",function(e){if(!jQuery(e.target).filter(":input, option").length){const n=jQuery(this),o=n.next(".dlm-metabox-content");n.toggleClass("opened"),o.toggle(),jQuery(".dlm-metabox h3").not(n).removeClass("opened"),jQuery(".dlm-metabox-content").not(o).hide()}}),jQuery(".download_monitor_files").on("click","a.add_file",function(e){e.preventDefault(),t.addNewFile()}),jQuery(".download_monitor_files").on("click",".remove_file",function(e){var n;return e.preventDefault(),confirm(dlm_ed_strings.confirm_delete)&&(0<(e=(n=jQuery(this).closest(".downloadable_file")).attr("data-file"))?(jQuery(n).block({message:null,overlayCSS:{background:"#fff url("+d("#dlm-plugin-url").val()+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}}),e={action:"download_monitor_remove_file",file_id:e,download_id:d("#dlm-post-id").val(),security:d("#dlm-ajax-nonce-remove-file").val()},jQuery.post(ajaxurl,e,function(e){jQuery(n).fadeOut("300").remove(),jQuery(document).trigger("dlm_remove_file",[this,n])})):jQuery(n).fadeOut("300").remove()),!1}),jQuery(".download_monitor_files").on("click","a.dlm_browse_for_file",function(e){if(e.preventDefault(),!(0<jQuery(this).parents("#dlm-new-upload").length))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="+d("#dlm-post-id").val()+"&amp;type=downloadable_file_browser&amp;from=wpdlm01&amp;TB_iframe=true"),dlmEditInstance.afterAddFile(downloadable_files_field),!1;t.addNewFile(),jQuery(document).on("dlm_new_file_added",function(e){const n=jQuery(this);return downloadable_files_field=jQuery(".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="+d("#dlm-post-id").val()+"&amp;type=downloadable_file_browser&amp;from=wpdlm01&amp;TB_iframe=true"),n.off(e),dlmEditInstance.afterAddFile(downloadable_files_field),!1})}),jQuery(".download_monitor_files").on("click","a.dlm_external_source",function(e){if(e.preventDefault(),!(0<jQuery(this).parents("#dlm-new-upload").length))return downloadable_files_field=jQuery(this).closest(".downloadable_file").find('textarea[name^="downloadable_file_urls"]'),dlmEditInstance.afterAddFile(downloadable_files_field),!1;t.addNewFile(),jQuery(document).on("dlm_new_file_added",function(e){const n=jQuery(this);return downloadable_files_field=jQuery(".downloadable_file").find('textarea[name^="downloadable_file_urls"]'),n.off(e),dlmEditInstance.afterAddFile(downloadable_files_field),!1})}),jQuery(document).on("click",".dlm_media_library",function(e){e.preventDefault();var o=d(this),l=null;0<jQuery(this).parents("#dlm-new-upload").length?(t.addNewFile(),jQuery(document).on("dlm_new_file_added",function(e){const n=jQuery(this);l=jQuery("textarea.downloadable_file_urls");t.addBrowsedFile(o,l,"",void 0),n.off(e),dlmEditInstance.afterAddFile(l)})):(e=(l=o.parents(".dlm-file-version__row").find(".downloadable_file_urls")).val(),t.addBrowsedFile(o,l,e,void 0),dlmEditInstance.afterAddFile(l))}),d(".copy-dlm-button").on("click",function(e){e.preventDefault();e=d(this).parent().find("input");e.focus(),e.select(),document.execCommand("copy"),d(this).next("span").text(d(this).data("item")+" copied"),d(".copy-dlm-button").not(d(this)).parent().find("span").text("")}),jQuery(document).on("dlm_remove_file",function(e,n,o){var l=jQuery(".downloadable_file");0===l.length?jQuery(".dlm-versions-tab").hide():jQuery(".dlm-versions-tab .dlm-versions-number").html("("+l.length+")")})}addNewFile(){jQuery(".download_monitor_files").block({message:null,overlayCSS:{background:"#fff url("+d("#dlm-plugin-url").val()+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var e=jQuery(".downloadable_files .downloadable_file").length,e={action:"download_monitor_add_file",post_id:d("#dlm-post-id").val(),size:e,security:d("#dlm-ajax-nonce-add-file").val()};return jQuery.post(ajaxurl,e,function(e){jQuery(".downloadable_files").prepend(e),o(),jQuery(".download_monitor_files").unblock(),jQuery(".date-picker-field").datepicker({dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:!0}),jQuery(document).trigger("dlm_new_file_added",[this,e])}),!1}addBrowsedFile(e,n,o,l){l&&l.close();var t=[new wp.media.controller.Library({library:wp.media.query(),multiple:!0,title:e.data("choose"),priority:20,filterable:"all"})];(l=wp.media.frames.downloadable_file=wp.media({title:e.data("choose"),library:{type:""},button:{text:e.data("update")},multiple:!0,states:t})).on("select",function(){l.state().get("selection").map(function(e){(e=e.toJSON()).url&&(o=o?o+"\n"+e.url:e.url)}),n.val(o)}),l.on("ready",function(){l.uploader.options.uploader.params={type:"dlm_download"}}),l.open()}afterAddFile(e){e.parents(".dlm-file-version__row").find(".dlm-file-version__drag_and_drop").addClass("hidden"),e.parents(".dlm-file-version__row").find(".dlm-file-version__file_present").removeClass("hidden")}}});
1
+ jQuery(function(d){var t=[],i={};function o(){jQuery(".downloadable_files .downloadable_file").each(function(e,n){jQuery(".file_menu_order",n).val(parseInt(jQuery(n).index(".downloadable_files .downloadable_file")))})}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(e,n){n.item.css("background-color","#f6f6f6")},stop:function(e,n){n.item.removeAttr("style"),o()}}),window.send_to_browse_file_url=function(e){e&&((old=jQuery.trim(jQuery(downloadable_files_field).val()))&&(old+="\n"),jQuery(downloadable_files_field).val(old+e)),tb_remove(),window.send_to_editor=window.send_to_editor_default},new class{constructor(){(dlmEditInstance=this).init()}init(){this.createUploaders(),this.initUploaders(),this.newFileAction(),this.removeFileAction(),this.clickActions()}createUploaders(){var e=Backbone.Model.extend({initialize:function(e){this.uploaderOptions=e,dlmUploaderInstance=this;const n=new wp.Uploader(dlmUploaderInstance.uploaderOptions),o=n.dropzone;o.on("dropzone:enter",dlmUploaderInstance.show),o.on("dropzone:leave",dlmUploaderInstance.hide),n.uploader.bind("FilesAdded",dlmUploaderInstance.dlmFileAdded),n.uploader.bind("FileUploaded",dlmUploaderInstance.dlmAddFileToPath),n.uploader.bind("Error",dlmUploaderInstance.dlmUploadError),n.uploader.bind("UploadProgress",dlmUploaderInstance.uploadProgress)},dlmAddFileToPath:function(i,r){const a=r.attachment.attributes.url;if("plupload-browse-button"!==jQuery(i.settings.browse_button).attr("id")){const n=jQuery(i.settings.browse_button).parents(".dlm-file-version__row").find("textarea");dlmUploaderInstance.endUploadProgress(n.parents(".dlm-file-version__row"));let e=n.val();e=e?e+"\n"+a:a,n.val(e),dlmEditInstance.afterAddFile(n,r,i)}else dlmEditInstance.addNewFile(),jQuery(document).on("dlm_new_file_added",function(e){const n=jQuery(this),o=jQuery(".dlm-metaboxes.downloadable_files").find(".downloadable_file").first(),l=o.find("textarea"),t=dlmUploaderInstance.retrieveVersion(r),d=o.find('input[name*="downloadable_file_version"]');dlmUploaderInstance.endUploadProgress(jQuery(i.settings.container).parents("#dlm-new-upload")),l.val(a),null!==t&&d.val(t),dlmEditInstance.afterAddFile(l,r,i),n.off(e)})},dlmFileAdded:function(e,n){if("plupload-browse-button"!==jQuery(e.settings.browse_button).attr("id")){const o=jQuery(e.settings.browse_button).parents(".dlm-file-version__row").find("textarea");dlmUploaderInstance.startUploadProgress(o.parents(".dlm-file-version__row"))}else dlmUploaderInstance.startUploadProgress(jQuery(e.settings.container).parents("#dlm-new-upload"))},dlmUploadError:function(e,n){jQuery(e.settings.browse_button).parent().append('<p class="error description" style="color:red;">'+n.message+"</p>"),setTimeout(function(){jQuery(e.settings.browse_button).parent().find(".error.description").remove()},3500)},uploadProgress:function(e,n){jQuery(e.settings.container).parent().parent().find(".dlm-uploading-file label span").html(e.total.percent+"%"),jQuery(e.settings.container).parent().parent().find(".dlm-uploading-file .dlm-uploading-progress-bar").css({width:e.total.percent+"%"})},retrieveVersion:function(e){const n=e.name;if(n.indexOf("-")<0)return null;let o=n.split("-")[1],l=o.split(".");return l=l.pop(),(o=o.slice(0,-(l.length+1))).length?o:null},startUploadProgress:function(e){e.find(".dlm-uploading-file").removeClass("hidden")},endUploadProgress:function(e){e.find(".dlm-uploading-file label").toggleClass("hidden"),setTimeout(function(){e.find(".dlm-uploading-file").addClass("hidden"),e.find(".dlm-uploading-file label").toggleClass("hidden")},1500)}}),n=Backbone.View.extend({tagName:"div",className:"dlm-uploader-editor",template:wp.template("uploader-editor"),localDrag:!1,overContainer:!1,overDropzone:!1,draggingFile:null,args:{},elementContainer:null,initialize:function(e){return this.initialized=!1,this.args=e,this.elementContainer=jQuery(this.args.container[0]).attr("id"),window.tinyMCEPreInit&&window.tinyMCEPreInit.dragDropUpload&&this.browserSupport()&&(this.$document=d(document),this.dropzone=null,this.files=[],this.$document.on("drop","#"+this.elementContainer+" .dlm-uploader-editor",_.bind(this.drop,this)),this.$document.on("click","#"+this.elementContainer+" .dlm-uploader-editor",_.bind(this.click,this)),this.$document.on("dragover","#"+this.elementContainer+" .dlm-uploader-editor",_.bind(this.dropzoneDragover,this)),this.$document.on("dragleave","#"+this.elementContainer+" .dlm-uploader-editor",_.bind(this.dropzoneDragleave,this)),this.$document.on("dragover",_.bind(this.containerDragover,this)),this.$document.on("dragleave",_.bind(this.containerDragleave,this)),this.$document.on("dragstart dragend drop",_.bind(function(e){this.localDrag="dragstart"===e.type,"drop"===e.type&&this.containerDragleave()},this)),this.initialized=!0),this},browserSupport:function(){var e=document.createElement("div");return("draggable"in e||"ondragstart"in e&&"ondrop"in e)&&!!(window.File&&window.FileList&&window.FileReader)},isDraggingFile:function(e){return null!==this.draggingFile?this.draggingFile:!_.isUndefined(e.originalEvent)&&!_.isUndefined(e.originalEvent.dataTransfer)&&(this.draggingFile=-1<_.indexOf(e.originalEvent.dataTransfer.types,"Files")&&-1===_.indexOf(e.originalEvent.dataTransfer.types,"text/plain"),this.draggingFile)},refresh:function(e){return this.dropzone.toggle(this.overContainer||this.overDropzone),_.isUndefined(e)||d(e.target).closest(".dlm-uploader-editor").toggleClass("droppable",this.overDropzone),this.overContainer||this.overDropzone||(this.draggingFile=null),this},render:function(){return this.initialized&&(this.$el.html(this.template()),jQuery("#"+this.elementContainer).append(this.$el),this.dropzone=this.$el),this},containerDragover:function(e){!this.localDrag&&this.isDraggingFile(e)&&(this.overContainer=!0,this.refresh())},containerDragleave:function(){this.overContainer=!1,_.delay(_.bind(this.refresh,this),50)},dropzoneDragover:function(e){if(!this.localDrag&&this.isDraggingFile(e))return this.overDropzone=!0,this.refresh(e),!1},dropzoneDragleave:function(e){this.overDropzone=!1,_.delay(_.bind(this.refresh,this,e),50)},drop:function(e){return this.containerDragleave(e),this.dropzoneDragleave(e),!1},click:function(e){this.containerDragleave(e),this.dropzoneDragleave(e),this.localDrag=!1}});i.uploadHandlerModel=e,i.uploadHandlerView=n}initUploaders(){var e={browser:jQuery("#plupload-browse-button"),plupload:{multi_selection:!1},params:{type:"dlm_download"},container:jQuery("#drag-drop-area"),dropzone:jQuery("#drag-drop-area")};new i.uploadHandlerModel(e);const n=new i.uploadHandlerView(e);n.render(),t.push(jQuery("#plupload-browse-button")),d(".dlm_upload_file:not(#plupload-browse-button)").each((e,n)=>{t.push(d(n));const o={browser:d(n),plupload:{multi_selection:!1},params:{type:"dlm_download"},container:d(n).parents("div.dlm-uploader-container"),dropzone:d(n).parents("div.dlm-uploader-container")},l=(new i.uploadHandlerModel(o),new i.uploadHandlerView(o));l.render()})}newFileAction(){d(document).on("dlm_new_file_added",()=>{d(".dlm_upload_file:not(#plupload-browse-button)").each((e,n)=>{if(t.includes(d(n)))return!0;t.push(d(n));const o={browser:d(n),plupload:{multi_selection:!1},params:{type:"dlm_download"},container:d(n).parents("div.dlm-uploader-container"),dropzone:d(n).parents("div.dlm-uploader-container")},l=(new i.uploadHandlerModel(o),new i.uploadHandlerView(o));l.render()}),jQuery("#dlm-new-upload").hide();var e=jQuery(".downloadable_file");0!==e.length&&(jQuery(".dlm-versions-tab").show(),jQuery(".dlm-versions-tab .dlm-versions-number").html("("+e.length+")"))})}removeFileAction(){d(document).on("dlm_remove_file",()=>{0===jQuery(".downloadable_files").find(".dlm-metabox.downloadable_file").length&&jQuery("#dlm-new-upload").show()})}clickActions(){const t=this;jQuery(".dlm-metaboxes-wrapper").on("click",".dlm-metabox h3",function(e){if(!jQuery(e.target).filter(":input, option").length){const n=jQuery(this),o=n.next(".dlm-metabox-content");n.toggleClass("opened"),o.toggle(),jQuery(".dlm-metabox h3").not(n).removeClass("opened"),jQuery(".dlm-metabox-content").not(o).hide()}}),jQuery(".download_monitor_files").on("click","a.add_file",function(e){e.preventDefault(),t.addNewFile()}),jQuery(".download_monitor_files").on("click",".remove_file",function(e){var n;return e.preventDefault(),confirm(dlm_ed_strings.confirm_delete)&&(0<(e=(n=jQuery(this).closest(".downloadable_file")).attr("data-file"))?(jQuery(n).block({message:null,overlayCSS:{background:"#fff url("+d("#dlm-plugin-url").val()+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}}),e={action:"download_monitor_remove_file",file_id:e,download_id:d("#dlm-post-id").val(),security:d("#dlm-ajax-nonce-remove-file").val()},jQuery.post(ajaxurl,e,function(e){jQuery(n).fadeOut("300").remove(),jQuery(document).trigger("dlm_remove_file",[this,n])})):jQuery(n).fadeOut("300").remove()),!1}),jQuery(".download_monitor_files").on("click","a.dlm_browse_for_file",function(e){if(e.preventDefault(),!(0<jQuery(this).parents("#dlm-new-upload").length))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="+d("#dlm-post-id").val()+"&amp;type=downloadable_file_browser&amp;from=wpdlm01&amp;TB_iframe=true"),dlmEditInstance.afterAddFile(downloadable_files_field),!1;t.addNewFile(),jQuery(document).on("dlm_new_file_added",function(e){const n=jQuery(this);return downloadable_files_field=jQuery(".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="+d("#dlm-post-id").val()+"&amp;type=downloadable_file_browser&amp;from=wpdlm01&amp;TB_iframe=true"),n.off(e),dlmEditInstance.afterAddFile(downloadable_files_field),!1})}),jQuery(".download_monitor_files").on("click","a.dlm_external_source",function(e){if(e.preventDefault(),!(0<jQuery(this).parents("#dlm-new-upload").length))return downloadable_files_field=jQuery(this).closest(".downloadable_file").find('textarea[name^="downloadable_file_urls"]'),dlmEditInstance.afterAddFile(downloadable_files_field),!1;t.addNewFile(),jQuery(document).on("dlm_new_file_added",function(e){const n=jQuery(this);return downloadable_files_field=jQuery(".downloadable_file").find('textarea[name^="downloadable_file_urls"]'),n.off(e),dlmEditInstance.afterAddFile(downloadable_files_field),!1})}),jQuery(document).on("click",".dlm_media_library",function(e){e.preventDefault();var o=d(this),l=null;0<jQuery(this).parents("#dlm-new-upload").length?(t.addNewFile(),jQuery(document).on("dlm_new_file_added",function(e){const n=jQuery(this);l=jQuery("textarea.downloadable_file_urls");t.addBrowsedFile(o,l,"",void 0),n.off(e),dlmEditInstance.afterAddFile(l)})):(e=(l=o.parents(".dlm-file-version__row").find(".downloadable_file_urls")).val(),t.addBrowsedFile(o,l,e,void 0),dlmEditInstance.afterAddFile(l))}),d(".copy-dlm-button").on("click",function(e){e.preventDefault();e=d(this).parent().find("input");e.focus(),e.select(),document.execCommand("copy"),d(this).next("span").text(d(this).data("item")+" copied"),d(".copy-dlm-button").not(d(this)).parent().find("span").text("")}),jQuery(document).on("dlm_remove_file",function(e,n,o){var l=jQuery(".downloadable_file");0===l.length?jQuery(".dlm-versions-tab").hide():jQuery(".dlm-versions-tab .dlm-versions-number").html("("+l.length+")")})}addNewFile(){jQuery(".download_monitor_files").block({message:null,overlayCSS:{background:"#fff url("+d("#dlm-plugin-url").val()+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var e=jQuery(".downloadable_files .downloadable_file").length,e={action:"download_monitor_add_file",post_id:d("#dlm-post-id").val(),size:e,security:d("#dlm-ajax-nonce-add-file").val()};return jQuery.post(ajaxurl,e,function(e){jQuery(".downloadable_files").prepend(e),o(),jQuery(".download_monitor_files").unblock(),jQuery(".date-picker-field").datepicker({dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:!0}),jQuery(document).trigger("dlm_new_file_added",[this,e])}),!1}addBrowsedFile(e,n,o,l){l&&l.close();var t=[new wp.media.controller.Library({library:wp.media.query(),multiple:!0,title:e.data("choose"),priority:20,filterable:"all"})];(l=wp.media.frames.downloadable_file=wp.media({title:e.data("choose"),library:{type:""},button:{text:e.data("update")},multiple:!0,states:t})).on("select",function(){l.state().get("selection").map(function(e){(e=e.toJSON()).url&&(o=o?o+"\n"+e.url:e.url)}),n.val(o)}),l.on("ready",function(){l.uploader.options.uploader.params={type:"dlm_download"}}),l.open()}afterAddFile(e,n=null,o=null){var l;e.parents(".dlm-file-version__row").find(".dlm-file-version__drag_and_drop").addClass("hidden"),e.parents(".dlm-file-version__row").find(".dlm-file-version__file_present").removeClass("hidden"),null!==n&&null!==o&&(o=n.attachment.id,n=d("#dlm-ajax-nonce-add-file").val(),l=parseInt(jQuery("input#post_ID").val()),e=e.parents(".downloadable_files").find(".downloadable_file").first().data("file"),jQuery.post(ajaxurl,{action:"dlm_update_file_meta",file_id:o,version_id:e,download_id:l,nonce:n},function(e){e.success||console.log("Error saving attachment meta")}))}}});
assets/js/insert-download.js DELETED
@@ -1,9 +0,0 @@
1
- jQuery( function ($) {
2
- // Browse for file
3
- jQuery( 'body' ).on( 'click', 'a.dlm_insert_download', function () {
4
-
5
- tb_show( dlm_id_strings.insert_download, 'media-upload.php?type=add_download&amp;from=wpdlm01&amp;TB_iframe=true&amp;height=200' );
6
-
7
- return false;
8
- } );
9
- } );
 
 
 
 
 
 
 
 
 
assets/js/insert-download.min.js DELETED
@@ -1 +0,0 @@
1
- jQuery(function(d){jQuery("body").on("click","a.dlm_insert_download",function(){return tb_show(dlm_id_strings.insert_download,"media-upload.php?type=add_download&amp;from=wpdlm01&amp;TB_iframe=true&amp;height=200"),!1})});
 
assets/js/legacy-upgrader/src/index.ejs CHANGED
@@ -241,7 +241,7 @@ var userSettings = {"url":"\/download-monitor\/","uid":"1","time":"1511968878","
241
  var dlm_id_strings = {"insert_download":"Insert Download"};
242
  /* ]]> */
243
  </script>
244
- <script type='text/javascript' src='http://lnmp.dev/download-monitor/wp-content/plugins/_download-monitor-new/assets/js/insert-download.js?ver=4.0.0'></script>
245
  <script type='text/javascript' src='http://lnmp.dev/download-monitor/wp-content/plugins/_download-monitor-new/assets/js/notices.js?ver=4.0.0'></script>
246
  <link id="wp-admin-canonical" rel="canonical" href="http://lnmp.dev/download-monitor/wp-admin/options.php?page=dlm_legacy_upgrade" />
247
  <script>
241
  var dlm_id_strings = {"insert_download":"Insert Download"};
242
  /* ]]> */
243
  </script>
244
+ <script type='text/javascript' src='http://lnmp.dev/download-monitor/wp-content/plugins/_download-monitor-new/assets/js/download-operations.js?ver=4.0.0'></script>
245
  <script type='text/javascript' src='http://lnmp.dev/download-monitor/wp-content/plugins/_download-monitor-new/assets/js/notices.js?ver=4.0.0'></script>
246
  <link id="wp-admin-canonical" rel="canonical" href="http://lnmp.dev/download-monitor/wp-admin/options.php?page=dlm_legacy_upgrade" />
247
  <script>
assets/js/reports/reports.js CHANGED
@@ -7,11 +7,6 @@ jQuery(function ($) {
7
  const reports = new DLM_Reports();
8
  // Fetch our users and the logs. Do this first so that we query for users we have data.
9
  dlmReportsInstance.fetchUserData();
10
- // Get the data used for the chart.
11
- dlmReportsInstance.fetchReportsData();
12
- $(document).on('dlm_downloads_report_fetched', function () {
13
- reports.init();
14
- });
15
  });
16
 
17
  /**
@@ -168,6 +163,7 @@ class DLM_Reports {
168
  ]);
169
 
170
  dlmReportsInstance.stopSpinner(jQuery('.total_downloads_chart-wrapper'));
 
171
  } else {
172
  dlmReportsInstance.fetchReportsData(response.offset);
173
  }
@@ -224,6 +220,8 @@ class DLM_Reports {
224
 
225
  let response = await fetchedUserData.json();
226
  dlmReportsInstance.dlmUsersStats.users = dlmReportsInstance.dlmUsersStats.users.concat(response);
 
 
227
  }
228
 
229
  /**
7
  const reports = new DLM_Reports();
8
  // Fetch our users and the logs. Do this first so that we query for users we have data.
9
  dlmReportsInstance.fetchUserData();
 
 
 
 
 
10
  });
11
 
12
  /**
163
  ]);
164
 
165
  dlmReportsInstance.stopSpinner(jQuery('.total_downloads_chart-wrapper'));
166
+ dlmReportsInstance.init();
167
  } else {
168
  dlmReportsInstance.fetchReportsData(response.offset);
169
  }
220
 
221
  let response = await fetchedUserData.json();
222
  dlmReportsInstance.dlmUsersStats.users = dlmReportsInstance.dlmUsersStats.users.concat(response);
223
+ // Get the data used for the chart. We get it so that the users are completed and we won't possibly overload the server
224
+ dlmReportsInstance.fetchReportsData();
225
  }
226
 
227
  /**
assets/js/reports/reports.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(function(e){const t=new DLM_Reports;dlmReportsInstance.fetchUserData(),dlmReportsInstance.fetchReportsData(),e(document).on("dlm_downloads_report_fetched",function(){t.init()})});class DLM_Reports{dlmReportsStats=[];dlmUsersStats={logs:[],users:[]};currentFilters=[];tempDownloads=null;templates={};totalDownloads=0;perPage=dlmReportsPerPage;constructor(){(dlmReportsInstance=this).chartContainer=document.getElementById("total_downloads_chart");const e=dlmReportsInstance.chartContainer.getContext("2d");dlmReportsInstance.chartColors={purple:{default:"rgba(149, 76, 233, 1)",threesome:"rgba(149, 76, 233, 0.75)",half:"rgba(149, 76, 233, 0.5)",quarter:"rgba(149, 76, 233, 0.5)",zero:"rgba(149, 76, 233, 0.05)"},blue:{default:"rgba(67, 56, 202, 1)",threesome:"rgba(67, 56, 202, 0.75)",half:"rgba(67, 56, 202, 0.5)",quarter:"rgba(67, 56, 202, 0.25)",zero:"rgba(67, 56, 202, 0.05)"},green:{default:"rgba(00, 255, 00, 1)",threesome:"rgba(00, 255, 00, 0.75)",half:"rgba(00, 255, 00, 0.5)",quarter:"rgba(00, 255, 00, 0.25)",zero:"rgba(67, 56, 202, 0.05)"},royalBlue:{default:"rgba(65, 105, 225, 1)",threesome:"rgba(65, 105, 225, 0.75)",half:"rgba(65, 105, 225, 0.5)",quarter:"rgba(65, 105, 225, 0.25)",zero:"rgba(65, 105, 225, 0.05)"},persianBlue:{default:"rgba(28, 57, 187, 1)",threesome:"rgba(28, 57, 187, 0.75)",half:"rgba(28, 57, 187, 0.5)",quarter:"rgba(28, 57, 187, 0.25)",zero:"rgba(28, 57, 187, 0.05)"},darkCyan:{default:"rgba(0,129,167, 1)",threesome:"rgba(0,129,167, 0.75)",half:"rgba(0,129,167, 0.5)",quarter:"rgba(0,129,167, 0.25)",zero:"rgba(0,129,167, 0.05)"},strongCyan:{default:"rgba(0, 175, 185, 1)",threesome:"rgba(0, 175, 185, 0.75)",half:"rgba(0, 175, 185, 0.5)",quarter:"rgba(0, 175, 185, 0.25)",zero:"rgba(0, 175, 185, 0.05)"}},dlmReportsInstance.chartGradient=e.createLinearGradient(0,25,0,300),dlmReportsInstance.chartGradient.addColorStop(0,dlmReportsInstance.chartColors.darkCyan.half),dlmReportsInstance.chartGradient.addColorStop(.45,dlmReportsInstance.chartColors.darkCyan.quarter),dlmReportsInstance.chartGradient.addColorStop(1,dlmReportsInstance.chartColors.darkCyan.zero),dlmReportsInstance.datePickerContainer=document.getElementById("dlm-date-range-picker"),dlmReportsInstance.dataSets=[];let t=new Date;dlmReportsInstance.dates={downloads:{start_date:new Date(t.setMonth(t.getMonth()-1)),end_date:new Date}},dlmReportsInstance.chartDataObject={}}async fetchReportsData(e=0,t=1e3){const a=jQuery('div[data-id="general_info"]');dlmReportsInstance.setSpinner(jQuery(".total_downloads_chart-wrapper")),dlmReportsInstance.setSpinner(jQuery("#users_download_log")),dlmReportsInstance.setSpinner(jQuery("#total_downloads_table_wrapper2"));let n=dlmDownloadReportsAPI+"?offset="+e+"&limit="+t;0<dlmDownloadReportsAPI.indexOf("index.php?")&&(n=dlmDownloadReportsAPI+"&offset="+e+"&limit="+t);const o=await fetch(n);if(!o.ok){const s=document.createElement("div"),r=(s.className="dlm-loading-data",document.createTextNode("Seems like we bumped into an error! ")),d=document.createTextNode("Data fetching returned a status text of : "+fetchedData.statusText),l=document.createElement("h1"),m=document.createElement("h3");throw l.appendChild(r),m.appendChild(d),s.appendChild(l),s.appendChild(m),a.find(".dlm-loading-data").remove(),a.append(s),new Error("Something went wrong! Reports response did not come OK - "+fetchedData.statusText)}dlmReportsInstance.mostDownloaded=!1,dlmReportsInstance.stats=!1,dlmReportsInstance.chartType="day";e=await o.json();dlmReportsInstance.dlmReportsStats=dlmReportsInstance.dlmReportsStats.concat(e.stats),!0===e.done?(0<window.location.href.indexOf("dlm_time")&&(dlmReportsInstance.dates.downloads.start_date=0<Object.keys(dlmReportsInstance.dlmReportsStats).length?new Date(dlmReportsInstance.dlmReportsStats[0].date):new Date,dlmReportsInstance.dates.downloads.end_date=new Date,jQuery("#dlm-date-range-picker .date-range-info").html(dlmReportsInstance.dates.downloads.start_date.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"2-digit"})+" - "+dlmReportsInstance.dates.downloads.end_date.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"2-digit"}))),dlmReportsInstance.createDataOnDate(dlmReportsInstance.dates.downloads.start_date,dlmReportsInstance.dates.downloads.end_date),dlmReportsInstance.datePicker={opened:!1},jQuery(document).trigger("dlm_downloads_report_fetched",[dlmReportsInstance,dlmReportsInstance.dlmReportsStats]),dlmReportsInstance.stopSpinner(jQuery(".total_downloads_chart-wrapper"))):dlmReportsInstance.fetchReportsData(e.offset)}async fetchUsersReportsData(e=0,t=dlmPHPinfo.retrieved_rows){const a=jQuery('div[data-id="user_reports"]');let n=dlmUserReportsAPI+"?offset="+e+"&limit="+t;0<dlmUserReportsAPI.indexOf("index.php?")&&(n=dlmUserReportsAPI+"&offset="+e+"&limit="+t);const o=await fetch(n);if(!o.ok)throw new Error("Something went wrong! Reports response did not come OK - "+o.statusText);e=await o.json();dlmReportsInstance.dlmUsersStats.logs=dlmReportsInstance.dlmUsersStats.logs.concat(e.logs),!0===e.done?(dlmReportsInstance.userDownloads=void 0!==dlmReportsInstance.dlmUsersStats.logs?JSON.parse(JSON.stringify(dlmReportsInstance.dlmUsersStats.logs)):{},a.find(".dlm-loading-data").remove(),dlmReportsInstance.userReportsTab(),dlmReportsInstance.setTopDownloads(),dlmReportsInstance.stopSpinner(jQuery("#total_downloads_table_wrapper2"))):dlmReportsInstance.fetchUsersReportsData(e.offset)}async fetchUserData(){const e=await fetch(dlmUserDataAPI);if(!e.ok)throw new Error("Something went wrong! Reports response did not come OK - "+e.statusText);var t=await e.json();dlmReportsInstance.dlmUsersStats.users=dlmReportsInstance.dlmUsersStats.users.concat(t)}init(){dlmReportsInstance.tabNagivation(),dlmReportsInstance.overViewTab(),dlmReportsInstance.togglePageSettings(),dlmReportsInstance.setSpinner(jQuery("#users_download_log")),dlmReportsInstance.setSpinner(jQuery("#total_downloads_table_wrapper2")),dlmReportsInstance.fetchUsersReportsData(),jQuery(document).trigger("dlm_reports_init",[dlmReportsInstance]),dlmReportsInstance.eventsFunctions()}overViewTab(){dlmReportsInstance.dlmCreateChart(dlmReportsInstance.stats.chartStats,dlmReportsInstance.chartContainer),dlmReportsInstance.dlmDownloadsSummary(),dlmReportsInstance.datePickerContainer.addEventListener("click",dlmReportsInstance.toggleDatepicker.bind(this)),dlmReportsInstance.setTodayDownloads(),dlmReportsInstance.handleTopDownloads(),jQuery(document).on("click","body",function(e){e.stopPropagation(),0<jQuery(dlmReportsInstance.datePickerContainer).find("#dlm_date_range_picker").length&&dlmReportsInstance.hideDatepicker(jQuery(dlmReportsInstance.datePickerContainer),{target:"dlm-date-range-picker"})})}userReportsTab(){0!==Object.values(dlmReportsInstance.dlmUsersStats).length&&(dlmReportsInstance.logsDataByDate(dlmReportsInstance.dates.downloads.start_date,dlmReportsInstance.dates.downloads.end_date),dlmReportsInstance.handleUserDownloads(),dlmReportsInstance.filterDownloads())}getDates(e,t){const a={};let n=e;for(;n<=t;)a[this.createDateElement(n)]=0,n=this.getNextDay(n);return a}getMonths(e){const t={};return Object.keys(e).map(e=>{e=e.substring(0,7);void 0===t[e]&&(t[e]=0)}),t}getDoubleMonths(e){const t={},a=Object.keys(e)[0],n=Object.keys(e)[Object.keys(e).length-1];let o=0,s=a.substring(0,7),r=n.substring(0,7);return Object.keys(e).map(e=>{e=e.substring(0,7);s!==e&&r!==e&&(s=e,o++),void 0===t[e]&&0==o%2&&(t[e]=0)}),t}getWeeks(e){let a={};return Object.keys(e).forEach(e=>{let t;t=15<moment(e).date()?e.substring(0,7)+"-15":e.substring(0,7)+"-01",void 0===a[t]&&(a[t]=0)}),a}getWeek(e){let t={},a=Object.keys(e)[Object.keys(e).length-1],n=0;return Object.keys(e).map(e=>{void 0===t[e]&&0==n%7&&(t[e]=0),n++}),void 0===t[a]&&(t[a]=0),t}getDoubleDays(e){let t={},a=Object.keys(e)[0],n=Object.keys(e)[Object.keys(e).length-1],o=0;return Object.keys(e).map(e=>{a!==e&&n!==e&&(a=e,o++),void 0===t[e]&&0==o%2&&(t[e]=0)}),t}getNextDay(e){const t=new Date(e);return t.setDate(e.getDate()+1),t}createDateElement(e){var t=(e.getMonth()+1<10?"0":"")+(e.getMonth()+1);return e.getFullYear()+"-"+t+"-"+("0"+e.getDate()).slice(-2)}getSetDates(e,t){let a,n;if(void 0!==e&&e)a=dlmReportsInstance.createDateElement(new Date(e));else{const o=new Date;o.setDate(o.getDate()-30),a=dlmReportsInstance.createDateElement(o)}if(void 0!==t&&t){e=new Date(t);n=dlmReportsInstance.createDateElement(e)}else{const s=new Date;s.setDate(s.getDate()+1),n=dlmReportsInstance.createDateElement(s)}return{startDate:a,endDate:n}}createDataOnDate(e,t){let{startDate:a,endDate:n}={...dlmReportsInstance.getSetDates(e,t)},o,s,r,d,l,m=(dlmReportsInstance.reportsData=void 0!==dlmReportsInstance.dlmReportsStats?JSON.parse(JSON.stringify(dlmReportsInstance.dlmReportsStats)):{},s=moment(n,"YYYY-MM-DD").month()-moment(a,"YYYY-MM-DD").month(),r=moment(n,"YYYY-MM-DD").year()-moment(a,"YYYY-MM-DD").year(),o=moment(n).date()-moment(a).date(),dlmReportsInstance.chartType="day",0==r&&-6<s&&s<6?1<s||s<-1?dlmReportsInstance.chartType=2==s?"week":"weeks":1==s&&(8<o||-14<o||0==o)&&(dlmReportsInstance.chartType="days"):s<=0?dlmReportsInstance.chartType="month":dlmReportsInstance.chartType="months",dlmReportsInstance.getDates(new Date(a),new Date(n))),c,p,i,g;switch(dlmReportsInstance.chartType){case"months":p=dlmReportsInstance.getDoubleMonths(m),l=p;break;case"month":var u=dlmReportsInstance.getMonths(m);l=u;break;case"weeks":i=dlmReportsInstance.getWeeks(m),l=i;break;case"week":g=dlmReportsInstance.getWeek(m),l=g;break;case"days":c=dlmReportsInstance.getDoubleDays(m),l=c;break;case"day":l=m}Object.values(dlmReportsInstance.reportsData).forEach((o,e)=>{var s=JSON.parse(o.download_ids);if(void 0!==m[o.date])switch(dlmReportsInstance.chartType){case"months":d=o.date.substring(0,7);let e=parseInt(o.date.substring(5,7)),t=o.date.substring(0,5),a=6<(e-1).length?t+(e-1):t+"0"+(e-1);Object.values(s).forEach((e,t)=>{void 0===p[d]?void 0!==p[a]&&(p[a]=p[a]+e.downloads):p[d]=p[d]+e.downloads}),l=p;break;case"month":d=o.date.substring(0,7),Object.values(s).forEach((e,t)=>{monthDownloads[d]=void 0!==monthDownloads[d]?monthDownloads[d]+e.downloads:e.downloads}),l=monthDownloads;break;case"weeks":d=15<moment(o.date).date()?o.date.substring(0,7)+"-15":o.date.substring(0,7)+"-01",Object.values(s).forEach((e,t)=>{i[d]=void 0!==i[d]?i[d]+e.downloads:e.downloads}),l=i;break;case"week":d=o.date,Object.values(s).forEach((t,e)=>{if(void 0===g[d])for(let e=1;e<8;e++){var a=moment(o.date).date(moment(o.date).date()-e).format("YYYY-MM-DD");void 0!==g[a]&&(g[a]=g[a]+t.downloads)}else g[d]=g[d]+t.downloads}),l=g;break;case"days":d=o.date;let n=moment(o.date).date(moment(o.date).date()-1).format("YYYY-MM-DD");Object.values(s).forEach((e,t)=>{void 0===c[d]?void 0!==c[n]&&(c[n]=c[n]+e.downloads):c[d]=c[d]+e.downloads}),l=c;break;case"day":Object.values(s).forEach((e,t)=>{m[o.date]=m[o.date]+e.downloads}),l=m}else delete dlmReportsInstance.reportsData[e]});const I=Object.keys(m);e=I.length,t=I.findIndex(e=>a===e);let R=I.findIndex(e=>n===e);-1===t&&-1===R?dlmReportsInstance.stats={chartStats:Object.assign({},l),summaryStats:!1,daysLength:e}:(-1===R&&(R=e),dlmReportsInstance.stats={chartStats:Object.assign({},l),summaryStats:dlmReportsInstance.reportsData,daysLength:e})}dlmCreateChart(t,a,n=!1){if(t&&a){let e=Chart.getChart("total_downloads_chart");dlmReportsInstance.chartDataObject={dataSetLabel:"Downloads",dataSetColor:"#27ae60",dataSetbg:dlmReportsInstance.chartGradient,dataSetPointbg:dlmReportsInstance.chartColors.darkCyan.default,dataSetBorder:dlmReportsInstance.chartColors.darkCyan.default,dataSetElementColor:"#2ecc71",lineType:"original",xAxis:"x",chartData:t},void 0!==e&&e.destroy(),jQuery(document).trigger("dlm_reports_before_data_sets",[dlmReportsInstance.chartDataObject,t,n]),0<dlmReportsInstance.dataSets.length&&(dlmReportsInstance.dataSets=dlmReportsInstance.dataSets.filter(e=>dlmReportsInstance.chartDataObject.lineType!==e.origin)),dlmReportsInstance.dataSets.push({origin:dlmReportsInstance.chartDataObject.lineType,label:dlmReportsInstance.chartDataObject.dataSetLabel,color:dlmReportsInstance.chartDataObject.dataSetColor,data:dlmReportsInstance.chartDataObject.chartData,type:"line",fill:!0,backgroundColor:dlmReportsInstance.chartDataObject.dataSetbg,pointBackgroundColor:dlmReportsInstance.chartDataObject.dataSetPointbg,pointHoverBackgroundColor:"#fff",borderColor:dlmReportsInstance.chartDataObject.dataSetBorder,pointBorderWidth:1,lineTension:.3,borderWidth:1,pointRadius:3,elements:{line:{borderColor:dlmReportsInstance.chartDataObject.dataSetElementColor,borderWidth:1},point:{radius:4,hoverRadius:4,pointStyle:"circle"}}});t=Object.values(dlmReportsInstance.dataSets).filter(e=>"original"===e.origin);let s=Object.keys(t[0].data);dlmReportsInstance.dataSets.sort(function(e,t){return"original"===e.origin?-1:1}),dlmReportsInstance.chart=new Chart(a,{title:"",data:{datasets:dlmReportsInstance.dataSets},height:450,is_series:1,options:{aspectRatio:5,animation:!1,interaction:{mode:"index",intersect:!1},stacked:!1,scales:{x:{grid:{display:!1},ticks:{callback:e=>{let t="";var a=s[e],n=s[s.length-1],o=moment(n).month(moment(n).month()-1).format("YYYY-MM");return t="undefined"!==dlmReportsInstance.chartType&&"months"===dlmReportsInstance.chartType?(e=moment(s[e]).month())<11?a===o?moment(a).format("MMM, YYYY"):moment(a).format("MMM")+" - "+moment(a).month(e+1).format("MMM")+moment(a).format(", YYYY"):a===o||a===n?moment(a).format("MMM, YYYY"):moment(a).format("MMM")+moment(a).format(" YYYY")+" - "+moment(a).month(e+1).format("MMM")+moment(a).month(e+1).format(", YYYY"):"undefined"!==dlmReportsInstance.chartType&&"months"===dlmReportsInstance.chartType?moment(a).format("MMMM, YYYY"):moment(a).format("D MMM")}}},y:{grid:{drawBorder:!1},min:0,max:0!==dlmReportsInstance.getMaxDownload()?1===Math.ceil(dlmReportsInstance.getMaxDownload()/10)?dlmReportsInstance.getMaxDownload()+1:10*Math.ceil(dlmReportsInstance.getMaxDownload()/10):100,ticks:{stepSize:0!==dlmReportsInstance.getMaxDownload()?Math.ceil(dlmReportsInstance.getMaxDownload()/4):25,callback:e=>dlmReportsInstance.shortNumber(e)}}},normalized:!0,parsing:{xAxisKey:"x",yAxisKey:"y"},plugins:{tooltip:{enabled:!1,external:dlmReportsInstance.externalTooltipHandler.bind(dlmReportsInstance,this)},legend:{display:!0}}}})}}dlmDownloadsSummary(){let a={};if(!1===dlmReportsInstance.stats||!1===dlmReportsInstance.stats.summaryStats||Object.keys(dlmReportsInstance.stats.summaryStats).length<=0)return this.setTotalDownloads(0),this.setDailyAverage(0),void this.setMostDownloaded("--");dlmReportsInstance.totalDownloads=0,dlmReportsInstance.stats.summaryStats.forEach(e=>{e=JSON.parse(e.download_ids),Object.entries(e).forEach(([e,t])=>{dlmReportsInstance.totalDownloads+=t.downloads,a[e]=void 0===a[e]?{downloads:t.downloads,title:t.title,id:e}:{downloads:a[e].downloads+t.downloads,title:t.title,id:e}})}),dlmReportsInstance.mostDownloaded=dlmReportsInstance.orderItems(Object.values(a),"desc","downloads"),dlmReportsInstance.setTotalDownloads(dlmReportsInstance.totalDownloads),dlmReportsInstance.setDailyAverage((dlmReportsInstance.totalDownloads/parseInt(dlmReportsInstance.stats.daysLength)).toFixed(0)),dlmReportsInstance.setMostDownloaded(dlmReportsInstance.mostDownloaded[0].title)}createDatepicker(e,t,a){const n=new Date;let o=n.getDate()-1,s=n.getMonth()+1,r=s-1;var d=n.getFullYear(),l=(o<10&&(o="0"+o),s<10&&(s="0"+s),r<10&&(r="0"+r),d+"-"+s+"-"+o),d=d+"-"+r+"-"+o,m=jQuery("<div>").addClass("dlm_rdrs_overlay"),a=jQuery("<div>").attr("id",a.replace("#",""));return"dlm-date-range-picker"===t.target?(dlmReportsInstance.startDateInput=jQuery("<input>").attr("type","hidden").attr("id","dlm_start_date").attr("value",d),dlmReportsInstance.endDateInput=jQuery("<input>").attr("type","hidden").attr("id","dlm_end_date").attr("value",l),m.append(a).append(dlmReportsInstance.startDateInput).append(dlmReportsInstance.endDateInput)):jQuery(document).trigger("dlm_create_date_picker_"+t.target,[dlmReportsInstance,m,a,d,l]),m}displayDatepicker(e,s){var t;if(jQuery(e)){if(t="#"+jQuery(e).attr("id").replace(/-/gi,"_"),"dlm-date-range-picker"===s.target){if(dlmReportsInstance.datePicker.opened)return;dlmReportsInstance.datePicker.opened=!0}else jQuery(document).trigger("dlm_display_datepicker_"+s.target,[dlmReportsInstance,s,e]);let o=dlmReportsInstance.createDatepicker(e,s,t);e.append(o);var a=0<Object.keys(dlmReportsInstance.dlmReportsStats).length?new Date(dlmReportsInstance.dlmReportsStats[0].date):new Date,n=(new Date,[]),e=(jQuery(document).trigger("dlm_datepicker_shortcuts_"+s.target,[dlmReportsInstance,s,e,n]),{separator:" to ",autoClose:!0,getValue:function(){},setValue:function(e,t,a){o.find('input[type="hidden"]').first().val(t),o.find('input[type="hidden"]').last().val(a)},inline:!0,alwaysOpen:!0,container:t,endDate:new Date,startDate:a,showShortcuts:!0,shortcuts:null,customShortcuts:n});o.dateRangePicker(e).on("datepicker-change",(e,t)=>{var a,n;t.date1&&t.date2&&(a=t.date1.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"2-digit"}),n=t.date2.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"2-digit"}),o.parent().find("span.date-range-info").text(a+" - "+n)),"dlm-date-range-picker"===s.target?(dlmReportsInstance.dates.downloads={start_date:t.date1,end_date:t.date2},dlmReportsInstance.createDataOnDate(dlmReportsInstance.dates.downloads.start_date,dlmReportsInstance.dates.downloads.end_date),dlmReportsInstance.dlmCreateChart(dlmReportsInstance.stats.chartStats,dlmReportsInstance.chartContainer,!1),dlmReportsInstance.dlmDownloadsSummary(),0<Object.values(dlmReportsInstance.dlmUsersStats.logs).length&&dlmReportsInstance.logsDataByDate(dlmReportsInstance.dates.downloads.start_date,dlmReportsInstance.dates.downloads.end_date)):jQuery(document).trigger("dlm_daterangepicker_init_"+s.target,[dlmReportsInstance,t.date1,t.date2]),dlmReportsInstance.setTopDownloads(),o.data("dateRangePicker").close()}),"dlm-date-range-picker"===s.target?o.data("dateRangePicker").setDateRange(dlmReportsInstance.dates.downloads.start_date,dlmReportsInstance.dates.downloads.end_date):jQuery(document).trigger("dlm_daterangepicker_after_init_"+s.target,[o,dlmReportsInstance])}}hideDatepicker(e,t){"dlm-date-range-picker"===t.target?dlmReportsInstance.datePicker.opened=!1:jQuery(document).trigger("dlm_hide_datepicker_"+t.target,[dlmReportsInstance,e,t]),e.find(".dlm_rdrs_overlay").remove()}toggleDatepicker(e){e.stopPropagation();const t=jQuery(e.target).parents(".dlm-reports-header-date-selector");e={target:t.attr("id"),object:dlmReportsInstance.datePicker};dlmReportsInstance.closeDatePickers(t),"dlm-date-range-picker"===e.target?dlmReportsInstance.datePicker.opened?dlmReportsInstance.hideDatepicker(t,e):dlmReportsInstance.displayDatepicker(t,e):jQuery(document).trigger("dlm_toggle_datepicker_"+e.target,[dlmReportsInstance,t,e])}setTotalDownloads(e){jQuery(".dlm-reports-block-summary li#total span").html(e.toLocaleString())}setDailyAverage(e){jQuery(".dlm-reports-block-summary li#average span").html(e.toLocaleString())}setMostDownloaded(e){jQuery(".dlm-reports-block-summary li#most_popular span").html(e)}setTodayDownloads(){let e=0;Object.keys(dlmReportsInstance.dlmReportsStats).length<=0?jQuery(".dlm-reports-block-summary li#today span").html(e.toLocaleString()):(dlmReportsInstance.dlmReportsStats[dlmReportsInstance.dlmReportsStats.length-1].date===dlmReportsInstance.createDateElement(new Date)&&(e=Object.values(JSON.parse(dlmReportsInstance.dlmReportsStats[dlmReportsInstance.dlmReportsStats.length-1].download_ids)).reduce((e,t)=>e+t.downloads,0)),jQuery(".dlm-reports-block-summary li#today span").html(e))}setTopDownloads(e=0,t=!1){const a=jQuery("#total_downloads_table_wrapper2"),n=jQuery("#total_downloads_table_wrapper2 .total_downloads_table__list");if(n.empty(),n.parent().addClass("empty"),dlmReportsInstance.mostDownloaded&&!0!==t){var o=JSON.parse(JSON.stringify(dlmReportsInstance.mostDownloaded)).slice(dlmReportsInstance.perPage*parseInt(e),dlmReportsInstance.perPage*parseInt(e+1));for(let e=0;e<o.length;e++){const r=dlmReportsInstance.getDownloadByID(o[e].id);if(void 0===r)return;var s={id:o[e].id,title:o[e].title,edit_link:dlmAdminUrl+"post.php?post="+o[e].id+"&action=edit",total_downloads:r.total.toLocaleString()};jQuery(document).trigger("dlm_reports_top_downloads_item_before_render",[s,dlmReportsInstance,o[e],r]),new dlmBackBone.modelTopDownloads(s)}n.parent().removeClass("empty"),a.find(".dlm-reports-total-pages").html(Math.ceil(dlmReportsInstance.mostDownloaded.length/dlmReportsInstance.perPage)),parseInt(dlmReportsInstance.perPage)!==parseInt(o.length)?a.find('.downloads-block-navigation button[data-action="load-more"]').attr("disabled","disabled"):a.find('.downloads-block-navigation button[data-action="load-more"]').removeAttr("disabled"),dlmReportsInstance.mostDownloaded.length>dlmReportsInstance.perPage?a.find(".downloads-block-navigation button").removeClass("hidden"):a.find(".downloads-block-navigation button").addClass("hidden"),dlmReportsInstance.stopSpinner(jQuery("#total_downloads_table_wrapper2"))}}handleTopDownloads(){jQuery("html body").on("click","#total_downloads_table_wrapper2 .downloads-block-navigation button",function(){let e=jQuery(this).parents("#total_downloads_table_wrapper2"),t=e,a=e.attr("data-page"),n=jQuery(this),o=parseInt(a)+1,s=0!==a?parseInt(a)-1:0,r=e.find(".downloads-block-navigation").find("button").first(),d=e.find(".downloads-block-navigation").find("button").last();n.attr("disabled","disabled");var l={data:dlmReportsInstance.mostDownloaded,main_parent:e,offsetHolder:t,offset:a,link:n,nextPage:o,prevPage:s,prevButton:r,nextButton:d,doAction:dlmReportsInstance.setTopDownloads};dlmReportsInstance.handleSliderNavigation(l)}),jQuery("#total_downloads_table_wrapper2").find("input.dlm-reports-current-page").on("change",function(){dlmReportsInstance.paginationChange(jQuery(this),dlmReportsInstance.mostDownloaded,jQuery("#total_downloads_table_wrapper2"),jQuery(this).parents("#total_downloads_table_wrapper2"),dlmReportsInstance.setTopDownloads)})}handleSliderNavigation(e){const{data:t,main_parent:a,offsetHolder:n,offset:o,link:s,nextPage:r,prevPage:d,prevButton:l,nextButton:m,doAction:c}={...e};let p=1;"load-more"===s.data("action")?(n.attr("data-page",r),c(r),Math.ceil(t.length/dlmReportsInstance.perPage)>r+1&&m.removeAttr("disabled"),l.removeAttr("disabled"),p=parseInt(r)+1):0!==parseInt(o)&&(n.attr("data-page",d),c(d),1!==parseInt(o)&&l.removeAttr("disabled"),m.removeAttr("disabled"),p=parseInt(d)+1),a.find(".dlm-reports-current-page").val(p)}tabNagivation(){jQuery(document).on("click",".dlm-reports .dlm-insights-tab-navigation > li",function(){const e=jQuery(this),t=jQuery(".dlm-reports .dlm-insights-tab-navigation > li").not(e),a=jQuery('div.dlm-insights-tab-navigation__content[data-id="'+e.attr("id")+'"]'),n=jQuery("div.dlm-insights-tab-navigation__content").not(a);e.hasClass("active")||(e.addClass("active"),t.removeClass("active"),a.addClass("active"),n.removeClass("active"))})}getOrCreateTooltip(e){let t=e.canvas.parentNode.querySelector("div.dlm-canvas-tooltip"),a=e.canvas.parentNode.querySelector("div.dlm-reports-tooltip__line");if(t||((a=document.createElement("div")).className="dlm-reports-tooltip__line"),!t){(t=document.createElement("div")).className="dlm-canvas-tooltip";const n=document.createElement("div");n.className="dlm-reports-tooltip",t.appendChild(n),e.canvas.parentNode.appendChild(t),e.canvas.parentNode.appendChild(a)}return{tooltipEl:t,tooltipLine:a}}externalTooltipHandler(d,e){const{chart:t,tooltip:l}=e,{tooltipEl:a,tooltipLine:n}={...d.getOrCreateTooltip(t)};e=jQuery(a).parent().width();if(0===l.opacity)return a.style.opacity=0,void(n.style.opacity=0);if(l.body){const m=l.title||[],c=document.createElement("div"),p=(c.className="dlm-reports-tooltip__header",m.forEach(e=>{const t=document.createElement("div"),a=(t.className="dlm-reports-tooltip__row",document.createElement("p")),n=(a.className="dlm-reports-tooltip__info",a.appendChild(document.createTextNode("Downloads")),t.appendChild(a),jQuery(document).trigger("dlm_chart_tooltip_before",[dlmReportsInstance,l,t,d]),document.createElement("p"));n.className="dlm-reports-tooltip__date";var o=dlmReportsInstance.setChartTooltipDate(l.dataPoints[0].label,d,d.stats.chartStats);n.appendChild(document.createTextNode(o)),t.appendChild(n);const s=document.createElement("p"),r=(s.className="dlm-reports-tooltip__downloads",document.createElement("span"));r.className="dlm-reports-tooltip__downloads_pointer",r.style.backgroundColor=dlmReportsInstance.chartColors.darkCyan.default,s.appendChild(r),s.appendChild(document.createTextNode(dlmReportsInstance.shortNumber(l.dataPoints[0].formattedValue))),t.appendChild(s),jQuery(document).trigger("dlm_chart_tooltip_after",[dlmReportsInstance,l,t,d]),c.appendChild(t)}),a.querySelector("div.dlm-reports-tooltip"));for(;p.firstChild;)p.firstChild.remove();p.appendChild(c)}var{offsetLeft:o,offsetTop:s}=t.canvas;a.style.opacity=1;let r={isMargin:!(n.style.opacity=1),left:!1};l.caretX-l.width<0&&(r.isMargin=!0,r.left=!0),o+l.caretX+l.width>e&&(r.isMargin=!0,r.left=!1),r.isMargin?r.left?a.style.left=o+l.width+"px":a.style.left=e-l.width+"px":a.style.left=o+l.caretX+"px",n.style.left=o+l.caretX+"px",a.style.top=s+l.caretY-a.offsetHeight-10+"px"}createUserRelatedData(){dlmReportsInstance.userRelatedData=[],Object.values(dlmReportsInstance.userDownloads).forEach((e,t)=>{var a;"0"!==e.user_id&&(a=[e.user_id,e.download_id,e.download_date,e.download_status],e="user_"+e.user_id,void 0!==dlmReportsInstance.userRelatedData[e]?dlmReportsInstance.userRelatedData[e].push(a):dlmReportsInstance.userRelatedData[e]=[a])})}logsDataByDate(e,t){var{startDate:e,endDate:t}={...dlmReportsInstance.getSetDates(e,t)};dlmReportsInstance.userDownloads=JSON.parse(JSON.stringify(dlmReportsInstance.dlmUsersStats.logs));let a=new Date(e),n=(a.setDate(a.getDate()-1),a=a.getTime(),new Date(t));n.setDate(n.getDate()+1),n=n.getTime(),dlmReportsInstance.userDownloads=dlmReportsInstance.userDownloads.filter((e,t)=>{e=dlmReportsInstance.createDateElement(new Date(e.download_date));return(e=new Date(e).getTime())>a&&e<n}),dlmReportsInstance.createUserRelatedData(),dlmReportsInstance.filterDownloads(),dlmReportsInstance.setMostActiveUser(),dlmReportsInstance.setLoggedOutDownloads(),dlmReportsInstance.setLoggedInDownloads(),jQuery(document).trigger("dlm_set_logs_data_by_date",[dlmReportsInstance])}setMostActiveUser(){var e=dlmReportsInstance.getUserByID(dlmReportsInstance.getMostActiveID()[0]);jQuery(".dlm-reports-block-summary li#most_active_user span").html(dlmReportsInstance.userToolTipMarkup(e))}getMostActiveID(){return Object.values(dlmReportsInstance.userRelatedData).length?Object.values(dlmReportsInstance.userRelatedData).reduce((e,t,a)=>parseInt(e.length)>parseInt(t.length)&&0<e.length&&null!==dlmReportsInstance.getUserByID(e[0][0])?e:null!==dlmReportsInstance.getUserByID(t[0][0])?t:[],[]):0}getUserByID(t){if(!t)return null;if("0"===t)return{role:"Guest",display_name:"Guest"};var e=Object.values(dlmReportsInstance.dlmUsersStats.users).filter(e=>parseInt(t)===parseInt(e.id));return Array.isArray(e)?0===e.length?null:e[0]:e}getLoggedInDownloads(){return Object.values(dlmReportsInstance.userRelatedData).length?1<Object.values(dlmReportsInstance.userRelatedData).length?Object.values(dlmReportsInstance.userRelatedData).reduce((e,t)=>parseInt(e)+parseInt(t.length),0):Object.values(dlmReportsInstance.userRelatedData)[0].length:0}setLoggedInDownloads(){const e=dlmReportsInstance.getLoggedInDownloads();jQuery(".dlm-reports-block-summary li#logged_in span,#total_downloads_summary_wrapper .dlm-reports-logged-in").html(e.toLocaleString())}getLoggedOutDownloads(){return dlmReportsInstance.userDownloads.length-dlmReportsInstance.getLoggedInDownloads()}setLoggedOutDownloads(){const e=dlmReportsInstance.getLoggedOutDownloads();jQuery(".dlm-reports-block-summary li#logged_out span,#total_downloads_summary_wrapper .dlm-reports-logged-out").html(e.toLocaleString())}userToolTipMarkup(e){let t='<div class="dlm-user-reports">';return t=(t=t+'<div class="wpchill-tooltip"><i>[?]</i>'+'<div class="wpchill-tooltip-content">')+("<span>User ID: "+(null!==e?e.id:"--")+"</span>"),"object"!=typeof e&&e.url.length&&(t+="<span>User URL: "+(null!==e?e.url:"--")+"</span>"),t+="<span>User registration date: "+(null!==e?e.registered:"--")+"</span>",null!==e&&void 0!==e.role&&e.role.length&&(t+="<span>User role: "+e.role+"</span>"),t=(t+="</div></div>")+(null!==e?e.display_name:"--")+"</div>"}setUserDownloads(e=0,t=!1){const a=jQuery("#users_download_log"),n=jQuery("#users_download_log .user-logs__list");if(n.empty(),!0!==t){let t=[];t=(null!==dlmReportsInstance.tempDownloads?JSON.parse(JSON.stringify(dlmReportsInstance.tempDownloads)):JSON.parse(JSON.stringify(dlmReportsInstance.userDownloads))).slice(dlmReportsInstance.perPage*parseInt(e),dlmReportsInstance.perPage*parseInt(e+1));for(let e=0;e<t.length;e++){var o=dlmReportsInstance.getUserByID(t[e].user_id.toString()),s=dlmReportsInstance.getDownloadCPT(t[e].download_id.toString()),r={key:e,user:null!=o?o.display_name:"--",ip:t[e].user_ip,role:null!==o&&null!==o.role?o.role:"--",download:null!=s?s.title:"--",valid_user:"0"!==t[e].user_id,edit_link:"0"!==t[e].user_id?"user-edit.php?user_id="+t[e].user_id:"#",edit_download_link:null!=s?dlmAdminUrl+"post.php?post="+s.id+"&action=edit":"#",status:t[e].download_status,download_date:t[e].download_date};jQuery(document).trigger("dlm_reports_user_logs_item_before_render",[r,dlmReportsInstance,t[e],o,s]),new dlmBackBone.modelUserLogs(r)}dlmReportsInstance.stopSpinner(jQuery("#users_download_log")),a.find(".dlm-reports-total-pages").html(Math.ceil(dlmReportsInstance.tempDownloads.length/dlmReportsInstance.perPage)),parseInt(dlmReportsInstance.perPage)!==parseInt(t.length)?a.find('.user-downloads-block-navigation button[data-action="load-more"]').attr("disabled","disabled"):a.find('.user-downloads-block-navigation button[data-action="load-more"]').removeAttr("disabled"),dlmReportsInstance.userDownloads.length>dlmReportsInstance.perPage?a.find(".user-downloads-block-navigation button").removeClass("hidden"):a.find(".user-downloads-block-navigation button").addClass("hidden")}}filterDownloads(){dlmReportsInstance.tempDownloads=JSON.parse(JSON.stringify(dlmReportsInstance.userDownloads)),dlmReportsInstance.currentFilters.length&&dlmReportsInstance.currentFilters.forEach(t=>{dlmReportsInstance.tempDownloads=dlmReportsInstance.tempDownloads.filter(e=>t.on===e[t.type])}),dlmReportsInstance.setUserDownloads()}handleUserDownloads(){jQuery(".user-downloads-block-navigation").on("click","button",function(e){e.stopPropagation();let t=jQuery(this).parents("#users_downloads_table_wrapper"),a=t.find("#users_download_log"),n=a.attr("data-page"),o=jQuery(this),s=parseInt(n)+1,r=0!==n?parseInt(n)-1:0,d=t.find(".downloads-block-navigation button").first(),l=t.find(".downloads-block-navigation button").last();o.attr("disabled","disabled");e={data:dlmReportsInstance.tempDownloads,main_parent:t,offsetHolder:a,offset:n,link:o,nextPage:s,prevPage:r,prevButton:d,nextButton:l,doAction:dlmReportsInstance.setUserDownloads};dlmReportsInstance.handleSliderNavigation(e)}),jQuery("#users_downloads_table_wrapper").find("input.dlm-reports-current-page").on("change",function(){dlmReportsInstance.paginationChange(jQuery(this),dlmReportsInstance.tempDownloads,jQuery("#users_downloads_table_wrapper"),jQuery("#users_downloads_table_wrapper").find("#users_download_log"),dlmReportsInstance.setUserDownloads)})}togglePageSettings(){jQuery("#dlm-toggle-settings").on("click",function(e){e.stopPropagation(),jQuery(this).find(".dlm-toggle-settings__settings").toggleClass("display")}),jQuery(".dlm-toggle-settings__settings").on("click",function(e){e.stopPropagation()}),jQuery("html,body").on("click",function(){jQuery(this).find(".dlm-toggle-settings__settings").removeClass("display")}),jQuery(document).on("change",".wpchill-toggle__input",function(e){const t=jQuery(this),a=t.attr("name"),n={action:"dlm_update_report_setting",name:a,checked:t.is(":checked"),_ajax_nonce:dlmReportsNonce};jQuery.post(ajaxurl,n,function(e){a,jQuery(document).trigger("dlm_settings_ajax_response",[dlmReportsInstance,t,e])})})}getMaxDownload(){let t=0;return dlmReportsInstance.dataSets.forEach(e=>{e=Object.values(e.data).reduce((e,t)=>t<e?e:t,0);t<e&&(t=e)}),parseInt(t)}setChartTooltipDate(e,t,a){let n="";var o,s,r;return n="undefined"!==t.chartType&&"months"===t.chartType?(moment(e).year(),r=moment(e).month(),a=Object.keys(a)[Object.keys(a).length-1],o=moment(a).month(moment(a).month()-1).format("YYYY-MM"),s=moment(e).format("YYYY-MM"),r<11?s===o?moment(s).format("MMMM, YYYY"):moment(e).format("MMM")+" - "+moment(e).month(r+1).format("MMM")+moment(e).format(", YYYY"):s===o||s===a?moment(s).format("MMMM, YYYY"):moment(e).format("MMM")+moment(e).format(" YYYY")+" - "+moment(e).month(r+1).format("MMM")+moment(e).month(r+1).format(", YYYY")):"undefined"!==t.chartType&&"days"===t.chartType?(moment(e).year(),o=moment(e).day(),a=moment(e).format("MMMM"),s=moment(e).day(o+1).format("MMMM"),r=dlmReportsInstance.dates.downloads.end_date,t=moment(r).day(moment(r).day()-1).format("MMMM Do"),moment(e).format("MMMM Do")===moment(r).format("MMMM Do")||moment(e).format("MMMM Do")===t?moment(e).format("MMMM Do, YYYY"):a===s?moment(e).format("MMMM Do")+" - "+moment(e).day(o+1).format("Do")+moment(e).format(", YYYY"):moment(e).format("MMM Do")+" - "+moment(e).day(o+1).format("MMM Do")+moment(e).format(", YYYY")):moment(e).format("MMMM Do, YY")}closeDatePickers(e){jQuery(".dlm-reports-header-date-selector").not(e).each(function(){var e={target:jQuery(this).attr("id")};dlmReportsInstance.hideDatepicker(jQuery(this),e)})}shortNumber(e){return e=4<=(e="string"==typeof e?e.replace(/,/gi,""):parseInt(e).toString()).length?parseInt(e.substring(0,e.length-3)).toLocaleString()+"k":e}getDownloadByID(t){let a={total:0},n;return dlmReportsInstance.tempDownloads.forEach(function(e){t===e.download_id&&(n=e,a.total=a.total+1,jQuery(document).trigger("dlm_download_by_id",[dlmReportsInstance,a,n]))}),a}getDownloadCPT(t){let e=null;return Array.isArray(dlmReportsInstance.mostDownloaded)&&(e=dlmReportsInstance.mostDownloaded.filter(e=>e.id===t,0)[0]),jQuery(document).trigger("dlm_download_cpt",[dlmReportsInstance,e]),e}setSpinner(e){e.append('<div class="dlm-reports-spinner"><span></span></div>')}stopSpinner(e){e.find(".dlm-reports-spinner").remove()}eventsFunctions(){jQuery("body").on("click",".total_downloads_table_filters_total_downloads > a",function(e){e.preventDefault(),jQuery(this).parent().find("span.dashicons").toggleClass("dashicons-arrow-down dashicons-arrow-up"),dlmReportsInstance.orderOverviewItemsByTotal()}),jQuery("body").on("click",".total_downloads_table_filters_download_date > a",function(e){e.preventDefault(),jQuery(this).parent().find("span.dashicons").toggleClass("dashicons-arrow-down dashicons-arrow-up"),dlmReportsInstance.orderUserReportsItemsByDate()}),jQuery("body").on("change","select.dlm-reports-per-page",function(e){dlmReportsInstance.perPage=jQuery(this).val(),dlmReportsInstance.setTopDownloads(),dlmReportsInstance.setUserDownloads(),jQuery.post(ajaxurl,{action:"dlm_update_report_setting",name:"dlm-reports-per-page",value:dlmReportsInstance.perPage,_ajax_nonce:dlmReportsNonce},function(e){})})}orderItems(e,a,n,t=0){return e.sort((e,t)=>"asc"!==a?t[n]-e[n]:e[n]-t[n]),e}orderOverviewItemsByTotal(){dlmReportsInstance.mostDownloaded=dlmReportsInstance.mostDownloaded.reverse(),dlmReportsInstance.setTopDownloads()}orderUserReportsItemsByDate(){dlmReportsInstance.tempDownloads=dlmReportsInstance.tempDownloads.reverse(),dlmReportsInstance.setUserDownloads()}paginationChange(e,t,a,n,o){let s=parseInt(e.val()),r=(0===s&&(s=1),t.length<s*dlmReportsInstance.perPage&&(s=Math.ceil(t.length/dlmReportsInstance.perPage)),jQuery(this).next('button[data-action="load-more"]')),d=s+1,l=s-1,m=a.find(".downloads-block-navigation button").first(),c=a.find(".downloads-block-navigation button").last();r.attr("disabled","disabled");e={data:t,main_parent:a,offsetHolder:n,offset:s,link:r,nextPage:d,prevPage:l,prevButton:m,nextButton:c,doAction:o};dlmReportsInstance.handleSliderNavigation(e)}}
1
+ jQuery(function(e){new DLM_Reports;dlmReportsInstance.fetchUserData()});class DLM_Reports{dlmReportsStats=[];dlmUsersStats={logs:[],users:[]};currentFilters=[];tempDownloads=null;templates={};totalDownloads=0;perPage=dlmReportsPerPage;constructor(){(dlmReportsInstance=this).chartContainer=document.getElementById("total_downloads_chart");const e=dlmReportsInstance.chartContainer.getContext("2d");dlmReportsInstance.chartColors={purple:{default:"rgba(149, 76, 233, 1)",threesome:"rgba(149, 76, 233, 0.75)",half:"rgba(149, 76, 233, 0.5)",quarter:"rgba(149, 76, 233, 0.5)",zero:"rgba(149, 76, 233, 0.05)"},blue:{default:"rgba(67, 56, 202, 1)",threesome:"rgba(67, 56, 202, 0.75)",half:"rgba(67, 56, 202, 0.5)",quarter:"rgba(67, 56, 202, 0.25)",zero:"rgba(67, 56, 202, 0.05)"},green:{default:"rgba(00, 255, 00, 1)",threesome:"rgba(00, 255, 00, 0.75)",half:"rgba(00, 255, 00, 0.5)",quarter:"rgba(00, 255, 00, 0.25)",zero:"rgba(67, 56, 202, 0.05)"},royalBlue:{default:"rgba(65, 105, 225, 1)",threesome:"rgba(65, 105, 225, 0.75)",half:"rgba(65, 105, 225, 0.5)",quarter:"rgba(65, 105, 225, 0.25)",zero:"rgba(65, 105, 225, 0.05)"},persianBlue:{default:"rgba(28, 57, 187, 1)",threesome:"rgba(28, 57, 187, 0.75)",half:"rgba(28, 57, 187, 0.5)",quarter:"rgba(28, 57, 187, 0.25)",zero:"rgba(28, 57, 187, 0.05)"},darkCyan:{default:"rgba(0,129,167, 1)",threesome:"rgba(0,129,167, 0.75)",half:"rgba(0,129,167, 0.5)",quarter:"rgba(0,129,167, 0.25)",zero:"rgba(0,129,167, 0.05)"},strongCyan:{default:"rgba(0, 175, 185, 1)",threesome:"rgba(0, 175, 185, 0.75)",half:"rgba(0, 175, 185, 0.5)",quarter:"rgba(0, 175, 185, 0.25)",zero:"rgba(0, 175, 185, 0.05)"}},dlmReportsInstance.chartGradient=e.createLinearGradient(0,25,0,300),dlmReportsInstance.chartGradient.addColorStop(0,dlmReportsInstance.chartColors.darkCyan.half),dlmReportsInstance.chartGradient.addColorStop(.45,dlmReportsInstance.chartColors.darkCyan.quarter),dlmReportsInstance.chartGradient.addColorStop(1,dlmReportsInstance.chartColors.darkCyan.zero),dlmReportsInstance.datePickerContainer=document.getElementById("dlm-date-range-picker"),dlmReportsInstance.dataSets=[];let t=new Date;dlmReportsInstance.dates={downloads:{start_date:new Date(t.setMonth(t.getMonth()-1)),end_date:new Date}},dlmReportsInstance.chartDataObject={}}async fetchReportsData(e=0,t=1e3){const a=jQuery('div[data-id="general_info"]');dlmReportsInstance.setSpinner(jQuery(".total_downloads_chart-wrapper")),dlmReportsInstance.setSpinner(jQuery("#users_download_log")),dlmReportsInstance.setSpinner(jQuery("#total_downloads_table_wrapper2"));let n=dlmDownloadReportsAPI+"?offset="+e+"&limit="+t;0<dlmDownloadReportsAPI.indexOf("index.php?")&&(n=dlmDownloadReportsAPI+"&offset="+e+"&limit="+t);const o=await fetch(n);if(!o.ok){const s=document.createElement("div"),r=(s.className="dlm-loading-data",document.createTextNode("Seems like we bumped into an error! ")),d=document.createTextNode("Data fetching returned a status text of : "+fetchedData.statusText),l=document.createElement("h1"),m=document.createElement("h3");throw l.appendChild(r),m.appendChild(d),s.appendChild(l),s.appendChild(m),a.find(".dlm-loading-data").remove(),a.append(s),new Error("Something went wrong! Reports response did not come OK - "+fetchedData.statusText)}dlmReportsInstance.mostDownloaded=!1,dlmReportsInstance.stats=!1,dlmReportsInstance.chartType="day";e=await o.json();dlmReportsInstance.dlmReportsStats=dlmReportsInstance.dlmReportsStats.concat(e.stats),!0===e.done?(0<window.location.href.indexOf("dlm_time")&&(dlmReportsInstance.dates.downloads.start_date=0<Object.keys(dlmReportsInstance.dlmReportsStats).length?new Date(dlmReportsInstance.dlmReportsStats[0].date):new Date,dlmReportsInstance.dates.downloads.end_date=new Date,jQuery("#dlm-date-range-picker .date-range-info").html(dlmReportsInstance.dates.downloads.start_date.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"2-digit"})+" - "+dlmReportsInstance.dates.downloads.end_date.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"2-digit"}))),dlmReportsInstance.createDataOnDate(dlmReportsInstance.dates.downloads.start_date,dlmReportsInstance.dates.downloads.end_date),dlmReportsInstance.datePicker={opened:!1},jQuery(document).trigger("dlm_downloads_report_fetched",[dlmReportsInstance,dlmReportsInstance.dlmReportsStats]),dlmReportsInstance.stopSpinner(jQuery(".total_downloads_chart-wrapper")),dlmReportsInstance.init()):dlmReportsInstance.fetchReportsData(e.offset)}async fetchUsersReportsData(e=0,t=dlmPHPinfo.retrieved_rows){const a=jQuery('div[data-id="user_reports"]');let n=dlmUserReportsAPI+"?offset="+e+"&limit="+t;0<dlmUserReportsAPI.indexOf("index.php?")&&(n=dlmUserReportsAPI+"&offset="+e+"&limit="+t);const o=await fetch(n);if(!o.ok)throw new Error("Something went wrong! Reports response did not come OK - "+o.statusText);e=await o.json();dlmReportsInstance.dlmUsersStats.logs=dlmReportsInstance.dlmUsersStats.logs.concat(e.logs),!0===e.done?(dlmReportsInstance.userDownloads=void 0!==dlmReportsInstance.dlmUsersStats.logs?JSON.parse(JSON.stringify(dlmReportsInstance.dlmUsersStats.logs)):{},a.find(".dlm-loading-data").remove(),dlmReportsInstance.userReportsTab(),dlmReportsInstance.setTopDownloads(),dlmReportsInstance.stopSpinner(jQuery("#total_downloads_table_wrapper2"))):dlmReportsInstance.fetchUsersReportsData(e.offset)}async fetchUserData(){const e=await fetch(dlmUserDataAPI);if(!e.ok)throw new Error("Something went wrong! Reports response did not come OK - "+e.statusText);var t=await e.json();dlmReportsInstance.dlmUsersStats.users=dlmReportsInstance.dlmUsersStats.users.concat(t),dlmReportsInstance.fetchReportsData()}init(){dlmReportsInstance.tabNagivation(),dlmReportsInstance.overViewTab(),dlmReportsInstance.togglePageSettings(),dlmReportsInstance.setSpinner(jQuery("#users_download_log")),dlmReportsInstance.setSpinner(jQuery("#total_downloads_table_wrapper2")),dlmReportsInstance.fetchUsersReportsData(),jQuery(document).trigger("dlm_reports_init",[dlmReportsInstance]),dlmReportsInstance.eventsFunctions()}overViewTab(){dlmReportsInstance.dlmCreateChart(dlmReportsInstance.stats.chartStats,dlmReportsInstance.chartContainer),dlmReportsInstance.dlmDownloadsSummary(),dlmReportsInstance.datePickerContainer.addEventListener("click",dlmReportsInstance.toggleDatepicker.bind(this)),dlmReportsInstance.setTodayDownloads(),dlmReportsInstance.handleTopDownloads(),jQuery(document).on("click","body",function(e){e.stopPropagation(),0<jQuery(dlmReportsInstance.datePickerContainer).find("#dlm_date_range_picker").length&&dlmReportsInstance.hideDatepicker(jQuery(dlmReportsInstance.datePickerContainer),{target:"dlm-date-range-picker"})})}userReportsTab(){0!==Object.values(dlmReportsInstance.dlmUsersStats).length&&(dlmReportsInstance.logsDataByDate(dlmReportsInstance.dates.downloads.start_date,dlmReportsInstance.dates.downloads.end_date),dlmReportsInstance.handleUserDownloads(),dlmReportsInstance.filterDownloads())}getDates(e,t){const a={};let n=e;for(;n<=t;)a[this.createDateElement(n)]=0,n=this.getNextDay(n);return a}getMonths(e){const t={};return Object.keys(e).map(e=>{e=e.substring(0,7);void 0===t[e]&&(t[e]=0)}),t}getDoubleMonths(e){const t={},a=Object.keys(e)[0],n=Object.keys(e)[Object.keys(e).length-1];let o=0,s=a.substring(0,7),r=n.substring(0,7);return Object.keys(e).map(e=>{e=e.substring(0,7);s!==e&&r!==e&&(s=e,o++),void 0===t[e]&&0==o%2&&(t[e]=0)}),t}getWeeks(e){let a={};return Object.keys(e).forEach(e=>{let t;t=15<moment(e).date()?e.substring(0,7)+"-15":e.substring(0,7)+"-01",void 0===a[t]&&(a[t]=0)}),a}getWeek(e){let t={},a=Object.keys(e)[Object.keys(e).length-1],n=0;return Object.keys(e).map(e=>{void 0===t[e]&&0==n%7&&(t[e]=0),n++}),void 0===t[a]&&(t[a]=0),t}getDoubleDays(e){let t={},a=Object.keys(e)[0],n=Object.keys(e)[Object.keys(e).length-1],o=0;return Object.keys(e).map(e=>{a!==e&&n!==e&&(a=e,o++),void 0===t[e]&&0==o%2&&(t[e]=0)}),t}getNextDay(e){const t=new Date(e);return t.setDate(e.getDate()+1),t}createDateElement(e){var t=(e.getMonth()+1<10?"0":"")+(e.getMonth()+1);return e.getFullYear()+"-"+t+"-"+("0"+e.getDate()).slice(-2)}getSetDates(e,t){let a,n;if(void 0!==e&&e)a=dlmReportsInstance.createDateElement(new Date(e));else{const o=new Date;o.setDate(o.getDate()-30),a=dlmReportsInstance.createDateElement(o)}if(void 0!==t&&t){e=new Date(t);n=dlmReportsInstance.createDateElement(e)}else{const s=new Date;s.setDate(s.getDate()+1),n=dlmReportsInstance.createDateElement(s)}return{startDate:a,endDate:n}}createDataOnDate(e,t){let{startDate:a,endDate:n}={...dlmReportsInstance.getSetDates(e,t)},o,s,r,d,l,m=(dlmReportsInstance.reportsData=void 0!==dlmReportsInstance.dlmReportsStats?JSON.parse(JSON.stringify(dlmReportsInstance.dlmReportsStats)):{},s=moment(n,"YYYY-MM-DD").month()-moment(a,"YYYY-MM-DD").month(),r=moment(n,"YYYY-MM-DD").year()-moment(a,"YYYY-MM-DD").year(),o=moment(n).date()-moment(a).date(),dlmReportsInstance.chartType="day",0==r&&-6<s&&s<6?1<s||s<-1?dlmReportsInstance.chartType=2==s?"week":"weeks":1==s&&(8<o||-14<o||0==o)&&(dlmReportsInstance.chartType="days"):s<=0?dlmReportsInstance.chartType="month":dlmReportsInstance.chartType="months",dlmReportsInstance.getDates(new Date(a),new Date(n))),c,p,i,g;switch(dlmReportsInstance.chartType){case"months":p=dlmReportsInstance.getDoubleMonths(m),l=p;break;case"month":var u=dlmReportsInstance.getMonths(m);l=u;break;case"weeks":i=dlmReportsInstance.getWeeks(m),l=i;break;case"week":g=dlmReportsInstance.getWeek(m),l=g;break;case"days":c=dlmReportsInstance.getDoubleDays(m),l=c;break;case"day":l=m}Object.values(dlmReportsInstance.reportsData).forEach((o,e)=>{var s=JSON.parse(o.download_ids);if(void 0!==m[o.date])switch(dlmReportsInstance.chartType){case"months":d=o.date.substring(0,7);let e=parseInt(o.date.substring(5,7)),t=o.date.substring(0,5),a=6<(e-1).length?t+(e-1):t+"0"+(e-1);Object.values(s).forEach((e,t)=>{void 0===p[d]?void 0!==p[a]&&(p[a]=p[a]+e.downloads):p[d]=p[d]+e.downloads}),l=p;break;case"month":d=o.date.substring(0,7),Object.values(s).forEach((e,t)=>{monthDownloads[d]=void 0!==monthDownloads[d]?monthDownloads[d]+e.downloads:e.downloads}),l=monthDownloads;break;case"weeks":d=15<moment(o.date).date()?o.date.substring(0,7)+"-15":o.date.substring(0,7)+"-01",Object.values(s).forEach((e,t)=>{i[d]=void 0!==i[d]?i[d]+e.downloads:e.downloads}),l=i;break;case"week":d=o.date,Object.values(s).forEach((t,e)=>{if(void 0===g[d])for(let e=1;e<8;e++){var a=moment(o.date).date(moment(o.date).date()-e).format("YYYY-MM-DD");void 0!==g[a]&&(g[a]=g[a]+t.downloads)}else g[d]=g[d]+t.downloads}),l=g;break;case"days":d=o.date;let n=moment(o.date).date(moment(o.date).date()-1).format("YYYY-MM-DD");Object.values(s).forEach((e,t)=>{void 0===c[d]?void 0!==c[n]&&(c[n]=c[n]+e.downloads):c[d]=c[d]+e.downloads}),l=c;break;case"day":Object.values(s).forEach((e,t)=>{m[o.date]=m[o.date]+e.downloads}),l=m}else delete dlmReportsInstance.reportsData[e]});const I=Object.keys(m);e=I.length,t=I.findIndex(e=>a===e);let R=I.findIndex(e=>n===e);-1===t&&-1===R?dlmReportsInstance.stats={chartStats:Object.assign({},l),summaryStats:!1,daysLength:e}:(-1===R&&(R=e),dlmReportsInstance.stats={chartStats:Object.assign({},l),summaryStats:dlmReportsInstance.reportsData,daysLength:e})}dlmCreateChart(t,a,n=!1){if(t&&a){let e=Chart.getChart("total_downloads_chart");dlmReportsInstance.chartDataObject={dataSetLabel:"Downloads",dataSetColor:"#27ae60",dataSetbg:dlmReportsInstance.chartGradient,dataSetPointbg:dlmReportsInstance.chartColors.darkCyan.default,dataSetBorder:dlmReportsInstance.chartColors.darkCyan.default,dataSetElementColor:"#2ecc71",lineType:"original",xAxis:"x",chartData:t},void 0!==e&&e.destroy(),jQuery(document).trigger("dlm_reports_before_data_sets",[dlmReportsInstance.chartDataObject,t,n]),0<dlmReportsInstance.dataSets.length&&(dlmReportsInstance.dataSets=dlmReportsInstance.dataSets.filter(e=>dlmReportsInstance.chartDataObject.lineType!==e.origin)),dlmReportsInstance.dataSets.push({origin:dlmReportsInstance.chartDataObject.lineType,label:dlmReportsInstance.chartDataObject.dataSetLabel,color:dlmReportsInstance.chartDataObject.dataSetColor,data:dlmReportsInstance.chartDataObject.chartData,type:"line",fill:!0,backgroundColor:dlmReportsInstance.chartDataObject.dataSetbg,pointBackgroundColor:dlmReportsInstance.chartDataObject.dataSetPointbg,pointHoverBackgroundColor:"#fff",borderColor:dlmReportsInstance.chartDataObject.dataSetBorder,pointBorderWidth:1,lineTension:.3,borderWidth:1,pointRadius:3,elements:{line:{borderColor:dlmReportsInstance.chartDataObject.dataSetElementColor,borderWidth:1},point:{radius:4,hoverRadius:4,pointStyle:"circle"}}});t=Object.values(dlmReportsInstance.dataSets).filter(e=>"original"===e.origin);let s=Object.keys(t[0].data);dlmReportsInstance.dataSets.sort(function(e,t){return"original"===e.origin?-1:1}),dlmReportsInstance.chart=new Chart(a,{title:"",data:{datasets:dlmReportsInstance.dataSets},height:450,is_series:1,options:{aspectRatio:5,animation:!1,interaction:{mode:"index",intersect:!1},stacked:!1,scales:{x:{grid:{display:!1},ticks:{callback:e=>{let t="";var a=s[e],n=s[s.length-1],o=moment(n).month(moment(n).month()-1).format("YYYY-MM");return t="undefined"!==dlmReportsInstance.chartType&&"months"===dlmReportsInstance.chartType?(e=moment(s[e]).month())<11?a===o?moment(a).format("MMM, YYYY"):moment(a).format("MMM")+" - "+moment(a).month(e+1).format("MMM")+moment(a).format(", YYYY"):a===o||a===n?moment(a).format("MMM, YYYY"):moment(a).format("MMM")+moment(a).format(" YYYY")+" - "+moment(a).month(e+1).format("MMM")+moment(a).month(e+1).format(", YYYY"):"undefined"!==dlmReportsInstance.chartType&&"months"===dlmReportsInstance.chartType?moment(a).format("MMMM, YYYY"):moment(a).format("D MMM")}}},y:{grid:{drawBorder:!1},min:0,max:0!==dlmReportsInstance.getMaxDownload()?1===Math.ceil(dlmReportsInstance.getMaxDownload()/10)?dlmReportsInstance.getMaxDownload()+1:10*Math.ceil(dlmReportsInstance.getMaxDownload()/10):100,ticks:{stepSize:0!==dlmReportsInstance.getMaxDownload()?Math.ceil(dlmReportsInstance.getMaxDownload()/4):25,callback:e=>dlmReportsInstance.shortNumber(e)}}},normalized:!0,parsing:{xAxisKey:"x",yAxisKey:"y"},plugins:{tooltip:{enabled:!1,external:dlmReportsInstance.externalTooltipHandler.bind(dlmReportsInstance,this)},legend:{display:!0}}}})}}dlmDownloadsSummary(){let a={};if(!1===dlmReportsInstance.stats||!1===dlmReportsInstance.stats.summaryStats||Object.keys(dlmReportsInstance.stats.summaryStats).length<=0)return this.setTotalDownloads(0),this.setDailyAverage(0),void this.setMostDownloaded("--");dlmReportsInstance.totalDownloads=0,dlmReportsInstance.stats.summaryStats.forEach(e=>{e=JSON.parse(e.download_ids),Object.entries(e).forEach(([e,t])=>{dlmReportsInstance.totalDownloads+=t.downloads,a[e]=void 0===a[e]?{downloads:t.downloads,title:t.title,id:e}:{downloads:a[e].downloads+t.downloads,title:t.title,id:e}})}),dlmReportsInstance.mostDownloaded=dlmReportsInstance.orderItems(Object.values(a),"desc","downloads"),dlmReportsInstance.setTotalDownloads(dlmReportsInstance.totalDownloads),dlmReportsInstance.setDailyAverage((dlmReportsInstance.totalDownloads/parseInt(dlmReportsInstance.stats.daysLength)).toFixed(0)),dlmReportsInstance.setMostDownloaded(dlmReportsInstance.mostDownloaded[0].title)}createDatepicker(e,t,a){const n=new Date;let o=n.getDate()-1,s=n.getMonth()+1,r=s-1;var d=n.getFullYear(),l=(o<10&&(o="0"+o),s<10&&(s="0"+s),r<10&&(r="0"+r),d+"-"+s+"-"+o),d=d+"-"+r+"-"+o,m=jQuery("<div>").addClass("dlm_rdrs_overlay"),a=jQuery("<div>").attr("id",a.replace("#",""));return"dlm-date-range-picker"===t.target?(dlmReportsInstance.startDateInput=jQuery("<input>").attr("type","hidden").attr("id","dlm_start_date").attr("value",d),dlmReportsInstance.endDateInput=jQuery("<input>").attr("type","hidden").attr("id","dlm_end_date").attr("value",l),m.append(a).append(dlmReportsInstance.startDateInput).append(dlmReportsInstance.endDateInput)):jQuery(document).trigger("dlm_create_date_picker_"+t.target,[dlmReportsInstance,m,a,d,l]),m}displayDatepicker(e,s){var t;if(jQuery(e)){if(t="#"+jQuery(e).attr("id").replace(/-/gi,"_"),"dlm-date-range-picker"===s.target){if(dlmReportsInstance.datePicker.opened)return;dlmReportsInstance.datePicker.opened=!0}else jQuery(document).trigger("dlm_display_datepicker_"+s.target,[dlmReportsInstance,s,e]);let o=dlmReportsInstance.createDatepicker(e,s,t);e.append(o);var a=0<Object.keys(dlmReportsInstance.dlmReportsStats).length?new Date(dlmReportsInstance.dlmReportsStats[0].date):new Date,n=(new Date,[]),e=(jQuery(document).trigger("dlm_datepicker_shortcuts_"+s.target,[dlmReportsInstance,s,e,n]),{separator:" to ",autoClose:!0,getValue:function(){},setValue:function(e,t,a){o.find('input[type="hidden"]').first().val(t),o.find('input[type="hidden"]').last().val(a)},inline:!0,alwaysOpen:!0,container:t,endDate:new Date,startDate:a,showShortcuts:!0,shortcuts:null,customShortcuts:n});o.dateRangePicker(e).on("datepicker-change",(e,t)=>{var a,n;t.date1&&t.date2&&(a=t.date1.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"2-digit"}),n=t.date2.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"2-digit"}),o.parent().find("span.date-range-info").text(a+" - "+n)),"dlm-date-range-picker"===s.target?(dlmReportsInstance.dates.downloads={start_date:t.date1,end_date:t.date2},dlmReportsInstance.createDataOnDate(dlmReportsInstance.dates.downloads.start_date,dlmReportsInstance.dates.downloads.end_date),dlmReportsInstance.dlmCreateChart(dlmReportsInstance.stats.chartStats,dlmReportsInstance.chartContainer,!1),dlmReportsInstance.dlmDownloadsSummary(),0<Object.values(dlmReportsInstance.dlmUsersStats.logs).length&&dlmReportsInstance.logsDataByDate(dlmReportsInstance.dates.downloads.start_date,dlmReportsInstance.dates.downloads.end_date)):jQuery(document).trigger("dlm_daterangepicker_init_"+s.target,[dlmReportsInstance,t.date1,t.date2]),dlmReportsInstance.setTopDownloads(),o.data("dateRangePicker").close()}),"dlm-date-range-picker"===s.target?o.data("dateRangePicker").setDateRange(dlmReportsInstance.dates.downloads.start_date,dlmReportsInstance.dates.downloads.end_date):jQuery(document).trigger("dlm_daterangepicker_after_init_"+s.target,[o,dlmReportsInstance])}}hideDatepicker(e,t){"dlm-date-range-picker"===t.target?dlmReportsInstance.datePicker.opened=!1:jQuery(document).trigger("dlm_hide_datepicker_"+t.target,[dlmReportsInstance,e,t]),e.find(".dlm_rdrs_overlay").remove()}toggleDatepicker(e){e.stopPropagation();const t=jQuery(e.target).parents(".dlm-reports-header-date-selector");e={target:t.attr("id"),object:dlmReportsInstance.datePicker};dlmReportsInstance.closeDatePickers(t),"dlm-date-range-picker"===e.target?dlmReportsInstance.datePicker.opened?dlmReportsInstance.hideDatepicker(t,e):dlmReportsInstance.displayDatepicker(t,e):jQuery(document).trigger("dlm_toggle_datepicker_"+e.target,[dlmReportsInstance,t,e])}setTotalDownloads(e){jQuery(".dlm-reports-block-summary li#total span").html(e.toLocaleString())}setDailyAverage(e){jQuery(".dlm-reports-block-summary li#average span").html(e.toLocaleString())}setMostDownloaded(e){jQuery(".dlm-reports-block-summary li#most_popular span").html(e)}setTodayDownloads(){let e=0;Object.keys(dlmReportsInstance.dlmReportsStats).length<=0?jQuery(".dlm-reports-block-summary li#today span").html(e.toLocaleString()):(dlmReportsInstance.dlmReportsStats[dlmReportsInstance.dlmReportsStats.length-1].date===dlmReportsInstance.createDateElement(new Date)&&(e=Object.values(JSON.parse(dlmReportsInstance.dlmReportsStats[dlmReportsInstance.dlmReportsStats.length-1].download_ids)).reduce((e,t)=>e+t.downloads,0)),jQuery(".dlm-reports-block-summary li#today span").html(e))}setTopDownloads(e=0,t=!1){const a=jQuery("#total_downloads_table_wrapper2"),n=jQuery("#total_downloads_table_wrapper2 .total_downloads_table__list");if(n.empty(),n.parent().addClass("empty"),dlmReportsInstance.mostDownloaded&&!0!==t){var o=JSON.parse(JSON.stringify(dlmReportsInstance.mostDownloaded)).slice(dlmReportsInstance.perPage*parseInt(e),dlmReportsInstance.perPage*parseInt(e+1));for(let e=0;e<o.length;e++){const r=dlmReportsInstance.getDownloadByID(o[e].id);if(void 0===r)return;var s={id:o[e].id,title:o[e].title,edit_link:dlmAdminUrl+"post.php?post="+o[e].id+"&action=edit",total_downloads:r.total.toLocaleString()};jQuery(document).trigger("dlm_reports_top_downloads_item_before_render",[s,dlmReportsInstance,o[e],r]),new dlmBackBone.modelTopDownloads(s)}n.parent().removeClass("empty"),a.find(".dlm-reports-total-pages").html(Math.ceil(dlmReportsInstance.mostDownloaded.length/dlmReportsInstance.perPage)),parseInt(dlmReportsInstance.perPage)!==parseInt(o.length)?a.find('.downloads-block-navigation button[data-action="load-more"]').attr("disabled","disabled"):a.find('.downloads-block-navigation button[data-action="load-more"]').removeAttr("disabled"),dlmReportsInstance.mostDownloaded.length>dlmReportsInstance.perPage?a.find(".downloads-block-navigation button").removeClass("hidden"):a.find(".downloads-block-navigation button").addClass("hidden"),dlmReportsInstance.stopSpinner(jQuery("#total_downloads_table_wrapper2"))}}handleTopDownloads(){jQuery("html body").on("click","#total_downloads_table_wrapper2 .downloads-block-navigation button",function(){let e=jQuery(this).parents("#total_downloads_table_wrapper2"),t=e,a=e.attr("data-page"),n=jQuery(this),o=parseInt(a)+1,s=0!==a?parseInt(a)-1:0,r=e.find(".downloads-block-navigation").find("button").first(),d=e.find(".downloads-block-navigation").find("button").last();n.attr("disabled","disabled");var l={data:dlmReportsInstance.mostDownloaded,main_parent:e,offsetHolder:t,offset:a,link:n,nextPage:o,prevPage:s,prevButton:r,nextButton:d,doAction:dlmReportsInstance.setTopDownloads};dlmReportsInstance.handleSliderNavigation(l)}),jQuery("#total_downloads_table_wrapper2").find("input.dlm-reports-current-page").on("change",function(){dlmReportsInstance.paginationChange(jQuery(this),dlmReportsInstance.mostDownloaded,jQuery("#total_downloads_table_wrapper2"),jQuery(this).parents("#total_downloads_table_wrapper2"),dlmReportsInstance.setTopDownloads)})}handleSliderNavigation(e){const{data:t,main_parent:a,offsetHolder:n,offset:o,link:s,nextPage:r,prevPage:d,prevButton:l,nextButton:m,doAction:c}={...e};let p=1;"load-more"===s.data("action")?(n.attr("data-page",r),c(r),Math.ceil(t.length/dlmReportsInstance.perPage)>r+1&&m.removeAttr("disabled"),l.removeAttr("disabled"),p=parseInt(r)+1):0!==parseInt(o)&&(n.attr("data-page",d),c(d),1!==parseInt(o)&&l.removeAttr("disabled"),m.removeAttr("disabled"),p=parseInt(d)+1),a.find(".dlm-reports-current-page").val(p)}tabNagivation(){jQuery(document).on("click",".dlm-reports .dlm-insights-tab-navigation > li",function(){const e=jQuery(this),t=jQuery(".dlm-reports .dlm-insights-tab-navigation > li").not(e),a=jQuery('div.dlm-insights-tab-navigation__content[data-id="'+e.attr("id")+'"]'),n=jQuery("div.dlm-insights-tab-navigation__content").not(a);e.hasClass("active")||(e.addClass("active"),t.removeClass("active"),a.addClass("active"),n.removeClass("active"))})}getOrCreateTooltip(e){let t=e.canvas.parentNode.querySelector("div.dlm-canvas-tooltip"),a=e.canvas.parentNode.querySelector("div.dlm-reports-tooltip__line");if(t||((a=document.createElement("div")).className="dlm-reports-tooltip__line"),!t){(t=document.createElement("div")).className="dlm-canvas-tooltip";const n=document.createElement("div");n.className="dlm-reports-tooltip",t.appendChild(n),e.canvas.parentNode.appendChild(t),e.canvas.parentNode.appendChild(a)}return{tooltipEl:t,tooltipLine:a}}externalTooltipHandler(d,e){const{chart:t,tooltip:l}=e,{tooltipEl:a,tooltipLine:n}={...d.getOrCreateTooltip(t)};e=jQuery(a).parent().width();if(0===l.opacity)return a.style.opacity=0,void(n.style.opacity=0);if(l.body){const m=l.title||[],c=document.createElement("div"),p=(c.className="dlm-reports-tooltip__header",m.forEach(e=>{const t=document.createElement("div"),a=(t.className="dlm-reports-tooltip__row",document.createElement("p")),n=(a.className="dlm-reports-tooltip__info",a.appendChild(document.createTextNode("Downloads")),t.appendChild(a),jQuery(document).trigger("dlm_chart_tooltip_before",[dlmReportsInstance,l,t,d]),document.createElement("p"));n.className="dlm-reports-tooltip__date";var o=dlmReportsInstance.setChartTooltipDate(l.dataPoints[0].label,d,d.stats.chartStats);n.appendChild(document.createTextNode(o)),t.appendChild(n);const s=document.createElement("p"),r=(s.className="dlm-reports-tooltip__downloads",document.createElement("span"));r.className="dlm-reports-tooltip__downloads_pointer",r.style.backgroundColor=dlmReportsInstance.chartColors.darkCyan.default,s.appendChild(r),s.appendChild(document.createTextNode(dlmReportsInstance.shortNumber(l.dataPoints[0].formattedValue))),t.appendChild(s),jQuery(document).trigger("dlm_chart_tooltip_after",[dlmReportsInstance,l,t,d]),c.appendChild(t)}),a.querySelector("div.dlm-reports-tooltip"));for(;p.firstChild;)p.firstChild.remove();p.appendChild(c)}var{offsetLeft:o,offsetTop:s}=t.canvas;a.style.opacity=1;let r={isMargin:!(n.style.opacity=1),left:!1};l.caretX-l.width<0&&(r.isMargin=!0,r.left=!0),o+l.caretX+l.width>e&&(r.isMargin=!0,r.left=!1),r.isMargin?r.left?a.style.left=o+l.width+"px":a.style.left=e-l.width+"px":a.style.left=o+l.caretX+"px",n.style.left=o+l.caretX+"px",a.style.top=s+l.caretY-a.offsetHeight-10+"px"}createUserRelatedData(){dlmReportsInstance.userRelatedData=[],Object.values(dlmReportsInstance.userDownloads).forEach((e,t)=>{var a;"0"!==e.user_id&&(a=[e.user_id,e.download_id,e.download_date,e.download_status],e="user_"+e.user_id,void 0!==dlmReportsInstance.userRelatedData[e]?dlmReportsInstance.userRelatedData[e].push(a):dlmReportsInstance.userRelatedData[e]=[a])})}logsDataByDate(e,t){var{startDate:e,endDate:t}={...dlmReportsInstance.getSetDates(e,t)};dlmReportsInstance.userDownloads=JSON.parse(JSON.stringify(dlmReportsInstance.dlmUsersStats.logs));let a=new Date(e),n=(a.setDate(a.getDate()-1),a=a.getTime(),new Date(t));n.setDate(n.getDate()+1),n=n.getTime(),dlmReportsInstance.userDownloads=dlmReportsInstance.userDownloads.filter((e,t)=>{e=dlmReportsInstance.createDateElement(new Date(e.download_date));return(e=new Date(e).getTime())>a&&e<n}),dlmReportsInstance.createUserRelatedData(),dlmReportsInstance.filterDownloads(),dlmReportsInstance.setMostActiveUser(),dlmReportsInstance.setLoggedOutDownloads(),dlmReportsInstance.setLoggedInDownloads(),jQuery(document).trigger("dlm_set_logs_data_by_date",[dlmReportsInstance])}setMostActiveUser(){var e=dlmReportsInstance.getUserByID(dlmReportsInstance.getMostActiveID()[0]);jQuery(".dlm-reports-block-summary li#most_active_user span").html(dlmReportsInstance.userToolTipMarkup(e))}getMostActiveID(){return Object.values(dlmReportsInstance.userRelatedData).length?Object.values(dlmReportsInstance.userRelatedData).reduce((e,t,a)=>parseInt(e.length)>parseInt(t.length)&&0<e.length&&null!==dlmReportsInstance.getUserByID(e[0][0])?e:null!==dlmReportsInstance.getUserByID(t[0][0])?t:[],[]):0}getUserByID(t){if(!t)return null;if("0"===t)return{role:"Guest",display_name:"Guest"};var e=Object.values(dlmReportsInstance.dlmUsersStats.users).filter(e=>parseInt(t)===parseInt(e.id));return Array.isArray(e)?0===e.length?null:e[0]:e}getLoggedInDownloads(){return Object.values(dlmReportsInstance.userRelatedData).length?1<Object.values(dlmReportsInstance.userRelatedData).length?Object.values(dlmReportsInstance.userRelatedData).reduce((e,t)=>parseInt(e)+parseInt(t.length),0):Object.values(dlmReportsInstance.userRelatedData)[0].length:0}setLoggedInDownloads(){const e=dlmReportsInstance.getLoggedInDownloads();jQuery(".dlm-reports-block-summary li#logged_in span,#total_downloads_summary_wrapper .dlm-reports-logged-in").html(e.toLocaleString())}getLoggedOutDownloads(){return dlmReportsInstance.userDownloads.length-dlmReportsInstance.getLoggedInDownloads()}setLoggedOutDownloads(){const e=dlmReportsInstance.getLoggedOutDownloads();jQuery(".dlm-reports-block-summary li#logged_out span,#total_downloads_summary_wrapper .dlm-reports-logged-out").html(e.toLocaleString())}userToolTipMarkup(e){let t='<div class="dlm-user-reports">';return t=(t=t+'<div class="wpchill-tooltip"><i>[?]</i>'+'<div class="wpchill-tooltip-content">')+("<span>User ID: "+(null!==e?e.id:"--")+"</span>"),"object"!=typeof e&&e.url.length&&(t+="<span>User URL: "+(null!==e?e.url:"--")+"</span>"),t+="<span>User registration date: "+(null!==e?e.registered:"--")+"</span>",null!==e&&void 0!==e.role&&e.role.length&&(t+="<span>User role: "+e.role+"</span>"),t=(t+="</div></div>")+(null!==e?e.display_name:"--")+"</div>"}setUserDownloads(e=0,t=!1){const a=jQuery("#users_download_log"),n=jQuery("#users_download_log .user-logs__list");if(n.empty(),!0!==t){let t=[];t=(null!==dlmReportsInstance.tempDownloads?JSON.parse(JSON.stringify(dlmReportsInstance.tempDownloads)):JSON.parse(JSON.stringify(dlmReportsInstance.userDownloads))).slice(dlmReportsInstance.perPage*parseInt(e),dlmReportsInstance.perPage*parseInt(e+1));for(let e=0;e<t.length;e++){var o=dlmReportsInstance.getUserByID(t[e].user_id.toString()),s=dlmReportsInstance.getDownloadCPT(t[e].download_id.toString()),r={key:e,user:null!=o?o.display_name:"--",ip:t[e].user_ip,role:null!==o&&null!==o.role?o.role:"--",download:null!=s?s.title:"--",valid_user:"0"!==t[e].user_id,edit_link:"0"!==t[e].user_id?"user-edit.php?user_id="+t[e].user_id:"#",edit_download_link:null!=s?dlmAdminUrl+"post.php?post="+s.id+"&action=edit":"#",status:t[e].download_status,download_date:t[e].download_date};jQuery(document).trigger("dlm_reports_user_logs_item_before_render",[r,dlmReportsInstance,t[e],o,s]),new dlmBackBone.modelUserLogs(r)}dlmReportsInstance.stopSpinner(jQuery("#users_download_log")),a.find(".dlm-reports-total-pages").html(Math.ceil(dlmReportsInstance.tempDownloads.length/dlmReportsInstance.perPage)),parseInt(dlmReportsInstance.perPage)!==parseInt(t.length)?a.find('.user-downloads-block-navigation button[data-action="load-more"]').attr("disabled","disabled"):a.find('.user-downloads-block-navigation button[data-action="load-more"]').removeAttr("disabled"),dlmReportsInstance.userDownloads.length>dlmReportsInstance.perPage?a.find(".user-downloads-block-navigation button").removeClass("hidden"):a.find(".user-downloads-block-navigation button").addClass("hidden")}}filterDownloads(){dlmReportsInstance.tempDownloads=JSON.parse(JSON.stringify(dlmReportsInstance.userDownloads)),dlmReportsInstance.currentFilters.length&&dlmReportsInstance.currentFilters.forEach(t=>{dlmReportsInstance.tempDownloads=dlmReportsInstance.tempDownloads.filter(e=>t.on===e[t.type])}),dlmReportsInstance.setUserDownloads()}handleUserDownloads(){jQuery(".user-downloads-block-navigation").on("click","button",function(e){e.stopPropagation();let t=jQuery(this).parents("#users_downloads_table_wrapper"),a=t.find("#users_download_log"),n=a.attr("data-page"),o=jQuery(this),s=parseInt(n)+1,r=0!==n?parseInt(n)-1:0,d=t.find(".downloads-block-navigation button").first(),l=t.find(".downloads-block-navigation button").last();o.attr("disabled","disabled");e={data:dlmReportsInstance.tempDownloads,main_parent:t,offsetHolder:a,offset:n,link:o,nextPage:s,prevPage:r,prevButton:d,nextButton:l,doAction:dlmReportsInstance.setUserDownloads};dlmReportsInstance.handleSliderNavigation(e)}),jQuery("#users_downloads_table_wrapper").find("input.dlm-reports-current-page").on("change",function(){dlmReportsInstance.paginationChange(jQuery(this),dlmReportsInstance.tempDownloads,jQuery("#users_downloads_table_wrapper"),jQuery("#users_downloads_table_wrapper").find("#users_download_log"),dlmReportsInstance.setUserDownloads)})}togglePageSettings(){jQuery("#dlm-toggle-settings").on("click",function(e){e.stopPropagation(),jQuery(this).find(".dlm-toggle-settings__settings").toggleClass("display")}),jQuery(".dlm-toggle-settings__settings").on("click",function(e){e.stopPropagation()}),jQuery("html,body").on("click",function(){jQuery(this).find(".dlm-toggle-settings__settings").removeClass("display")}),jQuery(document).on("change",".wpchill-toggle__input",function(e){const t=jQuery(this),a=t.attr("name"),n={action:"dlm_update_report_setting",name:a,checked:t.is(":checked"),_ajax_nonce:dlmReportsNonce};jQuery.post(ajaxurl,n,function(e){a,jQuery(document).trigger("dlm_settings_ajax_response",[dlmReportsInstance,t,e])})})}getMaxDownload(){let t=0;return dlmReportsInstance.dataSets.forEach(e=>{e=Object.values(e.data).reduce((e,t)=>t<e?e:t,0);t<e&&(t=e)}),parseInt(t)}setChartTooltipDate(e,t,a){let n="";var o,s,r;return n="undefined"!==t.chartType&&"months"===t.chartType?(moment(e).year(),r=moment(e).month(),a=Object.keys(a)[Object.keys(a).length-1],o=moment(a).month(moment(a).month()-1).format("YYYY-MM"),s=moment(e).format("YYYY-MM"),r<11?s===o?moment(s).format("MMMM, YYYY"):moment(e).format("MMM")+" - "+moment(e).month(r+1).format("MMM")+moment(e).format(", YYYY"):s===o||s===a?moment(s).format("MMMM, YYYY"):moment(e).format("MMM")+moment(e).format(" YYYY")+" - "+moment(e).month(r+1).format("MMM")+moment(e).month(r+1).format(", YYYY")):"undefined"!==t.chartType&&"days"===t.chartType?(moment(e).year(),o=moment(e).day(),a=moment(e).format("MMMM"),s=moment(e).day(o+1).format("MMMM"),r=dlmReportsInstance.dates.downloads.end_date,t=moment(r).day(moment(r).day()-1).format("MMMM Do"),moment(e).format("MMMM Do")===moment(r).format("MMMM Do")||moment(e).format("MMMM Do")===t?moment(e).format("MMMM Do, YYYY"):a===s?moment(e).format("MMMM Do")+" - "+moment(e).day(o+1).format("Do")+moment(e).format(", YYYY"):moment(e).format("MMM Do")+" - "+moment(e).day(o+1).format("MMM Do")+moment(e).format(", YYYY")):moment(e).format("MMMM Do, YY")}closeDatePickers(e){jQuery(".dlm-reports-header-date-selector").not(e).each(function(){var e={target:jQuery(this).attr("id")};dlmReportsInstance.hideDatepicker(jQuery(this),e)})}shortNumber(e){return e=4<=(e="string"==typeof e?e.replace(/,/gi,""):parseInt(e).toString()).length?parseInt(e.substring(0,e.length-3)).toLocaleString()+"k":e}getDownloadByID(t){let a={total:0},n;return dlmReportsInstance.tempDownloads.forEach(function(e){t===e.download_id&&(n=e,a.total=a.total+1,jQuery(document).trigger("dlm_download_by_id",[dlmReportsInstance,a,n]))}),a}getDownloadCPT(t){let e=null;return Array.isArray(dlmReportsInstance.mostDownloaded)&&(e=dlmReportsInstance.mostDownloaded.filter(e=>e.id===t,0)[0]),jQuery(document).trigger("dlm_download_cpt",[dlmReportsInstance,e]),e}setSpinner(e){e.append('<div class="dlm-reports-spinner"><span></span></div>')}stopSpinner(e){e.find(".dlm-reports-spinner").remove()}eventsFunctions(){jQuery("body").on("click",".total_downloads_table_filters_total_downloads > a",function(e){e.preventDefault(),jQuery(this).parent().find("span.dashicons").toggleClass("dashicons-arrow-down dashicons-arrow-up"),dlmReportsInstance.orderOverviewItemsByTotal()}),jQuery("body").on("click",".total_downloads_table_filters_download_date > a",function(e){e.preventDefault(),jQuery(this).parent().find("span.dashicons").toggleClass("dashicons-arrow-down dashicons-arrow-up"),dlmReportsInstance.orderUserReportsItemsByDate()}),jQuery("body").on("change","select.dlm-reports-per-page",function(e){dlmReportsInstance.perPage=jQuery(this).val(),dlmReportsInstance.setTopDownloads(),dlmReportsInstance.setUserDownloads(),jQuery.post(ajaxurl,{action:"dlm_update_report_setting",name:"dlm-reports-per-page",value:dlmReportsInstance.perPage,_ajax_nonce:dlmReportsNonce},function(e){})})}orderItems(e,a,n,t=0){return e.sort((e,t)=>"asc"!==a?t[n]-e[n]:e[n]-t[n]),e}orderOverviewItemsByTotal(){dlmReportsInstance.mostDownloaded=dlmReportsInstance.mostDownloaded.reverse(),dlmReportsInstance.setTopDownloads()}orderUserReportsItemsByDate(){dlmReportsInstance.tempDownloads=dlmReportsInstance.tempDownloads.reverse(),dlmReportsInstance.setUserDownloads()}paginationChange(e,t,a,n,o){let s=parseInt(e.val()),r=(0===s&&(s=1),t.length<s*dlmReportsInstance.perPage&&(s=Math.ceil(t.length/dlmReportsInstance.perPage)),jQuery(this).next('button[data-action="load-more"]')),d=s+1,l=s-1,m=a.find(".downloads-block-navigation button").first(),c=a.find(".downloads-block-navigation button").last();r.attr("disabled","disabled");e={data:t,main_parent:a,offsetHolder:n,offset:s,link:r,nextPage:d,prevPage:l,prevButton:m,nextButton:c,doAction:o};dlmReportsInstance.handleSliderNavigation(e)}}
changelog.txt CHANGED
@@ -1,3 +1,12 @@
 
 
 
 
 
 
 
 
 
1
  = 4.7.1 - 18.10.2022 =
2
  Fixed: Top Downloads widget wrong URL ( [#1087](https://github.com/WPChill/download-monitor/issues/1087) )
3
  Fixed: Error when getting version download ( [#1090](https://github.com/WPChill/download-monitor/issues/1090) )
1
+ = 4.7.2 - 24.10.2022 =
2
+ Fixed: Possible overload of server on the Reports page ( [#1102](https://github.com/WPChill/download-monitor/issues/1102) )
3
+ Changed: Plugin Logo ( [#1101](https://github.com/WPChill/download-monitor/issues/1101) )
4
+ Fixed: Log query strings for download location ( [#1099](https://github.com/WPChill/download-monitor/issues/1099) )
5
+ Fixed: Version's number of downloads wrong ( [#1097](https://github.com/WPChill/download-monitor/issues/1097) )
6
+ Added: Protection functionality for Media Library files ( [#1096](https://github.com/WPChill/download-monitor/issues/1096) )
7
+ Fixed: Redirect to file when unicode chars are present ( [#1095](https://github.com/WPChill/download-monitor/issues/1095) )
8
+ Fixed: Front-end CSS was not enqueued for Gutenberg blocks ( [#1094](https://github.com/WPChill/download-monitor/issues/1094) )
9
+
10
  = 4.7.1 - 18.10.2022 =
11
  Fixed: Top Downloads widget wrong URL ( [#1087](https://github.com/WPChill/download-monitor/issues/1087) )
12
  Fixed: Error when getting version download ( [#1090](https://github.com/WPChill/download-monitor/issues/1090) )
download-monitor.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Download Monitor
4
  Plugin URI: https://www.download-monitor.com
5
  Description: A full solution for managing and selling downloadable files, monitoring downloads and outputting download links and file information on your WordPress powered site.
6
- Version: 4.7.1
7
  Author: WPChill
8
  Author URI: https://wpchill.com
9
  Requires at least: 5.4
@@ -34,7 +34,7 @@ if ( ! defined( 'ABSPATH' ) ) {
34
 
35
  // Define DLM Version
36
 
37
- define( 'DLM_VERSION', '4.7.1' );
38
  define( 'DLM_UPGRADER_VERSION', '4.6.0' );
39
 
40
  // Define DLM FILE
3
  Plugin Name: Download Monitor
4
  Plugin URI: https://www.download-monitor.com
5
  Description: A full solution for managing and selling downloadable files, monitoring downloads and outputting download links and file information on your WordPress powered site.
6
+ Version: 4.7.2
7
  Author: WPChill
8
  Author URI: https://wpchill.com
9
  Requires at least: 5.4
34
 
35
  // Define DLM Version
36
 
37
+ define( 'DLM_VERSION', '4.7.2' );
38
  define( 'DLM_UPGRADER_VERSION', '4.6.0' );
39
 
40
  // Define DLM FILE
includes/admin/uninstall/class-dlm-uninstall.php CHANGED
@@ -40,7 +40,7 @@ class DLM_Uninstall {
40
 
41
  $current_screen = get_current_screen();
42
  if ( in_array( $current_screen->base, array( 'plugins', 'plugins-network' ) ) ) {
43
- wp_enqueue_style( 'dlm-uninstall', $plugin_url . '/assets/css/dlm-uninstall.min.css' );
44
  wp_enqueue_script( 'dlm-uninstall', $plugin_url . '/assets/js/dlm-uninstall.js', array( 'jquery' ), DLM_VERSION, true );
45
  wp_localize_script( 'dlm-uninstall', 'wpDLMUninstall', array(
46
  'redirect_url' => admin_url( '/plugins.php' ),
40
 
41
  $current_screen = get_current_screen();
42
  if ( in_array( $current_screen->base, array( 'plugins', 'plugins-network' ) ) ) {
43
+ wp_enqueue_style( 'dlm-uninstall', $plugin_url . '/assets/css/dlm-uninstall.min.css', array(), DLM_VERSION );
44
  wp_enqueue_script( 'dlm-uninstall', $plugin_url . '/assets/js/dlm-uninstall.js', array( 'jquery' ), DLM_VERSION, true );
45
  wp_localize_script( 'dlm-uninstall', 'wpDLMUninstall', array(
46
  'redirect_url' => admin_url( '/plugins.php' ),
includes/backwards-compatibility/class-dlm-backwards-compatibility.php CHANGED
@@ -52,7 +52,7 @@ class DLM_Backwards_Compatibility {
52
  // Reset postdata after the loop.
53
  add_action( 'dlm_reset_postdata', array( $this, 'reset_postdata' ), 15, 1 );
54
  // Add version postmeta downloads to the version download count.
55
- add_filter( 'dlm_add_version_meta_download_count', array( $this, 'meta_download_counts' ), 15, 2 );
56
  // Add Download postmeta downloads to the Download download count.
57
  add_filter( 'dlm_add_meta_download_count', array( $this, 'add_meta_download_count' ), 30, 2 );
58
  // If the DB upgrade functionality did not take place we won't have the option stored.
@@ -270,36 +270,6 @@ class DLM_Backwards_Compatibility {
270
  //remove_filter( 'posts_where', array( $this, 'where_download_count_compatibility' ) );
271
  }
272
 
273
- /**
274
- * Backwards compaitbility for users who did not use the logs
275
- *
276
- * @since 4.6.0
277
- *
278
- * @param mixed $counts
279
- * @param mixed $version_id
280
- * @return void
281
- */
282
- public function meta_download_counts( $counts, $id ) {
283
-
284
- // Filter to enable adding meta counts to download counts.
285
- $count_meta = apply_filters( 'dlm_count_meta_downloads', false );
286
-
287
- if ( ( isset( $this->upgrade_option['using_logs'] ) && '0' === $this->upgrade_option['using_logs'] ) || $count_meta ) {
288
-
289
- if ( 'dlm_download_version' === get_post_type( $id ) ) {
290
- $meta_counts = get_post_meta( get_post( $id )->post_parent, '_download_count', true );
291
- } else {
292
- $meta_counts = get_post_meta( $id, '_download_count', true );
293
- }
294
-
295
- if ( isset( $meta_counts ) && '' !== $meta_counts ) {
296
- return ( (int) $counts + (int) $meta_counts );
297
- }
298
- }
299
-
300
- return $counts;
301
- }
302
-
303
  /**
304
  * Backwards compatiblity for query args if using custom functionality
305
  *
@@ -349,7 +319,7 @@ class DLM_Backwards_Compatibility {
349
  }
350
 
351
  /**
352
- * Backwards compatibility to take meta count into consideration for Downloads
353
  *
354
  * @param [type] $count
355
  * @param [type] $download_id
@@ -364,7 +334,7 @@ class DLM_Backwards_Compatibility {
364
 
365
  if ( ( isset( $this->upgrade_option['using_logs'] ) && '0' === $this->upgrade_option['using_logs'] ) || $count_meta ) {
366
 
367
- if ( 'dlm_download' !== get_post_type( $download_id ) ) {
368
 
369
  return $counts;
370
  }
52
  // Reset postdata after the loop.
53
  add_action( 'dlm_reset_postdata', array( $this, 'reset_postdata' ), 15, 1 );
54
  // Add version postmeta downloads to the version download count.
55
+ add_filter( 'dlm_add_version_meta_download_count', array( $this, 'add_meta_download_count' ), 15, 2 );
56
  // Add Download postmeta downloads to the Download download count.
57
  add_filter( 'dlm_add_meta_download_count', array( $this, 'add_meta_download_count' ), 30, 2 );
58
  // If the DB upgrade functionality did not take place we won't have the option stored.
270
  //remove_filter( 'posts_where', array( $this, 'where_download_count_compatibility' ) );
271
  }
272
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
273
  /**
274
  * Backwards compatiblity for query args if using custom functionality
275
  *
319
  }
320
 
321
  /**
322
+ * Backwards compatibility to take meta count into consideration for Downloads & Versions
323
  *
324
  * @param [type] $count
325
  * @param [type] $download_id
334
 
335
  if ( ( isset( $this->upgrade_option['using_logs'] ) && '0' === $this->upgrade_option['using_logs'] ) || $count_meta ) {
336
 
337
+ if ( 'dlm_download' !== get_post_type( $download_id ) && 'dlm_download_version' !== get_post_type( $download_id ) ) {
338
 
339
  return $counts;
340
  }
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: wpchill, silkalns, barrykooij, mikejolley
3
  Tags: download manager, document management, file manager, digital store, ecommerce, document management plugin, download monitor, download counter, password protection, download protection, password, protect downloads, tracker, sell, shop, ecommerce, paypal
4
  Requires at least: 5.4
5
  Tested up to: 6.0
6
- Stable tag: 4.7.1
7
  License: GPLv3
8
  Text Domain: -
9
  Requires PHP: 5.6
@@ -121,6 +121,15 @@ More documentation can be found in our [Knowledge Base](https://www.download-mon
121
 
122
  == Changelog ==
123
 
 
 
 
 
 
 
 
 
 
124
  = 4.7.1 - 18.10.2022 =
125
  Fixed: Top Downloads widget wrong URL ( [#1087](https://github.com/WPChill/download-monitor/issues/1087) )
126
  Fixed: Error when getting version download ( [#1090](https://github.com/WPChill/download-monitor/issues/1090) )
3
  Tags: download manager, document management, file manager, digital store, ecommerce, document management plugin, download monitor, download counter, password protection, download protection, password, protect downloads, tracker, sell, shop, ecommerce, paypal
4
  Requires at least: 5.4
5
  Tested up to: 6.0
6
+ Stable tag: 4.7.2
7
  License: GPLv3
8
  Text Domain: -
9
  Requires PHP: 5.6
121
 
122
  == Changelog ==
123
 
124
+ = 4.7.2 - 24.10.2022 =
125
+ Fixed: Possible overload of server on the Reports page ( [#1102](https://github.com/WPChill/download-monitor/issues/1102) )
126
+ Changed: Plugin Logo ( [#1101](https://github.com/WPChill/download-monitor/issues/1101) )
127
+ Fixed: Log query strings for download location ( [#1099](https://github.com/WPChill/download-monitor/issues/1099) )
128
+ Fixed: Version's number of downloads wrong ( [#1097](https://github.com/WPChill/download-monitor/issues/1097) )
129
+ Added: Protection functionality for Media Library files ( [#1096](https://github.com/WPChill/download-monitor/issues/1096) )
130
+ Fixed: Redirect to file when unicode chars are present ( [#1095](https://github.com/WPChill/download-monitor/issues/1095) )
131
+ Fixed: Front-end CSS was not enqueued for Gutenberg blocks ( [#1094](https://github.com/WPChill/download-monitor/issues/1094) )
132
+
133
  = 4.7.1 - 18.10.2022 =
134
  Fixed: Top Downloads widget wrong URL ( [#1087](https://github.com/WPChill/download-monitor/issues/1087) )
135
  Fixed: Error when getting version download ( [#1090](https://github.com/WPChill/download-monitor/issues/1090) )
src/Admin/Admin.php CHANGED
@@ -50,15 +50,16 @@ class DLM_Admin {
50
  $reports_page = new DLM_Reports_Page();
51
  $reports_page->setup();
52
 
 
 
 
53
  // Dashboard
54
  add_action( 'wp_dashboard_setup', array( $this, 'admin_dashboard' ) );
55
  // Admin Footer Text
56
  add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ), 1 );
57
  // flush rewrite rules on shutdown
58
  add_action( 'shutdown', array( $this, 'maybe_flush_rewrites' ) );
59
- // filter attachment thumbnails in media library for files in dlm_uploads
60
- add_filter( 'wp_prepare_attachment_for_js', array( $this, 'filter_thumbnails_protected_files_grid' ), 10, 1 );
61
- add_filter( 'wp_get_attachment_image_src', array( $this, 'filter_thumbnails_protected_files_list' ), 10, 1 );
62
  // Legacy Upgrader
63
  $lu_check = new DLM_LU_Checker();
64
  if ( $lu_check->needs_upgrading() ) {
@@ -69,15 +70,7 @@ class DLM_Admin {
69
  add_filter( 'pre_update_option_dlm_download_endpoint', array( $this, 'set_rewrite_rules_flag_on_endpoint_change'), 15, 2 );
70
  // Checks and flushes rewrite rule if rewrite flag option is set.
71
  add_action( 'admin_init', array( $this, 'check_rewrite_rules') );
72
- // Do not make sub-sizes for images uploaded in dlm_uploads
73
- add_filter( 'file_is_displayable_image', array( $this, 'no_image_subsizes' ), 15, 2 );
74
- add_filter( 'ajax_query_attachments_args', array( $this, 'no_media_library_display' ), 15 );
75
- // Add a Media Library filter to list view so that we can filter out dlm_uploads
76
- add_action( 'restrict_manage_posts', array( $this, 'add_dlm_uploads_filter' ), 15, 2 );
77
- // Set query vars for dlm_uploads filter
78
- add_action( 'pre_get_posts', array( $this, 'media_library_filter' ), 15 );
79
- // Add DLM Uploads file as a mime type
80
- add_filter( 'post_mime_types', array( $this, 'add_mime_types' ), 15, 1 );
81
  }
82
 
83
  /**
@@ -135,56 +128,6 @@ class DLM_Admin {
135
  return $pathdata;
136
  }
137
 
138
- /**
139
- * filter attachment thumbnails in media library grid view for files in dlm_uploads
140
- *
141
- * @param array $response
142
- *
143
- * @return array
144
- */
145
- public function filter_thumbnails_protected_files_grid( $response ) {
146
- if ( apply_filters( 'dlm_filter_thumbnails_protected_files', true ) ) {
147
- $upload_dir = wp_upload_dir();
148
-
149
- if ( strpos( $response['url'], $upload_dir['baseurl'] . '/dlm_uploads' ) !== false ) {
150
- if ( ! empty( $response['sizes'] ) ) {
151
- $dlm_protected_thumb = download_monitor()->get_plugin_url() . '/assets/images/protected-file-thumbnail.png';
152
- foreach ( $response['sizes'] as $rs_key => $rs_val ) {
153
- $rs_val['url'] = $dlm_protected_thumb;
154
- $response['sizes'][ $rs_key ] = $rs_val;
155
- }
156
- }
157
- }
158
- }
159
-
160
- return $response;
161
- }
162
-
163
- /**
164
- * filter attachment thumbnails in media library list view for files in dlm_uploads
165
- *
166
- * @param bool|array $image
167
- *
168
- * @return bool|array
169
- */
170
- public function filter_thumbnails_protected_files_list( $image ) {
171
- if ( apply_filters( 'dlm_filter_thumbnails_protected_files', true ) ) {
172
- if ( $image ) {
173
-
174
- $upload_dir = wp_upload_dir();
175
-
176
- if ( strpos( $image[0], $upload_dir['baseurl'] . '/dlm_uploads' ) !== false ) {
177
- $image[0] = $dlm_protected_thumb = download_monitor()->get_plugin_url() . '/assets/images/protected-file-thumbnail.png';
178
- $image[1] = 60;
179
- $image[2] = 60;
180
- }
181
- }
182
-
183
- }
184
-
185
- return $image;
186
- }
187
-
188
  /**
189
  * admin_enqueue_scripts function.
190
  *
@@ -194,7 +137,7 @@ class DLM_Admin {
194
  public function admin_enqueue_scripts( $hook ) {
195
  global $post;
196
 
197
- wp_enqueue_style( 'download_monitor_menu_css', download_monitor()->get_plugin_url() . '/assets/css/menu.min.css', array(), DLM_VERSION );
198
 
199
  if ( $hook == 'index.php' ) {
200
  wp_enqueue_style( 'download_monitor_dashboard_css', download_monitor()->get_plugin_url() . '/assets/css/dashboard.min.css', array(), DLM_VERSION );
@@ -391,160 +334,4 @@ class DLM_Admin {
391
 
392
  }
393
 
394
- /**
395
- * Don't display or create sub-sizes for DLM uploads
396
- *
397
- * @param $result
398
- * @param $path
399
- *
400
- * @return false|mixed
401
- * @since 4.6.0
402
- */
403
- public function no_image_subsizes( $result, $path ) {
404
-
405
- $upload_dir = wp_upload_dir();
406
-
407
- if ( strpos( $path, $upload_dir['basedir'] . '/dlm_uploads' ) !== false ) {
408
- $result = false;
409
- }
410
-
411
- return $result;
412
- }
413
-
414
- /**
415
- * Don't display DLM Uploads in Media Library
416
- *
417
- * @param array $query Query parameters.
418
- *
419
- * @return array
420
- * @since 4.6.0
421
- */
422
- public function no_media_library_display( $query ) {
423
-
424
- //Check for the added temporary mime_type so that we can filter the Media Library contents
425
- if ( ! isset( $query['post_mime_type'] ) || 'dlm_uploads_files' !== $query['post_mime_type'] ) {
426
- if ( ! isset( $query['meta_query'] ) ) {
427
- $query['meta_query'] = array(
428
- 'relation' => 'AND',
429
- array(
430
- 'key' => '_wp_attached_file',
431
- 'compare' => 'NOT LIKE',
432
- 'value' => 'dlm_uploads'
433
- )
434
- );
435
- } else {
436
- $query['meta_query'][] = array(
437
- 'key' => '_wp_attached_file',
438
- 'compare' => 'NOT LIKE',
439
- 'value' => 'dlm_uploads'
440
- );
441
- }
442
- } else {
443
- unset($query['post_mime_type']);
444
- $query['meta_key'] = '_wp_attached_file';
445
- $query['meta_query'][] = array(
446
- 'key' => '_wp_attached_file',
447
- 'compare' => 'LIKE',
448
- 'value' => 'dlm_uploads'
449
- );
450
- }
451
-
452
- return $query;
453
- }
454
-
455
- /**
456
- * Add Media Library filters for DLM Downloads
457
- *
458
- * @param $screen
459
- * @param $which
460
- *
461
- * @return void
462
- * @since 4.6.4
463
- */
464
- public function add_dlm_uploads_filter( $screen, $which ) {
465
- // Add a filter to the Media Library page so that we can filter regular uploads and Download Monitor's uploads
466
- if ( $screen === 'attachment' ) {
467
- $views = apply_filters( 'dlm_media_views', array(
468
- 'uploads_folder' => __( 'Uploads folder', 'download-monitor' ),
469
- 'dlm_uploads_folder' => __( 'Download Monitor', 'download-monitor' )
470
- ) );
471
-
472
- $applied_filter = isset( $_GET['dlm_upload_folder_type'] ) ? sanitize_text_field( wp_unslash( $_GET['dlm_upload_folder_type'] ) ) : 'all';
473
- ?>
474
- <select name="dlm_upload_folder_type">
475
- <?php
476
- foreach ( $views as $key => $view ) {
477
- echo '<option value="' . $key . '" ' . selected( $key, $applied_filter ) . '>' . $view . '</option>';
478
- }
479
- ?>
480
- </select>
481
- <?php
482
- }
483
- }
484
-
485
- /**
486
- * Filter the media library query to wether show DLM uploads or not
487
- *
488
- * @param $query
489
- *
490
- * @return void
491
- * @since 4.6.4
492
- */
493
- public function media_library_filter( $query ) {
494
-
495
- if ( ! is_admin() || false === strpos( $_SERVER['REQUEST_URI'], '/wp-admin/upload.php' ) ) {
496
- return;
497
- }
498
- // If users views uploads folder then we don't need to show DLM uploads.
499
- $compare = 'NOT LIKE';
500
- // If user views the DLM Uploads folder then we need to show DLM uploads.
501
- if ( isset( $_GET['dlm_upload_folder_type'] ) && 'dlm_uploads_folder' === $_GET['dlm_upload_folder_type'] ) {
502
- $compare = 'LIKE';
503
- }
504
- // Set the meta query for the corresponding request.
505
- $query->set( 'meta_key', '_wp_attached_file' );
506
- $query->set( 'meta_query', array(
507
- 'key' => '_wp_attached_file',
508
- 'compare' => $compare,
509
- 'value' => 'dlm_uploads'
510
- ) );
511
- }
512
-
513
- /**
514
- * Add temporary dlm_uploads_files mime type to help us filter the media library
515
- *
516
- * @param $mimes
517
- *
518
- * @return mixed
519
- * @since 4.6.4
520
- */
521
- public function add_mime_types($mimes){
522
-
523
- if ( ! function_exists( 'get_current_screen' ) ) {
524
- return $mimes;
525
- }
526
-
527
- $screen = get_current_screen();
528
- // If we are not on the Media Library page or editing the Download then we don't need to add the mime types.
529
- if ( ! is_admin() || ( 'upload' !== $screen->base && 'attachment' !== $screen->post_type && 'dlm_download' !== $screen->post_type ) ) {
530
- return $mimes;
531
- }
532
-
533
- // Create temp mime_type that will only be available on Media Library page and edit Download page.
534
- // We need this to proper filter the Media Library contents and show only DLM uploads or regular uploads.
535
- $mimes['dlm_uploads_files'] = array(
536
- 'Download Monitor Files',
537
- 'Manage DLM Files',
538
- array(
539
- 'dlm_uploads',
540
- 'else',
541
- 'singular' => 'DLM File',
542
- 'plural' => 'DLM Files',
543
- 'content' => null,
544
- 'domain' => null
545
- )
546
- );
547
-
548
- return $mimes;
549
- }
550
  }
50
  $reports_page = new DLM_Reports_Page();
51
  $reports_page->setup();
52
 
53
+ // Handle all functinality that involves Media Library
54
+ $dlm_media_library = DLM_Media_Library::get_instance();
55
+
56
  // Dashboard
57
  add_action( 'wp_dashboard_setup', array( $this, 'admin_dashboard' ) );
58
  // Admin Footer Text
59
  add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ), 1 );
60
  // flush rewrite rules on shutdown
61
  add_action( 'shutdown', array( $this, 'maybe_flush_rewrites' ) );
62
+
 
 
63
  // Legacy Upgrader
64
  $lu_check = new DLM_LU_Checker();
65
  if ( $lu_check->needs_upgrading() ) {
70
  add_filter( 'pre_update_option_dlm_download_endpoint', array( $this, 'set_rewrite_rules_flag_on_endpoint_change'), 15, 2 );
71
  // Checks and flushes rewrite rule if rewrite flag option is set.
72
  add_action( 'admin_init', array( $this, 'check_rewrite_rules') );
73
+
 
 
 
 
 
 
 
 
74
  }
75
 
76
  /**
128
  return $pathdata;
129
  }
130
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  /**
132
  * admin_enqueue_scripts function.
133
  *
137
  public function admin_enqueue_scripts( $hook ) {
138
  global $post;
139
 
140
+ wp_enqueue_style( 'download_monitor_others', download_monitor()->get_plugin_url() . '/assets/css/others.min.css', array(), DLM_VERSION );
141
 
142
  if ( $hook == 'index.php' ) {
143
  wp_enqueue_style( 'download_monitor_dashboard_css', download_monitor()->get_plugin_url() . '/assets/css/dashboard.min.css', array(), DLM_VERSION );
334
 
335
  }
336
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
337
  }
src/Admin/AdminScripts.php CHANGED
@@ -24,7 +24,7 @@ class DLM_Admin_Scripts {
24
  // Enqueue Edit Post JS
25
  wp_enqueue_script(
26
  'dlm_insert_download',
27
- plugins_url( '/assets/js/insert-download' . ( ( ! SCRIPT_DEBUG ) ? '.min' : '' ) . '.js', $dlm->get_plugin_file() ),
28
  array( 'jquery' ),
29
  DLM_VERSION
30
  );
@@ -51,7 +51,7 @@ class DLM_Admin_Scripts {
51
  // Enqueue Edit Post JS
52
  wp_enqueue_script(
53
  'dlm_insert_download',
54
- plugins_url( '/assets/js/insert-download' . ( ( ! SCRIPT_DEBUG ) ? '.min' : '' ) . '.js', $dlm->get_plugin_file() ),
55
  array( 'jquery' ),
56
  DLM_VERSION
57
  );
@@ -228,7 +228,7 @@ class DLM_Admin_Scripts {
228
  ) );
229
 
230
  // Script used to install plugins
231
- wp_enqueue_script( 'dlm_install_plugins', plugins_url( '/assets/js/install-plugins' . ( ( ! SCRIPT_DEBUG ) ? '.min' : '' ) . '.js', $dlm->get_plugin_file() ), array( 'jquery', 'updates' ), null, true );
232
  wp_localize_script(
233
  'dlm_install_plugins',
234
  'dlm_install_plugins_vars',
24
  // Enqueue Edit Post JS
25
  wp_enqueue_script(
26
  'dlm_insert_download',
27
+ plugins_url( '/assets/js/download-operations' . ( ( ! SCRIPT_DEBUG ) ? '.min' : '' ) . '.js', $dlm->get_plugin_file() ),
28
  array( 'jquery' ),
29
  DLM_VERSION
30
  );
51
  // Enqueue Edit Post JS
52
  wp_enqueue_script(
53
  'dlm_insert_download',
54
+ plugins_url( '/assets/js/download-operations' . ( ( ! SCRIPT_DEBUG ) ? '.min' : '' ) . '.js', $dlm->get_plugin_file() ),
55
  array( 'jquery' ),
56
  DLM_VERSION
57
  );
228
  ) );
229
 
230
  // Script used to install plugins
231
+ wp_enqueue_script( 'dlm_install_plugins', plugins_url( '/assets/js/install-plugins' . ( ( ! SCRIPT_DEBUG ) ? '.min' : '' ) . '.js', $dlm->get_plugin_file() ), array( 'jquery', 'updates' ), DLM_VERSION, true );
232
  wp_localize_script(
233
  'dlm_install_plugins',
234
  'dlm_install_plugins_vars',
src/Admin/MediaBrowser.php CHANGED
@@ -33,7 +33,7 @@ class DLM_Admin_Media_Browser {
33
 
34
  echo '<!DOCTYPE html><html lang="en"><head><title>' . esc_html__( 'Browse for a file', 'download-monitor' ) . '</title>';
35
 
36
- wp_enqueue_style( 'download_monitor_admin_css', download_monitor()->get_plugin_url() . '/assets/css/admin.min.css', array( 'dashicons' ) );
37
  do_action( 'admin_print_styles' );
38
  do_action( 'admin_print_scripts' );
39
  do_action( 'admin_head' );
33
 
34
  echo '<!DOCTYPE html><html lang="en"><head><title>' . esc_html__( 'Browse for a file', 'download-monitor' ) . '</title>';
35
 
36
+ wp_enqueue_style( 'download_monitor_admin_css', download_monitor()->get_plugin_url() . '/assets/css/admin.min.css', array( 'dashicons' ), DLM_VERSION );
37
  do_action( 'admin_print_styles' );
38
  do_action( 'admin_print_scripts' );
39
  do_action( 'admin_head' );
src/Admin/MediaInsert.php CHANGED
@@ -45,7 +45,7 @@ class DLM_Admin_Media_Insert {
45
  public function media_browser() {
46
 
47
  // Enqueue scripts and styles for panel
48
- wp_enqueue_style( 'download_monitor_admin_css', download_monitor()->get_plugin_url() . '/assets/css/admin.min.css', array( 'dashicons' ) );
49
  wp_enqueue_script( 'common' );
50
  wp_enqueue_style( 'global' );
51
  wp_enqueue_style( 'wp-admin' );
45
  public function media_browser() {
46
 
47
  // Enqueue scripts and styles for panel
48
+ wp_enqueue_style( 'download_monitor_admin_css', download_monitor()->get_plugin_url() . '/assets/css/admin.min.css', array( 'dashicons' ), DLM_VERSION );
49
  wp_enqueue_script( 'common' );
50
  wp_enqueue_style( 'global' );
51
  wp_enqueue_style( 'wp-admin' );
src/Admin/Settings/Page.php CHANGED
@@ -332,7 +332,7 @@ class DLM_Settings_Page {
332
  <div class="dlm-page-header <?php echo ( $extra_class ) ? esc_attr( $extra_class ) : ''; ?>">
333
  <div class="dlm-header-logo">
334
 
335
- <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAIECAYAAABv6ZbsAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAACZASURBVHgB7d09cFzXeTfwAxCEXUhjlFZlaoZMa1Cdgg8DpdSYnknkUrTU2pLcJXEhqsgknaTIbWSqdTIjppFLwviwStJt6Bkjldy98FiFBwDB9zyrXXoJ4mOx2Lv33Ht/vxlkQQByPBaxz/885znnpgQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAXMpMAhrtyy+/vDbKzx0dHS3Ex3k/Nzc3t5tG8Oqrr470c0CZBACYsEFBHhTcJ0+eRNF9WnhnZmZ635+dnY2vfWfw9fxz14b+Ywb/XBr65575zylV/u+9O/zn/N/71D/n/33+b+jzvfy9veM/MwgkAgdMlgAAxwwK+OHh4bVB8Y7XKNhDRXth+HtNKc4tsZf/Nx+EheHA8OcIEUNBovea/531PgQIeJYAQKsdK+a9z2MFPijk/a8p4h0SHYpBh2E4OPQ7F09Dw/7+/u76+vpegpYSAGiU+/fvL3z7299eGBT0oZX59+L7/a9di88HrXa4p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W9EZuJXDwA/yHxcT8Iz8u7Gbf0ei4N87PDx8qOhTNQGAqet3BxajQyAQ0GEPZ2ZmfptX+bHSv6fgM20CALXrP4tgMa98FvPr4FSBUECbRLF/mFf2v8+r/IdW+JRAAKBYOzs7i3lldC2/cS7mN83vRTCIj/znawkK02/hP8yf7kWhz39P965evbrx6quv7iYokABAI0XXYH5+/lruGiz0g8FCfvONj+/lb8fXFuI1f1zrv8KFREGP11zId+MjPs9/3/4vf8T5+/jYzR2r3tcVeZpIAKATjgWGXjiITkKEhvz5dwaXGfU7DIPwQHvEFblPC3f6Zsr+z1HM+4W+970o6H/961/3tOfpAgEAThGh4dvf/vZCbudeiz8PQsJgC6LfbUhDNyH2woUAMXmD1Xjor8ijQPeKdKzKh38mvp//3ezFh2IOpxMAoEKDEBGdh/gYfH2o47DQ70L0DDoSx39u2GlXL09pNqK3kk4n///fPfbnp0V6YFCsw3BRT/0VeHwyaKsHrXUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADO9f8BiZVBFMCdLXQAAAAASUVORK5CYII=" class="dlm-logo"/>
336
  </div>
337
  <div class="dlm-header-links">
338
  <?php do_action( 'dlm_page_header_links' ); ?>
332
  <div class="dlm-page-header <?php echo ( $extra_class ) ? esc_attr( $extra_class ) : ''; ?>">
333
  <div class="dlm-header-logo">
334
 
335
+ <img src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTA1IiBoZWlnaHQ9IjEwNSIgdmlld0JveD0iMCAwIDEwNSAxMDUiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxwYXRoIGQ9Ik01Mi41IDAuMDAwNTk5Njc0QzM4LjU3NTYgMC4wMDA1OTk2NzQgMjUuMjIxOSA1LjUzMjAzIDE1LjM3NzYgMTUuMzc4MUM1LjUzMTQ2IDI1LjIyMjkgMCAzOC41NzY2IDAgNTIuNTAwM0MwIDY2LjQyNC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zAwOENENSIvPgo8c3RvcCBvZmZzZXQ9IjAuODU1OTk3IiBzdG9wLWNvbG9yPSIjMDI1RUEwIi8+CjxzdG9wIG9mZnNldD0iMSIgc3RvcC1jb2xvcj0iIzAyNTM4RCIvPgo8L2xpbmVhckdyYWRpZW50Pgo8L2RlZnM+Cjwvc3ZnPgo=" class="dlm-logo"/>
336
  </div>
337
  <div class="dlm-header-links">
338
  <?php do_action( 'dlm_page_header_links' ); ?>
src/Admin/class-dlm-db-upgrader.php CHANGED
@@ -552,10 +552,10 @@ if ( ! class_exists( 'DLM_DB_Upgrader' ) ) {
552
 
553
  wp_enqueue_script( 'jquery-ui' );
554
  wp_enqueue_script( 'jquery-ui-progressbar' );
555
- wp_enqueue_script( 'dlm-log-db-upgrade', download_monitor()->get_plugin_url() . '/assets/js/database-upgrader' . ( ( ! SCRIPT_DEBUG ) ? '.min' : '' ) . '.js', array( 'jquery' ), '4.4.7', true );
556
  wp_add_inline_script( 'dlm-log-db-upgrade', 'dlm_upgrader =' . wp_json_encode( array( 'nonce' => wp_create_nonce( 'dlm_db_log_nonce' ) ) ), 'before' );
557
 
558
- wp_enqueue_style( 'dlm-db-upgrade-style', download_monitor()->get_plugin_url() . '/assets/css/db-upgrader.min.css', array(), '4.4.7' );
559
  wp_enqueue_style( 'jquery-ui-style', download_monitor()->get_plugin_url() . '/assets/css/jquery-ui.min.css', array(), DLM_VERSION );
560
  }
561
 
552
 
553
  wp_enqueue_script( 'jquery-ui' );
554
  wp_enqueue_script( 'jquery-ui-progressbar' );
555
+ wp_enqueue_script( 'dlm-log-db-upgrade', download_monitor()->get_plugin_url() . '/assets/js/database-upgrader' . ( ( ! SCRIPT_DEBUG ) ? '.min' : '' ) . '.js', array( 'jquery' ), DLM_VERSION, true );
556
  wp_add_inline_script( 'dlm-log-db-upgrade', 'dlm_upgrader =' . wp_json_encode( array( 'nonce' => wp_create_nonce( 'dlm_db_log_nonce' ) ) ), 'before' );
557
 
558
+ wp_enqueue_style( 'dlm-db-upgrade-style', download_monitor()->get_plugin_url() . '/assets/css/db-upgrader.min.css', array(), DLM_VERSION );
559
  wp_enqueue_style( 'jquery-ui-style', download_monitor()->get_plugin_url() . '/assets/css/jquery-ui.min.css', array(), DLM_VERSION );
560
  }
561
 
src/Admin/class-dlm-media-library.php ADDED
@@ -0,0 +1,590 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Download Monitor - Media Library, class that handles the funcitonality from Media Library
4
+ */
5
+
6
+ if ( ! defined( 'ABSPATH' ) ) {
7
+ exit;
8
+ } // Exit if accessed directly
9
+
10
+ class DLM_Media_Library {
11
+
12
+ /**
13
+ * Holds the class object.
14
+ *
15
+ * @since 4.7.2
16
+ *
17
+ * @var object
18
+ */
19
+ public static $instance;
20
+
21
+ /**
22
+ * Returns the singleton instance of the class.
23
+ *
24
+ * @return object The DLM_Media_Library object.
25
+ * @since 4.7.2
26
+ */
27
+ public static function get_instance() {
28
+
29
+ if ( ! isset( self::$instance ) && ! ( self::$instance instanceof DLM_Media_Library ) ) {
30
+ self::$instance = new DLM_Media_Library();
31
+ }
32
+
33
+ return self::$instance;
34
+
35
+ }
36
+
37
+ /**
38
+ * Class constructor
39
+ */
40
+ private function __construct() {
41
+ // filter attachment thumbnails in media library for files in dlm_uploads
42
+ add_filter( 'wp_prepare_attachment_for_js', array( $this, 'filter_thumbnails_protected_files_grid' ), 10, 1 );
43
+ add_filter( 'wp_get_attachment_image_src', array( $this, 'filter_thumbnails_protected_files_list' ), 10, 1 );
44
+ // Do not make sub-sizes for images uploaded in dlm_uploads
45
+ add_filter( 'file_is_displayable_image', array( $this, 'no_image_subsizes' ), 15, 2 );
46
+ add_filter( 'ajax_query_attachments_args', array( $this, 'no_media_library_display' ), 15 );
47
+ // Add a Media Library filter to list view so that we can filter out dlm_uploads
48
+ add_action( 'restrict_manage_posts', array( $this, 'add_dlm_uploads_filter' ), 15, 2 );
49
+ // Set query vars for dlm_uploads filter
50
+ add_action( 'pre_get_posts', array( $this, 'media_library_filter' ), 15 );
51
+ // Add DLM Uploads file as a mime type
52
+ add_filter( 'post_mime_types', array( $this, 'add_mime_types' ), 15, 1 );
53
+ // Actions done to Media Library files in order to create Downloads and protect files
54
+ add_filter( 'attachment_fields_to_edit', array( $this, 'add_protect_button' ), 15, 2 );
55
+ add_action( 'wp_ajax_dlm_protect_file', array( $this, 'protect_file' ), 15 );
56
+ add_action( 'wp_ajax_dlm_unprotect_file', array( $this, 'unprotect_file' ), 15 );
57
+ add_filter( 'wp_prepare_attachment_for_js', array( $this, 'add_visual_indicator' ), 10, 2 );
58
+ add_filter( 'manage_upload_columns', array( $this, 'dlm_ml_column' ), 15, 1 );
59
+ add_action( 'manage_media_custom_column', array( $this, 'manage_dlm_ml_column' ), 0, 2 );
60
+ add_filter( 'bulk_actions-upload', array( $this, 'dlm_ml_bulk_actions' ), 15 );
61
+ add_filter( 'handle_bulk_actions-upload', array( $this, 'dlm_ml_handle_bulk' ), 15, 3 );
62
+ add_filter( 'admin_init', array( $this, 'dlm_ml_do_bulk' ), 15 );
63
+ // End Actions to Media Library files
64
+ }
65
+
66
+ /**
67
+ * filter attachment thumbnails in media library grid view for files in dlm_uploads
68
+ *
69
+ * @param array $response
70
+ *
71
+ * @return array
72
+ */
73
+ public function filter_thumbnails_protected_files_grid( $response ) {
74
+ if ( apply_filters( 'dlm_filter_thumbnails_protected_files', true ) ) {
75
+ $upload_dir = wp_upload_dir();
76
+
77
+ if ( strpos( $response['url'], $upload_dir['baseurl'] . '/dlm_uploads' ) !== false ) {
78
+ if ( ! empty( $response['sizes'] ) ) {
79
+ $dlm_protected_thumb = download_monitor()->get_plugin_url() . '/assets/images/protected-file-thumbnail.png';
80
+ foreach ( $response['sizes'] as $rs_key => $rs_val ) {
81
+ $rs_val['url'] = $dlm_protected_thumb;
82
+ $response['sizes'][ $rs_key ] = $rs_val;
83
+ }
84
+ }
85
+ }
86
+ }
87
+
88
+ return $response;
89
+ }
90
+
91
+ /**
92
+ * filter attachment thumbnails in media library list view for files in dlm_uploads
93
+ *
94
+ * @param bool|array $image
95
+ *
96
+ * @return bool|array
97
+ */
98
+ public function filter_thumbnails_protected_files_list( $image ) {
99
+ if ( apply_filters( 'dlm_filter_thumbnails_protected_files', true ) ) {
100
+ if ( $image ) {
101
+
102
+ $upload_dir = wp_upload_dir();
103
+
104
+ if ( strpos( $image[0], $upload_dir['baseurl'] . '/dlm_uploads' ) !== false ) {
105
+ $image[0] = $dlm_protected_thumb = download_monitor()->get_plugin_url() . '/assets/images/protected-file-thumbnail.png';
106
+ $image[1] = 60;
107
+ $image[2] = 60;
108
+ }
109
+ }
110
+
111
+ }
112
+
113
+ return $image;
114
+ }
115
+
116
+ /**
117
+ * Don't display or create sub-sizes for DLM uploads
118
+ *
119
+ * @param $result
120
+ * @param $path
121
+ *
122
+ * @return false|mixed
123
+ * @since 4.6.0
124
+ */
125
+ public function no_image_subsizes( $result, $path ) {
126
+
127
+ $upload_dir = wp_upload_dir();
128
+
129
+ if ( strpos( $path, $upload_dir['basedir'] . '/dlm_uploads' ) !== false ) {
130
+ $result = false;
131
+ }
132
+
133
+ return $result;
134
+ }
135
+
136
+ /**
137
+ * Don't display DLM Uploads in Media Library
138
+ *
139
+ * @param array $query Query parameters.
140
+ *
141
+ * @return array
142
+ * @since 4.6.0
143
+ */
144
+ public function no_media_library_display( $query ) {
145
+
146
+ //Check for the added temporary mime_type so that we can filter the Media Library contents
147
+ if ( ! isset( $query['post_mime_type'] ) || 'dlm_uploads_files' !== $query['post_mime_type'] ) {
148
+ if ( ! isset( $query['meta_query'] ) ) {
149
+ $query['meta_query'] = array(
150
+ 'relation' => 'AND',
151
+ array(
152
+ 'key' => '_wp_attached_file',
153
+ 'compare' => 'NOT LIKE',
154
+ 'value' => 'dlm_uploads'
155
+ )
156
+ );
157
+ } else {
158
+ $query['meta_query'][] = array(
159
+ 'key' => '_wp_attached_file',
160
+ 'compare' => 'NOT LIKE',
161
+ 'value' => 'dlm_uploads'
162
+ );
163
+ }
164
+ } else {
165
+ unset( $query['post_mime_type'] );
166
+ $query['meta_key'] = '_wp_attached_file';
167
+ $query['meta_query'][] = array(
168
+ 'key' => '_wp_attached_file',
169
+ 'compare' => 'LIKE',
170
+ 'value' => 'dlm_uploads'
171
+ );
172
+ }
173
+
174
+ return $query;
175
+ }
176
+
177
+ /**
178
+ * Add Media Library filters for DLM Downloads
179
+ *
180
+ * @param $screen
181
+ * @param $which
182
+ *
183
+ * @return void
184
+ * @since 4.6.4
185
+ */
186
+ public function add_dlm_uploads_filter( $screen, $which ) {
187
+ // Add a filter to the Media Library page so that we can filter regular uploads and Download Monitor's uploads
188
+ if ( $screen === 'attachment' ) {
189
+ $views = apply_filters( 'dlm_media_views', array(
190
+ 'uploads_folder' => __( 'Uploads folder', 'download-monitor' ),
191
+ 'dlm_uploads_folder' => __( 'Download Monitor', 'download-monitor' )
192
+ ) );
193
+
194
+ $applied_filter = isset( $_GET['dlm_upload_folder_type'] ) ? sanitize_text_field( wp_unslash( $_GET['dlm_upload_folder_type'] ) ) : 'all';
195
+ ?>
196
+ <select name="dlm_upload_folder_type">
197
+ <?php
198
+ foreach ( $views as $key => $view ) {
199
+ echo '<option value="' . $key . '" ' . selected( $key, $applied_filter ) . '>' . $view . '</option>';
200
+ }
201
+ ?>
202
+ </select>
203
+ <?php
204
+ }
205
+ }
206
+
207
+ /**
208
+ * Filter the media library query to wether show DLM uploads or not
209
+ *
210
+ * @param $query
211
+ *
212
+ * @return void
213
+ * @since 4.6.4
214
+ */
215
+ public function media_library_filter( $query ) {
216
+
217
+ if ( ! is_admin() || false === strpos( $_SERVER['REQUEST_URI'], '/wp-admin/upload.php' ) ) {
218
+ return;
219
+ }
220
+ // If users views uploads folder then we don't need to show DLM uploads.
221
+ $compare = 'NOT LIKE';
222
+ // If user views the DLM Uploads folder then we need to show DLM uploads.
223
+ if ( isset( $_GET['dlm_upload_folder_type'] ) && 'dlm_uploads_folder' === $_GET['dlm_upload_folder_type'] ) {
224
+ $compare = 'LIKE';
225
+ }
226
+ // Set the meta query for the corresponding request.
227
+ $query->set( 'meta_key', '_wp_attached_file' );
228
+ $query->set( 'meta_query', array(
229
+ 'key' => '_wp_attached_file',
230
+ 'compare' => $compare,
231
+ 'value' => 'dlm_uploads'
232
+ ) );
233
+ }
234
+
235
+ /**
236
+ * Add temporary dlm_uploads_files mime type to help us filter the media library
237
+ *
238
+ * @param $mimes
239
+ *
240
+ * @return mixed
241
+ * @since 4.6.4
242
+ */
243
+ public function add_mime_types( $mimes ) {
244
+
245
+ if ( ! function_exists( 'get_current_screen' ) ) {
246
+ return $mimes;
247
+ }
248
+
249
+ $screen = get_current_screen();
250
+ // If we are not on the Media Library page or editing the Download then we don't need to add the mime types.
251
+ if ( ! is_admin() || ( 'upload' !== $screen->base && 'attachment' !== $screen->post_type && 'dlm_download' !== $screen->post_type ) ) {
252
+ return $mimes;
253
+ }
254
+
255
+ // Create temp mime_type that will only be available on Media Library page and edit Download page.
256
+ // We need this to proper filter the Media Library contents and show only DLM uploads or regular uploads.
257
+ $mimes['dlm_uploads_files'] = array(
258
+ 'Download Monitor Files',
259
+ 'Manage DLM Files',
260
+ array(
261
+ 'dlm_uploads',
262
+ 'else',
263
+ 'singular' => 'DLM File',
264
+ 'plural' => 'DLM Files',
265
+ 'content' => null,
266
+ 'domain' => null
267
+ )
268
+ );
269
+
270
+ return $mimes;
271
+ }
272
+
273
+ /**
274
+ * Add a Protect Download button in the Attachment details view
275
+ *
276
+ * @param $fields
277
+ * @param $post
278
+ *
279
+ * @return mixed
280
+ * @since 4.7.2
281
+ */
282
+ public function add_protect_button( $fields, $post ) {
283
+ // Let's check if this is not already set.
284
+ if ( ! isset( $fields['dlm_protect_file'] ) ) {
285
+
286
+ $button_text = __( 'Protect', 'download-monitor' );
287
+ $action = 'protect_file';
288
+ $text = esc_html__( 'Creates a Download based on this file and moves the file to Download Monitor\'s protected folder. Also replaces the attachment\'s URL with the download link.', 'download-monitor' );
289
+
290
+ if ( '1' === get_post_meta( $post->ID, 'dlm_protected_file', true ) ) {
291
+ $button_text = __( 'Unprotect', 'download-monitor' );
292
+ $action = 'unprotect_file';
293
+ $text = esc_html__( 'Moves the file from Download Monitor\'s protected directory to the uploads directory. Also places back the original URL for this attachment.', 'download-monitor' );
294
+ }
295
+
296
+ $html = '<button id="dlm-protect-file" class="button button-primary" data-action="' . esc_attr( $action ) . '" data-post_id="' . absint( $post->ID ) . '" data-nonce="' . wp_create_nonce( 'dlm_protect_file' ) . '" data-title="' . esc_attr( $post->title ) . '" data-user_id="' . get_current_user_id() . '" data-file="' . esc_url( wp_get_attachment_url( $post->ID ) ) . '" >' . esc_html( $button_text ) . '</button><p class="description">' . $text . '</p>';
297
+
298
+ // Add our button
299
+ $fields['dlm_protect_file'] = array(
300
+ 'label' => __( 'DLM protect file', 'download-monitor' ),
301
+ 'input' => 'html',
302
+ 'html' => $html,
303
+
304
+ );
305
+ }
306
+
307
+ return $fields;
308
+ }
309
+
310
+ /**
311
+ * Function used to create new Downloads directly from the Media Library
312
+ *
313
+ * @return void
314
+ * @since 4.7.2
315
+ */
316
+ public function protect_file() {
317
+ // Check if nonce is transmitted
318
+ if ( ! isset( $_POST['_ajax_nonce'] ) ) {
319
+ wp_send_json_error( 'No nonce' );
320
+ }
321
+ // Check if nonce is correct
322
+ check_ajax_referer( 'dlm_protect_file', '_ajax_nonce' );
323
+ // Get the data so we can create the download
324
+ $file = $_POST;
325
+ // Move the file
326
+ download_monitor()->service( 'file_manager' )->move_file_to_dlm_uploads( $file['attachment_id'] );
327
+ // Create the download or update existing one
328
+ $current_url = $this->create_download( $file );
329
+ // Send the response
330
+ $data = array(
331
+ 'url' => $current_url,
332
+ 'text' => esc_html__( 'File protected. Download created', 'download-monitor' )
333
+ );
334
+ wp_send_json_success( $data );
335
+ }
336
+
337
+ /**
338
+ * Function used to unprotect Media Library file
339
+ *
340
+ * @return void
341
+ * @since 4.7.2
342
+ */
343
+ public function unprotect_file() {
344
+ // Check if nonce is transmitted
345
+ if ( ! isset( $_POST['_ajax_nonce'] ) ) {
346
+ wp_send_json_error( 'No nonce' );
347
+ }
348
+ // Check if nonce is correct
349
+ check_ajax_referer( 'dlm_protect_file', '_ajax_nonce' );
350
+ // Get the data so we can create the download
351
+ $file = $_POST;
352
+ // For the moment we don't know the version id or if it exists
353
+ $version_id = false;
354
+ // Now make the move to Download Monitor's protected folder dlm_uploads
355
+ download_monitor()->service( 'file_manager' )->move_file_back( $file['attachment_id'] );
356
+ // Get the currently protected download so that we can update its files
357
+ $known_download = get_post_meta( $file['attachment_id'], 'dlm_download', true );
358
+ if ( ! empty( $known_download ) ) {
359
+ $version_id = json_decode( $known_download, true )['version_id'];
360
+ }
361
+ // Delete set metas when the file was protected.
362
+ delete_post_meta( $file['attachment_id'], 'dlm_protected_file' );
363
+ // Get current URL so we can update the Version files.
364
+ $current_url = wp_get_attachment_url( $file['attachment_id'] );
365
+ // Get secure path and update the file path in the Download
366
+ list( $file_path, $remote_file, $restriction ) = download_monitor()->service( 'file_manager' )->get_secure_path( $current_url, 'relative' );
367
+
368
+ if ( $version_id ) {
369
+ // Update the Version meta.
370
+ update_post_meta( $version_id, '_files', download_monitor()->service( 'file_manager' )->json_encode_files( $file_path ) );
371
+ }
372
+
373
+ // Send the response
374
+ $data = array(
375
+ 'url' => $current_url,
376
+ 'text' => esc_html__( 'File unprotected.', 'download-monitor' )
377
+ );
378
+
379
+ wp_send_json_success( $data );
380
+ }
381
+
382
+ /**
383
+ * Create new Download and its version
384
+ *
385
+ * @param $file
386
+ *
387
+ * @return string URL of the new Download
388
+ * @since 4.7.2
389
+ */
390
+ public function create_download( $file ) {
391
+
392
+ // Get new path
393
+ list( $file_path, $remote_file, $restriction ) = download_monitor()->service( 'file_manager' )->get_secure_path( wp_get_attachment_url( $file['attachment_id'] ), 'relative' );
394
+
395
+ // Check if the file has been previously protected
396
+ $known_download = get_post_meta( $file['attachment_id'], 'dlm_download', true );
397
+ // If not, protect and add the corresponding meta, Download & Version
398
+ if ( empty( $known_download ) ) {
399
+ $download_title = ( empty( $file['title'] ) ) ? DLM_Utils::basename( $file['file'] ) : $file['title'];
400
+ // Create the Download object.
401
+ $download = array(
402
+ 'post_title' => $download_title,
403
+ 'post_content' => '',
404
+ 'post_status' => 'publish',
405
+ 'post_author' => absint( $file['user_id'] ),
406
+ 'post_type' => 'dlm_download'
407
+ );
408
+ // Insert the Download. We need its ID to create the Download Version.
409
+ $download_id = wp_insert_post( $download );
410
+ // Create the Version object
411
+ $version = array(
412
+ 'post_title' => 'Download #' . $download_title . 'File Version',
413
+ 'post_content' => '',
414
+ 'post_status' => 'publish',
415
+ 'post_author' => absint( $file['user_id'] ),
416
+ 'post_type' => 'dlm_download_version',
417
+ 'post_parent' => $download_id
418
+ );
419
+ // Insert the Version.
420
+ $version_id = wp_insert_post( $version );
421
+ // Update the Version meta.
422
+ update_post_meta( $version_id, '_files', download_monitor()->service( 'file_manager' )->json_encode_files( $file_path ) );
423
+ // Set a meta option to know what Download is using this file and what Version.
424
+ $attachment_meta = json_encode(
425
+ array(
426
+ 'download_id' => $download_id,
427
+ 'version_id' => $version_id
428
+ )
429
+ );
430
+ update_post_meta( $file['attachment_id'], 'dlm_download', $attachment_meta );
431
+ } else { // Use the current Download and Version
432
+ $download_id = json_decode( $known_download, true )['download_id'];
433
+ $version_id = json_decode( $known_download, true )['version_id'];
434
+ }
435
+
436
+ // Update the Version meta.
437
+ update_post_meta( $version_id, '_files', download_monitor()->service( 'file_manager' )->json_encode_files( $file_path ) );
438
+ update_post_meta( $version_id, '_version', '' );
439
+ $transient_name = 'dlm_file_version_ids_' . $download_id;
440
+ $transient_name_2 = 'dlm_file_version_ids_' . $version_id;
441
+ // Set a meta option to know that this file is protected by Download Monitor.
442
+ update_post_meta( $file['attachment_id'], 'dlm_protected_file', '1' );
443
+ // Update the file's URL with the Download Monitor's URL.
444
+ // First we need to retrieve the newly created Download
445
+ try {
446
+ /** @var DLM_Download $download */
447
+ $download = download_monitor()->service( 'download_repository' )->retrieve_single( absint( $download_id ) );
448
+ $attachment = array(
449
+ 'ID' => $file['attachment_id'],
450
+ );
451
+ wp_update_post( $attachment );
452
+ // Delete transient as it won't be able to find the versions if not.
453
+ delete_transient( $transient_name );
454
+ delete_transient( $transient_name_2 );
455
+
456
+ $url = $download->get_the_download_link();
457
+ // Set version also to the URL as the user might add another version to that Download that could download another file
458
+ if ( $version_id ) {
459
+ $url = add_query_arg( 'v', $version_id, $url );
460
+ }
461
+
462
+ return $url;
463
+
464
+ } catch ( Exception $exception ) {
465
+ // no download found, don't do anything.
466
+ }
467
+
468
+ return false;
469
+ }
470
+
471
+ /**
472
+ * Displays a visual indicator for Media Library files that are protected by DLM
473
+ *
474
+ * @param $response
475
+ * @param $attachment
476
+ *
477
+ * @return mixed
478
+ * @since 4.7.2
479
+ */
480
+ public function add_visual_indicator( $response, $attachment ) {
481
+
482
+ if ( '1' === get_post_meta( $attachment->ID, 'dlm_protected_file', true ) ) {
483
+ $response['customClass'] = 'dlm-ml-protected-file';
484
+ }
485
+
486
+ return $response;
487
+ }
488
+
489
+ public function dlm_ml_column( $columns ) {
490
+ $columns['dlm_protection'] = __( 'Download Monitor', 'download-monitor' );
491
+
492
+ return $columns;
493
+ }
494
+
495
+ public function manage_dlm_ml_column( $column_name, $id ) {
496
+
497
+ if ( $column_name == 'dlm_protection' ) {
498
+
499
+ if ( '1' === get_post_meta( $id, 'dlm_protected_file', true ) ) {
500
+ ?>
501
+ <img
502
+ src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjgiIGhlaWdodD0iMjgiIHZpZXdCb3g9IjAgMCAyOCAyOCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3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b2Zmc2V0PSIwLjQ0MzU2OCIgc3RvcC1jb2xvcj0iIzQxOUJDQSIvPgo8c3RvcCBvZmZzZXQ9IjAuNjM2MTIyIiBzdG9wLWNvbG9yPSIjMDA4Q0Q1Ii8+CjxzdG9wIG9mZnNldD0iMSIgc3RvcC1jb2xvcj0iIzAyNUVBMCIvPgo8L2xpbmVhckdyYWRpZW50Pgo8L2RlZnM+Cjwvc3ZnPgo=">
503
+ <?php
504
+ } else {
505
+ ?>
506
+ <span class="dashicons dashicons-no"
507
+ style="color:red"></span><?php echo esc_html__( 'Un-Protected', 'download-monitor' ) ?>
508
+ <?php
509
+ }
510
+
511
+ }
512
+ }
513
+
514
+ /**
515
+ * Add bulk actions to Media Library table
516
+ *
517
+ * @param $bulk_actions
518
+ *
519
+ * @return mixed
520
+ * @since 4.7.2
521
+ */
522
+ public function dlm_ml_bulk_actions( $bulk_actions ) {
523
+ $bulk_actions['dlm_protect_files'] = __( 'Download Monitor protect', 'download-monitor' );
524
+
525
+ return $bulk_actions;
526
+ }
527
+
528
+ /**
529
+ * Handle our bulk actions
530
+ *
531
+ * @param $location
532
+ * @param $doaction
533
+ * @param $post_ids
534
+ *
535
+ * @return string
536
+ * @since 4.7.2
537
+ */
538
+ public function dlm_ml_handle_bulk( $location, $doaction, $post_ids ) {
539
+
540
+ global $pagenow;
541
+ if ( 'dlm_protect_files' === $doaction ) {
542
+ return admin_url(
543
+ add_query_arg(
544
+ array(
545
+ 'dlm_action' => $doaction,
546
+ 'posts' => $post_ids
547
+ ), '/upload.php' ) );
548
+ }
549
+
550
+ return $location;
551
+ }
552
+
553
+ /**
554
+ * Bulk action for protecting files
555
+ *
556
+ * @return void
557
+ * @since 4.7.2
558
+ */
559
+ public function dlm_ml_do_bulk() {
560
+ // If there's no action or posts, bail
561
+ if ( ! isset( $_GET['dlm_action'] ) || ! isset( $_GET['posts'] ) ) {
562
+ return;
563
+ }
564
+
565
+ $action = $_GET['dlm_action'];
566
+ $posts = $_GET['posts'];
567
+
568
+ if ( 'dlm_protect_files' === $action ) {
569
+ foreach ( $posts as $post_id ) {
570
+ // If it's not an attachment or is already protected, skip it
571
+ if ( 'attachment' !== get_post_type( $post_id ) || ( '1' === get_post_meta( $post_id, 'dlm_protected_file', true ) ) ) {
572
+ continue;
573
+ }
574
+ // Create the file object
575
+ $file = array(
576
+ 'attachment_id' => $post_id,
577
+ 'user_id' => get_current_user_id(),
578
+ 'title' => get_the_title( $post_id ),
579
+ );
580
+ // Move the file
581
+ download_monitor()->service( 'file_manager' )->move_file_to_dlm_uploads( $file['attachment_id'] );
582
+ // Create the Download
583
+ $this->create_download( $file );
584
+ }
585
+ }
586
+ // Redirect to the media library when finished.
587
+ wp_redirect( admin_url( 'upload.php' ) );
588
+ exit;
589
+ }
590
+ }
src/AjaxHandler.php CHANGED
@@ -22,6 +22,7 @@ class DLM_Ajax_Handler {
22
  add_action( 'wp_ajax_dlm_settings_lazy_select', array( $this, 'handle_settings_lazy_select' ) );
23
  add_action( 'wp_ajax_dlm_extension', array( $this, 'handle_extensions' ) );
24
  add_action( 'wp_ajax_dlm_dismiss_notice', array( $this, 'dismiss_notice' ) );
 
25
  }
26
 
27
  /**
@@ -291,4 +292,27 @@ class DLM_Ajax_Handler {
291
  // Send JSON
292
  wp_send_json( $response );
293
  }
294
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  add_action( 'wp_ajax_dlm_settings_lazy_select', array( $this, 'handle_settings_lazy_select' ) );
23
  add_action( 'wp_ajax_dlm_extension', array( $this, 'handle_extensions' ) );
24
  add_action( 'wp_ajax_dlm_dismiss_notice', array( $this, 'dismiss_notice' ) );
25
+ add_action( 'wp_ajax_dlm_update_file_meta', array( $this, 'save_attachment_meta' ) );
26
  }
27
 
28
  /**
292
  // Send JSON
293
  wp_send_json( $response );
294
  }
295
+
296
+ /**
297
+ * Save attachment meta dlm_download
298
+ *
299
+ * @return void
300
+ * @since 4.7.2
301
+ */
302
+ public function save_attachment_meta() {
303
+ // Check if there is a nonce
304
+ if ( ! isset( $_POST['nonce'] ) ) {
305
+ wp_send_json_error( 'No nonce send' );
306
+ }
307
+ // check nonce
308
+ check_ajax_referer( 'add-file', 'nonce' );
309
+ $meta = json_encode(
310
+ array(
311
+ 'download_id' => absint( $_POST['download_id'] ),
312
+ 'version_id' => absint( $_POST['version_id'] )
313
+ )
314
+ );
315
+ update_post_meta( absint( $_POST['file_id'] ), 'dlm_download', $meta );
316
+ wp_send_json_success();
317
+ }
318
+ }
src/DLM.php CHANGED
@@ -217,6 +217,8 @@ class WP_DLM {
217
 
218
  // Fix to whitelist our function for PolyLang
219
  add_filter( 'pll_home_url_white_list', array( $this, 'whitelist_polylang' ), 15, 1 );
 
 
220
  }
221
 
222
  /**
@@ -625,4 +627,49 @@ class WP_DLM {
625
  public static function do_xhr() {
626
  return apply_filters( 'dlm_do_xhr', true );
627
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
628
  }
217
 
218
  // Fix to whitelist our function for PolyLang
219
  add_filter( 'pll_home_url_white_list', array( $this, 'whitelist_polylang' ), 15, 1 );
220
+ // Generate attachment URL as Download link for protected files. Adding this here because we need it both in admin and in front
221
+ add_filter( 'wp_get_attachment_url', array( $this, 'generate_attachment_url' ), 15, 2 );
222
  }
223
 
224
  /**
627
  public static function do_xhr() {
628
  return apply_filters( 'dlm_do_xhr', true );
629
  }
630
+
631
+ /**
632
+ * Return the Download Link for a given file if that file was protected by DLM
633
+ *
634
+ * @param $url
635
+ * @param $attachment_id
636
+ *
637
+ * @return mixed|String
638
+ * @since 4.7.2
639
+ */
640
+ public function generate_attachment_url( $url, $attachment_id ) {
641
+ // Get the Download ID, if exists
642
+ $known_download = get_post_meta( $attachment_id, 'dlm_download', true );
643
+ $protected = get_post_meta( $attachment_id, 'dlm_protected_file', true );
644
+ // If it doesn't exist, return the original URL
645
+ if ( empty( $known_download ) || '1' !== $protected ) {
646
+ return $url;
647
+ }
648
+
649
+ $known_download = json_decode( $known_download, true );
650
+ $download_id = isset( $known_download['download_id'] ) ? $known_download['download_id'] : false;
651
+ $version_id = isset( $known_download['version_id'] ) ? $known_download['version_id'] : false;
652
+
653
+ if ( ! $download_id ) {
654
+ return $url;
655
+ }
656
+
657
+ $download = false;
658
+ // Try to find our Download
659
+ try {
660
+ /** @var DLM_Download $download */
661
+ $download = download_monitor()->service( 'download_repository' )->retrieve_single( absint( $download_id ) );
662
+ } catch ( Exception $exception ) {
663
+ return $url;
664
+ }
665
+
666
+ $url = $download->get_the_download_link();
667
+ // Set version also to the URL as the user might add another version to that Download that could download another file
668
+ if ( $version_id ) {
669
+ $url = add_query_arg( 'v', $version_id, $url );
670
+ }
671
+
672
+ // Return our Download Link instead of the original URL
673
+ return $url;
674
+ }
675
  }
src/DownloadHandler.php CHANGED
@@ -504,6 +504,8 @@ class DLM_Download_Handler {
504
  do_action( 'dlm_downloading', $download, $version, $file_path );
505
  }
506
 
 
 
507
  $allowed_paths = download_monitor()->service( 'file_manager' )->get_allowed_paths();
508
  // we get the secure file path.
509
  $correct_path = download_monitor()->service( 'file_manager' )->get_correct_path( $file_path, $allowed_paths );
@@ -511,7 +513,7 @@ class DLM_Download_Handler {
511
  // Redirect to the file...
512
  if ( $download->is_redirect_only() || apply_filters( 'dlm_do_not_force', false, $download, $version ) ) {
513
  if ( ! $this->check_for_xhr() ) {
514
- $this->dlm_logging->log( $download, $version, 'redirect' );
515
  }
516
 
517
  // If it's not a remote file we need to create the correct URL.
@@ -525,6 +527,15 @@ class DLM_Download_Handler {
525
  }
526
 
527
  if ( $this->check_for_xhr() ) {
 
 
 
 
 
 
 
 
 
528
  header( 'DLM-Redirect: ' . $file_path );
529
  exit;
530
  }
@@ -542,7 +553,7 @@ class DLM_Download_Handler {
542
  if ( '1' === get_option( 'dlm_xsendfile_enabled' ) ) {
543
  if ( function_exists( 'apache_get_modules' ) && in_array( 'mod_xsendfile', apache_get_modules() ) ) {
544
  if ( ! $this->check_for_xhr() ) {
545
- $this->dlm_logging->log( $download, $version, 'completed' );
546
  }
547
 
548
  header( "X-Sendfile: $file_path" );
@@ -551,7 +562,7 @@ class DLM_Download_Handler {
551
  } elseif ( stristr( getenv( 'SERVER_SOFTWARE' ), 'lighttpd' ) ) {
552
 
553
  if ( ! $this->check_for_xhr() ) {
554
- $this->dlm_logging->log( $download, $version, 'completed' );
555
  }
556
 
557
  header( "X-LIGHTTPD-send-file: $file_path" );
@@ -559,7 +570,7 @@ class DLM_Download_Handler {
559
 
560
  } elseif ( stristr( getenv( 'SERVER_SOFTWARE' ), 'nginx' ) || stristr( getenv( 'SERVER_SOFTWARE' ), 'cherokee' ) ) {
561
  // Log this way as the js doesn't know who the download_id and version_id is
562
- $this->dlm_logging->log( $download, $version, 'completed' );
563
 
564
  // At this point the $correct_path should have a value of the file path as the verification was made prior to this check
565
  // If there are symbolik links the return of the function will be an URL, so the last replace will not be taken into consideration.
@@ -605,7 +616,7 @@ class DLM_Download_Handler {
605
  // Adding contents to an object will trigger error on big files.
606
  if ( $this->readfile_chunked( $file_path, false, $range ) ) {
607
  if ( ! $this->check_for_xhr() ) {
608
- $this->dlm_logging->log( $download, $version, 'completed' );
609
  }
610
  } elseif ( $remote_file ) {
611
  // Redirect - we can't track if this completes or not.
@@ -615,7 +626,7 @@ class DLM_Download_Handler {
615
  }
616
 
617
  header( 'Location: ' . $file_path );
618
- $this->dlm_logging->log( $download, $version, 'redirected' );
619
 
620
  } else {
621
 
@@ -624,7 +635,7 @@ class DLM_Download_Handler {
624
  exit;
625
  }
626
 
627
- $this->dlm_logging->log( $download, $version, 'failed' );
628
  wp_die( esc_html__( 'File not found.', 'download-monitor' ) . ' <a href="' . esc_url( home_url() ) . '">' . esc_html__( 'Go to homepage &rarr;', 'download-monitor' ) . '</a>', esc_html__( 'Download Error', 'download-monitor' ), array( 'response' => 404 ) );
629
  }
630
  exit;
504
  do_action( 'dlm_downloading', $download, $version, $file_path );
505
  }
506
 
507
+ $referrer = ( isset( $_SERVER['HTTP_REFERER'] ) ) ? esc_url_raw( $_SERVER['HTTP_REFERER'] ) : '';
508
+
509
  $allowed_paths = download_monitor()->service( 'file_manager' )->get_allowed_paths();
510
  // we get the secure file path.
511
  $correct_path = download_monitor()->service( 'file_manager' )->get_correct_path( $file_path, $allowed_paths );
513
  // Redirect to the file...
514
  if ( $download->is_redirect_only() || apply_filters( 'dlm_do_not_force', false, $download, $version ) ) {
515
  if ( ! $this->check_for_xhr() ) {
516
+ $this->dlm_logging->log( $download, $version, 'redirect', true, $referrer );
517
  }
518
 
519
  // If it's not a remote file we need to create the correct URL.
527
  }
528
 
529
  if ( $this->check_for_xhr() ) {
530
+ // We need to urlencode in case there are unicode characters in the file name.
531
+ // Get file name
532
+ $file_name = urldecode( DLM_Utils::basename( $file_path ) );
533
+
534
+ if ( strstr( $file_name, '?' ) ) {
535
+ $file_name = current( explode( '?', $file_name ) );
536
+ }
537
+
538
+ $file_path = str_replace( $file_name, urlencode( $file_name ), $file_path );
539
  header( 'DLM-Redirect: ' . $file_path );
540
  exit;
541
  }
553
  if ( '1' === get_option( 'dlm_xsendfile_enabled' ) ) {
554
  if ( function_exists( 'apache_get_modules' ) && in_array( 'mod_xsendfile', apache_get_modules() ) ) {
555
  if ( ! $this->check_for_xhr() ) {
556
+ $this->dlm_logging->log( $download, $version, 'completed', true, $referrer );
557
  }
558
 
559
  header( "X-Sendfile: $file_path" );
562
  } elseif ( stristr( getenv( 'SERVER_SOFTWARE' ), 'lighttpd' ) ) {
563
 
564
  if ( ! $this->check_for_xhr() ) {
565
+ $this->dlm_logging->log( $download, $version, 'completed', true, $referrer );
566
  }
567
 
568
  header( "X-LIGHTTPD-send-file: $file_path" );
570
 
571
  } elseif ( stristr( getenv( 'SERVER_SOFTWARE' ), 'nginx' ) || stristr( getenv( 'SERVER_SOFTWARE' ), 'cherokee' ) ) {
572
  // Log this way as the js doesn't know who the download_id and version_id is
573
+ $this->dlm_logging->log( $download, $version, 'completed', true, $referrer );
574
 
575
  // At this point the $correct_path should have a value of the file path as the verification was made prior to this check
576
  // If there are symbolik links the return of the function will be an URL, so the last replace will not be taken into consideration.
616
  // Adding contents to an object will trigger error on big files.
617
  if ( $this->readfile_chunked( $file_path, false, $range ) ) {
618
  if ( ! $this->check_for_xhr() ) {
619
+ $this->dlm_logging->log( $download, $version, 'completed', true, $referrer );
620
  }
621
  } elseif ( $remote_file ) {
622
  // Redirect - we can't track if this completes or not.
626
  }
627
 
628
  header( 'Location: ' . $file_path );
629
+ $this->dlm_logging->log( $download, $version, 'redirected', true, $referrer );
630
 
631
  } else {
632
 
635
  exit;
636
  }
637
 
638
+ $this->dlm_logging->log( $download, $version, 'failed', true, $referrer );
639
  wp_die( esc_html__( 'File not found.', 'download-monitor' ) . ' <a href="' . esc_url( home_url() ) . '">' . esc_html__( 'Go to homepage &rarr;', 'download-monitor' ) . '</a>', esc_html__( 'Download Error', 'download-monitor' ), array( 'response' => 404 ) );
640
  }
641
  exit;
src/FileManager.php CHANGED
@@ -467,4 +467,333 @@ class DLM_File_Manager {
467
 
468
  return $file_path;
469
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
470
  }
467
 
468
  return $file_path;
469
  }
470
+
471
+ /**
472
+ * Function to move files from Media Library to the DLM protected folder dlm_uploads.
473
+ *
474
+ * @param $post_id
475
+ *
476
+ * @return WP_Error
477
+ * @since 4.7.2
478
+ */
479
+ public function move_file_to_dlm_uploads( $post_id ) {
480
+ //Move file to dlm_uploads
481
+ $file = get_post_meta( $post_id, '_wp_attached_file', true );
482
+
483
+ if ( 0 === stripos( $file, $this->dlm_upload_dir( '/' ) ) ) {
484
+ return new WP_Error( 'protected_file_existed', sprintf(
485
+ __( 'This file is already protected. Please reload your page.', 'download-monitor' ),
486
+ $file
487
+ ), array( 'status' => 500 ) );
488
+ }
489
+
490
+ $reldir = dirname( $file );
491
+
492
+ if ( in_array( $reldir, array( '\\', '/', '.' ), true ) ) {
493
+ $reldir = '';
494
+ }
495
+
496
+ $protected_dir = path_join( $this->dlm_upload_dir(), $reldir );
497
+ return $this->move_attachment_to_protected( $post_id, $protected_dir );
498
+
499
+ }
500
+
501
+ /**
502
+ * Function to move files back to the Media Library.
503
+ *
504
+ * @param $post_id
505
+ *
506
+ * @return array|bool|int|WP_Error
507
+ * @since 4.7.2
508
+ */
509
+ public function move_file_back( $post_id ) {
510
+
511
+ $file = get_post_meta( $post_id, '_wp_attached_file', true );
512
+
513
+ // check if files are already not in Download Monitor's protected folder
514
+ if ( 0 !== stripos( $file, $this->dlm_upload_dir( '/' ) ) ) {
515
+ return true;
516
+ }
517
+
518
+ $protected_dir = ltrim( dirname( $file ), $this->dlm_upload_dir( '/' ) );
519
+ return $this->move_attachment_to_protected( $post_id, $protected_dir );
520
+ }
521
+
522
+ /**
523
+ * Download Monitor's upload directory ( dlm_uploads ).
524
+ *
525
+ * @param $path
526
+ * @param $in_url
527
+ *
528
+ * @return string
529
+ * @since 4.7.2
530
+ */
531
+ public function dlm_upload_dir( $path = '', $in_url = false ) {
532
+
533
+ $dirpath = $in_url ? '/' : '';
534
+ $dirpath .= 'dlm_uploads';
535
+ $dirpath .= $path;
536
+
537
+ return $dirpath;
538
+ }
539
+
540
+ /**
541
+ * Move attachment to protected folder.
542
+ *
543
+ * @param $attachment_id
544
+ * @param $protected_dir
545
+ * @param $meta_input
546
+ *
547
+ * @return array|bool|WP_Error
548
+ * @since 4.7.2
549
+ */
550
+ public function move_attachment_to_protected( $attachment_id, $protected_dir, $meta_input = [] ) {
551
+
552
+ if ( 'attachment' !== get_post_type( $attachment_id ) ) {
553
+ return new WP_Error( 'not_attachment', sprintf(
554
+ __( 'The post with ID: %d is not an attachment post type.', 'download-monitor' ),
555
+ $attachment_id
556
+ ), array( 'status' => 404 ) );
557
+ }
558
+
559
+ if ( path_is_absolute( $protected_dir ) ) {
560
+ return new WP_Error( 'protected_dir_not_relative', sprintf(
561
+ __( 'The new path provided: %s is absolute. The new path must be a path relative to the WP uploads directory.', 'download-monitor' ),
562
+ $protected_dir
563
+ ), array( 'status' => 404 ) );
564
+ }
565
+
566
+ $meta = empty( $meta_input ) ? wp_get_attachment_metadata( $attachment_id ) : $meta_input;
567
+ $meta = is_array( $meta ) ? $meta : array();
568
+
569
+ $file = get_post_meta( $attachment_id, '_wp_attached_file', true );
570
+ $backups = get_post_meta( $attachment_id, '_wp_attachment_backup_sizes', true );
571
+ $upload_dir = wp_upload_dir();
572
+ $old_dir = dirname( $file );
573
+
574
+ if ( in_array( $old_dir, array( '\\', '/', '.' ), true ) ) {
575
+ $old_dir = '';
576
+ }
577
+
578
+ if ( $protected_dir === $old_dir ) {
579
+ return true;
580
+ }
581
+
582
+ $old_full_path = path_join( $upload_dir['basedir'], $old_dir );
583
+ $protected_full_path = path_join( $upload_dir['basedir'], $protected_dir );
584
+
585
+ if ( ! wp_mkdir_p( $protected_full_path ) ) {
586
+ return new WP_Error( 'wp_mkdir_p_error', sprintf(
587
+ __( 'There was an error making or verifying the directory at: %s', 'download-monitor' ),
588
+ $protected_full_path
589
+ ), array( 'status' => 500 ) );
590
+ }
591
+
592
+ //Get all files
593
+ $sizes = array();
594
+
595
+ if ( array_key_exists( 'sizes', $meta ) ) {
596
+ $sizes = $this->get_files_from_meta( $meta['sizes'] );
597
+ }
598
+
599
+ $backup_sizes = $this->get_files_from_meta( $backups );
600
+ $old_basenames = $new_basenames = array_merge(
601
+ array( wp_basename( $file ) ),
602
+ $sizes,
603
+ $backup_sizes
604
+ );
605
+ $orig_basename = wp_basename( $file );
606
+
607
+ if ( is_array( $backups ) && isset( $backups['full-orig'] ) ) {
608
+ $orig_basename = $backups['full-orig']['file'];
609
+ }
610
+
611
+ $orig_filename = pathinfo( $orig_basename );
612
+ $orig_filename = $orig_filename['filename'];
613
+
614
+ $result = $this->resolve_name_conflict( $new_basenames, $protected_full_path, $orig_filename );
615
+ $new_basenames = $result['new_basenames'];
616
+
617
+ $this->rename_files( $old_basenames, $new_basenames, $old_full_path, $protected_full_path );
618
+
619
+ $base_file_name = 0;
620
+
621
+ $new_attached_file = path_join( $protected_dir, $new_basenames[0] );
622
+ if ( array_key_exists( 'file', $meta ) ) {
623
+ $meta['file'] = $new_attached_file;
624
+ }
625
+ update_post_meta( $attachment_id, '_wp_attached_file', $new_attached_file );
626
+
627
+ if ( $new_basenames[ $base_file_name ] != $old_basenames[ $base_file_name ] ) {
628
+ $pattern = $result['pattern'];
629
+ $replace = $result['replace'];
630
+ $separator = "#";
631
+ $orig_basename = ltrim(
632
+ str_replace( $pattern, $replace, $separator . $orig_basename ),
633
+ $separator
634
+ );
635
+ $meta = $this->update_meta_sizes_file( $meta, $new_basenames );
636
+ $this->update_backup_files( $attachment_id, $backups, $new_basenames );
637
+ }
638
+
639
+ update_post_meta( $attachment_id, '_wp_attachment_metadata', $meta );
640
+ $guid = path_join( $protected_full_path, $orig_basename );
641
+ wp_update_post( array( 'ID' => $attachment_id, 'guid' => $guid ) );
642
+
643
+ return empty( $meta_input ) ? true : $meta;
644
+ }
645
+
646
+ /**
647
+ * Get files from meta.
648
+ *
649
+ * @param $input
650
+ *
651
+ * @return array
652
+ * @since 4.7.2
653
+ */
654
+ public function get_files_from_meta( $input ) {
655
+
656
+ $files = array();
657
+ if ( is_array( $input ) ) {
658
+ foreach ( $input as $size ) {
659
+ $files[] = $size['file'];
660
+ }
661
+ }
662
+
663
+ return $files;
664
+ }
665
+
666
+ /**
667
+ * Resolve name conflict.
668
+ *
669
+ * @param $new_basenames
670
+ * @param $protected_full_path
671
+ * @param $orig_file_name
672
+ *
673
+ * @return array
674
+ * @since 4.7.2
675
+ */
676
+ public function resolve_name_conflict( $new_basenames, $protected_full_path, $orig_file_name ) {
677
+
678
+ $conflict = true;
679
+ $number = 1;
680
+ $separator = "#";
681
+ $med_filename = $orig_file_name;
682
+ $pattern = "";
683
+ $replace = "";
684
+
685
+ while ( $conflict ) {
686
+ $conflict = false;
687
+ foreach ( $new_basenames as $basename ) {
688
+ if ( is_file( path_join( $protected_full_path, $basename ) ) ) {
689
+ $conflict = true;
690
+ break;
691
+ }
692
+ }
693
+
694
+ if ( $conflict ) {
695
+ $new_filename = "$orig_file_name-$number";
696
+ $number ++;
697
+ $pattern = "$separator$med_filename";
698
+ $replace = "$separator$new_filename";
699
+ $new_basenames = explode(
700
+ $separator,
701
+ ltrim(
702
+ str_replace( $pattern, $replace, $separator . implode( $separator, $new_basenames ) ),
703
+ $separator
704
+ )
705
+ );
706
+
707
+ }
708
+ }
709
+
710
+ return array(
711
+ 'new_basenames' => $new_basenames,
712
+ 'pattern' => $pattern,
713
+ 'replace' => $replace
714
+ );
715
+ }
716
+
717
+ /**
718
+ * Rename files.
719
+ *
720
+ * @param $old_basenames
721
+ * @param $new_basenames
722
+ * @param $old_dir
723
+ * @param $protected_dir
724
+ *
725
+ * @return void|WP_Error
726
+ * @since 4.7.2
727
+ */
728
+ public function rename_files( $old_basenames, $new_basenames, $old_dir, $protected_dir ) {
729
+
730
+ $unique_old_basenames = array_values( array_unique( $old_basenames ) );
731
+ $unique_new_basenames = array_values( array_unique( $new_basenames ) );
732
+ $i = count( $unique_old_basenames );
733
+
734
+ while ( $i -- ) {
735
+ $old_fullpath = path_join( $old_dir, $unique_old_basenames[ $i ] );
736
+ $new_fullpath = path_join( $protected_dir, $unique_new_basenames[ $i ] );
737
+ if ( is_file( $old_fullpath ) ) {
738
+ rename( $old_fullpath, $new_fullpath );
739
+
740
+ if ( ! is_file( $new_fullpath ) ) {
741
+ return new WP_Error(
742
+ 'rename_failed',
743
+ sprintf(
744
+ __( 'Rename failed when trying to move file from: %s, to: %s', 'download-monitor' ),
745
+ $old_fullpath,
746
+ $new_fullpath
747
+ )
748
+ );
749
+ }
750
+ }
751
+ }
752
+ }
753
+
754
+ /**
755
+ * Update meta sizes file.
756
+ *
757
+ * @param $meta
758
+ * @param $new_basenames
759
+ *
760
+ * @return array
761
+ * @since 4.7.2
762
+ */
763
+ public function update_meta_sizes_file( $meta, $new_basenames ) {
764
+
765
+ if ( is_array( $meta['sizes'] ) ) {
766
+ $i = 0;
767
+
768
+ foreach ( $meta['sizes'] as $size => $data ) {
769
+ $meta['sizes'][ $size ]['file'] = $new_basenames[ ++ $i ];
770
+ }
771
+ }
772
+
773
+ return $meta;
774
+ }
775
+
776
+ /**
777
+ * Update backup files.
778
+ *
779
+ * @param $attachment_id
780
+ * @param $backups
781
+ * @param $new_basenames
782
+ *
783
+ * @return void
784
+ * @since 4.7.2
785
+ */
786
+ public function update_backup_files( $attachment_id, $backups, $new_basenames ) {
787
+
788
+ if ( is_array( $backups ) ) {
789
+ $i = 0;
790
+ $l = count( $backups );
791
+ $new_backup_sizes = array_slice( $new_basenames, - $l, $l );
792
+
793
+ foreach ( $backups as $size => $data ) {
794
+ $backups[ $size ]['file'] = $new_backup_sizes[ $i ++ ];
795
+ }
796
+ update_post_meta( $attachment_id, '_wp_attachment_backup_sizes', $backups );
797
+ }
798
+ }
799
  }
src/Gutenberg.php CHANGED
@@ -114,6 +114,11 @@ class DLM_Gutenberg {
114
  }
115
 
116
  $template_handler = new DLM_Template_Handler();
 
 
 
 
 
117
 
118
  // do the output
119
  ob_start();
114
  }
115
 
116
  $template_handler = new DLM_Template_Handler();
117
+ // enqueue style only on shortcode use
118
+ wp_enqueue_style( 'dlm-frontend' );
119
+
120
+ // Action to allow the adition of extra scripts and code related to the shortcode
121
+ do_action( 'dlm_download_shortcode_scripts' );
122
 
123
  // do the output
124
  ob_start();
src/Logs/LogItem.php CHANGED
@@ -114,7 +114,7 @@ class DLM_Log_Item {
114
  public function set_current_url( $current_url ) {
115
 
116
  if ( get_option( 'permalink_structure' ) ) {
117
- $current_url = wp_parse_url( $current_url )['path'];
118
  } else {
119
  $current_url = '/' . wp_parse_url( $current_url )['query'];
120
  }
114
  public function set_current_url( $current_url ) {
115
 
116
  if ( get_option( 'permalink_structure' ) ) {
117
+ $current_url = wp_parse_url( $current_url )['path'] . '?' . wp_parse_url( $current_url )['query'];
118
  } else {
119
  $current_url = '/' . wp_parse_url( $current_url )['query'];
120
  }
src/PostTypeManager.php CHANGED
@@ -69,7 +69,7 @@ class DLM_Post_Type_Manager {
69
  'show_in_nav_menus' => false,
70
  'menu_position' => 35,
71
  'show_in_rest' => true,
72
- 'menu_icon' => 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/Pgo8IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDIwMDEwOTA0Ly9FTiIKICJodHRwOi8vd3d3LnczLm9yZy9UUi8yMDAxL1JFQy1TVkctMjAwMTA5MDQvRFREL3N2ZzEwLmR0ZCI+CjxzdmcgdmVyc2lvbj0iMS4wIiB4b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AuMDAwNTk5Njc0QzM4LjU3NTYgMC4wMDA1OTk2NzQgMjUuMjIxOSA1LjUzMjAzIDE1LjM3NzYgMTUuMzc4MUM1LjUzMTQ2IDI1LjIyMjkgMCAzOC41NzY2IDAgNTIuNTAwM0MwIDY2LjQyNCA1LjUzMTQ2IDc5Ljc3ODMgMTUuMzc3NiA4OS42MjI1QzI1LjIyMjUgOTkuNDY4NiAzOC41NzYyIDEwNSA1Mi41IDEwNUM2Ni40MjM4IDEwNSA3OS43NzgxIDk5LjQ2ODYgODkuNjIyNCA4OS42MjI1Qzk5LjQ2ODUgNzkuNzc3NyAxMDUgNjYuNDI0IDEwNSA1Mi41MDAzQzEwNSA0My4yODQ1IDEwMi41NzQgMzQuMjMwOCA5Ny45NjY0IDI2LjI1MDJDOTMuMzU4NyAxOC4yNjk1IDg2LjczMDQgMTEuNjQxNiA3OC43NDk3IDcuMDMzNTRDNzAuNzY5IDIuNDI1ODEgNjEuNzE1MiAwIDUyLjQ5OTQgMEw1Mi41IDAuMDAwNTk5Njc0Wk00MC40Nzc3IDM4LjI3MThMNDcuMjQ5OSA0NS4wOTY5VjI2LjI0OTZINTcuNzUwMVY0NS4wOTY5TDY0LjUyMjMgMzguMzI0Nkw3MS45MjUyIDQ1LjcyNzVMNTIuNSA2NS4xNTI2TDMzLjAyMiA0NS42NzQ3TDQwLjQ3NzcgMzguMjcxOFpNNzguNzQ5MSA3OC43NTExSDI2LjI0ODVWNjguMjUxSDc4Ljc0OTFWNzguNzUxMVoiIGZpbGw9IndoaXRlIi8+Cjwvc3ZnPgo='
73
  ) )
74
  );
75
 
src/Shop/Util/Assets.php CHANGED
@@ -21,11 +21,11 @@ class Assets {
21
  public function enqueue_assets() {
22
 
23
  if ( Services::get()->service( 'page' )->is_cart() ) {
24
- wp_enqueue_style( 'dlm-frontend-cart', download_monitor()->get_plugin_url() . '/assets/css/cart.min.css' );
25
  }
26
 
27
  if ( Services::get()->service( 'page' )->is_checkout() ) {
28
- wp_enqueue_style( 'dlm-frontend-checkout', download_monitor()->get_plugin_url() . '/assets/css/checkout.min.css' );
29
 
30
  wp_enqueue_script(
31
  'dlm-frontend-checkout-js',
21
  public function enqueue_assets() {
22
 
23
  if ( Services::get()->service( 'page' )->is_cart() ) {
24
+ wp_enqueue_style( 'dlm-frontend-cart', download_monitor()->get_plugin_url() . '/assets/css/cart.min.css', array(), DLM_VERSION );
25
  }
26
 
27
  if ( Services::get()->service( 'page' )->is_checkout() ) {
28
+ wp_enqueue_style( 'dlm-frontend-checkout', download_monitor()->get_plugin_url() . '/assets/css/checkout.min.css', array(), DLM_VERSION );
29
 
30
  wp_enqueue_script(
31
  'dlm-frontend-checkout-js',
vendor/composer/autoload_classmap.php CHANGED
@@ -76,6 +76,7 @@ return array(
76
  'DLM_Log_Item' => $baseDir . '/src/Logs/LogItem.php',
77
  'DLM_Log_Item_Repository' => $baseDir . '/src/Logs/LogItemRepository.php',
78
  'DLM_Logging' => $baseDir . '/src/Logs/Logging.php',
 
79
  'DLM_Post_Type_Manager' => $baseDir . '/src/PostTypeManager.php',
80
  'DLM_Product' => $baseDir . '/src/Product/Product.php',
81
  'DLM_Product_Error_Handler' => $baseDir . '/src/Product/ProductErrorHandler.php',
76
  'DLM_Log_Item' => $baseDir . '/src/Logs/LogItem.php',
77
  'DLM_Log_Item_Repository' => $baseDir . '/src/Logs/LogItemRepository.php',
78
  'DLM_Logging' => $baseDir . '/src/Logs/Logging.php',
79
+ 'DLM_Media_Library' => $baseDir . '/src/Admin/class-dlm-media-library.php',
80
  'DLM_Post_Type_Manager' => $baseDir . '/src/PostTypeManager.php',
81
  'DLM_Product' => $baseDir . '/src/Product/Product.php',
82
  'DLM_Product_Error_Handler' => $baseDir . '/src/Product/ProductErrorHandler.php',
vendor/composer/autoload_static.php CHANGED
@@ -91,6 +91,7 @@ class ComposerStaticInit80ce4473100edd20fd6c17775a76ce9a
91
  'DLM_Log_Item' => __DIR__ . '/../..' . '/src/Logs/LogItem.php',
92
  'DLM_Log_Item_Repository' => __DIR__ . '/../..' . '/src/Logs/LogItemRepository.php',
93
  'DLM_Logging' => __DIR__ . '/../..' . '/src/Logs/Logging.php',
 
94
  'DLM_Post_Type_Manager' => __DIR__ . '/../..' . '/src/PostTypeManager.php',
95
  'DLM_Product' => __DIR__ . '/../..' . '/src/Product/Product.php',
96
  'DLM_Product_Error_Handler' => __DIR__ . '/../..' . '/src/Product/ProductErrorHandler.php',
91
  'DLM_Log_Item' => __DIR__ . '/../..' . '/src/Logs/LogItem.php',
92
  'DLM_Log_Item_Repository' => __DIR__ . '/../..' . '/src/Logs/LogItemRepository.php',
93
  'DLM_Logging' => __DIR__ . '/../..' . '/src/Logs/Logging.php',
94
+ 'DLM_Media_Library' => __DIR__ . '/../..' . '/src/Admin/class-dlm-media-library.php',
95
  'DLM_Post_Type_Manager' => __DIR__ . '/../..' . '/src/PostTypeManager.php',
96
  'DLM_Product' => __DIR__ . '/../..' . '/src/Product/Product.php',
97
  'DLM_Product_Error_Handler' => __DIR__ . '/../..' . '/src/Product/ProductErrorHandler.php',