Email Before Download - Version 5.1.0

Version Description

Download this release

Release Info

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

Code changes from version 5.0.9 to 5.1.0

assets/banner-1544x500.jpg DELETED
Binary file
assets/banner-772x250.jpg DELETED
Binary file
assets/icon-128x128.jpg DELETED
Binary file
assets/icon-256x256.jpg DELETED
Binary file
assets/screenshot-1.png DELETED
Binary file
assets/screenshot-2.png DELETED
Binary file
assets/screenshot-3.png DELETED
Binary file
assets/screenshot-4.png DELETED
Binary file
assets/screenshot-5.png DELETED
Binary file
assets/screenshot-6.png DELETED
Binary file
assets/screenshot-7.png DELETED
Binary file
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.9
15
  * Author: M&S Consulting
16
  * Author URI: mandsconsulting.com
17
  * License: GPL-2.0+
@@ -25,7 +25,15 @@ if ( ! defined( 'WPINC' ) ) {
25
  }
26
 
27
 
28
- define( 'PLUGIN_NAME_VERSION', '5.0.9' );
 
 
 
 
 
 
 
 
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.1.0
15
  * Author: M&S Consulting
16
  * Author URI: mandsconsulting.com
17
  * License: GPL-2.0+
25
  }
26
 
27
 
28
+ define( 'PLUGIN_NAME_VERSION', '5.1.0' );
29
+
30
+ //if Contact Form 7 version isn't in standard format, make it so.
31
+ if(strlen(WPCF7_VERSION) == 3){
32
+ define( 'DEPENDENCY_MIN_VERSION', WPCF7_VERSION.'.0' );
33
+ }else {
34
+ define( 'DEPENDENCY_MIN_VERSION', WPCF7_VERSION );
35
+
36
+ }
37
 
38
  function activate_email_before_download() {
39
  require_once plugin_dir_path( __FILE__ ) . 'includes/class-email-before-download-activator.php';
includes/class-email-before-download-form.php CHANGED
@@ -73,6 +73,7 @@ class Email_Before_Download_Form
73
 
74
 
75
  }
 
76
  return $form->saveHTML();
77
 
78
  }
@@ -129,9 +130,10 @@ class Email_Before_Download_Form
129
  jQuery( ". $formSelector. "selectors ).on( \"click\", function () {
130
  var ". $formSelector. "n = jQuery( ". $formSelector. "selectors+\":checked\" ).length;
131
 
132
- if(". $formSelector. "n > 0) jQuery(\"div#$formID form \").children().not('.ebd_input').show();
133
- else jQuery(\"div#$formID form \").children().not('.ebd_input').hide();
134
- } );</script>";
 
135
  $formObject->loadHTML($script);
136
  $node = $formObject->getElementsByTagName("script");
137
  return $node->item(0);
73
 
74
 
75
  }
76
+
77
  return $form->saveHTML();
78
 
79
  }
