Email Before Download - Version 5.0.5

Version Description

Download this release

Release Info

Developer mandsconsulting
Plugin Icon 128x128 Email Before Download
Version 5.0.5
Comparing to
See all releases

Code changes from version 5.0.4 to 5.0.5

email-before-download.php CHANGED
@@ -11,7 +11,7 @@
11
  * @wordpress-plugin
12
  * Plugin Name: Email Before Download
13
  * Plugin URI: mandsconsulting.com
14
- * Version: 5.0.4
15
  * Author: M&S Consulting
16
  * Author URI: mandsconsulting.com
17
  * License: GPL-2.0+
@@ -25,7 +25,7 @@ if ( ! defined( 'WPINC' ) ) {
25
  }
26
 
27
 
28
- define( 'PLUGIN_NAME_VERSION', '5.0.4' );
29
 
30
  function activate_email_before_download() {
31
  require_once plugin_dir_path( __FILE__ ) . 'includes/class-email-before-download-activator.php';
11
  * @wordpress-plugin
12
  * Plugin Name: Email Before Download
13
  * Plugin URI: mandsconsulting.com
14
+ * Version: 5.0.5
15
  * Author: M&S Consulting
16
  * Author URI: mandsconsulting.com
17
  * License: GPL-2.0+
25
  }
26
 
27
 
28
+ define( 'PLUGIN_NAME_VERSION', '5.0.5' );
29
 
30
  function activate_email_before_download() {
31
  require_once plugin_dir_path( __FILE__ ) . 'includes/class-email-before-download-activator.php';
includes/class-email-before-download-form.php CHANGED
@@ -37,10 +37,7 @@ class Email_Before_Download_Form
37
  if(($this->atts['hide_form'] == 'yes') && ($this->atts['checked'] == '')){
38
  if(count($this->download_id) > 1)
39
  $p->setAttribute('style','display:none');
40
-
41
  }
42
-
43
-
44
  }
45
  $paragraph = $parent->getElementsByTagName('p')->item(0);
46
  if($this->atts['hide_form'] != 'no') {
@@ -92,7 +89,7 @@ class Email_Before_Download_Form
92
  } else {
93
  $input = 'radio';
94
  }
95
- $formObject->loadHTML("<label class='ebd_input'><input type=\"$input\" $isChecked name=\"ebd_downloads[]\" value=\"$id:$title\"> $title</label>");
96
  $node = $formObject->getElementsByTagName("label");
97
  return $node->item(0);
98
  }
@@ -101,14 +98,14 @@ class Email_Before_Download_Form
101
  $formObject = new DOMDocument();
102
  $formObject->formatOutput = true;
103
  $title = $this->titles[$key];
104
- $formObject->loadHTML("<label class='ebd_input'><input type=\"hidden\" name=\"ebd_downloads[]\" value=\"$id:$title\"> </label>");
105
  $node = $formObject->getElementsByTagName("label");
106
  return $node->item(0);
107
  }
108
  private function hidden_dom_obj($name, $value){
109
  $formObject = new DOMDocument();
110
  $formObject->formatOutput = true;
111
- $formObject->loadHTML("<input type=\"hidden\" class=\"ebd_setting\" name =\"ebd_settings[]\" value=\"$name:$value\">");
112
  $node = $formObject->getElementsByTagName("input");
113
  return $node->item(0);
114
  }
37
  if(($this->atts['hide_form'] == 'yes') && ($this->atts['checked'] == '')){
38
  if(count($this->download_id) > 1)
39
  $p->setAttribute('style','display:none');
 
40
  }
 
 
41
  }
42
  $paragraph = $parent->getElementsByTagName('p')->item(0);
43
  if($this->atts['hide_form'] != 'no') {
89
  } else {
90
  $input = 'radio';
91
  }
