Contact Form 7 - Version 5.0.1

Version Description

  • Fixed incorrect uses of _n().
  • Config validation: Fixed incorrect count of alerts in the Additional Settings tab panel.
  • Config validation: Fixed improper treatment for the [_site_admin_email] special mail-tag in the From mail header field.
  • Acceptance checkbox: The class and id attributes specified were applied to the wrong HTML element.
  • Config validation: When there is an additional mail header for mailboxes like Cc or Reply-To, but it has a possible empty value, Invalid mailbox syntax is used error will be returned.
  • Explicitly specify the fourth parameter of add_action() to avoid passing unintended parameter values.
  • Check if the target directory is empty before removing the directory.
Download this release

Release Info

Developer takayukister
Plugin Icon 128x128 Contact Form 7
Version 5.0.1
Comparing to
See all releases

Code changes from version 5.0 to 5.0.1

admin/admin.php CHANGED
@@ -522,7 +522,7 @@ function wpcf7_admin_updated_message() {
522
  $updated_message = sprintf(
523
  /* translators: %s: number of contact forms */
524
  _n(
525
- "Configuration validation completed. An invalid contact form was found.",
526
  "Configuration validation completed. %s invalid contact forms were found.",
527
  $count_invalid, 'contact-form-7' ),
528
  number_format_i18n( $count_invalid ) );
522
  $updated_message = sprintf(
523
  /* translators: %s: number of contact forms */
524
  _n(
525
+ "Configuration validation completed. %s invalid contact form was found.",
526
  "Configuration validation completed. %s invalid contact forms were found.",
527
  $count_invalid, 'contact-form-7' ),
528
  number_format_i18n( $count_invalid ) );
admin/js/scripts.js CHANGED
@@ -213,7 +213,7 @@
213
 
214
  if ( 1 < errorCount[ tab.replace( '-', '_' ) ] ) {
215
  var manyErrorsInTab = wpcf7.configValidator.manyErrorsInTab
216
- .replace( '%d', errorCount[ tab ] );
217
  $tabPanelError.append( manyErrorsInTab );
218
  } else {
219
  $tabPanelError.append( wpcf7.configValidator.oneErrorInTab );
213
 
214
  if ( 1 < errorCount[ tab.replace( '-', '_' ) ] ) {
215
  var manyErrorsInTab = wpcf7.configValidator.manyErrorsInTab
216
+ .replace( '%d', errorCount[ tab.replace( '-', '_' ) ] );
217
  $tabPanelError.append( manyErrorsInTab );
218
  } else {
219
  $tabPanelError.append( wpcf7.configValidator.oneErrorInTab );
includes/config-validator.php CHANGED
@@ -285,7 +285,10 @@ class WPCF7_ConfigValidator {
285
  // for back-compat
286
  $field_name = preg_replace( '/^wpcf7\./', '_', $field_name );
287
 
288
- if ( '_user_agent' == $field_name ) {
 
 
 
289
  return $example_text;
290
 
291
  } elseif ( '_user_email' == $field_name ) {
@@ -384,11 +387,9 @@ class WPCF7_ConfigValidator {
384
  return $this->add_error( $section,
385
  self::error_unavailable_names,
386
  array(
387
- /* translators: %names%: a list of form control names */
388
- 'message' => _n(
389
- "An unavailable name (%names%) is used for form controls.",
390
- "Unavailable names (%names%) are used for form controls.",
391
- count( $ng_names ), 'contact-form-7' ),
392
  'params' => array( 'names' => implode( ', ', $ng_names ) ),
393
  'link' => self::get_doc_link( 'unavailable_names' ),
394
  )
@@ -466,11 +467,11 @@ class WPCF7_ConfigValidator {
466
  continue;
467
  }
468
 
469
- if ( ! preg_match( '/^([0-9A-Za-z-]+):(.+)$/', $header, $matches ) ) {
470
  $invalid_mail_header_exists = true;
471
  } else {
472
  $header_name = $matches[1];
473
- $header_value = $matches[2];
474
 
475
  if ( in_array( strtolower( $header_name ), $mailbox_header_types ) ) {
476
  $this->detect_invalid_mailbox_syntax(
@@ -479,6 +480,8 @@ class WPCF7_ConfigValidator {
479
  'message' =>
480
  __( "Invalid mailbox syntax is used in the %name% field.", 'contact-form-7' ),
481
  'params' => array( 'name' => $header_name ) ) );
 
 
482
  }
483
  }
484
  }
285
  // for back-compat
286
  $field_name = preg_replace( '/^wpcf7\./', '_', $field_name );
287
 
288
+ if ( '_site_admin_email' == $field_name ) {
289
+ return get_bloginfo( 'admin_email', 'raw' );
290
+
291
+ } elseif ( '_user_agent' == $field_name ) {
292
  return $example_text;
293
 
294
  } elseif ( '_user_email' == $field_name ) {
387
  return $this->add_error( $section,
388
  self::error_unavailable_names,
389
  array(
390
+ 'message' =>
391
+ /* translators: %names%: a list of form control names */
392
+ __( "Unavailable names (%names%) are used for form controls.", 'contact-form-7' ),
 
 
393
  'params' => array( 'names' => implode( ', ', $ng_names ) ),
394
  'link' => self::get_doc_link( 'unavailable_names' ),
395
  )
467
  continue;
468
  }
469
 
470
+ if ( ! preg_match( '/^([0-9A-Za-z-]+):(.*)$/', $header, $matches ) ) {
471
  $invalid_mail_header_exists = true;
472
  } else {
473
  $header_name = $matches[1];
474
+ $header_value = trim( $matches[2] );
475
 
476
  if ( in_array( strtolower( $header_name ), $mailbox_header_types ) ) {
477
  $this->detect_invalid_mailbox_syntax(
480
  'message' =>
481
  __( "Invalid mailbox syntax is used in the %name% field.", 'contact-form-7' ),
482
  'params' => array( 'name' => $header_name ) ) );
483
+ } elseif ( empty( $header_value ) ) {
484
+ $invalid_mail_header_exists = true;
485
  }
486
  }
487
  }
includes/functions.php CHANGED
@@ -282,7 +282,12 @@ function wpcf7_rmdir_p( $dir ) {
282
  closedir( $handle );
283
  }
284
 
285
- return rmdir( $dir );
 
 
 
 
 
286
  }
287
 
288
  /* From _http_build_query in wp-includes/functions.php */
282
  closedir( $handle );
283
  }
284
 
285
+ if ( false !== ( $files = scandir( $dir ) )
286
+ && ! array_diff( $files, array( '.', '..' ) ) ) {
287
+ return rmdir( $dir );
288
+ }
289
+
290
+ return false;
291
  }
292
 
293
  /* From _http_build_query in wp-includes/functions.php */
includes/submission.php CHANGED
@@ -383,7 +383,13 @@ class WPCF7_Submission {
383
  public function remove_uploaded_files() {
384
  foreach ( (array) $this->uploaded_files as $name => $path ) {
385
  wpcf7_rmdir_p( $path );
386
- rmdir( dirname( $path ) ); // remove parent dir if it's removable (empty).
 
 
 
 
 
 
387
  }
388
  }
389
 
383
  public function remove_uploaded_files() {
384
  foreach ( (array) $this->uploaded_files as $name => $path ) {
385
  wpcf7_rmdir_p( $path );
386
+
387
+ if ( ( $dir = dirname( $path ) )
388
+ && false !== ( $files = scandir( $dir ) )
389
+ && ! array_diff( $files, array( '.', '..' ) ) ) {
390
+ // remove parent dir if it's empty.
391
+ rmdir( $dir );
392
+ }
393
  }
394
  }
395
 
modules/acceptance.php CHANGED
@@ -38,7 +38,11 @@ function wpcf7_acceptance_form_tag_handler( $tag ) {
38
  $class .= ' optional';
39
  }
40
 
41
- $atts = $item_atts = array();
 
 
 
 
42
 
43
  $item_atts['type'] = 'checkbox';
44
  $item_atts['name'] = $tag->name;
@@ -50,6 +54,9 @@ function wpcf7_acceptance_form_tag_handler( $tag ) {
50
  $item_atts['checked'] = 'checked';
51
  }
52
 
 
 
 
53
  $item_atts = wpcf7_format_atts( $item_atts );
54
 
55
  $content = empty( $tag->content )
@@ -68,8 +75,6 @@ function wpcf7_acceptance_form_tag_handler( $tag ) {
68
  $item_atts );
69
  }
70
 
71
- $atts['class'] = $tag->get_class_option( $class );
72
- $atts['id'] = $tag->get_id_option();
73
  $atts = wpcf7_format_atts( $atts );
74
 
75
  $html = sprintf(
38
  $class .= ' optional';
39
  }
40
 
41
+ $atts = array(
42
+ 'class' => trim( $class ),
43
+ );
44
+
45
+ $item_atts = array();
46
 
47
  $item_atts['type'] = 'checkbox';
48
  $item_atts['name'] = $tag->name;
54
  $item_atts['checked'] = 'checked';
55
  }
56
 
57
+ $item_atts['class'] = $tag->get_class_option();
58
+ $item_atts['id'] = $tag->get_id_option();
59
+
60
  $item_atts = wpcf7_format_atts( $item_atts );
61
 
62
  $content = empty( $tag->content )
75
  $item_atts );
