Email Before Download - Version 5.0.7

Version Description

Download this release

Release Info

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

Code changes from version 5.0.6 to 5.0.7

admin/class-email-before-download-admin.php CHANGED
@@ -16,30 +16,30 @@ class Email_Before_Download_Admin
16
  private $option_name = 'email_before_download';
17
  private $page_title = "Email Before Download";
18
  private $db;
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'],
30
- ['name' => '_email', 'type' => 'section','label' => "Email Settings"],
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)
45
  {
16
  private $option_name = 'email_before_download';
17
  private $page_title = "Email Before Download";
18
  private $db;
19
+ private $options = array(
20
+ array('name' => '_support', 'type' => 'section','label' => "Support Links"),
21
+ array('name' => '_general', 'type' => 'section','label' => "General Settings"),
22
+ array('name' => '_delivery_format', 'type' => 'setting', 'label' => "Default Delivery Format", 'section' => '_general', 'default' => "inline link"),
23
+ array('name' => '_expire', 'type' => 'setting', 'label' => "Default Link Expiration Time", 'section' => '_general', 'default' => "0"),
24
+ array('name' => '_forbidden', 'type' => 'setting', 'label' => "Forbidden Domains", 'section' => '_general'),
25
+ array('name' => '_inline', 'type' => 'section','label' => "Inline Link Settings"),
26
+ array('name' => '_link_format', 'type' => 'setting', 'label' => "Default Link Target", 'section' => '_inline', 'default' => "_self"),
27
+ array('name' => '_link_css', 'type' => 'setting', 'label' => "Custom CSS", 'section' => '_inline'),
28
+ array('name' => '_html_before', 'type' => 'setting', 'label' => "HTML Before Link", 'section' => '_inline'),
29
+ array('name' => '_html_after', 'type' => 'setting', 'label' => "HTML After Link", 'section' => '_inline'),
30
+ array('name' => '_email', 'type' => 'section','label' => "Email Settings"),
31
+ array('name' => '_single_email', 'type' => 'setting', 'label' => "Single URL Template", 'section' => '_email'),
32
+ array('name' => '_multi_email', 'type' => 'setting', 'label' => "Multiple URL Template", 'section' => '_email'),
33
+ array('name' => '_attachment', 'type' => 'setting', 'label' => "Default Attachment", 'section' => '_email'),
34
+ array('name' => '_subject', 'type' => 'setting', 'label' => "From Email Subject", 'section' => '_email', 'default' => "Your Requested File(s)"),
35
+ array('name' => '_from_name', 'type' => 'setting', 'label' => "From Email Name", 'section' => '_email'),
36
+ array('name' => '_email_from', 'type' => 'setting', 'label' => "From Email", 'section' => '_email'),
37
+ array('name' => '_other', 'type' => 'section','label' => "Additional Settings"),
38
+ array('name' => '_default_cf7', 'type' => 'setting', 'label' => "Default CF7 Form ID", 'section' => '_other'),
39
+ array('name' => '_multi_check', 'type' => 'setting', 'label' => "Default Checkbox State", 'section' => '_other', 'default' => " "),
40
+ array('name' => '_hidden_form', 'type' => 'setting', 'label' => "Default Hide Form", 'section' => '_other', 'default' => "no"),
41
+ array('name' => '_radio', 'type' => 'setting', 'label' => "Default Radio Buttons", 'section' => '_other', 'default' => "no")
42
+ );
43
 
44
  public function __construct($plugin_name, $version)
45
  {
admin/class-email-before-download-table.php CHANGED
@@ -121,7 +121,7 @@ class Email_Before_download_Table extends WP_List_Table
121
  public function set_table($table)
122
  {
123
  if ($table == 'links') {
124
- $this->atts = [
125
  'table' => $this->db->prefix . "ebd_link",
126
  'columns' => array(
127
  'email' => __('Email'),
@@ -137,9 +137,10 @@ class Email_Before_download_Table extends WP_List_Table
137
  'delivered_as' => ['delivered_as', true],
138
  'expire_time' => ['expire_time', true],
139
  ),
140
- 'purge_text' => __("Purge Expired Links",'email-before-download')];
 
141
  } else {
142
- $this->atts = [
143
  'table' => $this->db->prefix . "ebd_posted_data",
144
  'columns' => array(
145
  'email' => __('Email'),
@@ -152,7 +153,8 @@ class Email_Before_download_Table extends WP_List_Table
152
  'is_downloaded' => ['is_downloaded', true],
153
  'time_requested' => ['time_requested', true],
154
  ),
155
- 'purge_text' => __("Purge Logs",'email-before-download')];
 
156
  }
157
 
158
  }
121
  public function set_table($table)
122
  {
123
  if ($table == 'links') {
124
+ $this->atts = array(
125
  'table' => $this->db->prefix . "ebd_link",
126
  'columns' => array(
127
  'email' => __('Email'),
137
  'delivered_as' => ['delivered_as', true],
138
  'expire_time' => ['expire_time', true],
139
  ),
140
+ 'purge_text' => __("Purge Expired Links",'email-before-download')
141
+ );
142
  } else {
143
+ $this->atts = array(
144
  'table' => $this->db->prefix . "ebd_posted_data",
145
  'columns' => array(
146
  'email' => __('Email'),
153
  'is_downloaded' => ['is_downloaded', true],
154
  'time_requested' => ['time_requested', true],
155
  ),
156
+ 'purge_text' => __("Purge Logs",'email-before-download')
157
+ );
158
  }
159
 
160
  }
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.6
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.6' );
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.7
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.7' );
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,19 +14,19 @@ class Email_Before_Download_Activator
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'))
14
 
15
  public static function activate()
16
  {
17
+ $plugins = array();
18
  $option_name = 'email_before_download';
19
+ $options = array(
20
+ array('name' => '_delivery_format', 'default' => "inline link"),
21
+ array('name' => '_expire', 'default' => "0"),
22
+ array('name' => '_link_format', 'default' => "_self"),
23
+ array('name' => '_single_email','default '=>"Here is the download for <a href=\"[file_url]\">[file_name]</a> that you requested." ),
24
+ array('name' => '_multi_email', 'default' => "[file_urls]"),
25
+ array('name' => '_subject', 'default' => "Your Requested File(s)"),
26
+ array('name' => '_multi_check', 'default' => " "),
27
+ array('name' => '_hidden_form', 'default' => "no"),
28
+ array('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'))
includes/class-email-before-download-db.php CHANGED
@@ -39,11 +39,11 @@ class Email_Before_Download_DB
39
  return $item;
40
  } else {
41
  $this->db->insert($this->item_table,
42
- [
43
  'download_id' => $atts['download_id'],
44
  'title' => sanitize_text_field($atts['title']),
45
  'file' => esc_url($atts['file'])
46
- ]);
47
  return $this->db->insert_id;
48
  }
49
  }
@@ -55,13 +55,15 @@ class Email_Before_Download_DB
55
  if (count($query) > 0) {
56
  if ($query->file != $data['file']) {
57
  $this->db->update($this->item_table,
58
- ['file' => $data['file']],
59
- ['id' => $query->id]);
 
60
  }
61
  if ($query->title != $data['title']) {
62
  $this->db->update($this->item_table,
63
- ['title' => $data['title']],
64
- ['id' => $query->id]);
 
65
  }
66
  return $query->id;
67
  }
@@ -89,8 +91,8 @@ class Email_Before_Download_DB
89
 
90
  return $this->db->update(
91
  $this->link_table,
92
- ['is_downloaded' => 1],
93
- ['ID' => $id]
94
  );
95
 
96
  }