92
+ $formObject->loadHTML("<label class='ebd_input'><input type=\"$input\" $isChecked name=\"ebd_downloads[]\" value=\"$id|$title\"> $title</label>");
93
  $node = $formObject->getElementsByTagName("label");
94
  return $node->item(0);
95
  }
98
  $formObject = new DOMDocument();
99
  $formObject->formatOutput = true;
100
  $title = $this->titles[$key];
101
+ $formObject->loadHTML("<label class='ebd_input'><input type=\"hidden\" name=\"ebd_downloads[]\" value=\"$id|$title\"> </label>");
102
  $node = $formObject->getElementsByTagName("label");
103
  return $node->item(0);
104
  }
105
  private function hidden_dom_obj($name, $value){
106
  $formObject = new DOMDocument();
107
  $formObject->formatOutput = true;
108
+ $formObject->loadHTML("<input type=\"hidden\" class=\"ebd_setting\" name =\"ebd_settings[]\" value=\"$name|$value\">");
109
  $node = $formObject->getElementsByTagName("input");
110
  return $node->item(0);
111
  }
includes/class-email-before-download-process.php CHANGED
@@ -62,12 +62,12 @@ class Email_Before_Download_Process
62
  private function parse_post_array($post_array)
63
  {
64
  $new_array = [];
65
- $delimiter = ":";
66
  foreach ($post_array as $item) {
67
  if (strpos($item, '|')) {
68
  $delimiter = "|";
69
  }
70
- $tmp = explode($delimiter, $item,2);
71
  $new_array[$tmp[0]] = strtolower($tmp[1]);
72
  }
73
  return $new_array;
@@ -84,12 +84,12 @@ class Email_Before_Download_Process
84
  }
85
  }
86
  $urls = "";
87
- foreach ($files as $key => $value) {
88
  if (count($files) == 1) {
89
- $body = str_replace('[file_url]', $value, $body);
90
- $body = str_replace('[file_name]', $key, $body);
91
  } else {
92
- $urls .= $value . "\n";
93
  }
94
  }
95
  $body = str_replace('[file_urls]', $urls, $body);
@@ -102,9 +102,10 @@ class Email_Before_Download_Process
102
  {
103
  $headers = "Content-Type: text/html; charset=UTF-8\r\n";
104
  if(isset($settings['from_name'])) $name = $settings['from_name'] ;
105
- if(isset($settings['from_email'])) $from = sanitize_email($settings['from_email']) ;
106
- if(is_email($from)){
107
- if($name != ""){
 
108
  $headers .= "From: $name <$from>\r\n";
109
  }else {
110
  $headers .= "From: $from\r\n";
@@ -120,12 +121,10 @@ class Email_Before_Download_Process
120
  if (!$template) $template = __("Here is the download for <a href=\"[file_url]\">[file_name]</a> that you requested.",'email-before-download');
121
 
122
  }
123
-
124
  $subject = get_option("email_before_download_subject");
125
  if (!$subject) $subject = __("Your Requested File(s)", 'email-before-download');
126
-
127
- $body = $this->generate_email($template, $user_input, $links);
128
- if ( (isset($settings['attachment']) ) && ($settings['attachment'] == 1) ) {
129
  $attachments = $this->email_attachments($links);
130
  }
131
  wp_mail($user_input['your-email'], $subject, $body, $headers, $attachments);
@@ -159,6 +158,7 @@ class Email_Before_Download_Process
159
  $linkdata = array_filter($linkdata);
160
  $linkdata["expire_time"] = get_option('email_before_download_expire',"");
161
  $link = $this->db->create_link($linkdata);
 
162
  $links[$link->id] = $link;
163
  }
164
  return $links;
@@ -169,11 +169,16 @@ class Email_Before_Download_Process
169
  $linkHTML = "<div>" . get_option('email_before_download_html_before',"");
170
  foreach ($links as $link) {
171
  $downloadURL = $this->link_url($link);
172
- $linkCSS = get_option('email_before_download_link_css',"");
173
  $target = get_option('email_before_download_link_format','_self');
174
- $html = "<a href=\"$downloadURL\" class=\"ebd_link $linkCSS\" target=\"$target\">";
175
- $html .= do_shortcode("[download_data id=\"$link->selected_id\" data=\"title\"]");
176
- $html .= "</a>";
 
 
 
 
 
177
  $linkHTML .= $html;
178
  }
179
  $linkHTML .= get_option('email_before_download_html_after','') . "</div>";
@@ -187,8 +192,13 @@ class Email_Before_Download_Process
187
  {
188
  $files = [];
189
  foreach ($links as $link) {
190
- $title = do_shortcode("[download_data id=\"$link->selected_id\" data=\"title\"]");
191
- $files[$title] = $this->link_url($link);
 
 
 
 
 
192
  }
193
  return $files;
194
  }
@@ -198,10 +208,18 @@ class Email_Before_Download_Process
198
  $filePaths = [];
199
  foreach ($links as $link) {
200
  $fileName = do_shortcode("[download_data id=\"$link->selected_id\" data=\"filename\"]");
201
- $fileDate = do_shortcode("[download_data id=\"$link->selected_id\" data=\"file_date\"]");
202
- $fileDate = date('Y/m', strtotime($fileDate));
203
- $filePaths[] = WP_CONTENT_DIR . "/uploads/dlm_uploads/$fileDate/$fileName";
 
 
 
 
 
 
 
204
  }
 
205
  return $filePaths;
206
  }
