Email Before Download - Version 5.0.4

Version Description

Download this release

Release Info

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

Code changes from version 5.0.3 to 5.0.4

LICENSE.txt CHANGED
File without changes
admin/class-email-before-download-admin.php CHANGED
@@ -19,11 +19,11 @@ class Email_Before_Download_Admin
19
  private $options = [
20
  ['name' => '_support', 'type' => 'section','label' => "Support Links"],
21
  ['name' => '_general', 'type' => 'section','label' => "General Settings"],
22
- ['name' => '_delivery_format', 'type' => 'setting', 'label' => "Default Delivery Format", 'section' => '_general'],
23
- ['name' => '_expire', 'type' => 'setting', 'label' => "Default Link Expiration Time", 'section' => '_general'],
24
  ['name' => '_forbidden', 'type' => 'setting', 'label' => "Forbidden Domains", 'section' => '_general'],
25
  ['name' => '_inline', 'type' => 'section','label' => "Inline Link Settings"],
26
- ['name' => '_link_format', 'type' => 'setting', 'label' => "Default Link Target", 'section' => '_inline'],
27
  ['name' => '_link_css', 'type' => 'setting', 'label' => "Custom CSS", 'section' => '_inline'],
28
  ['name' => '_html_before', 'type' => 'setting', 'label' => "HTML Before Link", 'section' => '_inline'],
29
  ['name' => '_html_after', 'type' => 'setting', 'label' => "HTML After Link", 'section' => '_inline'],
@@ -31,13 +31,14 @@ class Email_Before_Download_Admin
31
  ['name' => '_single_email', 'type' => 'setting', 'label' => "Single URL Template", 'section' => '_email'],
32
  ['name' => '_multi_email', 'type' => 'setting', 'label' => "Multiple URL Template", 'section' => '_email'],
33
  ['name' => '_attachment', 'type' => 'setting', 'label' => "Default Attachment", 'section' => '_email'],
34
- ['name' => '_subject', 'type' => 'setting', 'label' => "Email Subject", 'section' => '_email'],
35
- ['name' => '_from_email', 'type' => 'setting', 'label' => "Delivery Email", 'section' => '_email'],
 
36
  ['name' => '_other', 'type' => 'section','label' => "Additional Settings"],
37
  ['name' => '_default_cf7', 'type' => 'setting', 'label' => "Default CF7 Form ID", 'section' => '_other'],
38
- ['name' => '_multi_check', 'type' => 'setting', 'label' => "Default Checkbox State", 'section' => '_other'],
39
- ['name' => '_hidden_form', 'type' => 'setting', 'label' => "Default Hide Form", 'section' => '_other'],
40
- ['name' => '_radio', 'type' => 'setting', 'label' => "Default Radio Buttons", 'section' => '_other']
41
  ];
42
 
43
  public function __construct($plugin_name, $version)
@@ -174,8 +175,12 @@ class Email_Before_Download_Admin
174
  $this->option_name . $option['name'],
175
  'string'
176
  );
 
177
  }
178
  }
 
 
 
179
 
180
  public function email_before_download_inline_cb()
181
  {
@@ -350,14 +355,22 @@ class Email_Before_Download_Admin
350
  <span class="subtitle"><?php _e('If this field is left blank, the default subject is: "Your requested file(s)".','email-before-download');?></span>
351
  <?php
352
  }
353
- public function email_before_download_from_email_cb()
354
  {
355
  ?>
356
- <input type="text" size="40" name="<?php echo $this->option_name . '_from_email' ?>"
357
- value="<?php echo get_option($this->option_name . '_from_email'); ?>"/>
358
  <span class="subtitle"><?php _e('Email address used to deliver the download links. If this field is left blank, the default wordpress email will be used..','email-before-download');?></span>
359
  <?php
360
  }
 
 
 
 
 
 
 
 
361
 
362
  public function email_before_download_other_cb()
