WordPress File Upload - Version 2.4.6

Version Description

  • variables %blogid%, %pageid% and %pagetitle% added in email notifications and subject and %dq% in subject
  • corrected bug that was breaking Shortcode Composer when using more than ten attributes
  • corrected bug that was rejecting file uploads when uploadpattern attribute contained blank spaces
  • several code corrections in order to eliminate PHP warning messages when DEBUG mode is on
  • several code corrections in order to eliminate warning messages in Javascript
Download this release

Release Info

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

Code changes from version 2.4.5 to 2.4.6

images/Version Comparison.png ADDED
Binary file
js/wordpress_file_upload_adminfunctions.js CHANGED
@@ -1414,12 +1414,12 @@ function wfu_save_shortcode() {
1414
 
1415
  xhr.open("POST", url, true);
1416
  xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
1417
- xhr.setRequestHeader("Content-length", parameters.length);
1418
- xhr.setRequestHeader("Connection", "close");
1419
  xhr.onreadystatechange = function() {
1420
  if ( xhr.readyState == 4 ) {
1421
  if ( xhr.status == 200 ) {
1422
- if (xhr.responseText == "save_shortcode_success") {
1423
  document.getElementById("wfu_save_label").innerHTML = "saved";
1424
  document.getElementById("wfu_save_label").className = "wfu_save_label";
1425
  document.getElementById("wfu_save_label").style.opacity = 1;
1414
 
1415
  xhr.open("POST", url, true);
1416
  xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
1417
+ // xhr.setRequestHeader("Content-length", parameters.length);
1418
+ // xhr.setRequestHeader("Connection", "close");
1419
  xhr.onreadystatechange = function() {
1420
  if ( xhr.readyState == 4 ) {
1421
  if ( xhr.status == 200 ) {
1422
+ if (xhr.responseText.substr(0, 22) == "save_shortcode_success") {
1423
  document.getElementById("wfu_save_label").innerHTML = "saved";
1424
  document.getElementById("wfu_save_label").className = "wfu_save_label";
1425
  document.getElementById("wfu_save_label").style.opacity = 1;
js/wordpress_file_upload_functions.js CHANGED
@@ -368,8 +368,8 @@ function wfu_notify_WPFilebase(params_index, session_token) {
368
 
369
  xhr.open("POST", url, true);
370
  xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
371
- xhr.setRequestHeader("Content-length", parameters.length);
372
- xhr.setRequestHeader("Connection", "close");
373
  xhr.onreadystatechange = function() {}
374
  xhr.send(parameters);
375
  }
@@ -435,8 +435,8 @@ function wfu_send_email_notification(sid, unique_id, params_index, session_token
435
 
436
  xhr.open("POST", url, true);
437
  xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
438
- xhr.setRequestHeader("Content-length", parameters.length);
439
- xhr.setRequestHeader("Connection", "close");
440
  xhr.addEventListener("load", wfu_uploadComplete, false);
441
  xhr.addEventListener("error", wfu_uploadFailed, false);
442
  xhr.addEventListener("abort", wfu_uploadCanceled, false);
368
 
369
  xhr.open("POST", url, true);
370
  xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
371
+ // xhr.setRequestHeader("Content-length", parameters.length);
372
+ // xhr.setRequestHeader("Connection", "close");
373
  xhr.onreadystatechange = function() {}
374
  xhr.send(parameters);
375
  }
435
 
436
  xhr.open("POST", url, true);
437
  xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
438
+ // xhr.setRequestHeader("Content-length", parameters.length);
439
+ // xhr.setRequestHeader("Connection", "close");
440
  xhr.addEventListener("load", wfu_uploadComplete, false);
441
  xhr.addEventListener("error", wfu_uploadFailed, false);
442
  xhr.addEventListener("abort", wfu_uploadCanceled, false);
languages/wordpress-file-upload.pot CHANGED
@@ -2,9 +2,9 @@ msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Wordpress File Upload\n"
4
  "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2014-04-27 14:31+0200\n"
6
- "PO-Revision-Date: 2014-04-27 14:31+0200\n"
7
- "Last-Translator: nickboss <nickboss@iptanus.com>\n"
8
  "Language-Team: Iptanus Team <info@iptanus.com>\n"
9
  "Language: en\n"
10
  "MIME-Version: 1.0\n"
@@ -13,7 +13,7 @@ msgstr ""
13
  "X-Poedit-KeywordsList: __;gettext;gettext_noop\n"
14
  "X-Poedit-Basepath: ../\n"
15
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
16
- "X-Generator: Poedit 1.6.3\n"
17
  "X-Poedit-SearchPath-0: .\n"
18
 
19
  #: lib/wfu_constants.php:7
2
  msgstr ""
3
  "Project-Id-Version: Wordpress File Upload\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2014-11-23 01:01+0200\n"
6
+ "PO-Revision-Date: 2014-11-23 01:01+0200\n"
7
+ "Last-Translator: nickboss <info@iptanus.com>\n"
8
  "Language-Team: Iptanus Team <info@iptanus.com>\n"
9
  "Language: en\n"
10
  "MIME-Version: 1.0\n"
13
  "X-Poedit-KeywordsList: __;gettext;gettext_noop\n"
14
  "X-Poedit-Basepath: ../\n"
15
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
16
+ "X-Generator: Poedit 1.6.10\n"
17
  "X-Poedit-SearchPath-0: .\n"
18
 
19
  #: lib/wfu_constants.php:7
lib/wfu_admin.php CHANGED
@@ -1,7 +1,30 @@
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
3
  function wordpress_file_upload_add_admin_pages() {
4
- add_options_page('Wordpress File Upload', 'Wordpress File Upload', 10, 'wordpress_file_upload', 'wordpress_file_upload_manage_dashboard');
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  }
6
 
7
  function wordpress_file_upload_install() {
@@ -157,6 +180,40 @@ function wfu_manage_settings($message = '') {
157
  $echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&amp;action=shortcode_composer" class="button" title="Shortcode composer">Shortcode Composer</a>';
158
  if ( current_user_can( 'manage_options' ) ) $echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&amp;action=view_log" class="button" title="View log">View Log</a>';
159
  if ( current_user_can( 'manage_options' ) ) $echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&amp;action=sync_db" class="button" title="Update database to reflect current status of files">Sync Database</a>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
  $echo_str .= "\n\t\t".'<h3 style="margin-bottom: 10px; margin-top: 40px;">Settings</h3>';
161
  $echo_str .= "\n\t\t".'<form enctype="multipart/form-data" name="editsettings" id="editsettings" method="post" action="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&amp;action=edit_settings" class="validate">';
162
  $nonce = wp_nonce_field('wfu_edit_admin_settings', '_wpnonce', false, false);
1
  <?php
2
 
3
+ function wordpress_file_upload_admin_init() {
4
+ $uri = $_SERVER['REQUEST_URI'];
5
+ wp_register_style( 'myPluginStylesheet', plugins_url('stylesheet.css', __FILE__) );
6
+ if ( is_admin() && strpos($uri, "options-general.php") !== false ) {
7
+ wp_register_style('wordpress-file-upload-admin-style', WPFILEUPLOAD_DIR.'css/wordpress_file_upload_adminstyle.css',false,'1.0','all');
8
+ wp_register_script('wordpress_file_upload_admin_script', WPFILEUPLOAD_DIR.'js/wordpress_file_upload_adminfunctions.js', array( 'wp-color-picker' ), false, true);
9
+ wp_register_script('wordpress_file_upload_classname_script', WPFILEUPLOAD_DIR.'js/getElementsByClassName-1.0.1.js');
10
+ }
11
+ }
12
+
13
  function wordpress_file_upload_add_admin_pages() {
14
+ $page_hook_suffix = add_options_page('Wordpress File Upload', 'Wordpress File Upload', 'manage_options', 'wordpress_file_upload', 'wordpress_file_upload_manage_dashboard');
15
+ add_action('admin_print_scripts-'.$page_hook_suffix, 'wfu_enqueue_admin_scripts');
16
+ }
17
+
18
+ function wfu_enqueue_admin_scripts() {
19
+ $uri = $_SERVER['REQUEST_URI'];
20
+ if ( is_admin() && strpos($uri, "options-general.php") !== false ) {
21
+ wp_enqueue_style('wordpress-file-upload-admin-style');
22
+ wp_enqueue_style( 'wp-color-picker' );
23
+ wp_enqueue_script('wordpress_file_upload_admin_script');
24
+ wp_enqueue_script('wordpress_file_upload_classname_script');
25
+ $AdminParams = array("wfu_ajax_url" => site_url()."/wp-admin/admin-ajax.php");
26
+ wp_localize_script( 'wordpress_file_upload_admin_script', 'AdminParams', $AdminParams );
27
+ }
28
  }
29
 
30
  function wordpress_file_upload_install() {
180
  $echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&amp;action=shortcode_composer" class="button" title="Shortcode composer">Shortcode Composer</a>';
181
  if ( current_user_can( 'manage_options' ) ) $echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&amp;action=view_log" class="button" title="View log">View Log</a>';
182
  if ( current_user_can( 'manage_options' ) ) $echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&amp;action=sync_db" class="button" title="Update database to reflect current status of files">Sync Database</a>';
183
+ $echo_str .= "\n\t\t".'<h3 style="margin-bottom: 10px; margin-top: 40px;">Status</h3>';
184
+ $echo_str .= "\n\t\t".'<table class="form-table">';
185
+ $echo_str .= "\n\t\t\t".'<tbody>';
186
+ $echo_str .= "\n\t\t\t\t".'<tr class="form-field">';
187
+ $echo_str .= "\n\t\t\t\t\t".'<th scope="row">';
188
+ $echo_str .= "\n\t\t\t\t\t\t".'<label style="cursor:default;">Edition</label>';
189
+ $echo_str .= "\n\t\t\t\t\t".'</th>';
190
+ $echo_str .= "\n\t\t\t\t\t".'<td style="width:100px; vertical-align:top;">';
191
+ $echo_str .= "\n\t\t\t\t\t\t".'<label style="font-weight:bold; cursor:default;">Free</label>';
192
+ $echo_str .= "\n\t\t\t\t\t".'</td>';
193
+ $echo_str .= "\n\t\t\t\t\t".'<td>';
194
+ $echo_str .= "\n\t\t\t\t\t\t".'<div style="display:inline-block; background-color:bisque; padding:0 0 0 4px; border-left:3px solid lightcoral;">';
195
+ $echo_str .= "\n\t\t\t\t\t\t\t".'<label style="cursor:default;">Consider </label><a href="'.WFU_PRO_VERSION_URL.'">Upgrading</a><label style="cursor:default;"> to the Professional Version. </label>';
196
+ $echo_str .= "\n\t\t\t\t\t\t\t".'<button onclick="if (this.innerText == \'See why >>\') {this.innerText = \'<< Close\'; document.getElementById(\'wfu_version_comparison\').style.display = \'block\';} else {this.innerText = \'See why >>\'; document.getElementById(\'wfu_version_comparison\').style.display = \'none\';}">See why >></button>';
197
+ $echo_str .= "\n\t\t\t\t\t\t".'</div>';
198
+ $echo_str .= "\n\t\t\t\t\t\t".'<div id="wfu_version_comparison" style="display:none; background-color:lightyellow; border:1px solid yellow; margin:10px 0; padding:10px;">';
199
+ $echo_str .= "\n\t\t\t\t\t\t\t".'<img src="'.WFU_IMAGE_VERSION_COMPARISON.'" width="65%" style="display:block; margin-bottom:6px;" />';
200
+ $echo_str .= "\n\t\t\t\t\t\t\t".'<a class="button-primary" href="'.WFU_PRO_VERSION_URL.'">Go for the PRO version</a>';
201
+ $echo_str .= "\n\t\t\t\t\t\t".'</div>';
202
+ $echo_str .= "\n\t\t\t\t\t".'</td>';
203
+ $echo_str .= "\n\t\t\t\t".'</tr>';
204
+ $echo_str .= "\n\t\t\t\t".'<tr class="form-field">';
205
+ $echo_str .= "\n\t\t\t\t\t".'<th scope="row">';
206
+ $echo_str .= "\n\t\t\t\t\t\t".'<label style="cursor:default;">Version</label>';
207
+ $echo_str .= "\n\t\t\t\t\t".'</th>';
208
+ $echo_str .= "\n\t\t\t\t\t".'<td style="width:100px; vertical-align:top;">';
209
+ $cur_version = wfu_get_plugin_version();
210
+ $echo_str .= "\n\t\t\t\t\t\t".'<label style="font-weight:bold; cursor:default;">'.$cur_version.'</label>';
211
+ $echo_str .= "\n\t\t\t\t\t".'</td>';
212
+ $echo_str .= "\n\t\t\t\t\t".'<td style="vertical-align:top;">';
213
+ $echo_str .= "\n\t\t\t\t\t".'</td>';
214
+ $echo_str .= "\n\t\t\t\t".'</tr>';
215
+ $echo_str .= "\n\t\t\t".'</tbody>';
216
+ $echo_str .= "\n\t\t".'</table>';
217
  $echo_str .= "\n\t\t".'<h3 style="margin-bottom: 10px; margin-top: 40px;">Settings</h3>';
218
  $echo_str .= "\n\t\t".'<form enctype="multipart/form-data" name="editsettings" id="editsettings" method="post" action="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&amp;action=edit_settings" class="validate">';
219
  $nonce = wp_nonce_field('wfu_edit_admin_settings', '_wpnonce', false, false);
lib/wfu_admin_composer.php CHANGED
@@ -72,6 +72,7 @@ function wfu_shortcode_composer() {
72
  $governors[$dependency] = array( 'attribute' => $attr, 'active' => $subblock_active, 'inv' => '' );
73
  }
74
  //check if this attribute depends on other
 
75
  if ( $governors[$attr] != "" ) $governor = $governors[$attr];
76
  else $governor = array( 'attribute' => "independent", 'active' => true, 'inv' => '' );
77
 
@@ -143,7 +144,7 @@ function wfu_shortcode_composer() {
143
  elseif ( $def['type'] == "text" ) {
144
  $val = str_replace(array( "%n%", "%dq%", "%brl%", "%brr%" ), array( "\n", "&quot;", "[", "]" ), $def['value']);
145
  $echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" value="'.$val.'" />';
146
- if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
147
  }
148
  elseif ( $def['type'] == "placements" ) {
149
  $components_used = array();
@@ -185,7 +186,7 @@ function wfu_shortcode_composer() {
185
  elseif ( $def['type'] == "ltext" ) {
186
  $val = str_replace(array( "%n%", "%dq%", "%brl%", "%brr%" ), array( "\n", "&quot;", "[", "]" ), $def['value']);
187
  $echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" class="wfu_long_text" value="'.$val.'" />';
188
- if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
189
  }
190
  elseif ( $def['type'] == "integer" ) {
191
  $val = str_replace(array( "%n%", "%dq%", "%brl%", "%brr%" ), array( "\n", "&quot;", "[", "]" ), $def['value']);
@@ -210,15 +211,15 @@ function wfu_shortcode_composer() {
210
  else $plural = $parts[1];
211
  $echo_str .= $dlp."\t\t".'<span class="wfu_ptext_span">Singular</span><input id="wfu_attribute_s_'.$attr.'" type="text" name="wfu_ptext_elements" value="'.$singular.'" />';
212
  if ( $def['variables'] != null ) if ( count($def['variables']) > 0 ) $echo_str .= $dlp."\t\t".'<br /><span class="wfu_ptext_span">&nbsp;</span>';
213
- if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_s_'.$attr);
214
  $echo_str .= $dlp."\t\t".'<br /><span class="wfu_ptext_span">Plural</span><input id="wfu_attribute_p_'.$attr.'" type="text" name="wfu_ptext_elements" value="'.$plural.'" />';
215
  if ( $def['variables'] != null ) if ( count($def['variables']) > 0 ) $echo_str .= $dlp."\t\t".'<br /><span class="wfu_ptext_span">&nbsp;</span>';
216
- if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_p_'.$attr);
217
  }
218
  elseif ( $def['type'] == "mtext" ) {
219
  $val = str_replace(array( "%n%", "%dq%", "%brl%", "%brr%" ), array( "\n", "&quot;", "[", "]" ), $def['value']);
220
  $echo_str .= $dlp."\t\t".'<textarea id="wfu_attribute_'.$attr.'" name="wfu_text_elements" rows="5">'.$val.'</textarea>';
221
- if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
222
  }
223
  elseif ( $def['type'] == "folderlist" ) {
224
  $echo_str .= $dlp."\t\t".'<div id="wfu_subfolders_inner_shadow_'.$attr.'" class="wfu_subfolders_inner_shadow" style="display:none;"></div>';
@@ -344,8 +345,10 @@ function wfu_shortcode_composer() {
344
  $vals_arr = explode(",", $def['value']);
345
  $vals = array();
346
  foreach ( $vals_arr as $val_raw ) {
347
- list($val_id, $val) = explode(":", $val_raw);
348
- $vals[trim($val_id)] = trim($val);
 
 
349
  }
350
  $dims = array();
351
  foreach ( $components as $comp ) {
@@ -356,6 +359,7 @@ function wfu_shortcode_composer() {
356
  }
357
  }
358
  foreach ( $dims as $dim_id => $dim_name ) {
 
359
  $echo_str .= $dlp."\t\t".'<span style="display:inline-block; width:130px;">'.$dim_name.'</span><input id="wfu_attribute_'.$attr.'_'.$dim_id.'" type="text" name="wfu_dimension_elements_'.$attr.'" class="wfu_short_text" value="'.$vals[$dim_id].'" /><br />';
360
  }
361
  }
@@ -396,7 +400,7 @@ function wfu_shortcode_composer() {
396
  }
397
  else {
398
  $echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" value="'.$def['value'].'" />';
399
- if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
400
  }
401
  $echo_str .= $dlp."\t".'</div></td>';
402
  if ( $def['parent'] == "" ) {
@@ -433,8 +437,8 @@ function wfu_shortcode_composer() {
433
  function wfu_insert_variables($variables, $class) {
434
  $ret = "";
435
  foreach ( $variables as $variable )
436
- if ( $variable == "%userdataXXX%" ) $ret .= $dlp."\t\t".'<select class="'.$class.'" name="wfu_userfield_select" title="'.constant("WFU_VARIABLE_TITLE_".strtoupper(str_replace("%", "", $variable))).'" onchange="wfu_insert_userfield_variable(this);"><option style="display:none;">%userdataXXX%</option></select>';
437
- elseif ( $variable != "%n%" && $variable != "%dq%" && $variable != "%brl%" && $variable != "%brr%" ) $ret .= $dlp."\t\t".'<span class="'.$class.'" title="'.constant("WFU_VARIABLE_TITLE_".strtoupper(str_replace("%", "", $variable))).'" ondblclick="wfu_insert_variable(this);">'.$variable.'</span>';
438
  return $ret;
439
  }
440
 
72
  $governors[$dependency] = array( 'attribute' => $attr, 'active' => $subblock_active, 'inv' => '' );
73
  }
74
  //check if this attribute depends on other
75
+ if ( !array_key_exists($attr, $governors) ) $governors[$attr] = "";
76
  if ( $governors[$attr] != "" ) $governor = $governors[$attr];
77
  else $governor = array( 'attribute' => "independent", 'active' => true, 'inv' => '' );
78
 
144
  elseif ( $def['type'] == "text" ) {
145
  $val = str_replace(array( "%n%", "%dq%", "%brl%", "%brr%" ), array( "\n", "&quot;", "[", "]" ), $def['value']);
146
  $echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" value="'.$val.'" />';
147
+ if ( $def['variables'] != null ) $echo_str .= $dlp.wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
148
  }
149
  elseif ( $def['type'] == "placements" ) {
150
  $components_used = array();
186
  elseif ( $def['type'] == "ltext" ) {
187
  $val = str_replace(array( "%n%", "%dq%", "%brl%", "%brr%" ), array( "\n", "&quot;", "[", "]" ), $def['value']);
188
  $echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" class="wfu_long_text" value="'.$val.'" />';
189
+ if ( $def['variables'] != null ) $echo_str .= $dlp.wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
190
  }
191
  elseif ( $def['type'] == "integer" ) {
192
  $val = str_replace(array( "%n%", "%dq%", "%brl%", "%brr%" ), array( "\n", "&quot;", "[", "]" ), $def['value']);
211
  else $plural = $parts[1];
212
  $echo_str .= $dlp."\t\t".'<span class="wfu_ptext_span">Singular</span><input id="wfu_attribute_s_'.$attr.'" type="text" name="wfu_ptext_elements" value="'.$singular.'" />';
213
  if ( $def['variables'] != null ) if ( count($def['variables']) > 0 ) $echo_str .= $dlp."\t\t".'<br /><span class="wfu_ptext_span">&nbsp;</span>';
214
+ if ( $def['variables'] != null ) $echo_str .= $dlp.wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_s_'.$attr);
215
  $echo_str .= $dlp."\t\t".'<br /><span class="wfu_ptext_span">Plural</span><input id="wfu_attribute_p_'.$attr.'" type="text" name="wfu_ptext_elements" value="'.$plural.'" />';
216
  if ( $def['variables'] != null ) if ( count($def['variables']) > 0 ) $echo_str .= $dlp."\t\t".'<br /><span class="wfu_ptext_span">&nbsp;</span>';
217
+ if ( $def['variables'] != null ) $echo_str .= $dlp.wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_p_'.$attr, $dlp);
218
  }
219
  elseif ( $def['type'] == "mtext" ) {
220
  $val = str_replace(array( "%n%", "%dq%", "%brl%", "%brr%" ), array( "\n", "&quot;", "[", "]" ), $def['value']);
221
  $echo_str .= $dlp."\t\t".'<textarea id="wfu_attribute_'.$attr.'" name="wfu_text_elements" rows="5">'.$val.'</textarea>';
222
+ if ( $def['variables'] != null ) $echo_str .= $dlp.wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
223
  }
224
  elseif ( $def['type'] == "folderlist" ) {
225
  $echo_str .= $dlp."\t\t".'<div id="wfu_subfolders_inner_shadow_'.$attr.'" class="wfu_subfolders_inner_shadow" style="display:none;"></div>';
345
  $vals_arr = explode(",", $def['value']);
346
  $vals = array();
347
  foreach ( $vals_arr as $val_raw ) {
348
+ if ( trim($val_raw) != "" ) {
349
+ list($val_id, $val) = explode(":", $val_raw);
350
+ $vals[trim($val_id)] = trim($val);
351
+ }
352
  }
353
  $dims = array();
354
  foreach ( $components as $comp ) {
359
  }
360
  }
361
  foreach ( $dims as $dim_id => $dim_name ) {
362
+ if ( !array_key_exists($dim_id, $vals) ) $vals[$dim_id] = "";
363
  $echo_str .= $dlp."\t\t".'<span style="display:inline-block; width:130px;">'.$dim_name.'</span><input id="wfu_attribute_'.$attr.'_'.$dim_id.'" type="text" name="wfu_dimension_elements_'.$attr.'" class="wfu_short_text" value="'.$vals[$dim_id].'" /><br />';
364
  }
365
  }
400
  }
401
  else {
402
  $echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" value="'.$def['value'].'" />';
403
+ if ( $def['variables'] != null ) $echo_str .= $dlp.wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
404
  }
405
  $echo_str .= $dlp."\t".'</div></td>';
406
  if ( $def['parent'] == "" ) {
437
  function wfu_insert_variables($variables, $class) {
438
  $ret = "";
439
  foreach ( $variables as $variable )
440
+ if ( $variable == "%userdataXXX%" ) $ret .= "\t\t".'<select class="'.$class.'" name="wfu_userfield_select" title="'.constant("WFU_VARIABLE_TITLE_".strtoupper(str_replace("%", "", $variable))).'" onchange="wfu_insert_userfield_variable(this);"><option style="display:none;">%userdataXXX%</option></select>';
441
+ elseif ( $variable != "%n%" && $variable != "%dq%" && $variable != "%brl%" && $variable != "%brr%" ) $ret .= "\t\t".'<span class="'.$class.'" title="'.constant("WFU_VARIABLE_TITLE_".strtoupper(str_replace("%", "", $variable))).'" ondblclick="wfu_insert_variable(this);">'.$variable.'</span>';
442
  return $ret;
443
  }
444
 
lib/wfu_attributes.php CHANGED
@@ -571,7 +571,7 @@ function wfu_attribute_definitions() {
571
  "subcategory" => "Email Notifications",
572
  "parent" => "notify",
573
  "dependencies" => null,
574
- "variables" => array("%username%", "%useremail%", "%filename%", "%filepath%", "%userdataXXX%"),
575
  "help" => "Defines the email subject. Can be dynamic by using variables. Please check Documentation on how to use variables in atributes."
576
  ),
577
  array(
@@ -585,7 +585,7 @@ function wfu_attribute_definitions() {
585
  "subcategory" => "Email Notifications",
586
  "parent" => "notify",
587
  "dependencies" => null,
588
- "variables" => array("%username%", "%useremail%", "%filename%", "%filepath%", "%userdataXXX%", "%n%", "%dq%"),
589
  "help" => "Defines the email body. Can be dynamic by using variables. Please check Documentation on how to use variables in atributes."
590
  ),
591
  array(
571
  "subcategory" => "Email Notifications",
572
  "parent" => "notify",
573
  "dependencies" => null,
574
+ "variables" => array("%username%", "%useremail%", "%filename%", "%filepath%", "%blogid%", "%pageid%", "%pagetitle%", "%userdataXXX%", "%dq%"),
575
  "help" => "Defines the email subject. Can be dynamic by using variables. Please check Documentation on how to use variables in atributes."
576
  ),
577
  array(
585
  "subcategory" => "Email Notifications",
586
  "parent" => "notify",
587
  "dependencies" => null,
588
+ "variables" => array("%username%", "%useremail%", "%filename%", "%filepath%", "%blogid%", "%pageid%", "%pagetitle%", "%userdataXXX%", "%n%", "%dq%"),
589
  "help" => "Defines the email body. Can be dynamic by using variables. Please check Documentation on how to use variables in atributes."
590
  ),
591
  array(
lib/wfu_constants.php CHANGED
@@ -149,6 +149,7 @@ DEFINE("WFU_UPLOAD_STATE11", __("please wait while redirecting...", "wordpress-f
149
  DEFINE("WFU_MAX_TIME_LIMIT", ini_get("max_input_time"));
150
  DEFINE("WFU_RESPONSE_URL", $siteurl.WPFILEUPLOAD_DIR."wfu_response.php");
151
  DEFINE("WFU_AJAX_URL", $siteurl."/wp-admin/admin-ajax.php");
 
152
 
153
  //define colors
154
  DEFINE("WFU_TESTMESSAGECOLORS", "#666666,#EEEEEE,#333333");
@@ -176,6 +177,7 @@ DEFINE("WFU_IMAGE_ADMIN_SUBFOLDER_OK", $siteurl.WPFILEUPLOAD_DIR.'images/ok_12.g
176
  DEFINE("WFU_IMAGE_ADMIN_SUBFOLDER_CANCEL", $siteurl.WPFILEUPLOAD_DIR.'images/cancel_12.gif');
177
  DEFINE("WFU_IMAGE_ADMIN_SUBFOLDER_LOADING", $siteurl.WPFILEUPLOAD_DIR.'images/refresh_16.gif');
178
  DEFINE("WFU_IMAGE_SIMPLE_PROGBAR", $siteurl.WPFILEUPLOAD_DIR.'images/progbar.gif');
 
179
 
180
  function wfu_set_javascript_constants() {
181
  $consts = array(
149
  DEFINE("WFU_MAX_TIME_LIMIT", ini_get("max_input_time"));
150
  DEFINE("WFU_RESPONSE_URL", $siteurl.WPFILEUPLOAD_DIR."wfu_response.php");
151
  DEFINE("WFU_AJAX_URL", $siteurl."/wp-admin/admin-ajax.php");
152
+ DEFINE("WFU_PRO_VERSION_URL", 'http://www.iptanus.com/product/wordpress-file-upload-pro/');
153
 
154
  //define colors
155
  DEFINE("WFU_TESTMESSAGECOLORS", "#666666,#EEEEEE,#333333");
177
  DEFINE("WFU_IMAGE_ADMIN_SUBFOLDER_CANCEL", $siteurl.WPFILEUPLOAD_DIR.'images/cancel_12.gif');
178
  DEFINE("WFU_IMAGE_ADMIN_SUBFOLDER_LOADING", $siteurl.WPFILEUPLOAD_DIR.'images/refresh_16.gif');
179
  DEFINE("WFU_IMAGE_SIMPLE_PROGBAR", $siteurl.WPFILEUPLOAD_DIR.'images/progbar.gif');
180
+ DEFINE("WFU_IMAGE_VERSION_COMPARISON", $siteurl.WPFILEUPLOAD_DIR.'images/Version Comparison.png');
181
 
182
  function wfu_set_javascript_constants() {
183
  $consts = array(
lib/wfu_functions.php CHANGED
@@ -136,8 +136,8 @@ function wfu_shortcode_string_to_array($shortcode) {
136
  }
137
  else {
138
  $ret['items'][$ii] = substr($contents, $prev_pos, $pos - $prev_pos);
139
- $ret['tokens'][$ii] = $token.$ii;
140
- $new_contents .= $token.$ii.'"';
141
  $ii ++;
142
  $in_block = false;
143
  }
@@ -145,8 +145,8 @@ function wfu_shortcode_string_to_array($shortcode) {
145
  }
146
  if ( $in_block ) {
147
  $ret['items'][$ii] = substr($contents, $prev_pos);
148
- $ret['tokens'][$ii] = $token.$ii;
149
- $new_contents .= $token.$ii.'"';
150
  }
151
  else
152
  $new_contents .= substr($contents, $prev_pos);
@@ -237,6 +237,12 @@ function wfu_decode_plugin_options($encoded_options) {
237
  return $plugin_options;
238
  }
239
 
 
 
 
 
 
 
240
  //********************* Directory Functions ************************************************************************************************
241
 
242
  function wfu_upload_plugin_full_path( $params ) {
136
  }
137
  else {
138
  $ret['items'][$ii] = substr($contents, $prev_pos, $pos - $prev_pos);
139
+ $ret['tokens'][$ii] = $token.sprintf('%03d', $ii);
140
+ $new_contents .= $token.sprintf('%03d', $ii).'"';
141
  $ii ++;
142
  $in_block = false;
143
  }
145
  }
146
  if ( $in_block ) {
147
  $ret['items'][$ii] = substr($contents, $prev_pos);
148
+ $ret['tokens'][$ii] = $token.sprintf('%03d', $ii);
149
+ $new_contents .= $token.sprintf('%03d', $ii).'"';
150
  }
151
  else
152
  $new_contents .= substr($contents, $prev_pos);
237
  return $plugin_options;
238
  }
239
 
240
+ function wfu_get_plugin_version() {
241
+ $plugin_data = get_plugin_data(WPFILEUPLOAD_PLUGINFILE);
242
+ return $plugin_data['Version'];
243
+ }
244
+
245
+
246
  //********************* Directory Functions ************************************************************************************************
247
 
248
  function wfu_upload_plugin_full_path( $params ) {
lib/wfu_processfiles.php CHANGED
@@ -26,6 +26,9 @@ function wfu_process_files($params, $method) {
26
  $uploadedfile = 'uploadedfile_'.$sid;
27
  $hiddeninput = 'hiddeninput_'.$sid;
28
  $allowed_patterns = explode(",",$params["uploadpatterns"]);
 
 
 
29
  $userdata_fields = $params["userdata_fields"];
30
  foreach ( $userdata_fields as $userdata_key => $userdata_field )
31
  $userdata_fields[$userdata_key]["value"] = ( isset($_POST[$hiddeninput.'_userdata_'.$userdata_key]) ? $_POST[$hiddeninput.'_userdata_'.$userdata_key] : "" );
26
  $uploadedfile = 'uploadedfile_'.$sid;
27
  $hiddeninput = 'hiddeninput_'.$sid;
28
  $allowed_patterns = explode(",",$params["uploadpatterns"]);
29
+ foreach ($allowed_patterns as $key => $allowed_pattern) {
30
+ $allowed_patterns[$key] = trim($allowed_pattern);
31
+ }
32
  $userdata_fields = $params["userdata_fields"];
33
  foreach ( $userdata_fields as $userdata_key => $userdata_field )
34
  $userdata_fields[$userdata_key]["value"] = ( isset($_POST[$hiddeninput.'_userdata_'.$userdata_key]) ? $_POST[$hiddeninput.'_userdata_'.$userdata_key] : "" );
readme.txt CHANGED
@@ -110,6 +110,13 @@ Administrators can view and manage the uploaded files from the File Browser that
110
 
111
  == Changelog ==
112
 
 
 
 
 
 
 
 
113
  = 2.4.5 =
114
  * correction of bug when using userfields inside notifyrecipients
115
 
@@ -319,6 +326,9 @@ Initial version.
319
 
320
  == Upgrade Notice ==
321
 
 
 
 
322
  = 2.4.5 =
323
  Minor upgrade to address some bugs.
324
 
@@ -598,10 +608,10 @@ For the time being, the following variables are supported:
598
  * **%useremail%:** Is replaced by the email of the current user. Can be used inside attributes *notifyrecipients*, *notifysubject* and *notifymessage*.
599
  * **%filename%:** Is replaced by the filename (not including path information) of the uploaded file. Can be used inside attributes *notifysubject*, *notifymessage*, *successmessage* and *redirectlink*.
600
  * **%filepath%:** Is replaced by the filepath (full path and filename) of the uploaded file. Can be used inside attributes *notifysubject*, *notifymessage* and *successmessage*.
601
- * **%blogid%:** Is replaced by the blog_id of the current site. Can be used inside attribute *uploadpath*.
602
  * **%userdataXXX%:** Is replaced by the additional message that the user has sent together with the file upload. XXX is the number of the field (starting from 0). The shortcode attribute userdata must have been set to "true". Can be used inside attributes *uploadpath*, *notifysubject*, *notifymessage* and *notifyrecipients*.
603
- * **%pagetitle%:** Is replaced by the title of the current page. Can be used inside attribute *uploadpath*.
604
- * **%pageid%:** Is replaced by the id of the current page. Can be used inside attribute *uploadpath*.
605
 
606
  In addition, some special variables, which are used to replace literals not allowed in shortcodes (such as double quotes or brackets), are also supported. They can be used in attributes that receive free text (like button labels, email notification body etc.). These special variables are:
607
 
110
 
111
  == Changelog ==
112
 
113
+ = 2.4.6 =
114
+ * variables %blogid%, %pageid% and %pagetitle% added in email notifications and subject and %dq% in subject
115
+ * corrected bug that was breaking Shortcode Composer when using more than ten attributes
116
+ * corrected bug that was rejecting file uploads when uploadpattern attribute contained blank spaces
117
+ * several code corrections in order to eliminate PHP warning messages when DEBUG mode is on
118
+ * several code corrections in order to eliminate warning messages in Javascript
119
+
120
  = 2.4.5 =
121
  * correction of bug when using userfields inside notifyrecipients
122
 
326
 
327
  == Upgrade Notice ==
328
 
329
+ = 2.4.6 =
330
+ Important upgrade to address some bugs.
331
+
332
  = 2.4.5 =
333
  Minor upgrade to address some bugs.
334
 
608
  * **%useremail%:** Is replaced by the email of the current user. Can be used inside attributes *notifyrecipients*, *notifysubject* and *notifymessage*.
609
  * **%filename%:** Is replaced by the filename (not including path information) of the uploaded file. Can be used inside attributes *notifysubject*, *notifymessage*, *successmessage* and *redirectlink*.
610
  * **%filepath%:** Is replaced by the filepath (full path and filename) of the uploaded file. Can be used inside attributes *notifysubject*, *notifymessage* and *successmessage*.
611
+ * **%blogid%:** Is replaced by the blog_id of the current site. Can be used inside attribute *uploadpath*, *notifysubject* and *notifymessage*.
612
  * **%userdataXXX%:** Is replaced by the additional message that the user has sent together with the file upload. XXX is the number of the field (starting from 0). The shortcode attribute userdata must have been set to "true". Can be used inside attributes *uploadpath*, *notifysubject*, *notifymessage* and *notifyrecipients*.
613
+ * **%pagetitle%:** Is replaced by the title of the current page. Can be used inside attribute *uploadpath*, *notifysubject* and *notifymessage*.
614
+ * **%pageid%:** Is replaced by the id of the current page. Can be used inside attribute *uploadpath*, *notifysubject* and *notifymessage*.
615
 
616
  In addition, some special variables, which are used to replace literals not allowed in shortcodes (such as double quotes or brackets), are also supported. They can be used in attributes that receive free text (like button labels, email notification body etc.). These special variables are:
617
 
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.4.5
8
  Author: Nickolas Bossinas
9
  Author URI: http://www.iptanus.com
10
  */
@@ -36,27 +36,15 @@ $wfu_tb_userdata_version = "1.0";
36
  $uri = $_SERVER['REQUEST_URI'];
37
  if ( strpos($uri, 'wp-login.php') !== false ) return;
38
 
 
39
  DEFINE("WPFILEUPLOAD_DIR", '/'.PLUGINDIR .'/'.dirname(plugin_basename (__FILE__)).'/');
40
  add_shortcode("wordpress_file_upload", "wordpress_file_upload_handler");
41
  load_plugin_textdomain('wordpress-file-upload', false, dirname(plugin_basename (__FILE__)).'/languages');
42
- /* do not load styles and scripts in admin pages */
43
- if ( is_admin() ) {
44
- if ( strpos($uri, "options-general.php") !== false ) {
45
- wp_enqueue_style('wordpress-file-upload-admin-style', WPFILEUPLOAD_DIR.'css/wordpress_file_upload_adminstyle.css',false,'1.0','all');
46
- wp_enqueue_style( 'wp-color-picker' );
47
- wp_enqueue_script('wordpress_file_upload_admin_script', WPFILEUPLOAD_DIR.'js/wordpress_file_upload_adminfunctions.js', array( 'wp-color-picker' ), false, true);
48
- wp_enqueue_script('wordpress_file_upload_classname_script', WPFILEUPLOAD_DIR.'js/getElementsByClassName-1.0.1.js');
49
- $AdminParams = array("wfu_ajax_url" => site_url()."/wp-admin/admin-ajax.php");
50
- wp_localize_script( 'wordpress_file_upload_admin_script', 'AdminParams', $AdminParams );
51
- }
52
- }
53
- else {
54
- // wp_enqueue_style('wordpress-file-upload-reset', WPFILEUPLOAD_DIR.'css/wordpress_file_upload_reset.css',false,'1.0','all');
55
- wp_enqueue_style('wordpress-file-upload-style', WPFILEUPLOAD_DIR.'css/wordpress_file_upload_style.css',false,'1.0','all');
56
- wp_enqueue_style('wordpress-file-upload-style-safe', WPFILEUPLOAD_DIR.'css/wordpress_file_upload_style_safe.css',false,'1.0','all');
57
- wp_enqueue_script('json_class', WPFILEUPLOAD_DIR.'js/json2.js');
58
- wp_enqueue_script('wordpress_file_upload_script', WPFILEUPLOAD_DIR.'js/wordpress_file_upload_functions.js');
59
  }
 
60
  add_action('admin_menu', 'wordpress_file_upload_add_admin_pages');
61
  register_activation_hook(__FILE__,'wordpress_file_upload_install');
62
  add_action('plugins_loaded', 'wordpress_file_upload_update_db_check');
@@ -72,6 +60,14 @@ add_action('wp_ajax_wfu_ajax_action_read_subfolders', 'wfu_ajax_action_read_subf
72
  add_action('wp_ajax_wfu_ajax_action_download_file', 'wfu_ajax_action_download_file');
73
  wfu_include_lib();
74
 
 
 
 
 
 
 
 
 
75
  function wfu_include_lib() {
76
  if ( $handle = opendir(plugin_dir_path( __FILE__ )."lib/") ) {
77
  $blacklist = array('.', '..');
@@ -80,6 +76,9 @@ function wfu_include_lib() {
80
  include_once plugin_dir_path( __FILE__ )."lib/".$file;
81
  closedir($handle);
82
  }
 
 
 
83
  }
84
 
85
  /* exit if we are in admin pages (in case of ajax call) */
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.4.6
8
  Author: Nickolas Bossinas
9
  Author URI: http://www.iptanus.com
10
  */
36
  $uri = $_SERVER['REQUEST_URI'];
37
  if ( strpos($uri, 'wp-login.php') !== false ) return;
38
 
39
+ DEFINE("WPFILEUPLOAD_PLUGINFILE", __FILE__);
40
  DEFINE("WPFILEUPLOAD_DIR", '/'.PLUGINDIR .'/'.dirname(plugin_basename (__FILE__)).'/');
41
  add_shortcode("wordpress_file_upload", "wordpress_file_upload_handler");
42
  load_plugin_textdomain('wordpress-file-upload', false, dirname(plugin_basename (__FILE__)).'/languages');
43
+ /* load styles and scripts for front pages */
44
+ if ( !is_admin() ) {
45
+ add_action( 'wp_enqueue_scripts', 'wfu_enqueue_frontpage_scripts' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  }
47
+ add_action('admin_init', 'wordpress_file_upload_admin_init');
48
  add_action('admin_menu', 'wordpress_file_upload_add_admin_pages');
49
  register_activation_hook(__FILE__,'wordpress_file_upload_install');
50
  add_action('plugins_loaded', 'wordpress_file_upload_update_db_check');
60
  add_action('wp_ajax_wfu_ajax_action_download_file', 'wfu_ajax_action_download_file');
61
  wfu_include_lib();
62
 
63
+ function wfu_enqueue_frontpage_scripts() {
64
+ // wp_enqueue_style('wordpress-file-upload-reset', WPFILEUPLOAD_DIR.'css/wordpress_file_upload_reset.css',false,'1.0','all');
65
+ wp_enqueue_style('wordpress-file-upload-style', WPFILEUPLOAD_DIR.'css/wordpress_file_upload_style.css',false,'1.0','all');
66
+ wp_enqueue_style('wordpress-file-upload-style-safe', WPFILEUPLOAD_DIR.'css/wordpress_file_upload_style_safe.css',false,'1.0','all');
67
+ wp_enqueue_script('json_class', WPFILEUPLOAD_DIR.'js/json2.js');
68
+ wp_enqueue_script('wordpress_file_upload_script', WPFILEUPLOAD_DIR.'js/wordpress_file_upload_functions.js');
69
+ }
70
+
71
  function wfu_include_lib() {
72
  if ( $handle = opendir(plugin_dir_path( __FILE__ )."lib/") ) {
73
  $blacklist = array('.', '..');
76
  include_once plugin_dir_path( __FILE__ )."lib/".$file;
77
  closedir($handle);
78
  }
79
+ if ( $handle = opendir(plugin_dir_path( __FILE__ )) ) {
80
+ closedir($handle);
81
+ }
82
  }
83
 
84
  /* exit if we are in admin pages (in case of ajax call) */