130
  jQuery( ". $formSelector. "selectors ).on( \"click\", function () {
131
  var ". $formSelector. "n = jQuery( ". $formSelector. "selectors+\":checked\" ).length;
132
 
133
+ if(". $formSelector. "n > 0) jQuery(\"div#$formID form \").children().not('.ebd_input').not('.wpcf7-response-output').show();
134
+ else jQuery(\"div#$formID form \").children().not('.ebd_input').not('.wpcf7-response-output').hide();
135
+ } ); jQuery('.wpcf7-response-output').hide();
136
+ </script>";
137
  $formObject->loadHTML($script);
138
  $node = $formObject->getElementsByTagName("script");
139
  return $node->item(0);
includes/class-email-before-download-process.php CHANGED
@@ -205,10 +205,16 @@ class Email_Before_Download_Process
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'); \"";
211
- $form_obj->set_properties(array('additional_settings' => $additional_settings));
 
 
 
 
 
 
212
  return $form_obj;
213
  }
214
  private function email_links($links)
@@ -264,11 +270,12 @@ class Email_Before_Download_Process
264
  {
265
  $blacklist = strtolower(get_option('email_before_download_forbidden',""));
266
  if ($blacklist == "") return false;
267
- $blacklist = str_replace(array("\r", "\n",'@'), '', $blacklist);
268
  $email = explode('@', $email);
269
  $domain = $email[1];
270
  if (strpos($blacklist, ',')) {
271
  $blacklist = explode(',', $blacklist);
 
272
  if (in_array($domain, $blacklist))
273
  return true;
274
  } else {
205
  $linkHTML .= $html;
206
  }
207
  $linkHTML .= $htmlAfter. "</div>";
208
+ if(version_compare(DEPENDENCY_MIN_VERSION, '5.0.0') < 0){
209
+ $additional_settings = $form_obj->prop('additional_settings');
210
+ $hideOnSubmit = "jQuery('.ebd_input').hide();jQuery('.cf7_input').hide(); ";
211
+ $additional_settings .= "\n" . "on_sent_ok: \" jQuery('#$form_id').append('$linkHTML'); \"";
212
+ $form_obj->set_properties(array('additional_settings' => $additional_settings));
213
+ }else {
214
+ if( !session_id() )
215
+ session_start();
216
+ $_SESSION[$form_id] = $linkHTML;
217
+ }
218
  return $form_obj;
219
  }
220
  private function email_links($links)
270
  {
271
  $blacklist = strtolower(get_option('email_before_download_forbidden',""));
272
  if ($blacklist == "") return false;
273
+ $blacklist = str_replace(array("\r", "\n",'@',' '), '', $blacklist);
274
  $email = explode('@', $email);
275
  $domain = $email[1];
276
  if (strpos($blacklist, ',')) {
277
  $blacklist = explode(',', $blacklist);
278
+ file_put_contents('blacklinst.txt', var_export($blacklist, true),true);
279
  if (in_array($domain, $blacklist))
280
  return true;
281
  } else {
includes/class-email-before-download.php CHANGED
@@ -77,7 +77,10 @@ class Email_Before_Download {
77
  $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
78
  $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
79
  $this->loader->add_filter( 'the_content', $plugin_public,'shortcode_cleanup');
80
-
 
 
 
81
  }
82
  private function define_process_hooks(){
83
  $plugin_process = new Email_Before_Download_Process( $this->get_plugin_name(), $this->get_version() );
77
  $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
78
  $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
79
  $this->loader->add_filter( 'the_content', $plugin_public,'shortcode_cleanup');
80
+ if(version_compare(DEPENDENCY_MIN_VERSION, '5.0.0') >= 0) {
81
+ $this->loader->add_action('wp_ajax_ebd_inline_links', $plugin_public, 'ebd_ajax');
82
+ $this->loader->add_action('wp_ajax_nopriv_ebd_inline_links', $plugin_public, 'ebd_ajax');
83
+ }
84
  }
85
  private function define_process_hooks(){
86
  $plugin_process = new Email_Before_Download_Process( $this->get_plugin_name(), $this->get_version() );
public/class-email-before-download-public.php CHANGED
@@ -32,7 +32,10 @@ class Email_Before_Download_Public
32
 
33
  public function enqueue_scripts()
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
  {
@@ -54,4 +57,18 @@ class Email_Before_Download_Public
54
  return $content;
55
  }
56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  }
32
 
33
  public function enqueue_scripts()
34
  {
35
+ if(version_compare(DEPENDENCY_MIN_VERSION, '5.0.0') >= 0) {
36
+ wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__) . 'js/email-before-download-public.js', array('jquery'), $this->version, true);
37
+ wp_localize_script($this->plugin_name, 'ebd_inline', array('ajaxurl' => admin_url('admin-ajax.php'), 'ajax_nonce' => wp_create_nonce('ebd'),));
38
+ }
39
  }
40
  public function shortcode_cleanup($content)
41
  {
57
  return $content;
58
  }
59
 
60
+ public function ebd_ajax(){
61
+ check_ajax_referer( 'ebd', 'security');
62
+
63
+ $id = $_POST['id'];
64
+ $links = $_SESSION[$id];
65
+ if(isset($links)){
66
+ unset($_SESSION[$id]);
67
+ echo $links;
68
+ }else{
69
+ echo 'no data found';
70
+ }
71
+ exit();
72
+ }
73
+
74
  }
public/js/email-before-download-public.js CHANGED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery( document ).ready(function() {
2
+ document.addEventListener('wpcf7mailsent', function (event) {
3
+ var id = event.detail.id;
4
+ var data = {
5
+ action: 'ebd_inline_links',
6
+ id: id,
7
+ security: ebd_inline.ajax_nonce
8
+ };
9
+ jQuery.post(ebd_inline.ajaxurl, data, function (data) {
10
+ console.log(data);
11
+ jQuery('#' + id).append(data);
12
+ }
13
+ );
14
+ }, false);
15
+ });
readme.txt CHANGED
@@ -13,7 +13,7 @@ Plugin homepage: http://www.mandsconsulting.com/products/wp-email-before-downloa
13
  == Description ==
14
 
15
  ------------
16
- 5.0 Release is Here!
17
  We've completely rewritten EBD from the ground up. Since the plugin was built many years ago, we decided to implement the latest architecture and features that WordPress offers to plugin developers. In addition to testing as much as possible that this is backwards compatible with the original EBD version -- while also retaining a familiar experience for our existing admins/users -- we have added some popular requests such as the ability to change the from email address as well as support for Download Monitor's latest major release (4.0+).
18
  -------------
19
 
@@ -107,6 +107,11 @@ This is the list of all short code attributes that can be used. Some of them o
107
 
108
  == Changelog ==
109
 
 
 
 
 
 
110
  =5.0.9=
111
  * Fixed issue with character encoding when building form
112
 
13
  == Description ==
14
 
15
  ------------
16
+ 5.x Release is Here!
17
  We've completely rewritten EBD from the ground up. Since the plugin was built many years ago, we decided to implement the latest architecture and features that WordPress offers to plugin developers. In addition to testing as much as possible that this is backwards compatible with the original EBD version -- while also retaining a familiar experience for our existing admins/users -- we have added some popular requests such as the ability to change the from email address as well as support for Download Monitor's latest major release (4.0+).
18
  -------------
19
 
107
 
108
  == Changelog ==
109
 
110
+ =5.1.0=
111
+ * Added compatibility with version 5.0 of Contact Form 7
112
+ * Fixed issue where blacklist wasn't parsing correctly for some people
113
+ * Fixed issue with response box showing for some people
114
+
115
  =5.0.9=
116
  * Fixed issue with character encoding when building form
117