363
  {
@@ -379,7 +392,7 @@ class Email_Before_Download_Admin
379
  <option value="checked" <?php if (get_option($this->option_name . '_multi_check') == 'checked') echo 'selected="selected"'; ?> >
380
  Checked
381
  </option>
382
- <option value="" <?php if (get_option($this->option_name . '_multi_check') == '') echo 'selected="selected"'; ?> >
383
  Unchecked
384
  </option>
385
  </select>
@@ -394,7 +407,7 @@ class Email_Before_Download_Admin
394
  <option value="yes" <?php if (get_option($this->option_name . '_hidden_form') == 'yes') echo 'selected="selected"'; ?> >
395
  <?php _e('Yes','email-before-download'); ?>
396
  </option>
397
- <option value="no" <?php if (get_option($this->option_name . '_hidden_form') == 'no') echo 'selected="selected"'; ?> >
398
  <?php _e('No','email-before-download'); ?>
399
  </option>
400
  </select>
19
  private $options = [
20
  ['name' => '_support', 'type' => 'section','label' => "Support Links"],
21
  ['name' => '_general', 'type' => 'section','label' => "General Settings"],
22
+ ['name' => '_delivery_format', 'type' => 'setting', 'label' => "Default Delivery Format", 'section' => '_general', 'default' => "inline link"],
23
+ ['name' => '_expire', 'type' => 'setting', 'label' => "Default Link Expiration Time", 'section' => '_general', 'default' => "0"],
24
  ['name' => '_forbidden', 'type' => 'setting', 'label' => "Forbidden Domains", 'section' => '_general'],
25
  ['name' => '_inline', 'type' => 'section','label' => "Inline Link Settings"],
26
+ ['name' => '_link_format', 'type' => 'setting', 'label' => "Default Link Target", 'section' => '_inline', 'default' => "_self"],
27
  ['name' => '_link_css', 'type' => 'setting', 'label' => "Custom CSS", 'section' => '_inline'],
28
  ['name' => '_html_before', 'type' => 'setting', 'label' => "HTML Before Link", 'section' => '_inline'],
29
  ['name' => '_html_after', 'type' => 'setting', 'label' => "HTML After Link", 'section' => '_inline'],
31
  ['name' => '_single_email', 'type' => 'setting', 'label' => "Single URL Template", 'section' => '_email'],
32
  ['name' => '_multi_email', 'type' => 'setting', 'label' => "Multiple URL Template", 'section' => '_email'],
33
  ['name' => '_attachment', 'type' => 'setting', 'label' => "Default Attachment", 'section' => '_email'],
34
+ ['name' => '_subject', 'type' => 'setting', 'label' => "From Email Subject", 'section' => '_email', 'default' => "Your Requested File(s)"],
35
+ ['name' => '_from_name', 'type' => 'setting', 'label' => "From Email Name", 'section' => '_email'],
36
+ ['name' => '_email_from', 'type' => 'setting', 'label' => "From Email", 'section' => '_email'],
37
  ['name' => '_other', 'type' => 'section','label' => "Additional Settings"],
38
  ['name' => '_default_cf7', 'type' => 'setting', 'label' => "Default CF7 Form ID", 'section' => '_other'],
39
+ ['name' => '_multi_check', 'type' => 'setting', 'label' => "Default Checkbox State", 'section' => '_other', 'default' => " "],
40
+ ['name' => '_hidden_form', 'type' => 'setting', 'label' => "Default Hide Form", 'section' => '_other', 'default' => "no"],
41
+ ['name' => '_radio', 'type' => 'setting', 'label' => "Default Radio Buttons", 'section' => '_other', 'default' => "no"]
42
  ];
43
 
44
  public function __construct($plugin_name, $version)
175
  $this->option_name . $option['name'],
176
  'string'
177
  );
178
+
179
  }
180
  }
181
+ public function set_option_defaults(){
182
+
183
+ }
184
 
185
  public function email_before_download_inline_cb()
186
  {
355
  <span class="subtitle"><?php _e('If this field is left blank, the default subject is: "Your requested file(s)".','email-before-download');?></span>
356
  <?php
357
  }
358
+ public function email_before_download_email_from_cb()
359
  {
360
  ?>
361
+ <input type="text" size="40" name="<?php echo $this->option_name . '_email_from' ?>"
362
+ value="<?php echo get_option($this->option_name . '_email_from'); ?>"/>
363
  <span class="subtitle"><?php _e('Email address used to deliver the download links. If this field is left blank, the default wordpress email will be used..','email-before-download');?></span>
364
  <?php
365
  }