207
 
62
  private function parse_post_array($post_array)
63
  {
64
  $new_array = [];
65
+ $delimiter = "|";
66
  foreach ($post_array as $item) {
67
  if (strpos($item, '|')) {
68
  $delimiter = "|";
69
  }
70
+ $tmp = explode($delimiter, $item);
71
  $new_array[$tmp[0]] = strtolower($tmp[1]);
72
  }
73
  return $new_array;
84
  }
85
  }
86
  $urls = "";
87
+ foreach ($files as $file) {
88
  if (count($files) == 1) {
89
+ $body = str_replace('[file_url]', $file['url'], $body);
90
+ $body = str_replace('[file_name]', $file['title'], $body);
91
  } else {
92
+ $urls .= $file['url'] . "\r\n";
93
  }
94
  }
95
  $body = str_replace('[file_urls]', $urls, $body);
102
  {
103
  $headers = "Content-Type: text/html; charset=UTF-8\r\n";
104
  if(isset($settings['from_name'])) $name = $settings['from_name'] ;
105
+ if(isset($settings['from_email'])) $from = $settings['from_email'] ;
106
+ if( (isset($from) ) && ( is_email($from) ) ){
107
+ $from = sanitize_email($from);
108
+ if( (isset($name) ) && ( $name != "" ) ){
109
  $headers .= "From: $name <$from>\r\n";
110
  }else {
111
  $headers .= "From: $from\r\n";
121
  if (!$template) $template = __("Here is the download for <a href=\"[file_url]\">[file_name]</a> that you requested.",'email-before-download');
122
 
123
  }
 
124
  $subject = get_option("email_before_download_subject");
125
  if (!$subject) $subject = __("Your Requested File(s)", 'email-before-download');
126
+ $body = $this->generate_email($template, $user_input, $links);
127
+ if ( (isset($settings['attachment']) ) && ($settings['attachment'] != 'no') ) {
 
128
  $attachments = $this->email_attachments($links);
129
  }
130
  wp_mail($user_input['your-email'], $subject, $body, $headers, $attachments);
158
  $linkdata = array_filter($linkdata);
159
  $linkdata["expire_time"] = get_option('email_before_download_expire',"");
160
  $link = $this->db->create_link($linkdata);
161
+ $link->title = $title;
162
  $links[$link->id] = $link;
163
  }
164
  return $links;
169
  $linkHTML = "<div>" . get_option('email_before_download_html_before',"");
170
  foreach ($links as $link) {
171
  $downloadURL = $this->link_url($link);
172
+ $linkCSS = get_option('email_before_download_link_css');
173
  $target = get_option('email_before_download_link_format','_self');
174
+ $html = "<span class=\"et-icon\"><span><a href=\"$downloadURL\" class=\"icon-button download-icon ebd_link $linkCSS\" target=\"$target\">";
175
+ if(isset($link->title)){
176
+ $html .= $link->title;
177
+ }else {
178
+ $html .= do_shortcode("[download_data id=\"$link->selected_id\" data=\"title\"]");
179
+
180
+ }
181
+ $html .= "</a></</span></span></br>";
182
  $linkHTML .= $html;
183
  }
184
  $linkHTML .= get_option('email_before_download_html_after','') . "</div>";
192
  {
193
  $files = [];
194
  foreach ($links as $link) {
195
+ if(isset($link->title)){
196
+ $title = $link->title;
197
+ }else{
198
+ $title = do_shortcode("[download_data id=\"$link->selected_id\" data=\"title\"]");
199
+
200
+ }
201
+ $files[] = ['title' => $title,'url' => $this->link_url($link)];
202
  }
203
  return $files;
204
  }
208
  $filePaths = [];
209
  foreach ($links as $link) {
210
  $fileName = do_shortcode("[download_data id=\"$link->selected_id\" data=\"filename\"]");
211
+ $uploadsetting = get_option('uploads_use_yearmonth_folders');
212
+ $directory = wp_upload_dir();
213
+ if($uploadsetting == 1){
214
+ $fileDate = do_shortcode("[download_data id=\"$link->selected_id\" data=\"file_date\"]");
215
+ $fileDate = date('Y/m', strtotime($fileDate));
216
+ $filePaths[] = $directory['basedir']. "/dlm_uploads/$fileDate/$fileName";
217
+ }else{
218
+ $filePaths[] = $directory['basedir'] . "/dlm_uploads/$fileName";
219
+ }
220
+
221
  }
222
+
223
  return $filePaths;
224
  }
