WordPress File Upload - Version 2.7.3

Version Description

  • important bug fix in Pro version
  • added wfu_before_email_notification filter
  • corrected bug not showing correctly special characters (double quotes and braces) in email notifications
Download this release

Release Info

Developer nickboss
Plugin Icon 128x128 WordPress File Upload
Version 2.7.3
Comparing to
See all releases

Code changes from version 2.7.2 to 2.7.3

lib/wfu_admin.php CHANGED
@@ -478,24 +478,6 @@ function wfu_manage_settings($message = '') {
478
  $echo_str .= "\n\t\t\t\t\t\t\t".'<p style="cursor: text; font-size:9px; padding: 0px; margin: 0px; width: 95%; color: #AAAAAA;">Current value: <strong>'.$plugin_options['basedir'].'</strong></p>';
479
  $echo_str .= "\n\t\t\t\t\t\t".'</td>';
480
  $echo_str .= "\n\t\t\t\t\t".'</tr>';
481
- $echo_str .= "\n\t\t\t\t\t".'<tr class="form-field">';
482
- $echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
483
- $echo_str .= "\n\t\t\t\t\t\t\t".'<label for="wfu_captcha_sitekey">Google ReCaptcha Site Key</label>';
484
- $echo_str .= "\n\t\t\t\t\t\t".'</th>';
485
- $echo_str .= "\n\t\t\t\t\t\t".'<td>';
486
- $echo_str .= "\n\t\t\t\t\t\t\t".'<input name="wfu_captcha_sitekey" id="wfu_captcha_sitekey" type="text" value="'.$plugin_options['captcha_sitekey'].'" />';
487
- $echo_str .= "\n\t\t\t\t\t\t\t".'<p style="cursor: text; font-size:9px; padding: 0px; margin: 0px; width: 95%; color: #AAAAAA;">Current value: <strong>'.$plugin_options['captcha_sitekey'].'</strong></p>';
488
- $echo_str .= "\n\t\t\t\t\t\t".'</td>';
489
- $echo_str .= "\n\t\t\t\t\t".'</tr>';
490
- $echo_str .= "\n\t\t\t\t\t".'<tr class="form-field">';
491
- $echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
492
- $echo_str .= "\n\t\t\t\t\t\t\t".'<label for="wfu_captcha_secretkey">Google ReCaptcha Secret Key</label>';
493
- $echo_str .= "\n\t\t\t\t\t\t".'</th>';
494
- $echo_str .= "\n\t\t\t\t\t\t".'<td>';
495
- $echo_str .= "\n\t\t\t\t\t\t\t".'<input name="wfu_captcha_secretkey" id="wfu_captcha_secretkey" type="text" value="'.$plugin_options['captcha_secretkey'].'" />';
496
- $echo_str .= "\n\t\t\t\t\t\t\t".'<p style="cursor: text; font-size:9px; padding: 0px; margin: 0px; width: 95%; color: #AAAAAA;">Current value: <strong>'.$plugin_options['captcha_secretkey'].'</strong></p>';
497
- $echo_str .= "\n\t\t\t\t\t\t".'</td>';
498
- $echo_str .= "\n\t\t\t\t\t".'</tr>';
499
  $echo_str .= "\n\t\t\t\t".'</tbody>';
500
  $echo_str .= "\n\t\t\t".'</table>';
501
  $echo_str .= "\n\t\t\t".'<p class="submit">';
@@ -522,8 +504,6 @@ function wfu_update_settings() {
522
  $new_plugin_options['shortcode'] = $plugin_options['shortcode'];
523
  $new_plugin_options['hashfiles'] = $hashfiles;
524
  $new_plugin_options['basedir'] = $_POST['wfu_basedir'];
525
- $new_plugin_options['captcha_sitekey'] = $_POST['wfu_captcha_sitekey'];
526
- $new_plugin_options['captcha_secretkey'] = $_POST['wfu_captcha_secretkey'];
527
  $encoded_options = wfu_encode_plugin_options($new_plugin_options);
528
  update_option( "wordpress_file_upload_options", $encoded_options );
529
  if ( $new_plugin_options['hashfiles'] == '1' && $plugin_options['hashfiles'] != '1' )
478
  $echo_str .= "\n\t\t\t\t\t\t\t".'<p style="cursor: text; font-size:9px; padding: 0px; margin: 0px; width: 95%; color: #AAAAAA;">Current value: <strong>'.$plugin_options['basedir'].'</strong></p>';
479
  $echo_str .= "\n\t\t\t\t\t\t".'</td>';
480
  $echo_str .= "\n\t\t\t\t\t".'</tr>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
481
  $echo_str .= "\n\t\t\t\t".'</tbody>';
482
  $echo_str .= "\n\t\t\t".'</table>';
483
  $echo_str .= "\n\t\t\t".'<p class="submit">';
504
  $new_plugin_options['shortcode'] = $plugin_options['shortcode'];
505
  $new_plugin_options['hashfiles'] = $hashfiles;
506
  $new_plugin_options['basedir'] = $_POST['wfu_basedir'];
 
 
507
  $encoded_options = wfu_encode_plugin_options($new_plugin_options);
508
  update_option( "wordpress_file_upload_options", $encoded_options );
509
  if ( $new_plugin_options['hashfiles'] == '1' && $plugin_options['hashfiles'] != '1' )
lib/wfu_ajaxactions.php CHANGED
@@ -116,9 +116,9 @@ function wfu_ajax_action_save_shortcode() {
116
 
117
  if ( $_POST['post_id'] == "" ) {
118
  $plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
119
-
120
  $new_plugin_options['version'] = '1.0';
121
- $new_plugin_options['shortcode'] = wfu_plugin_decode_string($_POST['shortcode']);
 
122
  $new_plugin_options['basedir'] = $plugin_options['basedir'];
123
  $encoded_options = wfu_encode_plugin_options($new_plugin_options);
124
  update_option( "wordpress_file_upload_options", $encoded_options );
116
 
117
  if ( $_POST['post_id'] == "" ) {
118
  $plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
 
119
  $new_plugin_options['version'] = '1.0';
120
+ $new_plugin_options['shortcode'] = $plugin_options['shortcode'];
121
+ $new_plugin_options['hashfiles'] = $plugin_options['hashfiles'];
122
  $new_plugin_options['basedir'] = $plugin_options['basedir'];
123
  $encoded_options = wfu_encode_plugin_options($new_plugin_options);
124
  update_option( "wordpress_file_upload_options", $encoded_options );
lib/wfu_functions.php CHANGED
@@ -1088,43 +1088,67 @@ function wfu_add_div() {
1088
  //********************* Email Functions ****************************************************************************************************
1089
 
1090
  function wfu_send_notification_email($user, $only_filename_list, $target_path_list, $attachment_list, $userdata_fields, $params) {
1091
- if ( 0 == $user->ID ) {
1092
- $user_login = "guest";
1093
- $user_email = "";
1094
- }
1095
- else {
1096
- $user_login = $user->user_login;
1097
- $user_email = $user->user_email;
1098
- }
1099
- $search = array ('/%useremail%/');
1100
- $replace = array ($user_email);
1101
- foreach ( $userdata_fields as $userdata_key => $userdata_field ) {
1102
- $ind = 1 + $userdata_key;
1103
- array_push($search, '/%userdata'.$ind.'%/');
1104
- array_push($replace, $userdata_field["value"]);
1105
- }
1106
- // $notifyrecipients = trim(preg_replace('/%useremail%/', $user_email, $params["notifyrecipients"]));
1107
- $notifyrecipients = preg_replace($search, $replace, $params["notifyrecipients"]);
1108
- $search = array ('/%n%/');
1109
- $replace = array ("\n");
1110
- $notifyheaders = preg_replace($search, $replace, $params["notifyheaders"]);
1111
- $search = array ('/%username%/', '/%useremail%/', '/%filename%/', '/%filepath%/', '/%n%/');
1112
- $replace = array ($user_login, ( $user_email == "" ? "no email" : $user_email ), $only_filename_list, $target_path_list, "\n");
1113
- foreach ( $userdata_fields as $userdata_key => $userdata_field ) {
1114
- $ind = 1 + $userdata_key;
1115
- array_push($search, '/%userdata'.$ind.'%/');
1116
- array_push($replace, $userdata_field["value"]);
1117
- }
1118
- $notifysubject = preg_replace($search, $replace, $params["notifysubject"]);
1119
- $notifymessage = preg_replace($search, $replace, $params["notifymessage"]);
1120
- if ( $params["attachfile"] == "true" ) {
1121
- $attachments = explode(",", $attachment_list);
1122
- $notify_sent = wp_mail($notifyrecipients, $notifysubject, $notifymessage, $notifyheaders, $attachments);
1123
- }
1124
- else {
1125
- $notify_sent = wp_mail($notifyrecipients, $notifysubject, $notifymessage, $notifyheaders);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1126
  }
1127
- return ( $notify_sent ? "" : WFU_WARNING_NOTIFY_NOTSENT_UNKNOWNERROR );
1128
  }
1129
 
1130
  //********************* Media Functions ****************************************************************************************************
1088
  //********************* Email Functions ****************************************************************************************************
1089
 
1090
  function wfu_send_notification_email($user, $only_filename_list, $target_path_list, $attachment_list, $userdata_fields, $params) {
1091
+ //apply wfu_before_email_notification filter
1092
+ $changable_data['recipients'] = $params["notifyrecipients"];
1093
+ $changable_data['subject'] = $params["notifysubject"];
1094
+ $changable_data['message'] = $params["notifymessage"];
1095
+ $changable_data['headers'] = $params["notifyheaders"];
1096
+ $changable_data['user_data'] = $userdata_fields;
1097
+ $changable_data['filename'] = $only_filename_list;
1098
+ $changable_data['filepath'] = $target_path_list;
1099
+ $changable_data['error_message'] = '';
1100
+ $additional_data['shortcode_id'] = $params["uploadid"];
1101
+ $ret_data = apply_filters('wfu_before_email_notification', $changable_data, $additional_data);
1102
+
1103
+ if ( $ret_data['error_message'] == '' ) {
1104
+ $notifyrecipients = $ret_data['recipients'];
1105
+ $notifysubject = $ret_data['subject'];
1106
+ $notifymessage = $ret_data['message'];
1107
+ $notifyheaders = $ret_data['headers'];
1108
+ $userdata_fields = $ret_data['user_data'];
1109
+ $only_filename_list = $ret_data['filename'];
1110
+ $target_path_list = $ret_data['filepath'];
1111
+
1112
+ if ( 0 == $user->ID ) {
1113
+ $user_login = "guest";
1114
+ $user_email = "";
1115
+ }
1116
+ else {
1117
+ $user_login = $user->user_login;
1118
+ $user_email = $user->user_email;
1119
+ }
1120
+ $search = array ('/%useremail%/', '/%n%/', '/%dq%/', '/%brl%/', '/%brr%/');
1121
+ $replace = array ($user_email, "\n", "\"", "[", "]");
1122
+ foreach ( $userdata_fields as $userdata_key => $userdata_field ) {
1123
+ $ind = 1 + $userdata_key;
1124
+ array_push($search, '/%userdata'.$ind.'%/');
1125
+ array_push($replace, $userdata_field["value"]);
1126
+ }
1127
+ // $notifyrecipients = trim(preg_replace('/%useremail%/', $user_email, $params["notifyrecipients"]));
1128
+ $notifyrecipients = preg_replace($search, $replace, $notifyrecipients);
1129
+ $search = array ('/%n%/', '/%dq%/', '/%brl%/', '/%brr%/');
1130
+ $replace = array ("\n", "\"", "[", "]");
1131
+ $notifyheaders = preg_replace($search, $replace, $notifyheaders);
1132
+ $search = array ('/%username%/', '/%useremail%/', '/%filename%/', '/%filepath%/', '/%n%/', '/%dq%/', '/%brl%/', '/%brr%/');
1133
+ $replace = array ($user_login, ( $user_email == "" ? "no email" : $user_email ), $only_filename_list, $target_path_list, "\n", "\"", "[", "]");
1134
+ foreach ( $userdata_fields as $userdata_key => $userdata_field ) {
1135
+ $ind = 1 + $userdata_key;
1136
+ array_push($search, '/%userdata'.$ind.'%/');
1137
+ array_push($replace, $userdata_field["value"]);
1138
+ }
1139
+ $notifysubject = preg_replace($search, $replace, $notifysubject);
1140
+ $notifymessage = preg_replace($search, $replace, $notifymessage);
1141
+
1142
+ if ( $params["attachfile"] == "true" ) {
1143
+ $attachments = explode(",", $attachment_list);
1144
+ $notify_sent = wp_mail($notifyrecipients, $notifysubject, $notifymessage, $notifyheaders, $attachments);
1145
+ }
1146
+ else {
1147
+ $notify_sent = wp_mail($notifyrecipients, $notifysubject, $notifymessage, $notifyheaders);
1148
+ }
1149
+ return ( $notify_sent ? "" : WFU_WARNING_NOTIFY_NOTSENT_UNKNOWNERROR );
1150
  }
1151
+ else return $ret_data['error_message'];
1152
  }
1153
 
1154
  //********************* Media Functions ****************************************************************************************************
lib/wfu_processfiles.php CHANGED
@@ -162,6 +162,7 @@ function wfu_process_files($params, $method) {
162
  $changable_data['file_path'] = $target_path;
163
  $changable_data['user_data'] = $userdata_fields;
164
  $changable_data['error_message'] = $filter_error_message;
 
165
  $additional_data['file_unique_id'] = $file_unique_id;
166
  // correct file size in case of checking of file
167
  if ( $only_check ) $additional_data['file_size'] = $fileprops['size'];
162
  $changable_data['file_path'] = $target_path;
163
  $changable_data['user_data'] = $userdata_fields;
164
  $changable_data['error_message'] = $filter_error_message;
165
+ $additional_data['shortcode_id'] = $sid;
166
  $additional_data['file_unique_id'] = $file_unique_id;
167
  // correct file size in case of checking of file
168
  if ( $only_check ) $additional_data['file_size'] = $fileprops['size'];
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: nickboss
3
  Donate link: http://www.iptanus.com/support/wordpress-file-upload
4
  Tags: upload, upload file, upload files, multiple, multiple upload, multiple uploads, captcha, progress bar, form, ajax, directory, HTML5, filelist, gallery, image gallery, browser, file browser, gallery, image gallery, shortcode, logging, file logging
5
  Requires at least: 2.9.2
6
- Tested up to: 4.2.1
7
  Stable tag: "trunk"
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -117,6 +117,11 @@ In the free version the upload will fail. However in the Pro version the upload
117
 
118
  == Changelog ==
119
 
 
 
 
 
 
120
  = 2.7.2 =
121
  * important bug fix in Pro version, very slight changes in free version
122
 
@@ -400,6 +405,9 @@ Initial version.
400
 
401
  == Upgrade Notice ==
402
 
 
 
 
403
  = 2.7.2 =
404
  Upgrade to address some bugs.
405
 
@@ -744,8 +752,9 @@ add_filter('wfu_before_file_check', 'wfu_before_file_check_handler', 10, 2);
744
  // $changable_data is an array that can be modified by the filter and contains the items:
745
  // file_path: the full path of the uploaded file
746
  // user_data: an array of user data values, if userdata are activated
747
- // error_message: if this is non-zero, then upload of the file will be cancelled showing this error message to the user
748
  // $additional_data is an array with additional data to be used by the filter (but cannot be modified) as follows:
 
749
  // file_unique_id: this id is unique for each individual file upload and can be used to identify each separate upload
750
  // file_size: the size of the uploaded file
751
  // user_id: the id of the user that submitted the file for upload
@@ -778,6 +787,32 @@ function wfu_before_file_upload_handler($file_path, $file_unique_id) {
778
  }
779
  `
780
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
781
  The following actions are supported:
782
 
783
  **wfu_after_file_upload**
3
  Donate link: http://www.iptanus.com/support/wordpress-file-upload
4
  Tags: upload, upload file, upload files, multiple, multiple upload, multiple uploads, captcha, progress bar, form, ajax, directory, HTML5, filelist, gallery, image gallery, browser, file browser, gallery, image gallery, shortcode, logging, file logging
5
  Requires at least: 2.9.2
6
+ Tested up to: 4.2.2
7
  Stable tag: "trunk"
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
117
 
118
  == Changelog ==
119
 
120
+ = 2.7.3 =
121
+ * important bug fix in Pro version
122
+ * added wfu_before_email_notification filter
123
+ * corrected bug not showing correctly special characters (double quotes and braces) in email notifications
124
+
125
  = 2.7.2 =
126
  * important bug fix in Pro version, very slight changes in free version
127
 
405
 
406
  == Upgrade Notice ==
407
 
408
+ = 2.7.3 =
409
+ Upgrade to add some new features and address some bugs.
410
+
411
  = 2.7.2 =
412
  Upgrade to address some bugs.
413
 
752
  // $changable_data is an array that can be modified by the filter and contains the items:
753
  // file_path: the full path of the uploaded file
754
  // user_data: an array of user data values, if userdata are activated
755
+ // error_message: initially it is set to an empty value, if the handler sets a non-empty value then upload of the file will be cancelled showing this error message (message will be shown only to administrators if adminmessages attribute has been activated)
756
  // $additional_data is an array with additional data to be used by the filter (but cannot be modified) as follows:
757
+ // shortcode_id: this is the id of the plugin, as set using uploadid attribute; it can be used to apply this filter only to a specific instance of the plugin (if it is used in more than one pages or posts)
758
  // file_unique_id: this id is unique for each individual file upload and can be used to identify each separate upload
759
  // file_size: the size of the uploaded file
760
  // user_id: the id of the user that submitted the file for upload
787
  }
788
  `
789
 
790
+ **wfu_before_email_notification**
791
+
792
+ It is executed before email notification is sent, in order to allow advanced checks or modifications to the email. You can use it as follows:
793
+
794
+ `
795
+ add_filter('wfu_before_email_notification', 'wfu_before_email_notification_handler', 10, 2);
796
+
797
+ //The following function takes two parameters, $changable_data and $additional_data.
798
+ // $changable_data is an array that can be modified by the filter and contains the items:
799
+ // recipients: the list of recipients (before dynamic variables are applied)
800
+ // subject: the email subject (before dynamic variables are applied)
801
+ // message: the email body (before dynamic variables are applied)
802
+ // headers: the email headers, if exist (before dynamic variables are applied)
803
+ // user_data: an array of user data values, if userdata are activated
804
+ // filename: a comma separated list of uploaded file names (only the file names)
805
+ // filepath: a comma separated list of uploaded file paths (absolute full file paths)
806
+ // error_message: initially it is set to an empty value, if the handler sets a non-empty value then email sending will be cancelled showing this error message (message will be shown only to administrators if adminmessages attribute has been activated)
807
+ // $additional_data is an array with additional data to be used by the filter (but cannot be modified) as follows:
808
+ // shortcode_id: this is the id of the plugin, as set using uploadid attribute; it can be used to apply this filter only to a specific instance of the plugin (if it is used in more than one pages or posts)
809
+ //The function must return the final $changable_data.
810
+ function wfu_before_email_notification_handler($changable_data, $additional_data) {
811
+ // Add code here...
812
+ return $changable_data;
813
+ }
814
+ `
815
+
816
  The following actions are supported:
817
 
818
  **wfu_after_file_upload**
release_notes.txt CHANGED
@@ -1,3 +1,3 @@
1
- <span><strong>Latest release notes: </strong>An important bug fixed that prevented the plugin to operate correctly with the new captcha. Hopefully now everything works fine.</span>
2
  <!--
3
  -->
1
+ <span><strong>Latest release notes: </strong>A<!-- --> new filter was added, <strong>wfu_before_email_notification</strong> in order to allow modifications to the email contents before it is sent, or perform validity checks. This was a request of several users that wanted more flexibility, especially when including in the email body the list of uploaded files.</span>
2
  <!--
3
  -->
wordpress_file_upload.php CHANGED
@@ -4,7 +4,7 @@ session_start();
4
  /*
5
  Plugin URI: http://www.iptanus.com/support/wordpress-file-upload
6
  Description: Simple interface to upload files from a page.
7
- Version: 2.7.2
8
  Author: Nickolas Bossinas
9
  Author URI: http://www.iptanus.com
10
  */
4
  /*
5
  Plugin URI: http://www.iptanus.com/support/wordpress-file-upload
6
  Description: Simple interface to upload files from a page.
7
+ Version: 2.7.3
8
  Author: Nickolas Bossinas
9
  Author URI: http://www.iptanus.com
10
  */