366
+ public function email_before_download_from_name_cb()
367
+ {
368
+ ?>
369
+ <input type="text" size="40" name="<?php echo $this->option_name . '_from_name' ?>"
370
+ value="<?php echo get_option($this->option_name . '_from_name'); ?>"/>
371
+ <span class="subtitle"><?php _e('Name used to deliver the download links. If this field is left blank, the default wordpress email name will be used..','email-before-download');?></span>
372
+ <?php
373
+ }
374
 
375
  public function email_before_download_other_cb()
376
  {
392
  <option value="checked" <?php if (get_option($this->option_name . '_multi_check') == 'checked') echo 'selected="selected"'; ?> >
393
  Checked
394
  </option>
395
+ <option value="" <?php if ((get_option($this->option_name . '_multi_check') == '') || (!get_option($this->option_name . '_multi_check'))) echo 'selected="selected"'; ?> >
396
  Unchecked
397
  </option>
398
  </select>
407
  <option value="yes" <?php if (get_option($this->option_name . '_hidden_form') == 'yes') echo 'selected="selected"'; ?> >
408
  <?php _e('Yes','email-before-download'); ?>
409
  </option>
410
+ <option value="no" <?php if ((get_option($this->option_name . '_hidden_form')) == 'no'||(!get_option($this->option_name . '_hidden_form'))) echo 'selected="selected"'; ?> >
411
  <?php _e('No','email-before-download'); ?>
412
  </option>
413
  </select>
admin/css/email-before-download-admin.css CHANGED
File without changes
admin/index.php CHANGED
File without changes
admin/partials/email-before-download-admin-display.php CHANGED
File without changes
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.3
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.3' );
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.4
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.4' );
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-activator.php CHANGED
@@ -14,6 +14,19 @@ class Email_Before_Download_Activator
14
 
15
  public static function activate()
16
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  if (!is_plugin_active('download-monitor/download-monitor.php'))
18
  $plugins[] = "Download Monitor";
19
  if (!is_plugin_active('contact-form-7/wp-contact-form-7.php'))
@@ -66,6 +79,9 @@ class Email_Before_Download_Activator
66
  foreach ($tables as $table) {
67
  dbDelta($table . $charset_collate);
68
  }
 
 
 
69
 
70
  }
71
 
14
 
15
  public static function activate()
16
  {
17
+ $option_name = 'email_before_download';
18
+ $options = [
19
+ ['name' => '_delivery_format', 'default' => "inline link"],
20
+ ['name' => '_expire', 'default' => "0"],
21
+ ['name' => '_link_format', 'default' => "_self"],
22
+ ['name' => '_single_email','default '=>"Here is the download for <a href=\"[file_url]\">[file_name]</a> that you requested." ],
23
+ ['name' => '_multi_email', 'default' => "[file_urls]"],
24
+ ['name' => '_subject', 'default' => "Your Requested File(s)"],
25
+ ['name' => '_multi_check', 'default' => " "],
26
+ ['name' => '_from_name', 'default' => " "],
27
+ ['name' => '_hidden_form', 'default' => "no"],
28
+ ['name' => '_radio','default' => "no"]
29
+ ];
30
  if (!is_plugin_active('download-monitor/download-monitor.php'))
31
  $plugins[] = "Download Monitor";
32
  if (!is_plugin_active('contact-form-7/wp-contact-form-7.php'))
79
  foreach ($tables as $table) {
80
  dbDelta($table . $charset_collate);
81
  }
82
+ foreach ($options as $option) {
83
+ add_option($option_name . $option['name'],$option['default'],'','yes');
84
+ }
85
 
86
  }
87
 
includes/class-email-before-download-form.php CHANGED
@@ -34,6 +34,13 @@ class Email_Before_Download_Form
34
  $paragraphs = $parent->getElementsByTagName('p');
35
  foreach ($paragraphs as $p){
36
  $p->setAttribute('class','cf7_input');
 
 
 
 
 
 
 
37
  }
38
  $paragraph = $parent->getElementsByTagName('p')->item(0);