225
 
includes/class-email-before-download.php CHANGED
@@ -75,6 +75,7 @@ class Email_Before_Download {
75
  $plugin_public = new Email_Before_Download_Public( $this->get_plugin_name(), $this->get_version() );
76
  $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
77
  $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
 
78
 
79
  }
80
  private function define_process_hooks(){
@@ -90,6 +91,7 @@ class Email_Before_Download {
90
 
91
  public function build_shortcode(){
92
  add_shortcode('email-download' ,[new Email_Before_Download_Shortcode( $this->get_plugin_name(), $this->get_version()),'init_shortcode']);
 
93
 
94
  }
95
 
@@ -97,7 +99,7 @@ class Email_Before_Download {
97
  $this->loader->run();
98
  }
99
 
100
- public function get_plugin_name() {
101
  return $this->plugin_name;
102
  }
103
 
75
  $plugin_public = new Email_Before_Download_Public( $this->get_plugin_name(), $this->get_version() );
76
  $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
77
  $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
78
+ $this->loader->add_filter( 'the_content', $plugin_public,'shortcode_cleanup');
79
 
80
  }
81
  private function define_process_hooks(){
91
 
92
  public function build_shortcode(){
93
  add_shortcode('email-download' ,[new Email_Before_Download_Shortcode( $this->get_plugin_name(), $this->get_version()),'init_shortcode']);
94
+ add_shortcode('emailreq' ,[new Email_Before_Download_Shortcode( $this->get_plugin_name(), $this->get_version()),'init_shortcode']);
95
 
96
  }
97
 
99
  $this->loader->run();
100
  }
101
 
102
+ public function get_plugin_name() {
103
  return $this->plugin_name;
104
  }
105
 
public/class-email-before-download-public.php CHANGED
@@ -34,5 +34,24 @@ class Email_Before_Download_Public
34
  {
35
  wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__) . 'js/email-before-download-public.js', array('jquery'), $this->version, false);
