Version Description
Download this release
Release Info
Developer | mandsconsulting |
Plugin | Email Before Download |
Version | 5.1.1 |
Comparing to | |
See all releases |
Code changes from version 5.1.0 to 5.1.1
- email-before-download.php +3 -5
- includes/class-email-before-download-activator.php +1 -15
- includes/class-email-before-download-form.php +5 -2
- includes/class-email-before-download-process.php +22 -8
- includes/class-email-before-download.php +1 -0
- public/class-email-before-download-public.php +6 -3
- public/css/email-before-download-public.css +3 -0
- public/js/email-before-download-public.js +0 -1
- readme.txt +8 -1
- uninstall.php +0 -28
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.1.
|
15 |
* Author: M&S Consulting
|
16 |
* Author URI: mandsconsulting.com
|
17 |
* License: GPL-2.0+
|
@@ -24,8 +24,7 @@ if ( ! defined( 'WPINC' ) ) {
|
|
24 |
die;
|
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){
|
@@ -44,8 +43,7 @@ register_activation_hook( __FILE__, 'activate_email_before_download' );
|
|
44 |
require plugin_dir_path( __FILE__ ) . 'includes/class-email-before-download.php';
|
45 |
|
46 |
function run_email_before_download() {
|
47 |
-
|
48 |
-
$plugin = new Email_Before_Download();
|
49 |
$plugin->run();
|
50 |
|
51 |
}
|
11 |
* @wordpress-plugin
|
12 |
* Plugin Name: Email Before Download
|
13 |
* Plugin URI: mandsconsulting.com
|
14 |
+
* Version: 5.1.1
|
15 |
* Author: M&S Consulting
|
16 |
* Author URI: mandsconsulting.com
|
17 |
* License: GPL-2.0+
|
24 |
die;
|
25 |
}
|
26 |
|
27 |
+
define( 'PLUGIN_NAME_VERSION', '5.1.1' );
|
|
|
28 |
|
29 |
//if Contact Form 7 version isn't in standard format, make it so.
|
30 |
if(strlen(WPCF7_VERSION) == 3){
|
43 |
require plugin_dir_path( __FILE__ ) . 'includes/class-email-before-download.php';
|
44 |
|
45 |
function run_email_before_download() {
|
46 |
+
$plugin = new Email_Before_Download();
|
|
|
47 |
$plugin->run();
|
48 |
|
49 |
}
|
includes/class-email-before-download-activator.php
CHANGED
@@ -15,18 +15,6 @@ class Email_Before_Download_Activator
|
|
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'))
|
@@ -79,9 +67,7 @@ class Email_Before_Download_Activator
|
|
79 |
foreach ($tables as $table) {
|
80 |
dbDelta($table . $charset_collate);
|
81 |
}
|
82 |
-
|
83 |
-
add_option($option_name . $option['name'],$option['default'],'','yes');
|
84 |
-
}
|
85 |
|
86 |
}
|
87 |
|
15 |
public static function activate()
|
16 |
{
|
17 |
$plugins = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
if (!is_plugin_active('download-monitor/download-monitor.php'))
|
19 |
$plugins[] = "Download Monitor";
|
20 |
if (!is_plugin_active('contact-form-7/wp-contact-form-7.php'))
|
67 |
foreach ($tables as $table) {
|
68 |
dbDelta($table . $charset_collate);
|
69 |
}
|
70 |
+
|
|
|
|
|
71 |
|
72 |
}
|
73 |
|
includes/class-email-before-download-form.php
CHANGED
@@ -26,7 +26,10 @@ class Email_Before_Download_Form
|
|
26 |
public function html()
|
27 |
{
|
28 |
$raw = do_shortcode("[contact-form-7 id=\"$this->form_id\" ]");
|
|
|
|
|
29 |
$form = new DOMDocument;
|
|
|
30 |
$form->formatOutput = true;
|
31 |
$form->loadHTML('<?xml encoding="utf-8" ?>'.$raw);
|
32 |
$parent = $form->getElementsByTagName('form')->item(0);
|
@@ -36,7 +39,7 @@ class Email_Before_Download_Form
|
|
36 |
$children = $parent->getElementsByTagName('input');
|
37 |
$paragraphs = $parent->getElementsByTagName('p');
|
38 |
foreach ($paragraphs as $p){
|
39 |
-
$p->setAttribute('class'
|
40 |
if(($this->atts['hide_form'] == 'yes') && ($this->atts['checked'] == '')){
|
41 |
$parent->setAttribute('id','downloadinputform');
|
42 |
if(count($this->download_id) > 1)
|
@@ -73,7 +76,7 @@ class Email_Before_Download_Form
|
|
73 |
|
74 |
|
75 |
}
|
76 |
-
|
77 |
return $form->saveHTML();
|
78 |
|
79 |
}
|
26 |
public function html()
|
27 |
{
|
28 |
$raw = do_shortcode("[contact-form-7 id=\"$this->form_id\" ]");
|
29 |
+
$remove = array('<ebd />','<ebd/>','<ebd_left />','<ebd_left/>');
|
30 |
+
$raw = str_replace($remove, "", $raw);
|
31 |
$form = new DOMDocument;
|
32 |
+
libxml_use_internal_errors(true);
|
33 |
$form->formatOutput = true;
|
34 |
$form->loadHTML('<?xml encoding="utf-8" ?>'.$raw);
|
35 |
$parent = $form->getElementsByTagName('form')->item(0);
|
39 |
$children = $parent->getElementsByTagName('input');
|
40 |
$paragraphs = $parent->getElementsByTagName('p');
|
41 |
foreach ($paragraphs as $p){
|
42 |
+
$p->setAttribute('class',$p->getAttribute('class') .' cf7_input');
|
43 |
if(($this->atts['hide_form'] == 'yes') && ($this->atts['checked'] == '')){
|
44 |
$parent->setAttribute('id','downloadinputform');
|
45 |
if(count($this->download_id) > 1)
|
76 |
|
77 |
|
78 |
}
|
79 |
+
libxml_clear_errors();
|
80 |
return $form->saveHTML();
|
81 |
|
82 |
}
|
includes/class-email-before-download-process.php
CHANGED
@@ -39,7 +39,12 @@ class Email_Before_Download_Process
|
|
39 |
if (isset($settings['force_download'])) {
|
40 |
if (count($links) == 1) {
|
41 |
foreach ($links as $link) {
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
43 |
$additional_settings = $form_obj->prop('additional_settings');
|
44 |
$additional_settings .= "\n" . "on_sent_ok: \"window.location.href = '$linkURL';\"";
|
45 |
$form_obj->set_properties(array('additional_settings' => $additional_settings));
|
@@ -88,7 +93,7 @@ class Email_Before_Download_Process
|
|
88 |
return $new_array;
|
89 |
}
|
90 |
|
91 |
-
private function generate_email($body, $data, $links)
|
92 |
{
|
93 |
//build email to send to user
|
94 |
$files = $this->email_links($links);
|
@@ -101,6 +106,9 @@ class Email_Before_Download_Process
|
|
101 |
$urls = "";
|
102 |
foreach ($files as $file) {
|
103 |
if (count($files) == 1) {
|
|
|
|
|
|
|
104 |
$body = str_replace('[file_url]', $file['url'], $body);
|
105 |
$body = str_replace('[file_name]', $file['title'], $body);
|
106 |
} else {
|
@@ -140,7 +148,7 @@ class Email_Before_Download_Process
|
|
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);
|
146 |
}
|
@@ -183,6 +191,7 @@ class Email_Before_Download_Process
|
|
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 : "";
|
@@ -190,7 +199,11 @@ class Email_Before_Download_Process
|
|
190 |
$linkHTML = "<div>" .$htmlBefore ;
|
191 |
$form_id = $settings['form_id'];
|
192 |
foreach ($links as $link) {
|
193 |
-
|
|
|
|
|
|
|
|
|
194 |
$linkCSS = get_option('email_before_download_link_css');
|
195 |
$linkCSS = isset($linkCSS) ? $linkCSS : "";
|
196 |
$target = $settings['link_format'];
|
@@ -211,9 +224,7 @@ class Email_Before_Download_Process
|
|
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 |
-
|
215 |
-
session_start();
|
216 |
-
$_SESSION[$form_id] = $linkHTML;
|
217 |
}
|
218 |
return $form_obj;
|
219 |
}
|
@@ -227,7 +238,10 @@ class Email_Before_Download_Process
|
|
227 |
$title = do_shortcode("[download_data id=\"$link->selected_id\" data=\"title\"]");
|
228 |
|
229 |
}
|
230 |
-
|
|
|
|
|
|
|
231 |
}
|
232 |
return $files;
|
233 |
}
|
39 |
if (isset($settings['force_download'])) {
|
40 |
if (count($links) == 1) {
|
41 |
foreach ($links as $link) {
|
42 |
+
if(isset($settings['file'])){
|
43 |
+
$linkURL= $settings['file'];
|
44 |
+
}else{
|
45 |
+
$linkURL = $this->link_url($link);
|
46 |
+
}
|
47 |
+
|
48 |
$additional_settings = $form_obj->prop('additional_settings');
|
49 |
$additional_settings .= "\n" . "on_sent_ok: \"window.location.href = '$linkURL';\"";
|
50 |
$form_obj->set_properties(array('additional_settings' => $additional_settings));
|
93 |
return $new_array;
|
94 |
}
|
95 |
|
96 |
+
private function generate_email($body, $data, $links, $settings = null)
|
97 |
{
|
98 |
//build email to send to user
|
99 |
$files = $this->email_links($links);
|
106 |
$urls = "";
|
107 |
foreach ($files as $file) {
|
108 |
if (count($files) == 1) {
|
109 |
+
if(isset($settings['file'])){
|
110 |
+
$file['url'] = $settings['file'];
|
111 |
+
}
|
112 |
$body = str_replace('[file_url]', $file['url'], $body);
|
113 |
$body = str_replace('[file_name]', $file['title'], $body);
|
114 |
} else {
|
148 |
$subject = get_option("email_before_download_subject");
|
149 |
if (!$subject) $subject = __("Your Requested File(s)", 'email-before-download');
|
150 |
$subject = $this->generate_email($subject, $user_input, $links);
|
151 |
+
$body = $this->generate_email($template, $user_input, $links,$settings);
|
152 |
if ( (isset($settings['attachment']) ) && ($settings['attachment'] != 'no') ) {
|
153 |
$attachments = $this->email_attachments($links);
|
154 |
}
|
191 |
|
192 |
private function inline_links($links, $form_obj, $settings)
|
193 |
{
|
194 |
+
|
195 |
$htmlBefore = get_option('email_before_download_html_before');
|
196 |
$htmlAfter = get_option('email_before_download_html_after');
|
197 |
$htmlBefore = isset($htmlBefore) ? $htmlBefore : "";
|
199 |
$linkHTML = "<div>" .$htmlBefore ;
|
200 |
$form_id = $settings['form_id'];
|
201 |
foreach ($links as $link) {
|
202 |
+
if(isset($settings['file'])){
|
203 |
+
$downloadURL = $settings['file'];
|
204 |
+
}else{
|
205 |
+
$downloadURL = $this->link_url($link);
|
206 |
+
}
|
207 |
$linkCSS = get_option('email_before_download_link_css');
|
208 |
$linkCSS = isset($linkCSS) ? $linkCSS : "";
|
209 |
$target = $settings['link_format'];
|
224 |
$additional_settings .= "\n" . "on_sent_ok: \" jQuery('#$form_id').append('$linkHTML'); \"";
|
225 |
$form_obj->set_properties(array('additional_settings' => $additional_settings));
|
226 |
}else {
|
227 |
+
set_transient( $form_id, $linkHTML);
|
|
|
|
|
228 |
}
|
229 |
return $form_obj;
|
230 |
}
|
238 |
$title = do_shortcode("[download_data id=\"$link->selected_id\" data=\"title\"]");
|
239 |
|
240 |
}
|
241 |
+
|
242 |
+
$files[] = array('title' => $title,'url' => $this->link_url($link));
|
243 |
+
|
244 |
+
|
245 |
}
|
246 |
return $files;
|
247 |
}
|
includes/class-email-before-download.php
CHANGED
@@ -77,6 +77,7 @@ 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 |
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');
|
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 |
+
$this->loader->add_filter( 'init', $plugin_public,'session_start');
|
81 |
if(version_compare(DEPENDENCY_MIN_VERSION, '5.0.0') >= 0) {
|
82 |
$this->loader->add_action('wp_ajax_ebd_inline_links', $plugin_public, 'ebd_ajax');
|
83 |
$this->loader->add_action('wp_ajax_nopriv_ebd_inline_links', $plugin_public, 'ebd_ajax');
|
public/class-email-before-download-public.php
CHANGED
@@ -61,14 +61,17 @@ class Email_Before_Download_Public
|
|
61 |
check_ajax_referer( 'ebd', 'security');
|
62 |
|
63 |
$id = $_POST['id'];
|
64 |
-
$links = $
|
|
|
65 |
if(isset($links)){
|
66 |
-
unset($_SESSION[$id]);
|
67 |
echo $links;
|
68 |
}else{
|
69 |
echo 'no data found';
|
70 |
}
|
71 |
exit();
|
72 |
}
|
73 |
-
|
|
|
|
|
|
|
74 |
}
|
61 |
check_ajax_referer( 'ebd', 'security');
|
62 |
|
63 |
$id = $_POST['id'];
|
64 |
+
$links = get_transient( $id );
|
65 |
+
delete_transient( $id );
|
66 |
if(isset($links)){
|
|
|
67 |
echo $links;
|
68 |
}else{
|
69 |
echo 'no data found';
|
70 |
}
|
71 |
exit();
|
72 |
}
|
73 |
+
public function session_start() {
|
74 |
+
if( !session_id() )
|
75 |
+
session_start();
|
76 |
+
}
|
77 |
}
|
public/css/email-before-download-public.css
CHANGED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
.ebd_input {
|
2 |
+
display: block;
|
3 |
+
}
|
public/js/email-before-download-public.js
CHANGED
@@ -7,7 +7,6 @@ jQuery( document ).ready(function() {
|
|
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 |
);
|
7 |
security: ebd_inline.ajax_nonce
|
8 |
};
|
9 |
jQuery.post(ebd_inline.ajaxurl, data, function (data) {
|
|
|
10 |
jQuery('#' + id).append(data);
|
11 |
}
|
12 |
);
|
readme.txt
CHANGED
@@ -87,7 +87,7 @@ This is the list of all short code attributes that can be used. Some of them o
|
|
87 |
* delivered_as - possible values: "Send Email", "Both", "Inline Link"
|
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
|
91 |
* hide_form - "yes", "no"
|
92 |
* radio - "yes", "no"
|
93 |
* from_email - valid email address
|
@@ -107,6 +107,13 @@ This is the list of all short code attributes that can be used. Some of them o
|
|
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
|
87 |
* delivered_as - possible values: "Send Email", "Both", "Inline Link"
|
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 have multiple items, 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
|
107 |
|
108 |
== Changelog ==
|
109 |
|
110 |
+
=5.1.1=
|
111 |
+
* Fixed issue where some instances wouldn't activate after update
|
112 |
+
* Fixed issue where some servers wouldn't set session variables
|
113 |
+
* Added css class to download selectors for easier formatting
|
114 |
+
* Fixed issue where some settings would be reset to default on update
|
115 |
+
* Fixed issue with older versions of PHP not liking HTML5 tags
|
116 |
+
|
117 |
=5.1.0=
|
118 |
* Added compatibility with version 5.0 of Contact Form 7
|
119 |
* Fixed issue where blacklist wasn't parsing correctly for some people
|
uninstall.php
CHANGED
@@ -10,31 +10,3 @@
|
|
10 |
|
11 |
// If uninstall not called from WordPress, then exit.
|
12 |
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) )exit;
|
13 |
-
$option_prefix = "email_before_download";
|
14 |
-
$options = [
|
15 |
-
'_delivery_format',
|
16 |
-
'_expire',
|
17 |
-
'_forbidden',
|
18 |
-
'_link_format',
|
19 |
-
'_link_css',
|
20 |
-
'_html_before',
|
21 |
-
'_html_after',
|
22 |
-
'_single_email',
|
23 |
-
'_multi_email',
|
24 |
-
'_attachment',
|
25 |
-
'_subject',
|
26 |
-
'_from_email',
|
27 |
-
'_multi_check',
|
28 |
-
'_hidden_form',
|
29 |
-
'_radio',
|
30 |
-
'_default_cf7'
|
31 |
-
];
|
32 |
-
foreach ( $options as $option ) {
|
33 |
-
if ( get_option( $option_prefix.$option ) ) {
|
34 |
-
delete_option($option_prefix.$option );
|
35 |
-
}
|
36 |
-
}
|
37 |
-
global $wpdb;
|
38 |
-
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}ebd_link");
|
39 |
-
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}ebd_item");
|
40 |
-
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}ebd_posted_data");
|
10 |
|
11 |
// If uninstall not called from WordPress, then exit.
|
12 |
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) )exit;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|