39
  if($this->atts['hide_form'] != 'no') {
34
  $paragraphs = $parent->getElementsByTagName('p');
35
  foreach ($paragraphs as $p){
36
  $p->setAttribute('class','cf7_input');
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') {
includes/class-email-before-download-i18n.php CHANGED
File without changes
includes/class-email-before-download-loader.php CHANGED
File without changes
includes/class-email-before-download-process.php CHANGED
@@ -67,7 +67,7 @@ class Email_Before_Download_Process
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;
@@ -100,12 +100,17 @@ class Email_Before_Download_Process
100
 
101
  private function send_email($user_input, $links, $settings)
102
  {
103
- $headers = "MIME-Version: 1.0\r\n";
104
- $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
105
- $from = get_option("email_before_download_from_email", "");
106
  if(is_email($from)){
107
- $headers .= "From: $from" . "\r\n";
 
 
 
 
108
  }
 
109
  $attachments = [];
110
  if (count($links) > 1) {
111
  $template = get_option("email_before_download_multi_email");
@@ -115,6 +120,7 @@ class Email_Before_Download_Process
115
  if (!$template) $template = __("Here is the download for <a href=\"[file_url]\">[file_name]</a> that you requested.",'email-before-download');
116
 
117
  }
 
118
  $subject = get_option("email_before_download_subject");
119
  if (!$subject) $subject = __("Your Requested File(s)", 'email-before-download');
120
 
@@ -126,6 +132,7 @@ class Email_Before_Download_Process
126
  return true;
127
  }
128
 
 
129
  private function generate_links($downloads, $settings, $user_input)
130
  {
131
 
@@ -171,14 +178,13 @@ class Email_Before_Download_Process
171
  }
172
  $linkHTML .= get_option('email_before_download_html_after','') . "</div>";
173
  $additional_settings = $form_obj->prop('additional_settings');
 
174
  $additional_settings .= "\n" . "on_sent_ok: \" jQuery('#ebdForm').append('$linkHTML'); \"";
175
  $form_obj->set_properties(array('additional_settings' => $additional_settings));
176
  return $form_obj;
177
  }
178
-
179
  private function email_links($links)
180
  {
181
-
182
  $files = [];
183
  foreach ($links as $link) {
184
  $title = do_shortcode("[download_data id=\"$link->selected_id\" data=\"title\"]");
@@ -186,7 +192,6 @@ class Email_Before_Download_Process
186
  }
187
  return $files;
188
  }
189
-
190
  private function email_attachments($links)
191
  {
192
 
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;
100
 
101
  private function send_email($user_input, $links, $settings)
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";
111
+ }
112
  }
113
+ $headers = rtrim($headers);
114
  $attachments = [];
115
  if (count($links) > 1) {
116
  $template = get_option("email_before_download_multi_email");
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
 
132
  return true;
133
  }
134
 
135
+
136
  private function generate_links($downloads, $settings, $user_input)
137
  {
138
 
178
  }
179
  $linkHTML .= get_option('email_before_download_html_after','') . "</div>";
180
  $additional_settings = $form_obj->prop('additional_settings');
181
+ $hideOnSubmit = "jQuery('.ebd_input').hide();jQuery('.cf7_input').hide(); ";
182
  $additional_settings .= "\n" . "on_sent_ok: \" jQuery('#ebdForm').append('$linkHTML'); \"";
183
  $form_obj->set_properties(array('additional_settings' => $additional_settings));
184
  return $form_obj;
185
  }
 
186
  private function email_links($links)
187
  {
 
188
  $files = [];
189
  foreach ($links as $link) {
190
  $title = do_shortcode("[download_data id=\"$link->selected_id\" data=\"title\"]");
192
  }
193
  return $files;
194
  }
 
195
  private function email_attachments($links)
196
  {
197
 
includes/class-email-before-download-shortcode.php CHANGED
@@ -39,10 +39,12 @@ public function init_shortcode($user_atts = [], $content = null, $tag = 'email-d
39
  'delivered_as' => get_option($this->option_name.'_delivery_format',"inline link"),
40
  'attachment' => get_option($this->option_name.'_attachment'),
41
  'force_download' => '0',
42
- 'checked' => get_option($this->option_name.'_multi_check'),
43
  'hide_form' => get_option($this->option_name.'_hidden_form','yes'),
44
  'radio' => get_option($this->option_name.'_radio','no'),
45
- 'expire_time' => get_option($this->option_name.'_expire')
 
 
46
  ];
47
  $atts = shortcode_atts($default_atts, $user_atts, $tag);
48
  $atts['item_id'] = $this->add_item($atts);
39
  'delivered_as' => get_option($this->option_name.'_delivery_format',"inline link"),
40
  'attachment' => get_option($this->option_name.'_attachment'),
41
  'force_download' => '0',
42
+ 'checked' => get_option($this->option_name.'_multi_check','no'),
43
  'hide_form' => get_option($this->option_name.'_hidden_form','yes'),
44
  'radio' => get_option($this->option_name.'_radio','no'),
45
+ 'expire_time' => get_option($this->option_name.'_expire'),
46
+ 'from_email' => get_option($this->option_name.'_email_from'),
47
+ 'from_name' => get_option($this->option_name.'_from_name'," ")
48
  ];