@@ -104,12 +106,12 @@ class Email_Before_Download_DB
104
  public function expired($option)
105
  {
106
  if ($option != 0) {
107
- $duration = [
108
  'minute' => 60,
109
  'hour' => 3600,
110
  'day' => 172800,
111
  'week' => 604800
112
- ];
113
 
114
  $expired = explode(" ", $option);
115
  $expiration = $expired[0] * $duration[$expired[1]];
39
  return $item;
40
  } else {
41
  $this->db->insert($this->item_table,
42
+ array(
43
  'download_id' => $atts['download_id'],
44
  'title' => sanitize_text_field($atts['title']),
45
  'file' => esc_url($atts['file'])
46
+ ));
47
  return $this->db->insert_id;
48
  }
49
  }
55
  if (count($query) > 0) {
56
  if ($query->file != $data['file']) {
57
  $this->db->update($this->item_table,
58
+ array('file' => $data['file']),
59
+ array('id' => $query->id)
60
+ );
61
  }
62
  if ($query->title != $data['title']) {
63
  $this->db->update($this->item_table,
64
+ array('title' => $data['title']),
65
+ array('id' => $query->id)
66
+ );
67
  }
68
  return $query->id;
69
  }
91
 
92
  return $this->db->update(
93
  $this->link_table,
94
+ array('is_downloaded' => 1),
95
+ array('ID' => $id)
96
  );