76
  }
77
 
 
 
78
  $atts = wpcf7_format_atts( $atts );
79
 
80
  $html = sprintf(
modules/file.php CHANGED
@@ -409,7 +409,7 @@ function wpcf7_upload_tmp_dir() {
409
  }
410
  }
411
 
412
- add_action( 'template_redirect', 'wpcf7_cleanup_upload_files', 20 );
413
 
414
  function wpcf7_cleanup_upload_files( $seconds = 60, $max = 100 ) {
415
  if ( is_admin() || 'GET' != $_SERVER['REQUEST_METHOD']
409
  }
410
  }
411
 
412
+ add_action( 'template_redirect', 'wpcf7_cleanup_upload_files', 20, 0 );
413
 
414
  function wpcf7_cleanup_upload_files( $seconds = 60, $max = 100 ) {
415
  if ( is_admin() || 'GET' != $_SERVER['REQUEST_METHOD']
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: takayukister
3
  Donate link: https://contactform7.com/donate/
4
  Tags: contact, form, contact form, feedback, email, ajax, captcha, akismet, multilingual
5
  Requires at least: 4.8
6
- Tested up to: 4.9.2
7
- Stable tag: 5.0
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -60,6 +60,16 @@ Do you have questions or issues with Contact Form 7? Use these support channels
60
 
61
  For more information, see [Releases](https://contactform7.com/category/releases/).
62
 
 
 
 
 
 
 
 
 
 
 
63
  = 5.0 =
64
 
65
  * Additional settings: on_sent_ok and on_submit have been removed.
3
  Donate link: https://contactform7.com/donate/
4
  Tags: contact, form, contact form, feedback, email, ajax, captcha, akismet, multilingual
5
  Requires at least: 4.8
6
+ Tested up to: 4.9
7
+ Stable tag: 5.0.1
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
 
60
 
61
  For more information, see [Releases](https://contactform7.com/category/releases/).
62
 
63
+ = 5.0.1 =
64
+
65
+ * Fixed incorrect uses of _n().
66
+ * Config validation: Fixed incorrect count of alerts in the Additional Settings tab panel.
67
+ * Config validation: Fixed improper treatment for the [_site_admin_email] special mail-tag in the From mail header field.
68
+ * Acceptance checkbox: The class and id attributes specified were applied to the wrong HTML element.
69
+ * Config validation: When there is an additional mail header for mailboxes like Cc or Reply-To, but it has a possible empty value, “Invalid mailbox syntax is used” error will be returned.
70
+ * Explicitly specify the fourth parameter of add_action() to avoid passing unintended parameter values.
71
+ * Check if the target directory is empty before removing the directory.
72
+
73
  = 5.0 =
74
 
75
  * Additional settings: on_sent_ok and on_submit have been removed.
wp-contact-form-7.php CHANGED
@@ -7,10 +7,10 @@ Author: Takayuki Miyoshi
7
  Author URI: https://ideasilo.wordpress.com/
8
  Text Domain: contact-form-7
9
  Domain Path: /languages/
10
- Version: 5.0
11
  */
12
 
13
- define( 'WPCF7_VERSION', '5.0' );
14
 
15
  define( 'WPCF7_REQUIRED_WP_VERSION', '4.8' );
16
 
7
  Author URI: https://ideasilo.wordpress.com/
8
  Text Domain: contact-form-7
9
  Domain Path: /languages/
10
+ Version: 5.0.1
11
  */
12
 
13
+ define( 'WPCF7_VERSION', '5.0.1' );
14
 
15
  define( 'WPCF7_REQUIRED_WP_VERSION', '4.8' );
16