49
  $atts = shortcode_atts($default_atts, $user_atts, $tag);
50
  $atts['item_id'] = $this->add_item($atts);
includes/class-email-before-download.php CHANGED
@@ -11,7 +11,7 @@
11
  * @since 5.0.0
12
  * @package Email_Before_Download
13
  * @subpackage Email_Before_Download/includes
14
- * @author M&S Consulting
15
  */
16
  class Email_Before_Download {
17
 
@@ -20,11 +20,7 @@ class Email_Before_Download {
20
  protected $version;
21
 
22
  public function __construct() {
23
- if ( defined( 'PLUGIN_NAME_VERSION' ) ) {
24
- $this->version = PLUGIN_NAME_VERSION;
25
- } else {
26
- $this->version = '5.0.3';
27
- }
28
  $this->plugin_name = 'email-before-download';
29
 
30
  $this->load_dependencies();
@@ -121,11 +117,13 @@ class Email_Before_Download {
121
  ,
122
  ) );
123
  } );
 
 
124
  }
125
  public function run_download($data) {
126
  $downloader = new Email_Before_download_Downloader( $this->get_plugin_name(), $this->get_version() );
127
  $downloader->serve_file($data['uid']);
128
-
129
  return ;
130
  }
 
131
  }
11
  * @since 5.0.0
12
  * @package Email_Before_Download
13
  * @subpackage Email_Before_Download/includes
14
+ * @author M & S Consulting
15
  */
16
  class Email_Before_Download {
17
 
20
  protected $version;
21
 
22
  public function __construct() {
23
+ $this->version = PLUGIN_NAME_VERSION;
 
 
 
 
24
  $this->plugin_name = 'email-before-download';
25
 
26
  $this->load_dependencies();
117
  ,
118
  ) );
119
  } );
120
+
121
+
122
  }
123
  public function run_download($data) {
124
  $downloader = new Email_Before_download_Downloader( $this->get_plugin_name(), $this->get_version() );
125
  $downloader->serve_file($data['uid']);
 
126
  return ;
127
  }
128
+
129
  }
includes/index.php CHANGED
File without changes
index.php CHANGED
File without changes
public/class-email-before-download-public.php CHANGED
File without changes
public/css/email-before-download-public.css CHANGED
File without changes
public/index.php CHANGED
File without changes
public/js/email-before-download-public.js CHANGED
@@ -1,6 +1,7 @@
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();
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();
readme.txt CHANGED
@@ -90,6 +90,8 @@ This is the list of all short code attributes that can be used. Some of them o
90
  * checked - Loads form with item checked. If you are using checkboxes and hhave multiple ites, the will all be checked, Accepts "no", any other value is "yes"
91
  * hidden_form - "yes", "no"
92
  * radio - "yes", "no"
 
 
93
 
94
 
95
  == Screenshots ==
@@ -104,8 +106,14 @@ This is the list of all short code attributes that can be used. Some of them o
104
 
105
 
106
  == Changelog ==
 
 
 
 
 
 
107
  =5.0.3=
108
- Fixed issue with form not displayig for some people
109
 
110
  =5.0.2=
111
  Fixed issue with admin tables not showing.
90
  * checked - Loads form with item checked. If you are using checkboxes and hhave multiple ites, the will all be checked, Accepts "no", any other value is "yes"
91
  * hidden_form - "yes", "no"
92
  * radio - "yes", "no"
93
+ * from_email - valid email address
94
+ * from_name - any alphanumeric string
95
 
96
 
97
  == Screenshots ==
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.
uninstall.php CHANGED
File without changes