97
 
98
  }
106
  public function expired($option)
107
  {
108
  if ($option != 0) {
109
+ $duration = array(
110
  'minute' => 60,
111
  'hour' => 3600,
112
  'day' => 172800,
113
  'week' => 604800
114
+ );
115
 
116
  $expired = explode(" ", $option);
117
  $expiration = $expired[0] * $duration[$expired[1]];
includes/class-email-before-download-form.php CHANGED
@@ -29,15 +29,16 @@ class Email_Before_Download_Form
29
  $form = new DOMDocument;
30
  $form->formatOutput = true;
31
  $form->loadHTML($raw);
32
- $formDiv = $form->getElementsByTagName('div')->item(1);
33
- $formID = $formDiv->getAttribute('id');
34
- $this->atts['form_id'] = $formID;
35
  $parent = $form->getElementsByTagName('form')->item(0);
 
 
 
36
  $children = $parent->getElementsByTagName('input');
37
  $paragraphs = $parent->getElementsByTagName('p');
38
  foreach ($paragraphs as $p){
39
  $p->setAttribute('class','cf7_input');
40
  if(($this->atts['hide_form'] == 'yes') && ($this->atts['checked'] == '')){
 
41
  if(count($this->download_id) > 1)
42
  $p->setAttribute('style','display:none');
43
  }
@@ -138,7 +139,7 @@ class Email_Before_Download_Form
138
 
139
  }
140
  private function att_to_array($data){
141
- $formatted = [];
142
  if (stripos($data, ',')) {
143
  $formatted = explode(',', $data);
144
  } else {
29
  $form = new DOMDocument;
30
  $form->formatOutput = true;
31
  $form->loadHTML($raw);
 
 
 
32
  $parent = $form->getElementsByTagName('form')->item(0);
33
+ $formID = $parent->getAttribute('action');
34
+ $tmp = explode('#', $formID);
35
+ $this->atts['form_id'] = $tmp[1];
36
  $children = $parent->getElementsByTagName('input');
37
  $paragraphs = $parent->getElementsByTagName('p');
38
  foreach ($paragraphs as $p){
39
  $p->setAttribute('class','cf7_input');
40
  if(($this->atts['hide_form'] == 'yes') && ($this->atts['checked'] == '')){
41
+ $parent->setAttribute('id','downloadinputform');
42
  if(count($this->download_id) > 1)
43
  $p->setAttribute('style','display:none');
44
  }
139
 
140
  }
141
  private function att_to_array($data){
142
+ $formatted = array();
143
  if (stripos($data, ',')) {
144
  $formatted = explode(',', $data);
145
  } else {
includes/class-email-before-download-process.php CHANGED
@@ -26,7 +26,7 @@ class Email_Before_Download_Process
26
  return $form_obj; // make sure this only fires when there is EBD info
27
  }
28
  $post_data = $_POST;
29
- $user_input = [];
30
  $settings = $this->parse_post_array($post_data['ebd_settings']);
31
  $downloads = $this->parse_post_array($post_data['ebd_downloads']);
32
  foreach ($post_data as $key => $value) {
@@ -55,13 +55,28 @@ class Email_Before_Download_Process
55
  if (($settings['delivered_as'] == 'send email') || ($settings['delivered_as'] == 'both')) {
56
  $this->send_email($user_input, $links, $settings);
57
  }
 
 
 
58
  return $form_obj;
59
-
60
  }
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  private function parse_post_array($post_array)
63
  {
64
- $new_array = [];
65
  $delimiter = "|";
66
  foreach ($post_array as $item) {
67
  if (strpos($item, '|')) {
@@ -98,6 +113,7 @@ class Email_Before_Download_Process
98
  return $body;
99
  }
100
 
 
101
  private function send_email($user_input, $links, $settings)
102
  {
103
  $headers = "Content-Type: text/html; charset=UTF-8\r\n";
@@ -112,7 +128,7 @@ class Email_Before_Download_Process
112
  }
113
  }
114
  $headers = rtrim($headers);
115
- $attachments = [];
116
  if (count($links) > 1) {
117
  $template = get_option("email_before_download_multi_email");
118
  if (!$template) $template = "[file_urls]";
@@ -123,6 +139,7 @@ class Email_Before_Download_Process
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);
@@ -135,16 +152,16 @@ class Email_Before_Download_Process
135
  private function generate_links($downloads, $settings, $user_input)
136
  {
137
 
138
- $links = [];
139
- $default_link_data = [
140
  "expire_time" => "",
141
  "delivered_as" => "",
142
  "force_download" => ""
143
- ];
144
  $settings = array_merge($default_link_data, $settings);
145
 
146
  foreach ($downloads as $id => $title) {
147
- $linkdata = [
148
  "item_id" => $settings['item_id'],
149
  "selected_id" => $id,
150
  "is_force_download" => $settings['force_download'],
@@ -153,7 +170,7 @@ class Email_Before_Download_Process
153
  'uid' => substr(md5(uniqid(mt_rand(), true)), 0, 10),
154
  'time_requested' => time(),
155
 
156
- ];
157
 
158
  $linkdata = array_filter($linkdata);
159
  $linkdata["expire_time"] = get_option('email_before_download_expire',"");
@@ -166,11 +183,16 @@ class Email_Before_Download_Process
166
 
167
  private function inline_links($links, $form_obj, $settings)
168
  {
169
- $linkHTML = "<div>" . get_option('email_before_download_html_before',"");
 
 
 
 
170
  $form_id = $settings['form_id'];
171
  foreach ($links as $link) {
172
  $downloadURL = $this->link_url($link);
173
  $linkCSS = get_option('email_before_download_link_css');
 
174
  $target = $settings['link_format'];
175
  $html = "<span class=\"et-icon\"><span><a href=\"$downloadURL\" class=\"icon-button download-icon ebd_link $linkCSS\" target=\"$target\">";
176
  if(isset($link->title)){
@@ -182,7 +204,7 @@ class Email_Before_Download_Process
182
  $html .= "</a></</span></span></br>";
183
  $linkHTML .= $html;
184
  }
185
- $linkHTML .= get_option('email_before_download_html_after','') . "</div>";
186
  $additional_settings = $form_obj->prop('additional_settings');
187
  $hideOnSubmit = "jQuery('.ebd_input').hide();jQuery('.cf7_input').hide(); ";
188
  $additional_settings .= "\n" . "on_sent_ok: \" jQuery('#$form_id').append('$linkHTML'); \"";
@@ -191,7 +213,7 @@ class Email_Before_Download_Process
191
  }
192
  private function email_links($links)
193
  {
194
- $files = [];
195
  foreach ($links as $link) {
196
  if(isset($link->title)){
197
  $title = $link->title;
@@ -206,10 +228,12 @@ class Email_Before_Download_Process
206
  private function email_attachments($links)
207
  {
208
 
209
- $filePaths = [];
210
  foreach ($links as $link) {
211
  $fileName = do_shortcode("[download_data id=\"$link->selected_id\" data=\"filename\"]");
 
212
  $uploadsetting = get_option('uploads_use_yearmonth_folders');
 
213
  $directory = wp_upload_dir();
214
  if($uploadsetting == 1){
215
  $fileDate = do_shortcode("[download_data id=\"$link->selected_id\" data=\"file_date\"]");
@@ -262,12 +286,12 @@ class Email_Before_Download_Process
262
  public function log($post_data, $user_data)
263
  {
264
  $xml = $this->xml($post_data);
265
- $data = [
266
  'email' => sanitize_email($user_data['your-email']),
267
  'user_name' => sanitize_text_field($user_data['your-name']),
268
  'posted_data' => $xml,
269
  'time_requested' => time()
270
- ];
271
 
272
  return $this->db->create_log($data);
273
  }
26
  return $form_obj; // make sure this only fires when there is EBD info
27
  }
28
  $post_data = $_POST;
29
+ $user_input = array();
30
  $settings = $this->parse_post_array($post_data['ebd_settings']);
31
  $downloads = $this->parse_post_array($post_data['ebd_downloads']);
32
  foreach ($post_data as $key => $value) {
55
  if (($settings['delivered_as'] == 'send email') || ($settings['delivered_as'] == 'both')) {
56
  $this->send_email($user_input, $links, $settings);
57
  }
58
+ $mail = $form_obj->prop('mail');
59
+ $newMail = $this->reply($mail,$links);
60
+ $form_obj->set_properties(array('mail' => $newMail));
61
  return $form_obj;
 
62
  }
63
 
64
+ private function reply($mail,$links){
65
+ $message = "The downloaded file name(s): ";
66
+ foreach ($links as $link){
67
+ $message .= " ".$link->title.",";
68
+ }
69
+ $message = rtrim($message, ',');
70
+ if(stripos($mail['body'],"[your-message]")){
71
+ $mail['body'] = str_replace("[your-message]", $message, $mail['body']);
72
+ }else{
73
+ $mail['body'] .= $message;
74
+ }
75
+ return $mail;
76
+ }
77
  private function parse_post_array($post_array)
78
  {
79
+ $new_array = array();
80
  $delimiter = "|";
81
  foreach ($post_array as $item) {
82
  if (strpos($item, '|')) {
113
  return $body;
114
  }
115
 
116
+
117
  private function send_email($user_input, $links, $settings)
118
  {
119
  $headers = "Content-Type: text/html; charset=UTF-8\r\n";
128
  }
129
  }
130
  $headers = rtrim($headers);
131
+ $attachments = array();
132
  if (count($links) > 1) {
133
  $template = get_option("email_before_download_multi_email");
134
  if (!$template) $template = "[file_urls]";
139
  }
140
  $subject = get_option("email_before_download_subject");
141
  if (!$subject) $subject = __("Your Requested File(s)", 'email-before-download');
142
+ $subject = $this->generate_email($subject, $user_input, $links);
143
  $body = $this->generate_email($template, $user_input, $links);
144
  if ( (isset($settings['attachment']) ) && ($settings['attachment'] != 'no') ) {
145
  $attachments = $this->email_attachments($links);
152
  private function generate_links($downloads, $settings, $user_input)
153
  {
154
 
155
+ $links = array();
156
+ $default_link_data = array(
157
  "expire_time" => "",
158
  "delivered_as" => "",
159
  "force_download" => ""
160
+ );
161
  $settings = array_merge($default_link_data, $settings);
162
 
163
  foreach ($downloads as $id => $title) {
164
+ $linkdata = array(
165
  "item_id" => $settings['item_id'],
166
  "selected_id" => $id,
167
  "is_force_download" => $settings['force_download'],
170
  'uid' => substr(md5(uniqid(mt_rand(), true)), 0, 10),
171
  'time_requested' => time(),
172
 
173
+ );
174
 
175
  $linkdata = array_filter($linkdata);
176
  $linkdata["expire_time"] = get_option('email_before_download_expire',"");
183
 
184
  private function inline_links($links, $form_obj, $settings)
185
  {
186
+ $htmlBefore = get_option('email_before_download_html_before');
187
+ $htmlAfter = get_option('email_before_download_html_after');
188
+ $htmlBefore = isset($htmlBefore) ? $htmlBefore : "";
189
+ $htmlAfter = isset($htmlAfter) ? $htmlAfter : "";
190
+ $linkHTML = "<div>" .$htmlBefore ;
191
  $form_id = $settings['form_id'];
192
  foreach ($links as $link) {
193
  $downloadURL = $this->link_url($link);
194
  $linkCSS = get_option('email_before_download_link_css');
195
+ $linkCSS = isset($linkCSS) ? $linkCSS : "";
196
  $target = $settings['link_format'];
197
  $html = "<span class=\"et-icon\"><span><a href=\"$downloadURL\" class=\"icon-button download-icon ebd_link $linkCSS\" target=\"$target\">";
198
  if(isset($link->title)){
204
  $html .= "</a></</span></span></br>";
205
  $linkHTML .= $html;
206
  }
207
+ $linkHTML .= $htmlAfter. "</div>";
208
  $additional_settings = $form_obj->prop('additional_settings');
209
  $hideOnSubmit = "jQuery('.ebd_input').hide();jQuery('.cf7_input').hide(); ";
210
  $additional_settings .= "\n" . "on_sent_ok: \" jQuery('#$form_id').append('$linkHTML'); \"";
213
  }
214
  private function email_links($links)
215
  {
216
+ $files = array();
217
  foreach ($links as $link) {
218
  if(isset($link->title)){
219
  $title = $link->title;
228
  private function email_attachments($links)
229
  {
230
 
231
+ $filePaths = array();
232
  foreach ($links as $link) {
233
  $fileName = do_shortcode("[download_data id=\"$link->selected_id\" data=\"filename\"]");
234
+
235
  $uploadsetting = get_option('uploads_use_yearmonth_folders');
236
+ $uploadsetting = isset($uploadsetting) ? $uploadsetting : 0;
237
  $directory = wp_upload_dir();
238
  if($uploadsetting == 1){
239
  $fileDate = do_shortcode("[download_data id=\"$link->selected_id\" data=\"file_date\"]");
286
  public function log($post_data, $user_data)
287
  {
288
  $xml = $this->xml($post_data);
289
+ $data = array(
290
  'email' => sanitize_email($user_data['your-email']),
291
  'user_name' => sanitize_text_field($user_data['your-name']),
292
  'posted_data' => $xml,
293
  'time_requested' => time()
294
+ );
295
 
296
  return $this->db->create_log($data);
297
  }
includes/class-email-before-download-shortcode.php CHANGED
@@ -20,7 +20,7 @@ class Email_Before_Download_Shortcode {
20
  $this->db = $wpdb;
21
 
22
  }
23
- public function init_shortcode($user_atts = [], $content = null, $tag = 'email-download')
24
  {
25
  $user_atts = array_change_key_case((array)$user_atts, CASE_LOWER);
26
  if(isset($user_atts['checked'])){
@@ -33,12 +33,12 @@ public function init_shortcode($user_atts = [], $content = null, $tag = 'email-d
33
  $user_atts['download_id'] = str_replace(' ', '', $user_atts['download_id']);
34
 
35
  $default_titles = $this->generate_dl_title($user_atts['download_id']);
36
- $default_atts = [
37
  'download_id' => NULL,
38
  'contact_form_id' => get_option($this->option_name.'_default_cf7'),
39
  'title' => $default_titles,
40
  'file' => NULL,
41
- 'delivered_as' => get_option($this->option_name.'_delivery_format',"inline link"),
42
  'attachment' => get_option($this->option_name.'_attachment'),
43
  'force_download' => '0',
44
  'checked' => get_option($this->option_name.'_multi_check','no'),
@@ -48,15 +48,17 @@ public function init_shortcode($user_atts = [], $content = null, $tag = 'email-d
48
  'from_email' => get_option($this->option_name.'_email_from'),
49
  'from_name' => get_option($this->option_name.'_from_name'," "),
50
  'link_format' => get_option($this->option_name.'_link_format')
51
- ];
52
  $atts = shortcode_atts($default_atts, $user_atts, $tag);
53
  $atts['item_id'] = $this->add_item($atts);
54
  $form = new Email_Before_Download_Form($atts);
 
55
  $content = $form->html();
56
  return $content;
57
  }
58
  private function add_item($atts)
59
  {
 
60
  $db = new Email_Before_Download_DB();
61
  return $db->create_item($atts);
62
  }
@@ -76,6 +78,16 @@ private function generate_dl_title($data){
76
 
77
  }
78
 
 
 
 
 
 
 
 
 
 
 
79
 
80
 
81
  }
20
  $this->db = $wpdb;
21
 
22
  }
23
+ public function init_shortcode($user_atts = array(), $content = null, $tag = 'email-download')
24
  {
25
  $user_atts = array_change_key_case((array)$user_atts, CASE_LOWER);
26
  if(isset($user_atts['checked'])){
33
  $user_atts['download_id'] = str_replace(' ', '', $user_atts['download_id']);
34
 
35
  $default_titles = $this->generate_dl_title($user_atts['download_id']);
36
+ $default_atts = array(
37
  'download_id' => NULL,
38
  'contact_form_id' => get_option($this->option_name.'_default_cf7'),
39
  'title' => $default_titles,
40
  'file' => NULL,
41
+ 'delivered_as' => get_option($this->option_name.'_delivery_format'),
42
  'attachment' => get_option($this->option_name.'_attachment'),
43
  'force_download' => '0',
44
  'checked' => get_option($this->option_name.'_multi_check','no'),
48
  'from_email' => get_option($this->option_name.'_email_from'),
49
  'from_name' => get_option($this->option_name.'_from_name'," "),
50
  'link_format' => get_option($this->option_name.'_link_format')
51
+ );
52
  $atts = shortcode_atts($default_atts, $user_atts, $tag);
53
  $atts['item_id'] = $this->add_item($atts);
54
  $form = new Email_Before_Download_Form($atts);
55
+ $this->cf7_check();
56
  $content = $form->html();
57
  return $content;
58
  }
59
  private function add_item($atts)
60
  {
61
+
62
  $db = new Email_Before_Download_DB();
63
  return $db->create_item($atts);
64
  }
78
 
79
  }
80
 
81
+ private function cf7_check() {
82
+ if ( function_exists( 'wpcf7_enqueue_scripts' ) ) {
83
+ wpcf7_enqueue_scripts();
84
+ }
85
+
86
+ if ( function_exists( 'wpcf7_enqueue_styles' ) ) {
87
+ wpcf7_enqueue_styles();
88
+ }
89
+ }
90
+
91
 
92
 
93
  }
includes/class-email-before-download.php CHANGED
@@ -90,8 +90,8 @@ class Email_Before_Download {
90
  }
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
 
90
  }
91
 
92
  public function build_shortcode(){
93
+ add_shortcode('email-download' ,array( new Email_Before_Download_Shortcode( $this->get_plugin_name(), $this->get_version() ),'init_shortcode') );
94
+ add_shortcode('emailreq' ,array( new Email_Before_Download_Shortcode( $this->get_plugin_name(), $this->get_version() ),'init_shortcode') );
95
 
96
  }
97
 
public/class-email-before-download-public.php CHANGED
@@ -36,9 +36,9 @@ class Email_Before_Download_Public
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
  {
36
  }
37
  public function shortcode_cleanup($content)
38
  {
39
+ $shortcodes = array(
40
  'email-download', 'emailreq'
41
+ );
42
  foreach ($shortcodes as $shortcode){
43
  if (strpos($content, $shortcode))
44
  {
readme.txt CHANGED
@@ -106,6 +106,12 @@ This is the list of all short code attributes that can be used. Some of them o
106
 
107
 
108
  == Changelog ==
 
 
 
 
 
 
109
  =5.0.6=
110
  * Fixed issue where pages with multiple forms weren't displaying inline links properly
111
  * Fixed issee with link_format not working
106
 
107
 
108
  == Changelog ==
109
+ =5.0.7=
110
+ * Fixed issue with [your-message] not being parsed properly
111
+ * Fixed downloaded files not showing in admin email
112
+ * Fixed issue where some people couldn't activate the plugin
113
+ * Fixed issue where form reloaded the page on submit for some people
114
+
115
  =5.0.6=
116
  * Fixed issue where pages with multiple forms weren't displaying inline links properly
117
  * Fixed issee with link_format not working