Email Before Download - Version 5.0.1

Version Description

Download this release

Release Info

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

Code changes from version 5.0.0 to 5.0.1

email-before-download.php CHANGED
@@ -25,7 +25,7 @@ if ( ! defined( 'WPINC' ) ) {
25
  }
26
 
27
 
28
- define( 'PLUGIN_NAME_VERSION', '5.0.0' );
29
 
30
  function activate_email_before_download() {
31
  require_once plugin_dir_path( __FILE__ ) . 'includes/class-email-before-download-activator.php';
25
  }
26
 
27
 
28
+ define( 'PLUGIN_NAME_VERSION', '5.0.1' );
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-downloader.php CHANGED
@@ -40,7 +40,7 @@ class Email_Before_download_Downloader
40
  if ($this->expired($link)) {
41
  wp_die(__('This download has expired. Please fill out a new form to generate a new link.', 'email-before-download'));
42
  }
43
- if($link->file){
44
  $file = $link->file;
45
  }else{
46
  $file = do_shortcode("[download_data id=\"$link->selected_id\" data=\"download_link\"]");
40
  if ($this->expired($link)) {
41
  wp_die(__('This download has expired. Please fill out a new form to generate a new link.', 'email-before-download'));
42
  }
43
+ if(isset($link->file)){
44
  $file = $link->file;
45
  }else{
46
  $file = do_shortcode("[download_data id=\"$link->selected_id\" data=\"download_link\"]");
includes/class-email-before-download-form.php CHANGED
@@ -39,8 +39,13 @@ class Email_Before_Download_Form
39
  if($this->atts['hide_form'] != 'no') {
40
  $paragraph->setAttribute('id','downloadinputform');
41
  }
 
42
  foreach ($this->download_id as $key => $id) {
43
- $item = $this->download_dom_obj($id, $key);
 
 
 
 
44
  $item = $form->importNode($item, true);
45
  $paragraph->parentNode->insertBefore($item, $paragraph);
46
 
@@ -84,6 +89,15 @@ class Email_Before_Download_Form
84
  $node = $formObject->getElementsByTagName("label");
85
  return $node->item(0);
86
  }
 
 
 
 
 
 
 
 
 
87
  private function hidden_dom_obj($name, $value){
88
  $formObject = new DOMDocument();
89
  $formObject->formatOutput = true;
39
  if($this->atts['hide_form'] != 'no') {
40
  $paragraph->setAttribute('id','downloadinputform');
41
  }
42
+
43
  foreach ($this->download_id as $key => $id) {
44
+ if(count($this->download_id) == 1) {
45
+ $item = $this->hide_download_dom_obj($id, $key);
46
+ }else{
47
+ $item = $this->download_dom_obj($id, $key);
48
+ }
49
  $item = $form->importNode($item, true);
50
  $paragraph->parentNode->insertBefore($item, $paragraph);
51
 
89
  $node = $formObject->getElementsByTagName("label");
90
  return $node->item(0);
91
  }
92
+ private function hide_download_dom_obj($id, $key){
93
+
94
+ $formObject = new DOMDocument();
95
+ $formObject->formatOutput = true;
96
+ $title = $this->titles[$key];
97
+ $formObject->loadHTML("<label class='ebd_input'><input type=\"hidden\" name=\"ebd_downloads[]\" value=\"$id:$title\"> </label>");
98
+ $node = $formObject->getElementsByTagName("label");
99
+ return $node->item(0);
100
+ }
101
  private function hidden_dom_obj($name, $value){
102
  $formObject = new DOMDocument();
103
  $formObject->formatOutput = true;
includes/class-email-before-download-process.php CHANGED
@@ -232,7 +232,7 @@ class Email_Before_Download_Process
232
 
233
  public function link_url($link)
234
  {
235
- return get_site_url() . "/ebd-file?uid=$link->uid";
236
  }
237
 
238
  public function log($post_data, $user_data)
232
 
233
  public function link_url($link)
234
  {
235
+ return get_rest_url() . "ebd/file/$link->uid";
236
  }
237
 
238
  public function log($post_data, $user_data)
includes/class-email-before-download.php CHANGED
@@ -34,6 +34,8 @@ class Email_Before_Download {
34
  $this->define_process_hooks();
35
  $this->define_downloader_hooks();
36
  $this->build_shortcode();
 
 
37
 
38
  }
39
 
@@ -86,8 +88,6 @@ class Email_Before_Download {
86
  }
87
 
88
  private function define_downloader_hooks(){
89
- $plugin_downloader = new Email_Before_download_Downloader( $this->get_plugin_name(), $this->get_version() );
90
- $this->loader->add_action('parse_request', $plugin_downloader, 'parse');
91
 
92
 
93
  }
@@ -113,4 +113,19 @@ class Email_Before_Download {
113
  return $this->version;
114
  }
115
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  }
34
  $this->define_process_hooks();
35
  $this->define_downloader_hooks();
36
  $this->build_shortcode();
37
+ $this->api();
38
+
39
 
40
  }
41
 
88
  }
89
 
90
  private function define_downloader_hooks(){
 
 
91
 
92
 
93
  }
113
  return $this->version;
114
  }
115
 
116
+ public function api(){
117
+ add_action( 'rest_api_init', function () {
118
+ register_rest_route( 'ebd/file/', '(?P<uid>[a-zA-Z0-9-]+)', array(
119
+ 'methods' => 'GET',
120
+ 'callback' => array($this,'run_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
  }
readme.txt CHANGED
@@ -38,7 +38,7 @@ Note: You can see screenshots at [http://wordpress.org/extend/plugins/email-befo
38
  1. Navigate to the Post (or Page) you wish to include
39
  1. Add the following short code using the IDs collected in the first two steps
40
  [email-download download_id="X" contact_form_id="Y"]
41
-
42
 
43
 
44
  Plugin Homepage with Live Demos and Test Download: [http://www.mandsconsulting.com/products/wp-email-before-download](http://www.mandsconsulting.com/products/wp-email-before-download)
@@ -104,6 +104,8 @@ This is the list of all short code attributes that can be used. Some of them o
104
 
105
 
106
  == Changelog ==
 
 
107
 
108
  =5.0=
109
  * Complete tear down and rewrite of entire EBD plugin.
@@ -242,4 +244,3 @@ Automatically upgrade the plugin and all previous settings should remain intact.
242
 
243
  = 0.5 =
244
  First release.
245
-
38
  1. Navigate to the Post (or Page) you wish to include
39
  1. Add the following short code using the IDs collected in the first two steps
40
  [email-download download_id="X" contact_form_id="Y"]
41
+
42
 
43
 
44
  Plugin Homepage with Live Demos and Test Download: [http://www.mandsconsulting.com/products/wp-email-before-download](http://www.mandsconsulting.com/products/wp-email-before-download)
104
 
105
 
106
  == Changelog ==
107
+ =5.0.1=
108
+ * Bug fixes
109
 
110
  =5.0=
111
  * Complete tear down and rewrite of entire EBD plugin.
244
 
245
  = 0.5 =
246
  First release.