Version Description
Download this release
Release Info
Developer | ashokaggarwal |
Plugin | Email Before Download |
Version | 1.0 |
Comparing to | |
See all releases |
Code changes from version 0.5 to 1.0
- tags/0.5/trunk/email-before-download.php +254 -0
- tags/0.5/trunk/readme.txt +94 -0
- tags/0.5/trunk/screenshot-1.png +0 -0
- tags/0.5/trunk/screenshot-2.png +0 -0
- tags/0.5/trunk/screenshot-3.png +0 -0
- tags/0.5/trunk/screenshot-4.png +0 -0
- tags/0.5/trunk/screenshot-5.png +0 -0
- tags/0.5/trunk/screenshot-6.png +0 -0
- trunk/email-before-download.php +436 -253
- trunk/readme.txt +18 -12
tags/0.5/trunk/email-before-download.php
ADDED
@@ -0,0 +1,254 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Email Before Download
|
4 |
+
Plugin URI: http://www.mandsconsulting.com/
|
5 |
+
Description: This plugin seamlessly integrates two popular plugins (Contact Form 7 and Download Monitor) to create a simple shortcode for requesting an end-user to fill out a form before providing the download URL. You can use an existing Contact Form 7 form, where you might typically request contact information like an email address, but the questions in the form are completely up to you. Once the end user completes the form, you can choose to either show a link directly to the download or send an email with the direct link to the email provided in the contact form.
|
6 |
+
Author: M&S Consulting
|
7 |
+
Version: 0.5
|
8 |
+
Author URI: http://www.mandsconsulting.com
|
9 |
+
|
10 |
+
============================================================================================================
|
11 |
+
This software is provided "as is" and any express or implied warranties, including, but not limited to, the
|
12 |
+
implied warranties of merchantibility and fitness for a particular purpose are disclaimed. In no event shall
|
13 |
+
the copyright owner or contributors be liable for any direct, indirect, incidental, special, exemplary, or
|
14 |
+
consequential damages(including, but not limited to, procurement of substitute goods or services; loss of
|
15 |
+
use, data, or profits; or business interruption) however caused and on any theory of liability, whether in
|
16 |
+
contract, strict liability, or tort(including negligence or otherwise) arising in any way out of the use of
|
17 |
+
this software, even if advised of the possibility of such damage.
|
18 |
+
|
19 |
+
For full license details see license.txt
|
20 |
+
============================================================================================================
|
21 |
+
*/
|
22 |
+
|
23 |
+
function emailreqtag_func($atts) {
|
24 |
+
extract(shortcode_atts(array(
|
25 |
+
'download_id' => 'something',
|
26 |
+
'contact_form_id' => 'something else',
|
27 |
+
), $atts));
|
28 |
+
|
29 |
+
$dl = get_downloads('include='.$dowload_id.'&limit=5');
|
30 |
+
|
31 |
+
global $wpdb,$wp_dlm_root,$wp_dlm_db,$wp_dlm_db_taxonomies, $def_format, $dlm_url, $downloadurl, $downloadtype, $wp_dlm_db_meta;
|
32 |
+
$dl = $wpdb->get_row( "SELECT * FROM $wp_dlm_db WHERE id = ".$wpdb->escape($download_id).";" );
|
33 |
+
$d = new downloadable_file($dl);
|
34 |
+
$str = '';
|
35 |
+
|
36 |
+
$title = '';
|
37 |
+
|
38 |
+
$url = '';
|
39 |
+
|
40 |
+
if (!empty($d)) {
|
41 |
+
$date = date("jS M Y", strtotime($d->date));
|
42 |
+
$title = $d->title;
|
43 |
+
$url = $d->url;
|
44 |
+
}
|
45 |
+
|
46 |
+
$contact_form = do_shortcode("[contact-form $contact_form_id \"$title\"]");
|
47 |
+
|
48 |
+
$hf = '<input type="hidden" name="_wpcf7_download_id" value="' . $download_id. '" /></form>';
|
49 |
+
|
50 |
+
$contact_form = str_replace("</form>", $hf, $contact_form);
|
51 |
+
|
52 |
+
$wrap_in_div = get_option('email_before_download_wrap_in_div');
|
53 |
+
$div_class = '';
|
54 |
+
if(strlen(trim($wrap_in_div)) > 0 ){
|
55 |
+
$div_class = 'class="' . trim($wrap_in_div) . '"';
|
56 |
+
}
|
57 |
+
return "<br/>" . $contact_form . '<div id="wpm_download_' . $download_id . '" ' . $div_class . ' style="display:none;"> </div> ';
|
58 |
+
}
|
59 |
+
add_shortcode('emailreq', 'emailreqtag_func');
|
60 |
+
add_shortcode('email-download', 'emailreqtag_func');
|
61 |
+
|
62 |
+
function process_email_form( $cf7 ) {
|
63 |
+
|
64 |
+
if(isset( $_POST['_wpcf7_download_id'] )){
|
65 |
+
global $wpdb,$wp_dlm_root,$wp_dlm_db,$wp_dlm_db_taxonomies, $def_format, $dlm_url, $downloadurl, $downloadtype, $wp_dlm_db_meta;
|
66 |
+
$dl = $wpdb->get_row( "SELECT * FROM $wp_dlm_db WHERE id = ".$wpdb->escape($_POST['_wpcf7_download_id']).";" );
|
67 |
+
$d = new downloadable_file($dl);
|
68 |
+
$dId = $_POST['_wpcf7_download_id'];
|
69 |
+
$cf7->posted_data['your-message'] = 'The downloaded file name: ' . $d->title;
|
70 |
+
if(strpos($cf7->mail['body'], "[your-message]") === false ){
|
71 |
+
$cf7->posted_data['your-message'] = $d->title;
|
72 |
+
$cf7->mail['body'] = $cf7->mail['body'] ."\nThe downloaded file name: [your-message]";
|
73 |
+
|
74 |
+
}
|
75 |
+
|
76 |
+
$title = '';
|
77 |
+
|
78 |
+
$url = '';
|
79 |
+
|
80 |
+
if (!empty($d)) {
|
81 |
+
$title = $d->title;
|
82 |
+
$url = $d->url;
|
83 |
+
}
|
84 |
+
$target = '_blank';
|
85 |
+
$target = get_option('email_before_download_link_target');
|
86 |
+
$html_before = get_option('email_before_download_html_before_link');
|
87 |
+
$html_after = get_option('email_before_download_html_after_link');
|
88 |
+
$email_template = get_option('email_before_download_email_template');
|
89 |
+
$message = '';
|
90 |
+
if(strlen(trim($email_template)) > 0){
|
91 |
+
$message = str_replace(array('[requesting_name]', '[file_url]', '[file_name]'), array($cf7->posted_data['your-name'], $url, $title), trim($email_template));
|
92 |
+
}
|
93 |
+
else $message = '<a class="icon-button download-icon" target="' . $target . '" href="' . $url .'">' . $title . '</a>';
|
94 |
+
|
95 |
+
$innerHtml = $html_before . '<a class="icon-button download-icon" target="' . $target . '" href="' . $url .'"><span class="et-icon"><span>' . $title . '</span></span></a><br clear="both" />' . $html_after;
|
96 |
+
|
97 |
+
if(get_option('email_before_download_send_email') == 'Send Email') {
|
98 |
+
@wp_mail( $cf7->posted_data['your-email'], 'Requested URL for the file: '. $title , $message, "Content-Type: text/html\n");
|
99 |
+
$cf7->additional_settings = "on_sent_ok: \"document.getElementById('wpm_download_$dId').style.display = 'inline'; document.getElementById('wpm_download_$dId').innerHTML='The link to the file has been emailed to you.'; \"";
|
100 |
+
}
|
101 |
+
else if (get_option('email_before_download_send_email') == 'Both'){
|
102 |
+
@wp_mail( $cf7->posted_data['your-email'], 'Requested URL for the file: '. $title , $message, "Content-Type: text/html\n");
|
103 |
+
$cf7->additional_settings = "on_sent_ok: \"document.getElementById('wpm_download_$dId').style.display = 'inline'; document.getElementById('wpm_download_$dId').innerHTML='$innerHtml'; \"";
|
104 |
+
}
|
105 |
+
else $cf7->additional_settings = "on_sent_ok: \"document.getElementById('wpm_download_$dId').style.display = 'inline'; document.getElementById('wpm_download_$dId').innerHTML='$innerHtml'; \"";
|
106 |
+
}
|
107 |
+
return $cf7;
|
108 |
+
}
|
109 |
+
add_action( 'wpcf7_before_send_mail', 'process_email_form' );
|
110 |
+
|
111 |
+
add_action('admin_menu', 'ebd_plugin_menu');
|
112 |
+
|
113 |
+
function ebd_plugin_menu() {
|
114 |
+
|
115 |
+
add_options_page('Email Before Download Options', 'Email Before Download', 'manage_options', 'email-before-download', 'email_before_download_options');
|
116 |
+
add_action( 'admin_init', 'register_email_before_download_settings' );
|
117 |
+
|
118 |
+
}
|
119 |
+
|
120 |
+
add_filter( 'plugin_action_links', 'ebd_plugin_action_links', 10, 2 );
|
121 |
+
|
122 |
+
function ebd_plugin_action_links( $links, $file ) {
|
123 |
+
if ( $file != plugin_basename( __FILE__ ))
|
124 |
+
return $links;
|
125 |
+
|
126 |
+
$settings_link = '<a href="options-general.php?page=email-before-download">' . __( 'Settings', 'email-before-download' ) . '</a>';
|
127 |
+
|
128 |
+
array_unshift( $links, $settings_link );
|
129 |
+
|
130 |
+
return $links;
|
131 |
+
}
|
132 |
+
|
133 |
+
function register_email_before_download_settings() {
|
134 |
+
register_setting( 'email-before-download-group', 'email_before_download_link_target' );
|
135 |
+
register_setting( 'email-before-download-group', 'email_before_download_wrap_in_div' );
|
136 |
+
register_setting( 'email-before-download-group', 'email_before_download_html_before_link' );
|
137 |
+
register_setting( 'email-before-download-group', 'email_before_download_html_after_link' );
|
138 |
+
register_setting( 'email-before-download-group', 'email_before_download_send_email' );
|
139 |
+
register_setting( 'email-before-download-group', 'email_before_download_email_template' );
|
140 |
+
|
141 |
+
}
|
142 |
+
|
143 |
+
function email_before_download_options() {
|
144 |
+
|
145 |
+
if (!current_user_can('manage_options')) {
|
146 |
+
wp_die( __('You do not have sufficient permissions to access this page.') );
|
147 |
+
}
|
148 |
+
|
149 |
+
?>
|
150 |
+
<style type="text/css">
|
151 |
+
.ebd th, .ebd td
|
152 |
+
{
|
153 |
+
vertical-align:top;
|
154 |
+
}
|
155 |
+
.ebd th
|
156 |
+
{
|
157 |
+
text-align: left;
|
158 |
+
padding-right:8px;
|
159 |
+
}
|
160 |
+
.ebd .alert
|
161 |
+
{
|
162 |
+
padding:8px;
|
163 |
+
font:bold 12pt Arial;
|
164 |
+
border:1px dashed red;
|
165 |
+
}
|
166 |
+
</style>
|
167 |
+
|
168 |
+
<div class="wrap">
|
169 |
+
<h2>Email Before Download Options</h2>
|
170 |
+
|
171 |
+
<form method="post" action="options.php">
|
172 |
+
<?php settings_fields( 'email-before-download-group' ); ?>
|
173 |
+
<table class="optiontable ebd">
|
174 |
+
<tr valign="top">
|
175 |
+
<th scope="row"><p>1. Delivery Format</p></th>
|
176 |
+
<td><p>
|
177 |
+
<select name="email_before_download_send_email">
|
178 |
+
<option value="Inline Link" <?php if(get_option('email_before_download_send_email') == 'Inline Link') echo 'selected="selected"'; ?> >Inline Link</option>
|
179 |
+
<option value="Send Email" <?php if(get_option('email_before_download_send_email') == 'Send Email') echo 'selected="selected"'; ?> >Send Email</option>
|
180 |
+
<option value="Both" <?php if(get_option('email_before_download_send_email') == 'Both') echo 'selected="selected"'; ?> >Both</option>
|
181 |
+
</select>
|
182 |
+
</p>
|
183 |
+
</td>
|
184 |
+
</tr>
|
185 |
+
|
186 |
+
<tr valign="top"><td colspan="2"><p class="alert">#2 through #5 only apply if you selected "Inline Link" or "Both" as the Deliver Format in #1</p></td></tr>
|
187 |
+
<tr valign="top">
|
188 |
+
<th scope="row"><p>2. Inline Link Target</p></th>
|
189 |
+
<td><p>
|
190 |
+
<select name="email_before_download_link_target">
|
191 |
+
<option value="_blank" <?php if(get_option('email_before_download_link_target') == '_blank') echo 'selected="selected"'; ?> >_blank</option>
|
192 |
+
<option value="_self" <?php if(get_option('email_before_download_link_target') == '_self') echo 'selected="selected"'; ?> >_self</option>
|
193 |
+
</select> <br />
|
194 |
+
<font size="-1"><i>If "_self" is selected link will open in the same browser window/tab, if "_blank" is selected the link will open in the new browser window/tab</i></font>
|
195 |
+
</p>
|
196 |
+
</td>
|
197 |
+
</tr>
|
198 |
+
|
199 |
+
<tr valign="top">
|
200 |
+
<th scope="row"><p>3. Inline Link Custom CSS</p></th>
|
201 |
+
<td><p><input type="text" size="40" name="email_before_download_wrap_in_div" value="<?php echo get_option('email_before_download_wrap_in_div'); ?>" />
|
202 |
+
<br /> <font size="-1"><i>CSS class used to render the div and the link (this is only used if you choose to display the link inline in #5)</i></font>
|
203 |
+
</td>
|
204 |
+
</tr>
|
205 |
+
|
206 |
+
<tr valign="top">
|
207 |
+
<th scope="row"><p>4. HTML Before Inline Link</p></th>
|
208 |
+
<td><p><input type="text" name="email_before_download_html_before_link" size="40" value="<?php echo get_option('email_before_download_html_before_link'); ?>" /><br />
|
209 |
+
<font size="-1"><i>HTML you want to be added before the link</i></font>
|
210 |
+
</p>
|
211 |
+
</td>
|
212 |
+
</tr>
|
213 |
+
|
214 |
+
<tr valign="top">
|
215 |
+
<th scope="row"><p>5. HTML After Inline Link</p></th>
|
216 |
+
<td> <p><input type="text" size="40" name="email_before_download_html_after_link" value="<?php echo get_option('email_before_download_html_after_link'); ?>" />
|
217 |
+
<br /><font size="-1"><i>HTML you want to be added after the link</i></font>
|
218 |
+
</p>
|
219 |
+
</td>
|
220 |
+
</tr>
|
221 |
+
|
222 |
+
<tr valign="top" class="alert"><td colspan="2"><p class="alert">#6 only applies if you selected "Send Email" or "Both" as the Deliver Format in #1</p></td></tr>
|
223 |
+
<tr valign="top">
|
224 |
+
<th scope="row"><p>6. Email Template</p></th>
|
225 |
+
<td><textarea cols="40" rows="10" name="email_before_download_email_template"> <?php echo get_option('email_before_download_email_template'); ?> </textarea><br />
|
226 |
+
<font size="-1"><i>You can use the following placeholders: [requesting_name], [file_url] and [file_name]. </i></font> <br />
|
227 |
+
<font size="-1"><i>The placeholders: [requesting_name], [file_url] and [file_name] are used to generate the link.
|
228 |
+
<br /> So if you, for example, don't provide the [file_url] placeholder
|
229 |
+
<br />user will not receive any link. Here is an example of the template: <br />
|
230 |
+
<b> Hello [requesting_name], <br />
|
231 |
+
|
232 |
+
Here is the download for <a href="[file_url]">[file_name]</a> that you requested.<br />
|
233 |
+
|
234 |
+
Sincerely,<br />
|
235 |
+
|
236 |
+
My Company name </b>
|
237 |
+
<br /> Note. If you leave this field empty, an email containing only the file URL will be sent.
|
238 |
+
|
239 |
+
</i>
|
240 |
+
</td>
|
241 |
+
</tr>
|
242 |
+
|
243 |
+
</table>
|
244 |
+
|
245 |
+
<p class="submit">
|
246 |
+
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
|
247 |
+
</p>
|
248 |
+
|
249 |
+
</form>
|
250 |
+
</div>
|
251 |
+
<?php
|
252 |
+
|
253 |
+
}
|
254 |
+
?>
|
tags/0.5/trunk/readme.txt
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Plugin Name ===
|
2 |
+
Contributors: mandsconsulting
|
3 |
+
Donate link: http://www.mandsconsulting.com/
|
4 |
+
Tags: email, download
|
5 |
+
Requires at least: 3.x
|
6 |
+
Tested up to: 3.0.4
|
7 |
+
Stable tag: trunk
|
8 |
+
|
9 |
+
Email Before Download presents your users with a form where they submit information, like their name and email address, prior to receiving a download.
|
10 |
+
|
11 |
+
Plugin homepage: http://www.mandsconsulting.com/products/wp-email-before-download
|
12 |
+
|
13 |
+
== Description ==
|
14 |
+
|
15 |
+
Email Before Download presents your users with a form where they submit information, like their name and email address, prior to receiving a download. This plugin integrates with the popular Contact Form 7 and Download Monitor plugins, allowing you to create any form you like and manage/monitor your file downloads. Prior to installing Email Before Download, please confirm each of these dependent plugins is already installed and working independently.
|
16 |
+
|
17 |
+
As an option, you can configure Email Before Download to:
|
18 |
+
|
19 |
+
1. Display a link to your file directly under the contact form once it is submitted. This happens dynamically, inline of your post/page.
|
20 |
+
1. Send the user an email with a link to download your file.
|
21 |
+
1. Both #1 and #2
|
22 |
+
|
23 |
+
|
24 |
+
Usage
|
25 |
+
|
26 |
+
Note: You can see screenshots at [http://wordpress.org/extend/plugins/email-before-download/screenshots/](http://bit.ly/g4r1w2)
|
27 |
+
|
28 |
+
1. Create a contact form used by Email Before Download using Contact Form 7 and note the Contact Form ID
|
29 |
+
1. Upload a file using Download Monitor and note the Download ID
|
30 |
+
1. Navigate to the Post (or Page) you wish to include
|
31 |
+
1. Add the following short code using the IDs collected in the first two steps
|
32 |
+
[email-download download_id="X" contact_form_id="Y"]
|
33 |
+
|
34 |
+
|
35 |
+
|
36 |
+
Plugin homepage: [http://www.mandsconsulting.com/products/wp-email-before-download](http://www.mandsconsulting.com/products/wp-email-before-download)
|
37 |
+
|
38 |
+
|
39 |
+
== Installation ==
|
40 |
+
|
41 |
+
1. Download from http://wordpress.org/extend/plugins
|
42 |
+
1. Upload the entire email-before-download folder to the /wp-content/plugins/ directory.
|
43 |
+
1. Activate the plugin through the "Plugins" menu in WordPress.
|
44 |
+
1. Locate the "Email Before Download" menu item in your WordPress Admin panel under "Settings" to configure.
|
45 |
+
|
46 |
+
|
47 |
+
== Frequently Asked Questions ==
|
48 |
+
|
49 |
+
|
50 |
+
= What if I don't use the Contact Form 7 and/or Download Monintor Plugins? =
|
51 |
+
|
52 |
+
You will not be able to use this version of Email Before Download without these dependent plugins. If you have specific reasons to avoid using the dependent plugins, please contact us and let us know the reason so we can take it into consideration.
|
53 |
+
|
54 |
+
= Anything special I need to do with my contact form? =
|
55 |
+
|
56 |
+
If you decide to configure the Email Before Download option to send the user an email with a link to the download, then you will want to name the email field "your-email" as shown in the example screenshots. Outside of that, nothing special.
|
57 |
+
|
58 |
+
= What happens after the user completes the form? =
|
59 |
+
|
60 |
+
By default, the user is presented with a link to download their file. There is also an option to email a link to the file, which can be done instead of (or in addition to) displaying the link inline.
|
61 |
+
|
62 |
+
= Are you changing any of my file or directory permissions? =
|
63 |
+
|
64 |
+
WordPress allows direct access to any files in your upload directories using a direct URL and we do not change those permissions.
|
65 |
+
|
66 |
+
= So someone can still download my files directly without providing their email? =
|
67 |
+
|
68 |
+
Users generally do not have a desire to put in the work required to determine your direct upload filenames. This plugin provides a quick way to know who is downloading information that you might feel to be more premium content like whitepapers, images, etc. from sincere users who are visiting your site, with the understanding the user can share the file itself or the URL if they wish.
|
69 |
+
|
70 |
+
= What if I don't want the user to be able to share the file? =
|
71 |
+
|
72 |
+
We can't help you prevent a user from sharing a file they have downloaded with other people. We are however working on allowing you to set some options that will make sharing links a little more difficult. Also, there is a chance you fit more into the category of needing to charge for the content which is something this plugin does not currently address.
|
73 |
+
|
74 |
+
|
75 |
+
|
76 |
+
== Screenshots ==
|
77 |
+
|
78 |
+
1. Note the ID of a file you have uploaded to Download Monitor.
|
79 |
+
2. Note the ID of a contact form you have created using Contact Form 7.
|
80 |
+
3. Use the following shortcode in your page or post: [email-download download_id="X" contact_form_id="Y"].
|
81 |
+
4. Upon installation and use of the plugin on a post/page, an end-user will see your contact form.
|
82 |
+
5. User will be required to enter valid data in accordance with Contact Form 7 validation rules.
|
83 |
+
6. Upon submission, user will either see a direct link below the form. (Note: there is also an option to only email the link to the user.)
|
84 |
+
|
85 |
+
== Changelog ==
|
86 |
+
|
87 |
+
= 0.5 =
|
88 |
+
* First release.
|
89 |
+
|
90 |
+
== Upgrade Notice ==
|
91 |
+
|
92 |
+
= 0.5 =
|
93 |
+
First release.
|
94 |
+
|
tags/0.5/trunk/screenshot-1.png
ADDED
Binary file
|
tags/0.5/trunk/screenshot-2.png
ADDED
Binary file
|
tags/0.5/trunk/screenshot-3.png
ADDED
Binary file
|
tags/0.5/trunk/screenshot-4.png
ADDED
Binary file
|
tags/0.5/trunk/screenshot-5.png
ADDED
Binary file
|
tags/0.5/trunk/screenshot-6.png
ADDED
Binary file
|
trunk/email-before-download.php
CHANGED
@@ -1,254 +1,437 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Plugin Name: Email Before Download
|
4 |
-
Plugin URI: http://www.mandsconsulting.com/
|
5 |
-
Description: This plugin seamlessly integrates two popular plugins (Contact Form 7 and Download Monitor) to create a simple shortcode for requesting an end-user to fill out a form before providing the download URL. You can use an existing Contact Form 7 form, where you might typically request contact information like an email address, but the questions in the form are completely up to you. Once the end user completes the form, you can choose to either show a link directly to the download or send an email with the direct link to the email provided in the contact form.
|
6 |
-
Author: M&S Consulting
|
7 |
-
Version: 0
|
8 |
-
Author URI: http://www.mandsconsulting.com
|
9 |
-
|
10 |
-
============================================================================================================
|
11 |
-
This software is provided "as is" and any express or implied warranties, including, but not limited to, the
|
12 |
-
implied warranties of merchantibility and fitness for a particular purpose are disclaimed. In no event shall
|
13 |
-
the copyright owner or contributors be liable for any direct, indirect, incidental, special, exemplary, or
|
14 |
-
consequential damages(including, but not limited to, procurement of substitute goods or services; loss of
|
15 |
-
use, data, or profits; or business interruption) however caused and on any theory of liability, whether in
|
16 |
-
contract, strict liability, or tort(including negligence or otherwise) arising in any way out of the use of
|
17 |
-
this software, even if advised of the possibility of such damage.
|
18 |
-
|
19 |
-
For full license details see license.txt
|
20 |
-
============================================================================================================
|
21 |
-
*/
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
$
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
$
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
}
|
160 |
-
|
161 |
-
{
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
254 |
?>
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Email Before Download
|
4 |
+
Plugin URI: http://www.mandsconsulting.com/
|
5 |
+
Description: This plugin seamlessly integrates two popular plugins (Contact Form 7 and Download Monitor) to create a simple shortcode for requesting an end-user to fill out a form before providing the download URL. You can use an existing Contact Form 7 form, where you might typically request contact information like an email address, but the questions in the form are completely up to you. Once the end user completes the form, you can choose to either show a link directly to the download or send an email with the direct link to the email provided in the contact form.
|
6 |
+
Author: M&S Consulting
|
7 |
+
Version: 1.0
|
8 |
+
Author URI: http://www.mandsconsulting.com
|
9 |
+
|
10 |
+
============================================================================================================
|
11 |
+
This software is provided "as is" and any express or implied warranties, including, but not limited to, the
|
12 |
+
implied warranties of merchantibility and fitness for a particular purpose are disclaimed. In no event shall
|
13 |
+
the copyright owner or contributors be liable for any direct, indirect, incidental, special, exemplary, or
|
14 |
+
consequential damages(including, but not limited to, procurement of substitute goods or services; loss of
|
15 |
+
use, data, or profits; or business interruption) however caused and on any theory of liability, whether in
|
16 |
+
contract, strict liability, or tort(including negligence or otherwise) arising in any way out of the use of
|
17 |
+
this software, even if advised of the possibility of such damage.
|
18 |
+
|
19 |
+
For full license details see license.txt
|
20 |
+
============================================================================================================
|
21 |
+
*/
|
22 |
+
/*
|
23 |
+
* Init database tables
|
24 |
+
*/
|
25 |
+
|
26 |
+
global $wpdb;
|
27 |
+
|
28 |
+
$table_item = $wpdb->prefix . "ebd_item";
|
29 |
+
$table_link = $wpdb->prefix . "ebd_link";
|
30 |
+
|
31 |
+
if($wpdb->get_var("SHOW TABLES LIKE '$table_item'") != $table_item) {
|
32 |
+
|
33 |
+
$sql = "CREATE TABLE " . $table_item . " (
|
34 |
+
`id` int(11) NOT NULL auto_increment,
|
35 |
+
`download_id` varchar(128) NULL,
|
36 |
+
`file` varchar(255) NULL,
|
37 |
+
`title` varchar(255) NULL,
|
38 |
+
`timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
|
39 |
+
PRIMARY KEY (`id`)
|
40 |
+
)";
|
41 |
+
$wpdb->query($sql);
|
42 |
+
|
43 |
+
}
|
44 |
+
if($wpdb->get_var("SHOW TABLES LIKE '$table_link'") != $table_link) {
|
45 |
+
|
46 |
+
$sql = "CREATE TABLE " . $table_link . " (
|
47 |
+
id mediumint(9) NOT NULL AUTO_INCREMENT,
|
48 |
+
item_id int(11) NOT NULL,
|
49 |
+
is_downloaded smallint(3) NOT NULL default '0',
|
50 |
+
email VARCHAR(128) NOT NULL,
|
51 |
+
expire_time bigint(11),
|
52 |
+
uid varchar(255) NOT NULL,
|
53 |
+
delivered_as varchar(255) NULL,
|
54 |
+
UNIQUE KEY id (id)
|
55 |
+
);";
|
56 |
+
$wpdb->query($sql);
|
57 |
+
}
|
58 |
+
|
59 |
+
//Shortcode function
|
60 |
+
function emailreqtag_func($atts) {
|
61 |
+
extract(shortcode_atts(array(
|
62 |
+
'download_id' => NULL,
|
63 |
+
'contact_form_id' => NULL,
|
64 |
+
'title' => NULL,
|
65 |
+
'file' => NULL,
|
66 |
+
), $atts));
|
67 |
+
|
68 |
+
global $wpdb,$wp_dlm_root,$wp_dlm_db,$wp_dlm_db_taxonomies, $def_format, $dlm_url, $downloadurl, $downloadtype, $wp_dlm_db_meta;
|
69 |
+
|
70 |
+
$str = '';
|
71 |
+
|
72 |
+
//$title = '';
|
73 |
+
|
74 |
+
$url = '';
|
75 |
+
$table_item = $wpdb->prefix . "ebd_item";
|
76 |
+
if($download_id != NULL){
|
77 |
+
|
78 |
+
$dl = $wpdb->get_row( "SELECT * FROM $wp_dlm_db WHERE id = ".$wpdb->escape($download_id).";" );
|
79 |
+
|
80 |
+
$ebd_item = $wpdb->get_row( "SELECT * FROM $table_item WHERE download_id = ".$wpdb->escape($download_id).";" );
|
81 |
+
$d = new downloadable_file($dl);
|
82 |
+
|
83 |
+
if (!empty($d)) {
|
84 |
+
$date = date("jS M Y", strtotime($d->date));
|
85 |
+
if ($title == NULL || $title == '') $title = $d->title;
|
86 |
+
$url = $d->url;
|
87 |
+
}
|
88 |
+
|
89 |
+
if (empty($ebd_item)){
|
90 |
+
$wpdb->insert( $table_item, array("download_id"=>$download_id, "title"=>$title) );
|
91 |
+
$download_id = $wpdb->insert_id;
|
92 |
+
$ebd_item = $wpdb->get_row( "SELECT * FROM $table_item WHERE download_id = ".$wpdb->escape($download_id).";" );
|
93 |
+
}
|
94 |
+
else $download_id = $ebd_item->id;
|
95 |
+
//update title if needed
|
96 |
+
if(($title != NULL || $title != '') && $ebd_item->title != $title)
|
97 |
+
$wpdb->update( $table_item, array("title"=>$title), array("id"=>$download_id) );
|
98 |
+
}
|
99 |
+
else if($file){
|
100 |
+
|
101 |
+
if ($title == NULL || $title == '') $title = basename($file);
|
102 |
+
|
103 |
+
// return "<br/>" . '<div id="wpm_download_" ' . $div_class . ' style="inline;"> ' .$file. ' </div> ';
|
104 |
+
$ebd_item = $wpdb->get_row( "SELECT * FROM $table_item WHERE file = '".$wpdb->escape($file)."';" );
|
105 |
+
|
106 |
+
if (empty($ebd_item)){
|
107 |
+
$wpdb->insert( $table_item, array("file"=>$wpdb->escape($file), "title"=>$title) );
|
108 |
+
$download_id = $wpdb->insert_id;
|
109 |
+
$ebd_item = $wpdb->get_row( "SELECT * FROM $table_item WHERE file = '".$wpdb->escape($file)."';" );
|
110 |
+
|
111 |
+
}
|
112 |
+
else $download_id = $ebd_item->id;
|
113 |
+
//update title if needed
|
114 |
+
if(($title != NULL || $title != '') && $ebd_item->title != $title)
|
115 |
+
$wpdb->update( $table_item, array("title"=>$title), array("id"=>$download_id) );
|
116 |
+
|
117 |
+
}
|
118 |
+
$contact_form = do_shortcode("[contact-form $contact_form_id \"$title\"]");
|
119 |
+
|
120 |
+
$hf = '<input type="hidden" name="_wpcf7_download_id" value="' . $download_id. '" /></form>';
|
121 |
+
|
122 |
+
$contact_form = str_replace("</form>", $hf, $contact_form);
|
123 |
+
|
124 |
+
$wrap_in_div = get_option('email_before_download_wrap_in_div');
|
125 |
+
$div_class = '';
|
126 |
+
if(strlen(trim($wrap_in_div)) > 0 ){
|
127 |
+
$div_class = 'class="' . trim($wrap_in_div) . '"';
|
128 |
+
}
|
129 |
+
return "<br/>" . $contact_form . '<div id="wpm_download_' . $download_id . '" ' . $div_class . ' style="display:none;"> </div> ';
|
130 |
+
}
|
131 |
+
add_shortcode('emailreq', 'emailreqtag_func');
|
132 |
+
add_shortcode('email-download', 'emailreqtag_func');
|
133 |
+
|
134 |
+
/*Function that processes contact form 7, generates links, sends emails */
|
135 |
+
function process_email_form( $cf7 ) {
|
136 |
+
|
137 |
+
if(isset( $_POST['_wpcf7_download_id'] )){
|
138 |
+
global $wpdb,$wp_dlm_root,$wp_dlm_db,$wp_dlm_db_taxonomies, $def_format, $dlm_url, $downloadurl, $downloadtype, $wp_dlm_db_meta;
|
139 |
+
$table_item = $wpdb->prefix . "ebd_item";
|
140 |
+
$table_link = $wpdb->prefix . "ebd_link";
|
141 |
+
$ebd_item = $wpdb->get_row( "SELECT * FROM $table_item WHERE id = ".$wpdb->escape($_POST['_wpcf7_download_id']).";" );
|
142 |
+
|
143 |
+
$dl = $wpdb->get_row( "SELECT * FROM $wp_dlm_db WHERE id = ".$wpdb->escape($ebd_item->download_id).";" );
|
144 |
+
$d = new downloadable_file($dl);
|
145 |
+
|
146 |
+
$dId = $_POST['_wpcf7_download_id'];
|
147 |
+
|
148 |
+
|
149 |
+
$title = '';
|
150 |
+
//echo 'debug: ' . $ebd_item->id . ' ' . $ebd_item->title;
|
151 |
+
//print_r($ebd_item);
|
152 |
+
$title = $ebd_item->title;
|
153 |
+
|
154 |
+
if($title == NULL || $title == '')
|
155 |
+
{
|
156 |
+
if($ebd_item->file)
|
157 |
+
{
|
158 |
+
$title = basename($ebd_item->file);
|
159 |
+
}
|
160 |
+
else
|
161 |
+
{
|
162 |
+
$title = $d->title;
|
163 |
+
}
|
164 |
+
}
|
165 |
+
|
166 |
+
$url = '';
|
167 |
+
//generate unique id for the file (link)
|
168 |
+
$uid = md5(uniqid(rand(), true));
|
169 |
+
|
170 |
+
//expiration date if needed if it's 0 or NULL the link will never expire
|
171 |
+
$expireAt = 0;
|
172 |
+
if(get_option('email_before_download_expire_time') != NULL && get_option('email_before_download_expire_time') != "0")
|
173 |
+
$expireAt = strtotime(get_option('email_before_download_expire_time'));
|
174 |
+
$link_data = array();
|
175 |
+
$link_data['uid'] = $uid;
|
176 |
+
$link_data['expire_time'] = $expireAt;
|
177 |
+
$link_data['email'] = $cf7->posted_data['your-email'];
|
178 |
+
$link_data['item_id'] = $_POST['_wpcf7_download_id'];
|
179 |
+
$link_data['delivered_as'] = get_option('email_before_download_send_email');
|
180 |
+
$wpdb->insert( $table_link, $link_data );
|
181 |
+
|
182 |
+
//generate url for the link (using rewrite rules might require a little more extra coding)
|
183 |
+
$url = WP_PLUGIN_URL."/email-before-download/download.php?dl=".$uid;
|
184 |
+
|
185 |
+
$cf7->posted_data['your-message'] = 'The downloaded file name: ' . $title;
|
186 |
+
if(strpos($cf7->mail['body'], "[your-message]") === false ){
|
187 |
+
$cf7->posted_data['your-message'] = $title;
|
188 |
+
$cf7->mail['body'] = $cf7->mail['body'] ."\nThe downloaded file name: [your-message]";
|
189 |
+
|
190 |
+
}
|
191 |
+
|
192 |
+
|
193 |
+
$target = '_blank';
|
194 |
+
$target = get_option('email_before_download_link_target');
|
195 |
+
$html_before = get_option('email_before_download_html_before_link');
|
196 |
+
$html_after = get_option('email_before_download_html_after_link');
|
197 |
+
$email_template = get_option('email_before_download_email_template');
|
198 |
+
$message = '';
|
199 |
+
if(strlen(trim($email_template)) > 0){
|
200 |
+
$message = str_replace(array('[requesting_name]', '[file_url]', '[file_name]'), array($cf7->posted_data['your-name'], $url, $title), trim($email_template));
|
201 |
+
}
|
202 |
+
else $message = '<a class="icon-button download-icon" target="' . $target . '" href="' . $url .'">' . $title . '</a>';
|
203 |
+
//$title = "Click this link to download this file.";
|
204 |
+
$innerHtml = $html_before . '<a class="icon-button download-icon" target="' . $target . '" href="' . $url .'"><span class="et-icon"><span>' . $title . '</span></span></a><br clear="both" />' . $html_after;
|
205 |
+
|
206 |
+
if(get_option('email_before_download_send_email') == 'Send Email') {
|
207 |
+
$attachments = NULL;
|
208 |
+
if(get_option('email_before_download_attachment')) {
|
209 |
+
$dirs = wp_upload_dir();
|
210 |
+
$uploadpath = trailingslashit( $dirs['baseurl'] );
|
211 |
+
$absuploadpath = trailingslashit( $dirs['basedir'] );
|
212 |
+
$attachment = NULL;
|
213 |
+
if ( $uploadpath && ( strstr ( $d->filename, $uploadpath ) || strstr ( $d->filename, $absuploadpath )) ) {
|
214 |
+
|
215 |
+
$file = str_replace( $uploadpath , "" , $d->filename);
|
216 |
+
if(is_file($absuploadpath.$file)){
|
217 |
+
$attachment = $absuploadpath.$file;
|
218 |
+
}
|
219 |
+
}
|
220 |
+
$attachments = array($attachment);
|
221 |
+
}
|
222 |
+
|
223 |
+
@wp_mail( $cf7->posted_data['your-email'], 'Requested URL for the file: '. $title , $message, "Content-Type: text/html\n", $attachments);
|
224 |
+
$cf7->additional_settings = "on_sent_ok: \"document.getElementById('wpm_download_$dId').style.display = 'inline'; document.getElementById('wpm_download_$dId').innerHTML='The link to the file has been emailed to you.'; \"";
|
225 |
+
}
|
226 |
+
else if (get_option('email_before_download_send_email') == 'Both'){
|
227 |
+
$attachments = NULL;
|
228 |
+
if(get_option('email_before_download_attachment')) {
|
229 |
+
$dirs = wp_upload_dir();
|
230 |
+
$uploadpath = trailingslashit( $dirs['baseurl'] );
|
231 |
+
$absuploadpath = trailingslashit( $dirs['basedir'] );
|
232 |
+
$attachment = NULL;
|
233 |
+
if ( $uploadpath && ( strstr ( $d->filename, $uploadpath ) || strstr ( $d->filename, $absuploadpath )) ) {
|
234 |
+
|
235 |
+
$file = str_replace( $uploadpath , "" , $d->filename);
|
236 |
+
if(is_file($absuploadpath.$file)){
|
237 |
+
$attachment = $absuploadpath.$file;
|
238 |
+
}
|
239 |
+
}
|
240 |
+
$attachments = array($attachment);
|
241 |
+
}
|
242 |
+
|
243 |
+
@wp_mail( $cf7->posted_data['your-email'], 'Requested URL for the file: '. $title , $message, "Content-Type: text/html\n", $attachments);
|
244 |
+
$cf7->additional_settings = "on_sent_ok: \"document.getElementById('wpm_download_$dId').style.display = 'inline'; document.getElementById('wpm_download_$dId').innerHTML='$innerHtml'; \"";
|
245 |
+
}
|
246 |
+
else $cf7->additional_settings = "on_sent_ok: \"document.getElementById('wpm_download_$dId').style.display = 'inline'; document.getElementById('wpm_download_$dId').innerHTML='$innerHtml'; \"";
|
247 |
+
}
|
248 |
+
return $cf7;
|
249 |
+
}
|
250 |
+
add_action( 'wpcf7_before_send_mail', 'process_email_form' );
|
251 |
+
|
252 |
+
add_action('admin_menu', 'ebd_plugin_menu');
|
253 |
+
|
254 |
+
function ebd_plugin_menu() {
|
255 |
+
|
256 |
+
add_options_page('Email Before Download Options', 'Email Before Download', 'manage_options', 'email-before-download', 'email_before_download_options');
|
257 |
+
add_action( 'admin_init', 'register_email_before_download_settings' );
|
258 |
+
|
259 |
+
}
|
260 |
+
|
261 |
+
add_filter( 'plugin_action_links', 'ebd_plugin_action_links', 10, 2 );
|
262 |
+
|
263 |
+
function ebd_plugin_action_links( $links, $file ) {
|
264 |
+
if ( $file != plugin_basename( __FILE__ ))
|
265 |
+
return $links;
|
266 |
+
|
267 |
+
$settings_link = '<a href="options-general.php?page=email-before-download">' . __( 'Settings', 'email-before-download' ) . '</a>';
|
268 |
+
|
269 |
+
array_unshift( $links, $settings_link );
|
270 |
+
|
271 |
+
return $links;
|
272 |
+
}
|
273 |
+
|
274 |
+
function register_email_before_download_settings() {
|
275 |
+
register_setting( 'email-before-download-group', 'email_before_download_link_target' );
|
276 |
+
register_setting( 'email-before-download-group', 'email_before_download_wrap_in_div' );
|
277 |
+
register_setting( 'email-before-download-group', 'email_before_download_html_before_link' );
|
278 |
+
register_setting( 'email-before-download-group', 'email_before_download_html_after_link' );
|
279 |
+
register_setting( 'email-before-download-group', 'email_before_download_send_email' );
|
280 |
+
register_setting( 'email-before-download-group', 'email_before_download_email_template' );
|
281 |
+
register_setting( 'email-before-download-group', 'email_before_download_expire_time' );
|
282 |
+
register_setting( 'email-before-download-group', 'email_before_download_hide' );
|
283 |
+
register_setting( 'email-before-download-group', 'email_before_download_attachment' );
|
284 |
+
|
285 |
+
}
|
286 |
+
|
287 |
+
function email_before_download_options() {
|
288 |
+
|
289 |
+
if (!current_user_can('manage_options')) {
|
290 |
+
wp_die( __('You do not have sufficient permissions to access this page.') );
|
291 |
+
}
|
292 |
+
|
293 |
+
?>
|
294 |
+
<style type="text/css">
|
295 |
+
.ebd th, .ebd td
|
296 |
+
{
|
297 |
+
vertical-align:top;
|
298 |
+
}
|
299 |
+
.ebd th
|
300 |
+
{
|
301 |
+
text-align: left;
|
302 |
+
padding-right:8px;
|
303 |
+
}
|
304 |
+
.ebd .alert
|
305 |
+
{
|
306 |
+
padding:8px;
|
307 |
+
font:bold 12pt Arial;
|
308 |
+
border:1px dashed red;
|
309 |
+
}
|
310 |
+
</style>
|
311 |
+
|
312 |
+
<div class="wrap">
|
313 |
+
<h2>Email Before Download Options</h2>
|
314 |
+
<p>
|
315 |
+
<a href="<?php echo WP_PLUGIN_URL."/email-before-download/export.php"; ?>" target="_blank">Click this link export the Email Before Download log as csv file</a>
|
316 |
+
</p>
|
317 |
+
<form method="post" action="options.php">
|
318 |
+
<?php settings_fields( 'email-before-download-group' ); ?>
|
319 |
+
<table class="optiontable ebd">
|
320 |
+
<tr valign="top">
|
321 |
+
<th scope="row"><p>1. Delivery Format</p></th>
|
322 |
+
<td><p>
|
323 |
+
<select name="email_before_download_send_email">
|
324 |
+
<option value="Inline Link" <?php if(get_option('email_before_download_send_email') == 'Inline Link') echo 'selected="selected"'; ?> >Inline Link</option>
|
325 |
+
<option value="Send Email" <?php if(get_option('email_before_download_send_email') == 'Send Email') echo 'selected="selected"'; ?> >Send Email</option>
|
326 |
+
<option value="Both" <?php if(get_option('email_before_download_send_email') == 'Both') echo 'selected="selected"'; ?> >Both</option>
|
327 |
+
</select><br />
|
328 |
+
</p>
|
329 |
+
</td>
|
330 |
+
</tr>
|
331 |
+
|
332 |
+
|
333 |
+
<tr valign="top">
|
334 |
+
<th scope="row"><p>2. Hide/Mask Real Link</p></th>
|
335 |
+
<td><p><input type="checkbox" size="40" name="email_before_download_hide" value="1" <?php if(get_option('email_before_download_hide')) echo 'checked="checked"'; ?> />
|
336 |
+
<br /> <font size="-1"><i>Hide/mask the real file link from the user. It requires the cURL php extention to be enabled, which is done by uncommenting it from the php.ini file. <a href="#"
|
337 |
+
onclick="window.open('<?php echo WP_PLUGIN_URL."/email-before-download/checkcurl.php" ?>','Check cURL','menubar=no,width=430,height=360,toolbar=no'); return false;">Check if cURL is enabled</a>.</i></font>
|
338 |
+
</p>
|
339 |
+
</td>
|
340 |
+
</tr>
|
341 |
+
|
342 |
+
<tr valign="top">
|
343 |
+
<th scope="row"><p>3. Link Expiration Time (only applies if #2 is checked)</p></th>
|
344 |
+
<td><p>
|
345 |
+
<select name="email_before_download_expire_time">
|
346 |
+
<option value="0" <?php if(get_option('email_before_download_expire_time') == '0') echo 'selected="selected"'; ?> >Never</option>
|
347 |
+
<option value="+1 minute" <?php if(get_option('email_before_download_expire_time') == '+1 minute') echo 'selected="selected"'; ?> >1 min</option>
|
348 |
+
<option value="+3 minute" <?php if(get_option('email_before_download_expire_time') == '+3 minute') echo 'selected="selected"'; ?> >3 min</option>
|
349 |
+
<option value="+10 minute" <?php if(get_option('email_before_download_expire_time') == '+10 minute') echo 'selected="selected"'; ?> >10 min</option>
|
350 |
+
<option value="+30 minute" <?php if(get_option('email_before_download_expire_time') == '+30 minute') echo 'selected="selected"'; ?> >30 min</option>
|
351 |
+
<option value="+1 hour" <?php if(get_option('email_before_download_expire_time') == '+1 hour') echo 'selected="selected"'; ?> >1 hr</option>
|
352 |
+
<option value="+12 hour" <?php if(get_option('email_before_download_expire_time') == '+12 hour') echo 'selected="selected"'; ?> >12 hr</option>
|
353 |
+
<option value="+1 day" <?php if(get_option('email_before_download_expire_time') == '+1 day') echo 'selected="selected"'; ?> >1 day</option>
|
354 |
+
<option value="+1 week" <?php if(get_option('email_before_download_expire_time') == '+1 week') echo 'selected="selected"'; ?> >1 week</option>
|
355 |
+
</select>
|
356 |
+
<br /> <font size="-1"><i>If you are masking the link by checking #2, this option will expire the link sent the user so if they click it again (or send it to someone else who tries) after the specified period, they will have to submit a new form.</i></font>
|
357 |
+
</p>
|
358 |
+
</td>
|
359 |
+
</tr>
|
360 |
+
|
361 |
+
|
362 |
+
<tr valign="top"><td colspan="2"><p class="alert">#4 through #7 only apply if you selected "Inline Link" or "Both" as the Delivery Format in #1</p></td></tr>
|
363 |
+
<tr valign="top">
|
364 |
+
<th scope="row"><p>4. Inline Link Target</p></th>
|
365 |
+
<td><p>
|
366 |
+
<select name="email_before_download_link_target">
|
367 |
+
<option value="_blank" <?php if(get_option('email_before_download_link_target') == '_blank') echo 'selected="selected"'; ?> >_blank</option>
|
368 |
+
<option value="_self" <?php if(get_option('email_before_download_link_target') == '_self') echo 'selected="selected"'; ?> >_self</option>
|
369 |
+
</select> <br />
|
370 |
+
<font size="-1"><i>If "_self" is selected link will open in the same browser window/tab, if "_blank" is selected the link will open in the new browser window/tab</i></font>
|
371 |
+
</p>
|
372 |
+
</td>
|
373 |
+
</tr>
|
374 |
+
|
375 |
+
<tr valign="top">
|
376 |
+
<th scope="row"><p>5. Inline Link Custom CSS</p></th>
|
377 |
+
<td><p><input type="text" size="40" name="email_before_download_wrap_in_div" value="<?php echo get_option('email_before_download_wrap_in_div'); ?>" />
|
378 |
+
<br /> <font size="-1"><i>CSS class used to render the div and the link (this is only used if you choose to display the link inline in #5)</i></font>
|
379 |
+
</td>
|
380 |
+
</tr>
|
381 |
+
|
382 |
+
<tr valign="top">
|
383 |
+
<th scope="row"><p>6. HTML Before Inline Link</p></th>
|
384 |
+
<td><p><input type="text" name="email_before_download_html_before_link" size="40" value="<?php echo get_option('email_before_download_html_before_link'); ?>" /><br />
|
385 |
+
<font size="-1"><i>HTML you want to be added before the link</i></font>
|
386 |
+
</p>
|
387 |
+
</td>
|
388 |
+
</tr>
|
389 |
+
|
390 |
+
<tr valign="top">
|
391 |
+
<th scope="row"><p>7. HTML After Inline Link</p></th>
|
392 |
+
<td> <p><input type="text" size="40" name="email_before_download_html_after_link" value="<?php echo get_option('email_before_download_html_after_link'); ?>" />
|
393 |
+
<br /><font size="-1"><i>HTML you want to be added after the link</i></font>
|
394 |
+
</p>
|
395 |
+
</td>
|
396 |
+
</tr>
|
397 |
+
|
398 |
+
<tr valign="top" class="alert"><td colspan="2"><p class="alert">#8 through #9 only apply if you selected "Send Email" or "Both" as the Delivery Format in #1</p></td></tr>
|
399 |
+
<tr valign="top">
|
400 |
+
<th scope="row"><p>8. Email Template</p></th>
|
401 |
+
<td><textarea cols="40" rows="10" name="email_before_download_email_template"> <?php echo get_option('email_before_download_email_template'); ?> </textarea><br />
|
402 |
+
<i>You can use the following placeholders: [requesting_name], [file_url] and [file_name]. </i><br />
|
403 |
+
<i>So if you, for example, don't provide the [file_url] placeholder, the
|
404 |
+
<br />user will not receive any link. Here is an example of the template:<br /><br />
|
405 |
+
<b> Hello [requesting_name], <br />
|
406 |
+
|
407 |
+
Here is the download for <a href="[file_url]">[file_name]</a> that you requested.<br />
|
408 |
+
|
409 |
+
Sincerely,<br />
|
410 |
+
|
411 |
+
My Company name </b>
|
412 |
+
<br /><br /> Note. If you leave this field empty, an email containing only the file URL will be sent.
|
413 |
+
|
414 |
+
</i>
|
415 |
+
</td>
|
416 |
+
</tr>
|
417 |
+
|
418 |
+
<tr valign="top">
|
419 |
+
<th scope="row"><p>9. Attachment</p></th>
|
420 |
+
<td><p><input type="checkbox" size="40" name="email_before_download_attachment" value="1" <?php if(get_option('email_before_download_attachment')) echo 'checked="checked"'; ?> />
|
421 |
+
<br />
|
422 |
+
<font size="-1"><i>"Attachment" can only be applied to the files uploaded using Download Monitor plugin.</i></font>
|
423 |
+
</p>
|
424 |
+
</td>
|
425 |
+
</tr>
|
426 |
+
</table>
|
427 |
+
|
428 |
+
<p class="submit">
|
429 |
+
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
|
430 |
+
</p>
|
431 |
+
|
432 |
+
</form>
|
433 |
+
</div>
|
434 |
+
<?php
|
435 |
+
|
436 |
+
}
|
437 |
?>
|
trunk/readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: mandsconsulting
|
|
3 |
Donate link: http://www.mandsconsulting.com/
|
4 |
Tags: email, download
|
5 |
Requires at least: 3.x
|
6 |
-
Tested up to: 3.
|
7 |
Stable tag: trunk
|
8 |
|
9 |
Email Before Download presents your users with a form where they submit information, like their name and email address, prior to receiving a download.
|
@@ -17,7 +17,7 @@ Email Before Download presents your users with a form where they submit informat
|
|
17 |
As an option, you can configure Email Before Download to:
|
18 |
|
19 |
1. Display a link to your file directly under the contact form once it is submitted. This happens dynamically, inline of your post/page.
|
20 |
-
1. Send the user an email with a link to download your file.
|
21 |
1. Both #1 and #2
|
22 |
|
23 |
|
@@ -46,6 +46,9 @@ Plugin homepage: [http://www.mandsconsulting.com/products/wp-email-before-downlo
|
|
46 |
|
47 |
== Frequently Asked Questions ==
|
48 |
|
|
|
|
|
|
|
49 |
|
50 |
= What if I don't use the Contact Form 7 and/or Download Monintor Plugins? =
|
51 |
|
@@ -57,19 +60,11 @@ If you decide to configure the Email Before Download option to send the user an
|
|
57 |
|
58 |
= What happens after the user completes the form? =
|
59 |
|
60 |
-
By default, the user is presented with a link to download their file. There is also an option to email a link to the file
|
61 |
|
62 |
= Are you changing any of my file or directory permissions? =
|
63 |
|
64 |
-
WordPress allows direct access to
|
65 |
-
|
66 |
-
= So someone can still download my files directly without providing their email? =
|
67 |
-
|
68 |
-
Users generally do not have a desire to put in the work required to determine your direct upload filenames. This plugin provides a quick way to know who is downloading information that you might feel to be more premium content like whitepapers, images, etc. from sincere users who are visiting your site, with the understanding the user can share the file itself or the URL if they wish.
|
69 |
-
|
70 |
-
= What if I don't want the user to be able to share the file? =
|
71 |
-
|
72 |
-
We can't help you prevent a user from sharing a file they have downloaded with other people. We are however working on allowing you to set some options that will make sharing links a little more difficult. Also, there is a chance you fit more into the category of needing to charge for the content which is something this plugin does not currently address.
|
73 |
|
74 |
|
75 |
|
@@ -84,11 +79,22 @@ We can't help you prevent a user from sharing a file they have downloaded with o
|
|
84 |
|
85 |
== Changelog ==
|
86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
= 0.5 =
|
88 |
* First release.
|
89 |
|
90 |
== Upgrade Notice ==
|
91 |
|
|
|
|
|
|
|
92 |
= 0.5 =
|
93 |
First release.
|
94 |
|
3 |
Donate link: http://www.mandsconsulting.com/
|
4 |
Tags: email, download
|
5 |
Requires at least: 3.x
|
6 |
+
Tested up to: 3.1
|
7 |
Stable tag: trunk
|
8 |
|
9 |
Email Before Download presents your users with a form where they submit information, like their name and email address, prior to receiving a download.
|
17 |
As an option, you can configure Email Before Download to:
|
18 |
|
19 |
1. Display a link to your file directly under the contact form once it is submitted. This happens dynamically, inline of your post/page.
|
20 |
+
1. Send the user an email with a link and/or attachment to download your file.
|
21 |
1. Both #1 and #2
|
22 |
|
23 |
|
46 |
|
47 |
== Frequently Asked Questions ==
|
48 |
|
49 |
+
= Can I export a list of download requests people have made? =
|
50 |
+
|
51 |
+
Yes. We store a log of the downloads and you can export a CSV file of this from the Email Before Download settings page in your admin screens.
|
52 |
|
53 |
= What if I don't use the Contact Form 7 and/or Download Monintor Plugins? =
|
54 |
|
60 |
|
61 |
= What happens after the user completes the form? =
|
62 |
|
63 |
+
By default, the user is presented with a link to download their file. There is also an option to email the user (with a link to the file and/or attachment) if you choose that route. You can even provide both the inline link as well as the email if you choose.
|
64 |
|
65 |
= Are you changing any of my file or directory permissions? =
|
66 |
|
67 |
+
WordPress allows direct access to files in your upload directories using a direct URL and we do not change those permissions. We do provide an option to mask the URL to your downloads if you have cURL enabled.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
|
70 |
|
79 |
|
80 |
== Changelog ==
|
81 |
|
82 |
+
= 1.0 =
|
83 |
+
* Added ability to export log in CSV format from admin settings page.
|
84 |
+
* Added ability to mask download file's URL if cURL is enabled.
|
85 |
+
* Added ability to expire the download link after a given timeframe.
|
86 |
+
* In addition to emailing a link to the file, added ability to email the file as an attachment.
|
87 |
+
* Added ability to email attachment.
|
88 |
+
* Added ability to download files outside of Download Monitor.
|
89 |
+
|
90 |
= 0.5 =
|
91 |
* First release.
|
92 |
|
93 |
== Upgrade Notice ==
|
94 |
|
95 |
+
= 1.0 =
|
96 |
+
Automatically upgrade the plugin and all previous settings should remain intact.
|
97 |
+
|
98 |
= 0.5 =
|
99 |
First release.
|
100 |
|