36
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
  }
34
  {
35
  wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__) . 'js/email-before-download-public.js', array('jquery'), $this->version, false);
36
  }
37
+ public function shortcode_cleanup($content)
38
+ {
39
+ $shortcodes = [
40
+ 'email-download', 'emailreq'
41
+ ];
42
+ foreach ($shortcodes as $shortcode){
43
+ if (strpos($content, $shortcode))
44
+ {
45
+ $search = array(
46
+ '"','’','‘','“','”','"');
47
+
48
+ $replace = "'";
49
+
50
+ $content = str_replace($search, $replace, $content);
51
+ }
52
+ }
53
+
54
+ return $content;
55
+ }
56
 
57
  }
public/css/email-before-download-public.css CHANGED
@@ -1,15 +0,0 @@
1
- /**
2
- * All of the CSS for your public-facing functionality should be
3
- * included in this file.
4
- */
5
- .ebd_link {
6
- display: inline-block;
7
- padding: 10px 40px;
8
- margin: 10px;
9
- text-align: center;
10
- border: 1px solid #555;
11
- border-radius: 3px;
12
- }
13
- .ebd_link:hover {
14
- border: 1px solid #0A246A;
15
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
public/js/email-before-download-public.js CHANGED
@@ -1,7 +1,6 @@
1
 
2
  jQuery(document).ready(function(){
3
  if (jQuery("#downloadinputform").length === 1) {
4
-
5
  jQuery( "input[name*=ebd_downloads]" ).on( "click", function () {
6
  var n = jQuery( "input:checked[name*=ebd_downloads]" ).length;
7
  if(n > 0) jQuery( ".cf7_input" ).show();
1
 
2
  jQuery(document).ready(function(){
3
  if (jQuery("#downloadinputform").length === 1) {
 
4
  jQuery( "input[name*=ebd_downloads]" ).on( "click", function () {
5
  var n = jQuery( "input:checked[name*=ebd_downloads]" ).length;
6
  if(n > 0) jQuery( ".cf7_input" ).show();
readme.txt CHANGED
@@ -106,17 +106,25 @@ This is the list of all short code attributes that can be used. Some of them o
106
 
107
 
108
  == Changelog ==
 
 
 
 
 
 
 
 
109
  =5.0.4=
110
- Fixed emails not being sent for some people
111
- Fixed display issues with colons in download titles
112
- Modified settings so EBD stays compatible with Custom Sender plugin.
113
- Added shortcode attributes for from_email and from_name.
114
 
115
  =5.0.3=
116
- Fixed issue with form not displaying for some people
117
 
118
  =5.0.2=
119
- Fixed issue with admin tables not showing.
120
 
121
  =5.0.1=
122
  * Bug fixes
106
 
107
 
108
  == Changelog ==
109
+ =5.0.5=
110
+ * Fixed issue with some servers not attaching files to emails
111
+ * Fixed issue with malformed email headers if from_name was left blank
112
+ * Fixed issue with some multiple download forms
113
+ * Fixed issue with smart quotes being used in shortcode by third party content editors
114
+ * Removed some default styling that was conflicting with some custom styles
115
+ * Fixed issue with non standard upload folder names
116
+
117
  =5.0.4=
118
+ * Fixed emails not being sent for some people
119
+ * Fixed display issues with colons in download titles
120
+ * Modified settings so EBD stays compatible with Custom Sender plugin.
121
+ * Added shortcode attributes for from_email and from_name.
122
 
123
  =5.0.3=
124
+ * Fixed issue with form not displaying for some people
125
 
126
  =5.0.2=
127
+ * Fixed issue with admin tables not showing.
128
 
129
  =5.0.1=
130
  * Bug fixes