Email Before Download - Version 5.0.6

Version Description

Download this release

Release Info

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

Code changes from version 5.0.5 to 5.0.6

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.5
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.5' );
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.6
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.6' );
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
@@ -29,6 +29,9 @@ class Email_Before_Download_Form
29
  $form = new DOMDocument;
30
  $form->formatOutput = true;
31
  $form->loadHTML($raw);
 
 
 
32
  $parent = $form->getElementsByTagName('form')->item(0);
33
  $children = $parent->getElementsByTagName('input');
34
  $paragraphs = $parent->getElementsByTagName('p');
@@ -61,6 +64,13 @@ class Email_Before_Download_Form
61
  $item = $form->importNode($item, true);
62
  $children->item(0)->parentNode->insertBefore($item, $children->item(0));
63
  }
 
 
 
 
 
 
 
64
  }
65
  return $form->saveHTML();
66
 
@@ -109,6 +119,24 @@ class Email_Before_Download_Form
109
  $node = $formObject->getElementsByTagName("input");
110
  return $node->item(0);
111
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  private function att_to_array($data){
113
  $formatted = [];
114
  if (stripos($data, ',')) {
@@ -118,4 +146,5 @@ class Email_Before_Download_Form
118
  }
119
  return $formatted;
120
  }
 
121
  }
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');
64
  $item = $form->importNode($item, true);
65
  $children->item(0)->parentNode->insertBefore($item, $children->item(0));
66
  }
67
+ }
68
+ if($this->atts['hide_form'] == 'yes'){
69
+ $script = $this->jquery_dom_obj();
70
+ $item = $form->importNode($script, true);
71
+ $parent->appendChild($item);
72
+
73
+
74
  }
75
  return $form->saveHTML();
76
 
119
  $node = $formObject->getElementsByTagName("input");
120
  return $node->item(0);
121
  }
122
+ private function jquery_dom_obj(){
123
+ $formObject = new DOMDocument();
124
+ $formID = $this->atts['form_id'];
125
+ $formSelector = str_replace('-','',$formID);
126
+ $formObject->formatOutput = true;
127
+ $script = "<script> var ". $formSelector. "selectors = \"div#$formID > form > .ebd_input > input\";
128
+ var ". $formSelector. "cf7_p = \"div#$formID > form > .cf7_input\";
129
+ jQuery( ". $formSelector. "selectors ).on( \"click\", function () {
130
+ var ". $formSelector. "n = jQuery( ". $formSelector. "selectors+\":checked\" ).length;
131
+
132
+ if(". $formSelector. "n > 0) jQuery( ". $formSelector. "cf7_p ).show();
133
+ else jQuery( ". $formSelector. "cf7_p ).hide();
134
+ } );</script>";
135
+ $formObject->loadHTML($script);
136
+ $node = $formObject->getElementsByTagName("script");
137
+ return $node->item(0);
138
+
139
+ }
140
  private function att_to_array($data){
141
  $formatted = [];
142
  if (stripos($data, ',')) {
146
  }
147
  return $formatted;
148
  }
149
+
150
  }
includes/class-email-before-download-process.php CHANGED
@@ -48,7 +48,7 @@ class Email_Before_Download_Process
48
  }
49
 
50
  } else {
51
- $form_obj = $this->inline_links($links, $form_obj);
52
  }
53
  }
54
 
@@ -164,13 +164,14 @@ class Email_Before_Download_Process
164
  return $links;
165
  }
166
 
167
- private function inline_links($links, $form_obj)
168
  {
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;
@@ -184,7 +185,7 @@ class Email_Before_Download_Process
184
  $linkHTML .= get_option('email_before_download_html_after','') . "</div>";
185
  $additional_settings = $form_obj->prop('additional_settings');
186
  $hideOnSubmit = "jQuery('.ebd_input').hide();jQuery('.cf7_input').hide(); ";
187
- $additional_settings .= "\n" . "on_sent_ok: \" jQuery('#ebdForm').append('$linkHTML'); \"";
188
  $form_obj->set_properties(array('additional_settings' => $additional_settings));
189
  return $form_obj;
190
  }
48
  }
49
 
50
  } else {
51
+ $form_obj = $this->inline_links($links, $form_obj,$settings);
52
  }
53
  }
54
 
164
  return $links;
165
  }
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)){
177
  $html .= $link->title;
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'); \"";
189
  $form_obj->set_properties(array('additional_settings' => $additional_settings));
190
  return $form_obj;
191
  }
includes/class-email-before-download-shortcode.php CHANGED
@@ -30,6 +30,8 @@ public function init_shortcode($user_atts = [], $content = null, $tag = 'email-d
30
  $user_atts['checked'] = 'checked';
31
  }
32
  }
 
 
33
  $default_titles = $this->generate_dl_title($user_atts['download_id']);
34
  $default_atts = [
35
  'download_id' => NULL,
@@ -44,7 +46,8 @@ public function init_shortcode($user_atts = [], $content = null, $tag = 'email-d
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);
30
  $user_atts['checked'] = 'checked';
31
  }
32
  }
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,
46
  'radio' => get_option($this->option_name.'_radio','no'),
47
  'expire_time' => get_option($this->option_name.'_expire'),
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);
includes/class-email-before-download.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/js/email-before-download-public.js CHANGED
@@ -1,10 +0,0 @@
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();
7
- else jQuery( ".cf7_input" ).hide();
8
- } );
9
- }
10
- });
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -88,7 +88,7 @@ This is the list of all short code attributes that can be used. Some of them o
88
  * attachment - "yes", "no" Attachments only work if files were uploaded with Download Monitor.
89
  * force_download - any value that is passed considered as "yes" (we don't have a global menu item for that) only works with a single download_id.
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
@@ -106,6 +106,10 @@ This is the list of all short code attributes that can be used. Some of them o
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
88
  * attachment - "yes", "no" Attachments only work if files were uploaded with Download Monitor.
89
  * force_download - any value that is passed considered as "yes" (we don't have a global menu item for that) only works with a single download_id.
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
+ * hide_form - "yes", "no"
92
  * radio - "yes", "no"
93
  * from_email - valid email address
94
  * from_name - any alphanumeric string
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
112
+
113
  =5.0.5=
114
  * Fixed issue with some servers not attaching files to emails
115
  * Fixed issue with malformed email headers if from_name was left blank