Contact Form 7 - Version 4.7

Version Description

  • Added REST API custom endpoints to manipulate contact form data.
  • Config Validator: Added test items for field names and attachment file paths.
  • Added custom DOM events: wpcf7invalid, wpcf7spam, wpcf7mailsent, wpcf7mailfailed and wpcf7submit.
  • New action hook: wpcf7_after_flamingo.
  • Added size option to select and select* form-tag types.
  • Made it possible to use the 3rd parameter of wpcf7_add_form_tag() to specify "features" of the form-tag type.
Download this release

Release Info

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

Code changes from version 4.6.1 to 4.7

Files changed (51) hide show
  1. admin/admin.php +97 -66
  2. admin/css/styles-rtl.css +4 -5
  3. admin/css/styles.css +24 -24
  4. admin/edit-contact-form.php +4 -4
  5. admin/includes/admin-functions.php +0 -144
  6. admin/includes/class-contact-forms-list-table.php +41 -23
  7. admin/includes/editor.php +40 -20
  8. admin/includes/help-tabs.php +3 -3
  9. admin/includes/tag-generator.php +4 -2
  10. admin/includes/welcome-panel.php +2 -2
  11. admin/js/scripts.js +211 -94
  12. admin/js/tag-generator.js +128 -122
  13. includes/capabilities.php +2 -1
  14. includes/config-validator.php +330 -167
  15. includes/contact-form-functions.php +267 -0
  16. includes/contact-form-template.php +14 -12
  17. includes/contact-form.php +78 -197
  18. includes/controller.php +17 -7
  19. includes/css/styles.css +1 -0
  20. includes/form-tag.php +2 -1
  21. includes/form-tags-manager.php +88 -14
  22. includes/formatting.php +18 -6
  23. includes/functions.php +12 -6
  24. includes/integration.php +2 -1
  25. includes/js/scripts.js +315 -266
  26. includes/l10n.php +4 -2
  27. includes/mail.php +17 -8
  28. includes/rest-api.php +248 -0
  29. includes/submission.php +5 -4
  30. includes/upgrade.php +4 -2
  31. includes/validation.php +4 -2
  32. modules/acceptance.php +2 -2
  33. modules/checkbox.php +5 -2
  34. modules/count.php +2 -1
  35. modules/date.php +2 -2
  36. modules/file.php +2 -2
  37. modules/flamingo.php +10 -2
  38. modules/hidden.php +2 -1
  39. modules/listo.php +1 -1
  40. modules/number.php +2 -2
  41. modules/quiz.php +3 -2
  42. modules/really-simple-captcha.php +2 -2
  43. modules/recaptcha.php +7 -3
  44. modules/select.php +19 -4
  45. modules/submit.php +1 -1
  46. modules/text.php +2 -2
  47. modules/textarea.php +2 -2
  48. readme.txt +22 -13
  49. settings.php +16 -8
  50. uninstall.php +7 -4
  51. wp-contact-form-7.php +4 -4
admin/admin.php CHANGED
@@ -59,8 +59,9 @@ function wpcf7_set_screen_options( $result, $option, $value ) {
59
  $wpcf7_screens = array(
60
  'cfseven_contact_forms_per_page' );
61
 
62
- if ( in_array( $option, $wpcf7_screens ) )
63
  $result = $value;
 
64
 
65
  return $result;
66
  }
@@ -71,18 +72,60 @@ function wpcf7_load_contact_form_admin() {
71
  $action = wpcf7_current_action();
72
 
73
  if ( 'save' == $action ) {
74
- $id = $_POST['post_ID'];
75
  check_admin_referer( 'wpcf7-save-contact-form_' . $id );
76
 
77
- if ( ! current_user_can( 'wpcf7_edit_contact_form', $id ) )
78
  wp_die( __( 'You are not allowed to edit this item.', 'contact-form-7' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
 
80
- $id = wpcf7_save_contact_form( $id );
 
 
 
 
81
 
82
  $query = array(
83
- 'message' => ( -1 == $_POST['post_ID'] ) ? 'created' : 'saved',
84
- 'post' => $id,
85
- 'active-tab' => isset( $_POST['active-tab'] ) ? (int) $_POST['active-tab'] : 0 );
 
 
 
 
 
 
 
 
 
86
 
87
  $redirect_to = add_query_arg( $query, menu_page_url( 'wpcf7', false ) );
88
  wp_safe_redirect( $redirect_to );
@@ -96,8 +139,9 @@ function wpcf7_load_contact_form_admin() {
96
 
97
  check_admin_referer( 'wpcf7-copy-contact-form_' . $id );
98
 
99
- if ( ! current_user_can( 'wpcf7_edit_contact_form', $id ) )
100
  wp_die( __( 'You are not allowed to edit this item.', 'contact-form-7' ) );
 
101
 
102
  $query = array();
103
 
@@ -116,12 +160,13 @@ function wpcf7_load_contact_form_admin() {
116
  }
117
 
118
  if ( 'delete' == $action ) {
119
- if ( ! empty( $_POST['post_ID'] ) )
120
  check_admin_referer( 'wpcf7-delete-contact-form_' . $_POST['post_ID'] );
121
- elseif ( ! is_array( $_REQUEST['post'] ) )
122
  check_admin_referer( 'wpcf7-delete-contact-form_' . $_REQUEST['post'] );
123
- else
124
  check_admin_referer( 'bulk-posts' );
 
125
 
126
  $posts = empty( $_POST['post_ID'] )
127
  ? (array) $_REQUEST['post']
@@ -132,22 +177,26 @@ function wpcf7_load_contact_form_admin() {
132
  foreach ( $posts as $post ) {
133
  $post = WPCF7_ContactForm::get_instance( $post );
134
 
135
- if ( empty( $post ) )
136
  continue;
 
137
 
138
- if ( ! current_user_can( 'wpcf7_delete_contact_form', $post->id() ) )
139
  wp_die( __( 'You are not allowed to delete this item.', 'contact-form-7' ) );
 
140
 
141
- if ( ! $post->delete() )
142
  wp_die( __( 'Error in deleting.', 'contact-form-7' ) );
 
143
 
144
  $deleted += 1;
145
  }
146
 
147
  $query = array();
148
 
149
- if ( ! empty( $deleted ) )
150
  $query['message'] = 'deleted';
 
151
 
152
  $redirect_to = add_query_arg( $query, menu_page_url( 'wpcf7', false ) );
153
 
@@ -164,15 +213,18 @@ function wpcf7_load_contact_form_admin() {
164
  }
165
 
166
  $contact_forms = WPCF7_ContactForm::find();
 
167
  $result = array(
168
  'timestamp' => current_time( 'timestamp' ),
169
  'version' => WPCF7_VERSION,
170
  'count_valid' => 0,
171
- 'count_invalid' => 0 );
 
172
 
173
  foreach ( $contact_forms as $contact_form ) {
174
  $config_validator = new WPCF7_ConfigValidator( $contact_form );
175
  $config_validator->validate();
 
176
 
177
  if ( $config_validator->is_valid() ) {
178
  $result['count_valid'] += 1;
@@ -248,30 +300,34 @@ function wpcf7_admin_enqueue_scripts( $hook_suffix ) {
248
  WPCF7_VERSION, true );
249
 
250
  $args = array(
 
 
 
 
251
  'pluginUrl' => wpcf7_plugin_url(),
252
  'saveAlert' => __(
253
  "The changes you made will be lost if you navigate away from this page.",
254
  'contact-form-7' ),
255
  'activeTab' => isset( $_GET['active-tab'] )
256
  ? (int) $_GET['active-tab'] : 0,
257
- 'howToCorrectLink' => __( "How to correct this?", 'contact-form-7' ),
258
- 'configErrors' => array() );
 
 
 
 
 
 
 
 
259
 
260
  if ( ( $post = wpcf7_get_current_contact_form() )
261
  && current_user_can( 'wpcf7_edit_contact_form', $post->id() )
262
  && wpcf7_validate_configuration() ) {
263
  $config_validator = new WPCF7_ConfigValidator( $post );
264
- $error_messages = $config_validator->collect_error_messages();
265
-
266
- foreach ( $error_messages as $section => $errors ) {
267
- $args['configErrors'][$section] = array();
268
-
269
- foreach ( $errors as $error ) {
270
- $args['configErrors'][$section][] = array(
271
- 'message' => esc_html( $error['message'] ),
272
- 'link' => esc_url( $error['link'] ) );
273
- }
274
- }
275
  }
276
 
277
  wp_localize_script( 'wpcf7-admin', '_wpcf7', $args );
@@ -355,7 +411,7 @@ function wpcf7_admin_bulk_validate_page() {
355
  <p><input type="submit" class="button" value="<?php echo esc_attr( $submit_text ); ?>" /></p>
356
  </form>
357
 
358
- <?php echo wpcf7_link( __( 'http://contactform7.com/configuration-validator-faq/', 'contact-form-7' ), __( 'FAQ about Configuration Validator', 'contact-form-7' ) ); ?>
359
 
360
  </div>
361
  <?php
@@ -431,7 +487,15 @@ function wpcf7_admin_updated_message() {
431
  }
432
 
433
  if ( ! empty( $updated_message ) ) {
434
- echo sprintf( '<div id="message" class="updated notice notice-success is-dismissible"><p>%s</p></div>', esc_html( $updated_message ) );
 
 
 
 
 
 
 
 
435
  return;
436
  }
437
 
@@ -462,8 +526,9 @@ function wpcf7_admin_updated_message() {
462
  add_filter( 'plugin_action_links', 'wpcf7_plugin_action_links', 10, 2 );
463
 
464
  function wpcf7_plugin_action_links( $links, $file ) {
465
- if ( $file != WPCF7_PLUGIN_BASENAME )
466
  return $links;
 
467
 
468
  $settings_link = '<a href="' . menu_page_url( 'wpcf7', false ) . '">'
469
  . esc_html( __( 'Settings', 'contact-form-7' ) ) . '</a>';
@@ -510,40 +575,6 @@ function wpcf7_not_allowed_to_edit() {
510
  esc_html( $message ) );
511
  }
512
 
513
- add_action( 'wpcf7_admin_misc_pub_section', 'wpcf7_notice_config_errors' );
514
-
515
- function wpcf7_notice_config_errors() {
516
- if ( ! $contact_form = wpcf7_get_current_contact_form() ) {
517
- return;
518
- }
519
-
520
- if ( ! wpcf7_validate_configuration()
521
- || ! current_user_can( 'wpcf7_edit_contact_form', $contact_form->id() ) ) {
522
- return;
523
- }
524
-
525
- $config_validator = new WPCF7_ConfigValidator( $contact_form );
526
-
527
- if ( $count_errors = $config_validator->count_errors() ) {
528
- $message = sprintf(
529
- _n(
530
- '%s configuration error found',
531
- '%s configuration errors found',
532
- $count_errors, 'contact-form-7' ),
533
- number_format_i18n( $count_errors ) );
534
-
535
- $link = wpcf7_link(
536
- __( 'http://contactform7.com/configuration-validator-faq/',
537
- 'contact-form-7' ),
538
- __( "What's this?", 'contact-form-7' ),
539
- array( 'class' => 'external' ) );
540
-
541
- echo sprintf(
542
- '<div class="misc-pub-section warning">%1$s<br />%2$s</div>',
543
- $message, $link );
544
- }
545
- }
546
-
547
  add_action( 'wpcf7_admin_warnings', 'wpcf7_notice_bulk_validate_config', 5 );
548
 
549
  function wpcf7_notice_bulk_validate_config() {
59
  $wpcf7_screens = array(
60
  'cfseven_contact_forms_per_page' );
61
 
62
+ if ( in_array( $option, $wpcf7_screens ) ) {
63
  $result = $value;
64
+ }
65
 
66
  return $result;
67
  }
72
  $action = wpcf7_current_action();
73
 
74
  if ( 'save' == $action ) {
75
+ $id = isset( $_POST['post_ID'] ) ? $_POST['post_ID'] : '-1';
76
  check_admin_referer( 'wpcf7-save-contact-form_' . $id );
77
 
78
+ if ( ! current_user_can( 'wpcf7_edit_contact_form', $id ) ) {
79
  wp_die( __( 'You are not allowed to edit this item.', 'contact-form-7' ) );
80
+ }
81
+
82
+ $args = $_REQUEST;
83
+ $args['id'] = $id;
84
+
85
+ $args['title'] = isset( $_POST['post_title'] )
86
+ ? $_POST['post_title'] : null;
87
+
88
+ $args['locale'] = isset( $_POST['wpcf7-locale'] )
89
+ ? $_POST['wpcf7-locale'] : null;
90
+
91
+ $args['form'] = isset( $_POST['wpcf7-form'] )
92
+ ? $_POST['wpcf7-form'] : '';
93
+
94
+ $args['mail'] = isset( $_POST['wpcf7-mail'] )
95
+ ? wpcf7_sanitize_mail( $_POST['wpcf7-mail'] )
96
+ : array();
97
+
98
+ $args['mail_2'] = isset( $_POST['wpcf7-mail-2'] )
99
+ ? wpcf7_sanitize_mail( $_POST['wpcf7-mail-2'] )
100
+ : array();
101
+
102
+ $args['messages'] = isset( $_POST['wpcf7-messages'] )
103
+ ? $_POST['wpcf7-messages'] : array();
104
+
105
+ $args['additional_settings'] = isset( $_POST['wpcf7-additional-settings'] )
106
+ ? $_POST['wpcf7-additional-settings'] : '';
107
+
108
+ $contact_form = wpcf7_save_contact_form( $args );
109
 
110
+ if ( $contact_form && wpcf7_validate_configuration() ) {
111
+ $config_validator = new WPCF7_ConfigValidator( $contact_form );
112
+ $config_validator->validate();
113
+ $config_validator->save();
114
+ }
115
 
116
  $query = array(
117
+ 'post' => $contact_form ? $contact_form->id() : 0,
118
+ 'active-tab' => isset( $_POST['active-tab'] )
119
+ ? (int) $_POST['active-tab'] : 0,
120
+ );
121
+
122
+ if ( ! $contact_form ) {
123
+ $query['message'] = 'failed';
124
+ } elseif ( -1 == $id ) {
125
+ $query['message'] = 'created';
126
+ } else {
127
+ $query['message'] = 'saved';
128
+ }
129
 
130
  $redirect_to = add_query_arg( $query, menu_page_url( 'wpcf7', false ) );
131
  wp_safe_redirect( $redirect_to );
139
 
140
  check_admin_referer( 'wpcf7-copy-contact-form_' . $id );
141
 
142
+ if ( ! current_user_can( 'wpcf7_edit_contact_form', $id ) ) {
143
  wp_die( __( 'You are not allowed to edit this item.', 'contact-form-7' ) );
144
+ }
145
 
146
  $query = array();
147
 
160
  }
161
 
162
  if ( 'delete' == $action ) {
163
+ if ( ! empty( $_POST['post_ID'] ) ) {
164
  check_admin_referer( 'wpcf7-delete-contact-form_' . $_POST['post_ID'] );
165
+ } elseif ( ! is_array( $_REQUEST['post'] ) ) {
166
  check_admin_referer( 'wpcf7-delete-contact-form_' . $_REQUEST['post'] );
167
+ } else {
168
  check_admin_referer( 'bulk-posts' );
169
+ }
170
 
171
  $posts = empty( $_POST['post_ID'] )
172
  ? (array) $_REQUEST['post']
177
  foreach ( $posts as $post ) {
178
  $post = WPCF7_ContactForm::get_instance( $post );
179
 
180
+ if ( empty( $post ) ) {
181
  continue;
182
+ }
183
 
184
+ if ( ! current_user_can( 'wpcf7_delete_contact_form', $post->id() ) ) {
185
  wp_die( __( 'You are not allowed to delete this item.', 'contact-form-7' ) );
186
+ }
187
 
188
+ if ( ! $post->delete() ) {
189
  wp_die( __( 'Error in deleting.', 'contact-form-7' ) );
190
+ }
191
 
192
  $deleted += 1;
193
  }
194
 
195
  $query = array();
196
 
197
+ if ( ! empty( $deleted ) ) {
198
  $query['message'] = 'deleted';
199
+ }
200
 
201
  $redirect_to = add_query_arg( $query, menu_page_url( 'wpcf7', false ) );
202
 
213
  }
214
 
215
  $contact_forms = WPCF7_ContactForm::find();
216
+
217
  $result = array(
218
  'timestamp' => current_time( 'timestamp' ),
219
  'version' => WPCF7_VERSION,
220
  'count_valid' => 0,
221
+ 'count_invalid' => 0,
222
+ );
223
 
224
  foreach ( $contact_forms as $contact_form ) {
225
  $config_validator = new WPCF7_ConfigValidator( $contact_form );
226
  $config_validator->validate();
227
+ $config_validator->save();
228
 
229
  if ( $config_validator->is_valid() ) {
230
  $result['count_valid'] += 1;
300
  WPCF7_VERSION, true );
301
 
302
  $args = array(
303
+ 'apiSettings' => array(
304
+ 'root' => esc_url_raw( get_rest_url() ),
305
+ 'nonce' => ( wp_installing() && ! is_multisite() )
306
+ ? '' : wp_create_nonce( 'wp_rest' ) ),
307
  'pluginUrl' => wpcf7_plugin_url(),
308
  'saveAlert' => __(
309
  "The changes you made will be lost if you navigate away from this page.",
310
  'contact-form-7' ),
311
  'activeTab' => isset( $_GET['active-tab'] )
312
  ? (int) $_GET['active-tab'] : 0,
313
+ 'configValidator' => array(
314
+ 'errors' => array(),
315
+ 'howToCorrect' => __( "How to correct this?", 'contact-form-7' ),
316
+ 'oneError' => __( '1 configuration error detected', 'contact-form-7' ),
317
+ 'manyErrors' => __( '%d configuration errors detected', 'contact-form-7' ),
318
+ 'oneErrorInTab' => __( '1 configuration error detected in this tab panel', 'contact-form-7' ),
319
+ 'manyErrorsInTab' => __( '%d configuration errors detected in this tab panel', 'contact-form-7' ),
320
+ 'docUrl' => WPCF7_ConfigValidator::get_doc_link(),
321
+ ),
322
+ );
323
 
324
  if ( ( $post = wpcf7_get_current_contact_form() )
325
  && current_user_can( 'wpcf7_edit_contact_form', $post->id() )
326
  && wpcf7_validate_configuration() ) {
327
  $config_validator = new WPCF7_ConfigValidator( $post );
328
+ $config_validator->restore();
329
+ $args['configValidator']['errors'] =
330
+ $config_validator->collect_error_messages();
 
 
 
 
 
 
 
 
331
  }
332
 
333
  wp_localize_script( 'wpcf7-admin', '_wpcf7', $args );
411
  <p><input type="submit" class="button" value="<?php echo esc_attr( $submit_text ); ?>" /></p>
412
  </form>
413
 
414
+ <?php echo wpcf7_link( __( 'https://contactform7.com/configuration-validator-faq/', 'contact-form-7' ), __( 'FAQ about Configuration Validator', 'contact-form-7' ) ); ?>
415
 
416
  </div>
417
  <?php
487
  }
488
 
489
  if ( ! empty( $updated_message ) ) {
490
+ echo sprintf( '<div id="message" class="notice notice-success is-dismissible"><p>%s</p></div>', esc_html( $updated_message ) );
491
+ return;
492
+ }
493
+
494
+ if ( 'failed' == $_REQUEST['message'] ) {
495
+ $updated_message = __( "There was an error saving the contact form.",
496
+ 'contact-form-7' );
497
+
498
+ echo sprintf( '<div id="message" class="notice notice-error is-dismissible"><p>%s</p></div>', esc_html( $updated_message ) );
499
  return;
500
  }
501
 
526
  add_filter( 'plugin_action_links', 'wpcf7_plugin_action_links', 10, 2 );
527
 
528
  function wpcf7_plugin_action_links( $links, $file ) {
529
+ if ( $file != WPCF7_PLUGIN_BASENAME ) {
530
  return $links;
531
+ }
532
 
533
  $settings_link = '<a href="' . menu_page_url( 'wpcf7', false ) . '">'
534
  . esc_html( __( 'Settings', 'contact-form-7' ) ) . '</a>';
575
  esc_html( $message ) );
576
  }
577
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
578
  add_action( 'wpcf7_admin_warnings', 'wpcf7_notice_bulk_validate_config', 5 );
579
 
580
  function wpcf7_notice_bulk_validate_config() {
admin/css/styles-rtl.css CHANGED
@@ -1,8 +1,3 @@
1
- #misc-publishing-actions .misc-pub-section::before {
2
- right: -1px;
3
- padding: 0 0 0 2px;
4
- }
5
-
6
  /*
7
  * Tabs
8
  */
@@ -10,6 +5,10 @@
10
  padding: 9px 10px 0 15px;
11
  }
12
 
 
 
 
 
13
  /*
14
  * Form Tab
15
  */
 
 
 
 
 
1
  /*
2
  * Tabs
3
  */
5
  padding: 9px 10px 0 15px;
6
  }
7
 
8
+ #contact-form-editor-tabs li a span.dashicons {
9
+ padding: 6px 4px 4px 0;
10
+ }
11
+
12
  /*
13
  * Form Tab
14
  */
admin/css/styles.css CHANGED
@@ -56,45 +56,31 @@ span.shortcode > input {
56
  color: #23282d;
57
  }
58
 
59
- #misc-publishing-actions .misc-pub-section::before {
60
- content: "\f488";
61
- -moz-osx-font-smoothing: grayscale;
62
- display: inline-block;
63
- font: 20px/1 dashicons;
64
- left: -1px;
65
- padding: 0 2px 0 0;
66
- position: relative;
67
- text-decoration: none !important;
68
- top: 0;
69
- vertical-align: top;
70
- color: #82878c;
71
- }
72
-
73
- #misc-publishing-actions .misc-pub-section.warning::before {
74
- content: "\f534";
75
- }
76
-
77
- #misc-publishing-actions .misc-pub-section.warning a.external {
78
- font-style: italic;
79
- }
80
-
81
  div.config-error, span.config-error, ul.config-error {
82
- color: #d00;
83
  font-style: normal;
84
  font-size: 13px;
85
  }
86
 
 
 
 
 
87
  ul.config-error {
88
  margin: 0;
89
  }
90
 
91
  ul.config-error li {
 
92
  padding: 0 4px;
93
  margin: 0;
94
  }
95
 
96
  ul.config-error li a.external {
97
- font-style: italic;
 
 
 
98
  }
99
 
100
  [data-config-field][aria-invalid="true"] {
@@ -152,6 +138,16 @@ ul.config-error li a.external {
152
  color: #000;
153
  }
154
 
 
 
 
 
 
 
 
 
 
 
155
  #contact-form-editor .contact-form-editor-panel h2 {
156
  font-size: 18px;
157
  font-weight: 400;
@@ -320,6 +316,10 @@ ul.config-error li a.external {
320
  width: 38%;
321
  }
322
 
 
 
 
 
323
  /*
324
  * Welcome Panel
325
  */
56
  color: #23282d;
57
  }
58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  div.config-error, span.config-error, ul.config-error {
60
+ color: #444;
61
  font-style: normal;
62
  font-size: 13px;
63
  }
64
 
65
+ div.config-error span.dashicons {
66
+ color: #82878c;
67
+ }
68
+
69
  ul.config-error {
70
  margin: 0;
71
  }
72
 
73
  ul.config-error li {
74
+ list-style: disc inside;
75
  padding: 0 4px;
76
  margin: 0;
77
  }
78
 
79
  ul.config-error li a.external {
80
+ font-style: normal;
81
+ font-weight: normal;
82
+ font-size: 18px;
83
+ vertical-align: middle;
84
  }
85
 
86
  [data-config-field][aria-invalid="true"] {
138
  color: #000;
139
  }
140
 
141
+ #contact-form-editor-tabs li a span.dashicons {
142
+ font-style: normal;
143
+ padding: 6px 0 4px 4px;
144
+ color: #82878c;
145
+ }
146
+
147
+ #contact-form-editor-tabs li.ui-tabs-active a span.dashicons {
148
+ display: none;
149
+ }
150
+
151
  #contact-form-editor .contact-form-editor-panel h2 {
152
  font-size: 18px;
153
  font-weight: 400;
316
  width: 38%;
317
  }
318
 
319
+ .wp-list-table .config-error span.dashicons {
320
+ color: #82878c;
321
+ }
322
+
323
  /*
324
  * Welcome Panel
325
  */
admin/edit-contact-form.php CHANGED
@@ -63,7 +63,7 @@ if ( $post ) :
63
  }
64
  ?>
65
  <input type="hidden" id="post_ID" name="post_ID" value="<?php echo (int) $post_id; ?>" />
66
- <input type="hidden" id="wpcf7-locale" name="wpcf7-locale" value="<?php echo esc_attr( $post->locale ); ?>" />
67
  <input type="hidden" id="hiddenaction" name="action" value="save" />
68
  <input type="hidden" id="active-tab" name="active-tab" value="<?php echo isset( $_GET['active-tab'] ) ? (int) $_GET['active-tab'] : '0'; ?>" />
69
 
@@ -163,9 +163,9 @@ if ( $post ) :
163
  <h3><?php echo esc_html( __( 'Information', 'contact-form-7' ) ); ?></h3>
164
  <div class="inside">
165
  <ul>
166
- <li><?php echo wpcf7_link( __( 'http://contactform7.com/docs/', 'contact-form-7' ), __( 'Docs', 'contact-form-7' ) ); ?></li>
167
- <li><?php echo wpcf7_link( __( 'http://contactform7.com/faq/', 'contact-form-7' ), __( 'FAQ', 'contact-form-7' ) ); ?></li>
168
- <li><?php echo wpcf7_link( __( 'http://contactform7.com/support/', 'contact-form-7' ), __( 'Support', 'contact-form-7' ) ); ?></li>
169
  </ul>
170
  </div>
171
  </div><!-- #informationdiv -->
63
  }
64
  ?>
65
  <input type="hidden" id="post_ID" name="post_ID" value="<?php echo (int) $post_id; ?>" />
66
+ <input type="hidden" id="wpcf7-locale" name="wpcf7-locale" value="<?php echo esc_attr( $post->locale() ); ?>" />
67
  <input type="hidden" id="hiddenaction" name="action" value="save" />
68
  <input type="hidden" id="active-tab" name="active-tab" value="<?php echo isset( $_GET['active-tab'] ) ? (int) $_GET['active-tab'] : '0'; ?>" />
69
 
163
  <h3><?php echo esc_html( __( 'Information', 'contact-form-7' ) ); ?></h3>
164
  <div class="inside">
165
  <ul>
166
+ <li><?php echo wpcf7_link( __( 'https://contactform7.com/docs/', 'contact-form-7' ), __( 'Docs', 'contact-form-7' ) ); ?></li>
167
+ <li><?php echo wpcf7_link( __( 'https://contactform7.com/faq/', 'contact-form-7' ), __( 'FAQ', 'contact-form-7' ) ); ?></li>
168
+ <li><?php echo wpcf7_link( __( 'https://contactform7.com/support/', 'contact-form-7' ), __( 'Support', 'contact-form-7' ) ); ?></li>
169
  </ul>
170
  </div>
171
  </div><!-- #informationdiv -->
admin/includes/admin-functions.php CHANGED
@@ -20,147 +20,3 @@ function wpcf7_add_tag_generator( $name, $title, $elm_id, $callback, $options =
20
  $tag_generator = WPCF7_TagGenerator::get_instance();
21
  return $tag_generator->add( $name, $title, $callback, $options );
22
  }
23
-
24
- function wpcf7_save_contact_form( $post_id = -1 ) {
25
- if ( -1 != $post_id ) {
26
- $contact_form = wpcf7_contact_form( $post_id );
27
- }
28
-
29
- if ( empty( $contact_form ) ) {
30
- $contact_form = WPCF7_ContactForm::get_template();
31
- }
32
-
33
- if ( isset( $_POST['post_title'] ) ) {
34
- $contact_form->set_title( $_POST['post_title'] );
35
- }
36
-
37
- if ( isset( $_POST['wpcf7-locale'] ) ) {
38
- $locale = trim( $_POST['wpcf7-locale'] );
39
-
40
- if ( wpcf7_is_valid_locale( $locale ) ) {
41
- $contact_form->locale = $locale;
42
- }
43
- }
44
-
45
- $properties = $contact_form->get_properties();
46
-
47
- if ( isset( $_POST['wpcf7-form'] ) ) {
48
- $properties['form'] = trim( $_POST['wpcf7-form'] );
49
- }
50
-
51
- $mail = $properties['mail'];
52
-
53
- if ( isset( $_POST['wpcf7-mail-subject'] ) ) {
54
- $mail['subject'] = trim( $_POST['wpcf7-mail-subject'] );
55
- }
56
-
57
- if ( isset( $_POST['wpcf7-mail-sender'] ) ) {
58
- $mail['sender'] = trim( $_POST['wpcf7-mail-sender'] );
59
- }
60
-
61
- if ( isset( $_POST['wpcf7-mail-body'] ) ) {
62
- $mail['body'] = trim( $_POST['wpcf7-mail-body'] );
63
- }
64
-
65
- if ( isset( $_POST['wpcf7-mail-recipient'] ) ) {
66
- $mail['recipient'] = trim( $_POST['wpcf7-mail-recipient'] );
67
- }
68
-
69
- if ( isset( $_POST['wpcf7-mail-additional-headers'] ) ) {
70
- $headers = '';
71
- $tempheaders = str_replace(
72
- "\r\n", "\n", $_POST['wpcf7-mail-additional-headers'] );
73
- $tempheaders = explode( "\n", $tempheaders );
74
-
75
- foreach ( $tempheaders as $header ) {
76
- $header = trim( $header );
77
-
78
- if ( '' !== $header ) {
79
- $headers .= $header . "\n";
80
- }
81
- }
82
-
83
- $mail['additional_headers'] = trim( $headers );
84
- }
85
-
86
- if ( isset( $_POST['wpcf7-mail-attachments'] ) ) {
87
- $mail['attachments'] = trim( $_POST['wpcf7-mail-attachments'] );
88
- }
89
-
90
- $mail['use_html'] = ! empty( $_POST['wpcf7-mail-use-html'] );
91
- $mail['exclude_blank'] = ! empty( $_POST['wpcf7-mail-exclude-blank'] );
92
-
93
- $properties['mail'] = $mail;
94
-
95
- $mail_2 = $properties['mail_2'];
96
-
97
- $mail_2['active'] = ! empty( $_POST['wpcf7-mail-2-active'] );
98
-
99
- if ( isset( $_POST['wpcf7-mail-2-subject'] ) ) {
100
- $mail_2['subject'] = trim( $_POST['wpcf7-mail-2-subject'] );
101
- }
102
-
103
- if ( isset( $_POST['wpcf7-mail-2-sender'] ) ) {
104
- $mail_2['sender'] = trim( $_POST['wpcf7-mail-2-sender'] );
105
- }
106
-
107
- if ( isset( $_POST['wpcf7-mail-2-body'] ) ) {
108
- $mail_2['body'] = trim( $_POST['wpcf7-mail-2-body'] );
109
- }
110
-
111
- if ( isset( $_POST['wpcf7-mail-2-recipient'] ) ) {
112
- $mail_2['recipient'] = trim( $_POST['wpcf7-mail-2-recipient'] );
113
- }
114
-
115
- if ( isset( $_POST['wpcf7-mail-2-additional-headers'] ) ) {
116
- $headers = '';
117
- $tempheaders = str_replace(
118
- "\r\n", "\n", $_POST['wpcf7-mail-2-additional-headers'] );
119
- $tempheaders = explode( "\n", $tempheaders );
120
-
121
- foreach ( $tempheaders as $header ) {
122
- $header = trim( $header );
123
-
124
- if ( '' !== $header ) {
125
- $headers .= $header . "\n";
126
- }
127
- }
128
-
129
- $mail_2['additional_headers'] = trim( $headers );
130
- }
131
-
132
- if ( isset( $_POST['wpcf7-mail-2-attachments'] ) ) {
133
- $mail_2['attachments'] = trim( $_POST['wpcf7-mail-2-attachments'] );
134
- }
135
-
136
- $mail_2['use_html'] = ! empty( $_POST['wpcf7-mail-2-use-html'] );
137
- $mail_2['exclude_blank'] = ! empty( $_POST['wpcf7-mail-2-exclude-blank'] );
138
-
139
- $properties['mail_2'] = $mail_2;
140
-
141
- foreach ( wpcf7_messages() as $key => $arr ) {
142
- $field_name = 'wpcf7-message-' . strtr( $key, '_', '-' );
143
-
144
- if ( isset( $_POST[$field_name] ) ) {
145
- $properties['messages'][$key] = trim( $_POST[$field_name] );
146
- }
147
- }
148
-
149
- if ( isset( $_POST['wpcf7-additional-settings'] ) ) {
150
- $properties['additional_settings'] = trim(
151
- $_POST['wpcf7-additional-settings'] );
152
- }
153
-
154
- $contact_form->set_properties( $properties );
155
-
156
- do_action( 'wpcf7_save_contact_form', $contact_form );
157
-
158
- $post_id = $contact_form->save();
159
-
160
- if ( wpcf7_validate_configuration() ) {
161
- $config_validator = new WPCF7_ConfigValidator( $contact_form );
162
- $config_validator->validate();
163
- }
164
-
165
- return $post_id;
166
- }
20
  $tag_generator = WPCF7_TagGenerator::get_instance();
21
  return $tag_generator->add( $name, $title, $callback, $options );
22
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/includes/class-contact-forms-list-table.php CHANGED
@@ -12,7 +12,8 @@ class WPCF7_Contact_Form_List_Table extends WP_List_Table {
12
  'title' => __( 'Title', 'contact-form-7' ),
13
  'shortcode' => __( 'Shortcode', 'contact-form-7' ),
14
  'author' => __( 'Author', 'contact-form-7' ),
15
- 'date' => __( 'Date', 'contact-form-7' ) );
 
16
 
17
  return $columns;
18
  }
@@ -21,7 +22,8 @@ class WPCF7_Contact_Form_List_Table extends WP_List_Table {
21
  parent::__construct( array(
22
  'singular' => 'post',
23
  'plural' => 'posts',
24
- 'ajax' => false ) );
 
25
  }
26
 
27
  function prepare_items() {
@@ -34,25 +36,29 @@ class WPCF7_Contact_Form_List_Table extends WP_List_Table {
34
  'posts_per_page' => $per_page,
35
  'orderby' => 'title',
36
  'order' => 'ASC',
37
- 'offset' => ( $this->get_pagenum() - 1 ) * $per_page );
 
38
 
39
- if ( ! empty( $_REQUEST['s'] ) )
40
  $args['s'] = $_REQUEST['s'];
 
41
 
42
  if ( ! empty( $_REQUEST['orderby'] ) ) {
43
- if ( 'title' == $_REQUEST['orderby'] )
44
  $args['orderby'] = 'title';
45
- elseif ( 'author' == $_REQUEST['orderby'] )
46
  $args['orderby'] = 'author';
47
- elseif ( 'date' == $_REQUEST['orderby'] )
48
  $args['orderby'] = 'date';
 
49
  }
50
 
51
  if ( ! empty( $_REQUEST['order'] ) ) {
52
- if ( 'asc' == strtolower( $_REQUEST['order'] ) )
53
  $args['order'] = 'ASC';
54
- elseif ( 'desc' == strtolower( $_REQUEST['order'] ) )
55
  $args['order'] = 'DESC';
 
56
  }
57
 
58
  $this->items = WPCF7_ContactForm::find( $args );
@@ -63,7 +69,8 @@ class WPCF7_Contact_Form_List_Table extends WP_List_Table {
63
  $this->set_pagination_args( array(
64
  'total_items' => $total_items,
65
  'total_pages' => $total_pages,
66
- 'per_page' => $per_page ) );
 
67
  }
68
 
69
  function get_columns() {
@@ -74,14 +81,16 @@ class WPCF7_Contact_Form_List_Table extends WP_List_Table {
74
  $columns = array(
75
  'title' => array( 'title', true ),
76
  'author' => array( 'author', false ),
77
- 'date' => array( 'date', false ) );
 
78
 
79
  return $columns;
80
  }
81
 
82
  function get_bulk_actions() {
83
  $actions = array(
84
- 'delete' => __( 'Delete', 'contact-form-7' ) );
 
85
 
86
  return $actions;
87
  }
@@ -106,23 +115,25 @@ class WPCF7_Contact_Form_List_Table extends WP_List_Table {
106
  esc_url( $edit_link ),
107
  esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;', 'contact-form-7' ),
108
  $item->title() ) ),
109
- esc_html( $item->title() ) );
 
110
 
111
  $output = sprintf( '<strong>%s</strong>', $output );
112
 
113
  if ( wpcf7_validate_configuration()
114
  && current_user_can( 'wpcf7_edit_contact_form', $item->id() ) ) {
115
  $config_validator = new WPCF7_ConfigValidator( $item );
 
116
 
117
  if ( $count_errors = $config_validator->count_errors() ) {
118
  $error_notice = sprintf(
119
  _n(
120
- '%s configuration error found',
121
- '%s configuration errors found',
122
  $count_errors, 'contact-form-7' ),
123
  number_format_i18n( $count_errors ) );
124
  $output .= sprintf(
125
- '<div class="config-error">%s</div>',
126
  $error_notice );
127
  }
128
  }
@@ -140,7 +151,9 @@ class WPCF7_Contact_Form_List_Table extends WP_List_Table {
140
  $actions = array_merge( $actions, array(
141
  'copy' => sprintf( '<a href="%1$s">%2$s</a>',
142
  esc_url( $copy_link ),
143
- esc_html( __( 'Duplicate', 'contact-form-7' ) ) ) ) );
 
 
144
  }
145
 
146
  $output .= $this->row_actions( $actions );
@@ -182,19 +195,24 @@ class WPCF7_Contact_Form_List_Table extends WP_List_Table {
182
  function column_date( $item ) {
183
  $post = get_post( $item->id() );
184
 
185
- if ( ! $post )
186
  return;
 
187
 
188
- $t_time = mysql2date( __( 'Y/m/d g:i:s A', 'contact-form-7' ), $post->post_date, true );
 
189
  $m_time = $post->post_date;
190
- $time = mysql2date( 'G', $post->post_date ) - get_option( 'gmt_offset' ) * 3600;
 
191
 
192
  $time_diff = time() - $time;
193
 
194
- if ( $time_diff > 0 && $time_diff < 24*60*60 )
195
- $h_time = sprintf( __( '%s ago', 'contact-form-7' ), human_time_diff( $time ) );
196
- else
 
197
  $h_time = mysql2date( __( 'Y/m/d', 'contact-form-7' ), $m_time );
 
198
 
199
  return '<abbr title="' . $t_time . '">' . $h_time . '</abbr>';
200
  }
12
  'title' => __( 'Title', 'contact-form-7' ),
13
  'shortcode' => __( 'Shortcode', 'contact-form-7' ),
14
  'author' => __( 'Author', 'contact-form-7' ),
15
+ 'date' => __( 'Date', 'contact-form-7' ),
16
+ );
17
 
18
  return $columns;
19
  }
22
  parent::__construct( array(
23
  'singular' => 'post',
24
  'plural' => 'posts',
25
+ 'ajax' => false,
26
+ ) );
27
  }
28
 
29
  function prepare_items() {
36
  'posts_per_page' => $per_page,
37
  'orderby' => 'title',
38
  'order' => 'ASC',
39
+ 'offset' => ( $this->get_pagenum() - 1 ) * $per_page,
40
+ );
41
 
42
+ if ( ! empty( $_REQUEST['s'] ) ) {
43
  $args['s'] = $_REQUEST['s'];
44
+ }
45
 
46
  if ( ! empty( $_REQUEST['orderby'] ) ) {
47
+ if ( 'title' == $_REQUEST['orderby'] ) {
48
  $args['orderby'] = 'title';
49
+ } elseif ( 'author' == $_REQUEST['orderby'] ) {
50
  $args['orderby'] = 'author';
51
+ } elseif ( 'date' == $_REQUEST['orderby'] ) {
52
  $args['orderby'] = 'date';
53
+ }
54
  }
55
 
56
  if ( ! empty( $_REQUEST['order'] ) ) {
57
+ if ( 'asc' == strtolower( $_REQUEST['order'] ) ) {
58
  $args['order'] = 'ASC';
59
+ } elseif ( 'desc' == strtolower( $_REQUEST['order'] ) ) {
60
  $args['order'] = 'DESC';
61
+ }
62
  }
63
 
64
  $this->items = WPCF7_ContactForm::find( $args );
69
  $this->set_pagination_args( array(
70
  'total_items' => $total_items,
71
  'total_pages' => $total_pages,
72
+ 'per_page' => $per_page,
73
+ ) );
74
  }
75
 
76
  function get_columns() {
81
  $columns = array(
82
  'title' => array( 'title', true ),
83
  'author' => array( 'author', false ),
84
+ 'date' => array( 'date', false ),
85
+ );
86
 
87
  return $columns;
88
  }
89
 
90
  function get_bulk_actions() {
91
  $actions = array(
92
+ 'delete' => __( 'Delete', 'contact-form-7' ),
93
+ );
94
 
95
  return $actions;
96
  }
115
  esc_url( $edit_link ),
116
  esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;', 'contact-form-7' ),
117
  $item->title() ) ),
118
+ esc_html( $item->title() )
119
+ );
120
 
121
  $output = sprintf( '<strong>%s</strong>', $output );
122
 
123
  if ( wpcf7_validate_configuration()
124
  && current_user_can( 'wpcf7_edit_contact_form', $item->id() ) ) {
125
  $config_validator = new WPCF7_ConfigValidator( $item );
126
+ $config_validator->restore();
127
 
128
  if ( $count_errors = $config_validator->count_errors() ) {
129
  $error_notice = sprintf(
130
  _n(
131
+ '%s configuration error detected',
132
+ '%s configuration errors detected',
133
  $count_errors, 'contact-form-7' ),
134
  number_format_i18n( $count_errors ) );
135
  $output .= sprintf(
136
+ '<div class="config-error"><span class="dashicons dashicons-warning"></span> %s</div>',
137
  $error_notice );
138
  }
139
  }
151
  $actions = array_merge( $actions, array(
152
  'copy' => sprintf( '<a href="%1$s">%2$s</a>',
153
  esc_url( $copy_link ),
154
+ esc_html( __( 'Duplicate', 'contact-form-7' ) )
155
+ ),
156
+ ) );
157
  }
158
 
159
  $output .= $this->row_actions( $actions );
195
  function column_date( $item ) {
196
  $post = get_post( $item->id() );
197
 
198
+ if ( ! $post ) {
199
  return;
200
+ }
201
 
202
+ $t_time = mysql2date( __( 'Y/m/d g:i:s A', 'contact-form-7' ),
203
+ $post->post_date, true );
204
  $m_time = $post->post_date;
205
+ $time = mysql2date( 'G', $post->post_date )
206
+ - get_option( 'gmt_offset' ) * 3600;
207
 
208
  $time_diff = time() - $time;
209
 
210
+ if ( $time_diff > 0 && $time_diff < 24*60*60 ) {
211
+ $h_time = sprintf(
212
+ __( '%s ago', 'contact-form-7' ), human_time_diff( $time ) );
213
+ } else {
214
  $h_time = mysql2date( __( 'Y/m/d', 'contact-form-7' ), $m_time );
215
+ }
216
 
217
  return '<abbr title="' . $t_time . '">' . $h_time . '</abbr>';
218
  }
admin/includes/editor.php CHANGED
@@ -13,7 +13,8 @@ class WPCF7_Editor {
13
  if ( wpcf7_is_name( $id ) ) {
14
  $this->panels[$id] = array(
15
  'title' => $title,
16
- 'callback' => $callback );
 
17
  }
18
  }
19
 
@@ -34,10 +35,19 @@ class WPCF7_Editor {
34
  foreach ( $this->panels as $id => $panel ) {
35
  echo sprintf( '<div class="contact-form-editor-panel" id="%1$s">',
36
  esc_attr( $id ) );
37
- call_user_func( $panel['callback'], $this->contact_form );
 
 
 
 
 
38
  echo '</div>';
39
  }
40
  }
 
 
 
 
41
  }
42
 
43
  function wpcf7_editor_panel_form( $post ) {
@@ -62,7 +72,8 @@ function wpcf7_editor_panel_mail( $post ) {
62
  'id' => 'wpcf7-mail-2',
63
  'name' => 'mail_2',
64
  'title' => __( 'Mail (2)', 'contact-form-7' ),
65
- 'use' => __( 'Use Mail (2)', 'contact-form-7' ) ) );
 
66
  }
67
 
68
  function wpcf7_editor_box_mail( $post, $args = '' ) {
@@ -70,14 +81,22 @@ function wpcf7_editor_box_mail( $post, $args = '' ) {
70
  'id' => 'wpcf7-mail',
71
  'name' => 'mail',
72
  'title' => __( 'Mail', 'contact-form-7' ),
73
- 'use' => null ) );
 
74
 
75
  $id = esc_attr( $args['id'] );
76
 
77
  $mail = wp_parse_args( $post->prop( $args['name'] ), array(
78
- 'active' => false, 'recipient' => '', 'sender' => '',
79
- 'subject' => '', 'body' => '', 'additional_headers' => '',
80
- 'attachments' => '', 'use_html' => false, 'exclude_blank' => false ) );
 
 
 
 
 
 
 
81
 
82
  ?>
83
  <div class="contact-form-editor-box-mail" id="<?php echo $id; ?>">
@@ -86,7 +105,7 @@ function wpcf7_editor_box_mail( $post, $args = '' ) {
86
  <?php
87
  if ( ! empty( $args['use'] ) ) :
88
  ?>
89
- <label for="<?php echo $id; ?>-active"><input type="checkbox" id="<?php echo $id; ?>-active" name="<?php echo $id; ?>-active" class="toggle-form-table" value="1"<?php echo ( $mail['active'] ) ? ' checked="checked"' : ''; ?> /> <?php echo esc_html( $args['use'] ); ?></label>
90
  <p class="description"><?php echo esc_html( __( "Mail (2) is an additional mail template often used as an autoresponder.", 'contact-form-7' ) ); ?></p>
91
  <?php
92
  endif;
@@ -102,7 +121,7 @@ function wpcf7_editor_box_mail( $post, $args = '' ) {
102
  <label for="<?php echo $id; ?>-recipient"><?php echo esc_html( __( 'To', 'contact-form-7' ) ); ?></label>
103
  </th>
104
  <td>
105
- <input type="text" id="<?php echo $id; ?>-recipient" name="<?php echo $id; ?>-recipient" class="large-text code" size="70" value="<?php echo esc_attr( $mail['recipient'] ); ?>" data-config-field="<?php echo sprintf( '%s.recipient', esc_attr( $args['name'] ) ); ?>" />
106
  </td>
107
  </tr>
108
 
@@ -111,7 +130,7 @@ function wpcf7_editor_box_mail( $post, $args = '' ) {
111
  <label for="<?php echo $id; ?>-sender"><?php echo esc_html( __( 'From', 'contact-form-7' ) ); ?></label>
112
  </th>
113
  <td>
114
- <input type="text" id="<?php echo $id; ?>-sender" name="<?php echo $id; ?>-sender" class="large-text code" size="70" value="<?php echo esc_attr( $mail['sender'] ); ?>" data-config-field="<?php echo sprintf( '%s.sender', esc_attr( $args['name'] ) ); ?>" />
115
  </td>
116
  </tr>
117
 
@@ -120,7 +139,7 @@ function wpcf7_editor_box_mail( $post, $args = '' ) {
120
  <label for="<?php echo $id; ?>-subject"><?php echo esc_html( __( 'Subject', 'contact-form-7' ) ); ?></label>
121
  </th>
122
  <td>
123
- <input type="text" id="<?php echo $id; ?>-subject" name="<?php echo $id; ?>-subject" class="large-text code" size="70" value="<?php echo esc_attr( $mail['subject'] ); ?>" data-config-field="<?php echo sprintf( '%s.subject', esc_attr( $args['name'] ) ); ?>" />
124
  </td>
125
  </tr>
126
 
@@ -129,7 +148,7 @@ function wpcf7_editor_box_mail( $post, $args = '' ) {
129
  <label for="<?php echo $id; ?>-additional-headers"><?php echo esc_html( __( 'Additional Headers', 'contact-form-7' ) ); ?></label>
130
  </th>
131
  <td>
132
- <textarea id="<?php echo $id; ?>-additional-headers" name="<?php echo $id; ?>-additional-headers" cols="100" rows="4" class="large-text code" data-config-field="<?php echo sprintf( '%s.additional_headers', esc_attr( $args['name'] ) ); ?>"><?php echo esc_textarea( $mail['additional_headers'] ); ?></textarea>
133
  </td>
134
  </tr>
135
 
@@ -138,11 +157,11 @@ function wpcf7_editor_box_mail( $post, $args = '' ) {
138
  <label for="<?php echo $id; ?>-body"><?php echo esc_html( __( 'Message Body', 'contact-form-7' ) ); ?></label>
139
  </th>
140
  <td>
141
- <textarea id="<?php echo $id; ?>-body" name="<?php echo $id; ?>-body" cols="100" rows="18" class="large-text code" data-config-field="<?php echo sprintf( '%s.body', esc_attr( $args['name'] ) ); ?>"><?php echo esc_textarea( $mail['body'] ); ?></textarea>
142
 
143
- <p><label for="<?php echo $id; ?>-exclude-blank"><input type="checkbox" id="<?php echo $id; ?>-exclude-blank" name="<?php echo $id; ?>-exclude-blank" value="1"<?php echo ( ! empty( $mail['exclude_blank'] ) ) ? ' checked="checked"' : ''; ?> /> <?php echo esc_html( __( 'Exclude lines with blank mail-tags from output', 'contact-form-7' ) ); ?></label></p>
144
 
145
- <p><label for="<?php echo $id; ?>-use-html"><input type="checkbox" id="<?php echo $id; ?>-use-html" name="<?php echo $id; ?>-use-html" value="1"<?php echo ( $mail['use_html'] ) ? ' checked="checked"' : ''; ?> /> <?php echo esc_html( __( 'Use HTML content type', 'contact-form-7' ) ); ?></label></p>
146
  </td>
147
  </tr>
148
 
@@ -151,7 +170,7 @@ function wpcf7_editor_box_mail( $post, $args = '' ) {
151
  <label for="<?php echo $id; ?>-attachments"><?php echo esc_html( __( 'File Attachments', 'contact-form-7' ) ); ?></label>
152
  </th>
153
  <td>
154
- <textarea id="<?php echo $id; ?>-attachments" name="<?php echo $id; ?>-attachments" cols="100" rows="4" class="large-text code" data-config-field="<?php echo sprintf( '%s.attachments', esc_attr( $args['name'] ) ); ?>"><?php echo esc_textarea( $mail['attachments'] ); ?></textarea>
155
  </td>
156
  </tr>
157
  </tbody>
@@ -176,12 +195,13 @@ function wpcf7_editor_panel_messages( $post ) {
176
  <?php
177
 
178
  foreach ( $messages as $key => $arr ) {
179
- $field_name = 'wpcf7-message-' . strtr( $key, '_', '-' );
 
180
 
181
  ?>
182
  <p class="description">
183
- <label for="<?php echo $field_name; ?>"><?php echo esc_html( $arr['description'] ); ?><br />
184
- <input type="text" id="<?php echo $field_name; ?>" name="<?php echo $field_name; ?>" class="large-text" size="70" value="<?php echo esc_attr( $post->message( $key, false ) ); ?>" data-config-field="<?php echo sprintf( 'messages.%s', esc_attr( $key ) ); ?>" />
185
  </label>
186
  </p>
187
  <?php
@@ -193,7 +213,7 @@ function wpcf7_editor_panel_messages( $post ) {
193
 
194
  function wpcf7_editor_panel_additional_settings( $post ) {
195
  $desc_link = wpcf7_link(
196
- __( 'http://contactform7.com/additional-settings/', 'contact-form-7' ),
197
  __( 'Additional Settings', 'contact-form-7' ) );
198
  $description = __( "You can add customization code snippets here. For details, see %s.", 'contact-form-7' );
199
  $description = sprintf( esc_html( $description ), $desc_link );
13
  if ( wpcf7_is_name( $id ) ) {
14
  $this->panels[$id] = array(
15
  'title' => $title,
16
+ 'callback' => $callback,
17
+ );
18
  }
19
  }
20
 
35
  foreach ( $this->panels as $id => $panel ) {
36
  echo sprintf( '<div class="contact-form-editor-panel" id="%1$s">',
37
  esc_attr( $id ) );
38
+
39
+ if ( is_callable( $panel['callback'] ) ) {
40
+ $this->notice( $id, $panel );
41
+ call_user_func( $panel['callback'], $this->contact_form );
42
+ }
43
+
44
  echo '</div>';
45
  }
46
  }
47
+
48
+ public function notice( $id, $panel ) {
49
+ echo '<div class="config-error"></div>';
50
+ }
51
  }
52
 
53
  function wpcf7_editor_panel_form( $post ) {
72
  'id' => 'wpcf7-mail-2',
73
  'name' => 'mail_2',
74
  'title' => __( 'Mail (2)', 'contact-form-7' ),
75
+ 'use' => __( 'Use Mail (2)', 'contact-form-7' ),
76
+ ) );
77
  }
78
 
79
  function wpcf7_editor_box_mail( $post, $args = '' ) {
81
  'id' => 'wpcf7-mail',
82
  'name' => 'mail',
83
  'title' => __( 'Mail', 'contact-form-7' ),
84
+ 'use' => null,
85
+ ) );
86
 
87
  $id = esc_attr( $args['id'] );
88
 
89
  $mail = wp_parse_args( $post->prop( $args['name'] ), array(
90
+ 'active' => false,
91
+ 'recipient' => '',
92
+ 'sender' => '',
93
+ 'subject' => '',
94
+ 'body' => '',
95
+ 'additional_headers' => '',
96
+ 'attachments' => '',
97
+ 'use_html' => false,
98
+ 'exclude_blank' => false,
99
+ ) );
100
 
101
  ?>
102
  <div class="contact-form-editor-box-mail" id="<?php echo $id; ?>">
105
  <?php
106
  if ( ! empty( $args['use'] ) ) :
107
  ?>
108
+ <label for="<?php echo $id; ?>-active"><input type="checkbox" id="<?php echo $id; ?>-active" name="<?php echo $id; ?>[active]" class="toggle-form-table" value="1"<?php echo ( $mail['active'] ) ? ' checked="checked"' : ''; ?> /> <?php echo esc_html( $args['use'] ); ?></label>
109
  <p class="description"><?php echo esc_html( __( "Mail (2) is an additional mail template often used as an autoresponder.", 'contact-form-7' ) ); ?></p>
110
  <?php
111
  endif;
121
  <label for="<?php echo $id; ?>-recipient"><?php echo esc_html( __( 'To', 'contact-form-7' ) ); ?></label>
122
  </th>
123
  <td>
124
+ <input type="text" id="<?php echo $id; ?>-recipient" name="<?php echo $id; ?>[recipient]" class="large-text code" size="70" value="<?php echo esc_attr( $mail['recipient'] ); ?>" data-config-field="<?php echo sprintf( '%s.recipient', esc_attr( $args['name'] ) ); ?>" />
125
  </td>
126
  </tr>
127
 
130
  <label for="<?php echo $id; ?>-sender"><?php echo esc_html( __( 'From', 'contact-form-7' ) ); ?></label>
131
  </th>
132
  <td>
133
+ <input type="text" id="<?php echo $id; ?>-sender" name="<?php echo $id; ?>[sender]" class="large-text code" size="70" value="<?php echo esc_attr( $mail['sender'] ); ?>" data-config-field="<?php echo sprintf( '%s.sender', esc_attr( $args['name'] ) ); ?>" />
134
  </td>
135
  </tr>
136
 
139
  <label for="<?php echo $id; ?>-subject"><?php echo esc_html( __( 'Subject', 'contact-form-7' ) ); ?></label>
140
  </th>
141
  <td>
142
+ <input type="text" id="<?php echo $id; ?>-subject" name="<?php echo $id; ?>[subject]" class="large-text code" size="70" value="<?php echo esc_attr( $mail['subject'] ); ?>" data-config-field="<?php echo sprintf( '%s.subject', esc_attr( $args['name'] ) ); ?>" />
143
  </td>
144
  </tr>
145
 
148
  <label for="<?php echo $id; ?>-additional-headers"><?php echo esc_html( __( 'Additional Headers', 'contact-form-7' ) ); ?></label>
149
  </th>
150
  <td>
151
+ <textarea id="<?php echo $id; ?>-additional-headers" name="<?php echo $id; ?>[additional_headers]" cols="100" rows="4" class="large-text code" data-config-field="<?php echo sprintf( '%s.additional_headers', esc_attr( $args['name'] ) ); ?>"><?php echo esc_textarea( $mail['additional_headers'] ); ?></textarea>
152
  </td>
153
  </tr>
154
 
157
  <label for="<?php echo $id; ?>-body"><?php echo esc_html( __( 'Message Body', 'contact-form-7' ) ); ?></label>
158
  </th>
159
  <td>
160
+ <textarea id="<?php echo $id; ?>-body" name="<?php echo $id; ?>[body]" cols="100" rows="18" class="large-text code" data-config-field="<?php echo sprintf( '%s.body', esc_attr( $args['name'] ) ); ?>"><?php echo esc_textarea( $mail['body'] ); ?></textarea>
161
 
162
+ <p><label for="<?php echo $id; ?>-exclude-blank"><input type="checkbox" id="<?php echo $id; ?>-exclude-blank" name="<?php echo $id; ?>[exclude_blank]" value="1"<?php echo ( ! empty( $mail['exclude_blank'] ) ) ? ' checked="checked"' : ''; ?> /> <?php echo esc_html( __( 'Exclude lines with blank mail-tags from output', 'contact-form-7' ) ); ?></label></p>
163
 
164
+ <p><label for="<?php echo $id; ?>-use-html"><input type="checkbox" id="<?php echo $id; ?>-use-html" name="<?php echo $id; ?>[use_html]" value="1"<?php echo ( $mail['use_html'] ) ? ' checked="checked"' : ''; ?> /> <?php echo esc_html( __( 'Use HTML content type', 'contact-form-7' ) ); ?></label></p>
165
  </td>
166
  </tr>
167
 
170
  <label for="<?php echo $id; ?>-attachments"><?php echo esc_html( __( 'File Attachments', 'contact-form-7' ) ); ?></label>
171
  </th>
172
  <td>
173
+ <textarea id="<?php echo $id; ?>-attachments" name="<?php echo $id; ?>[attachments]" cols="100" rows="4" class="large-text code" data-config-field="<?php echo sprintf( '%s.attachments', esc_attr( $args['name'] ) ); ?>"><?php echo esc_textarea( $mail['attachments'] ); ?></textarea>
174
  </td>
175
  </tr>
176
  </tbody>
195
  <?php
196
 
197
  foreach ( $messages as $key => $arr ) {
198
+ $field_id = sprintf( 'wpcf7-message-%s', strtr( $key, '_', '-' ) );
199
+ $field_name = sprintf( 'wpcf7-messages[%s]', $key );
200
 
201
  ?>
202
  <p class="description">
203
+ <label for="<?php echo $field_id; ?>"><?php echo esc_html( $arr['description'] ); ?><br />
204
+ <input type="text" id="<?php echo $field_id; ?>" name="<?php echo $field_name; ?>" class="large-text" size="70" value="<?php echo esc_attr( $post->message( $key, false ) ); ?>" data-config-field="<?php echo sprintf( 'messages.%s', esc_attr( $key ) ); ?>" />
205
  </label>
206
  </p>
207
  <?php
213
 
214
  function wpcf7_editor_panel_additional_settings( $post ) {
215
  $desc_link = wpcf7_link(
216
+ __( 'https://contactform7.com/additional-settings/', 'contact-form-7' ),
217
  __( 'Additional Settings', 'contact-form-7' ) );
218
  $description = __( "You can add customization code snippets here. For details, see %s.", 'contact-form-7' );
219
  $description = sprintf( esc_html( $description ), $desc_link );
admin/includes/help-tabs.php CHANGED
@@ -89,9 +89,9 @@ class WPCF7_Help_Tabs {
89
 
90
  public function sidebar() {
91
  $content = '<p><strong>' . __( 'For more information:', 'contact-form-7' ) . '</strong></p>';
92
- $content .= '<p>' . wpcf7_link( __( 'http://contactform7.com/docs/', 'contact-form-7' ), __( 'Docs', 'contact-form-7' ) ) . '</p>';
93
- $content .= '<p>' . wpcf7_link( __( 'http://contactform7.com/faq/', 'contact-form-7' ), __( 'FAQ', 'contact-form-7' ) ) . '</p>';
94
- $content .= '<p>' . wpcf7_link( __( 'http://contactform7.com/support/', 'contact-form-7' ), __( 'Support', 'contact-form-7' ) ) . '</p>';
95
 
96
  $this->screen->set_help_sidebar( $content );
97
  }
89
 
90
  public function sidebar() {
91
  $content = '<p><strong>' . __( 'For more information:', 'contact-form-7' ) . '</strong></p>';
92
+ $content .= '<p>' . wpcf7_link( __( 'https://contactform7.com/docs/', 'contact-form-7' ), __( 'Docs', 'contact-form-7' ) ) . '</p>';
93
+ $content .= '<p>' . wpcf7_link( __( 'https://contactform7.com/faq/', 'contact-form-7' ), __( 'FAQ', 'contact-form-7' ) ) . '</p>';
94
+ $content .= '<p>' . wpcf7_link( __( 'https://contactform7.com/support/', 'contact-form-7' ), __( 'Support', 'contact-form-7' ) ) . '</p>';
95
 
96
  $this->screen->set_help_sidebar( $content );
97
  }
admin/includes/tag-generator.php CHANGED
@@ -27,7 +27,8 @@ class WPCF7_TagGenerator {
27
  'title' => $title,
28
  'content' => 'tag-generator-panel-' . $id,
29
  'options' => $options,
30
- 'callback' => $callback );
 
31
 
32
  return true;
33
  }
@@ -56,7 +57,8 @@ class WPCF7_TagGenerator {
56
  $options = array_merge( $options, array(
57
  'id' => $id,
58
  'title' => $panel['title'],
59
- 'content' => $panel['content'] ) );
 
60
 
61
  if ( is_callable( $callback ) ) {
62
  echo sprintf( '<div id="%s" class="hidden">',
27
  'title' => $title,
28
  'content' => 'tag-generator-panel-' . $id,
29
  'options' => $options,
30
+ 'callback' => $callback,
31
+ );
32
 
33
  return true;
34
  }
57
  $options = array_merge( $options, array(
58
  'id' => $id,
59
  'title' => $panel['title'],
60
+ 'content' => $panel['content'],
61
+ ) );
62
 
63
  if ( is_callable( $callback ) ) {
64
  echo sprintf( '<div id="%s" class="hidden">',
admin/includes/welcome-panel.php CHANGED
@@ -23,7 +23,7 @@ function wpcf7_welcome_panel() {
23
 
24
  <p><?php echo esc_html( __( "Spammers target everything; your contact forms aren&#8217;t an exception. Before you get spammed, protect your contact forms with the powerful anti-spam features Contact Form 7 provides.", 'contact-form-7' ) ); ?></p>
25
 
26
- <p><?php echo sprintf( esc_html( __( 'Contact Form 7 supports spam-filtering with %1$s. Intelligent %2$s blocks annoying spambots. Plus, using %3$s, you can block messages containing specified keywords or those sent from specified IP addresses.', 'contact-form-7' ) ), wpcf7_link( __( 'http://contactform7.com/spam-filtering-with-akismet/', 'contact-form-7' ), __( 'Akismet', 'contact-form-7' ) ), wpcf7_link( __( 'http://contactform7.com/recaptcha/', 'contact-form-7' ), __( 'reCAPTCHA', 'contact-form-7' ) ), wpcf7_link( __( 'http://contactform7.com/comment-blacklist/', 'contact-form-7' ), __( 'comment blacklist', 'contact-form-7' ) ) ); ?></p>
27
  </div>
28
 
29
  <div class="welcome-panel-column">
@@ -31,7 +31,7 @@ function wpcf7_welcome_panel() {
31
 
32
  <p><?php echo esc_html( __( "Contact Form 7 doesn&#8217;t store submitted messages anywhere. Therefore, you may lose important messages forever if your mail server has issues or you make a mistake in mail configuration.", 'contact-form-7' ) ); ?></p>
33
 
34
- <p><?php echo sprintf( esc_html( __( 'Install a message storage plugin before this happens to you. %s saves all messages through contact forms into the database. Flamingo is a free WordPress plugin created by the same author as Contact Form 7.', 'contact-form-7' ) ), wpcf7_link( __( 'http://contactform7.com/save-submitted-messages-with-flamingo/', 'contact-form-7' ), __( 'Flamingo', 'contact-form-7' ) ) ); ?></p>
35
  </div>
36
 
37
  </div>
23
 
24
  <p><?php echo esc_html( __( "Spammers target everything; your contact forms aren&#8217;t an exception. Before you get spammed, protect your contact forms with the powerful anti-spam features Contact Form 7 provides.", 'contact-form-7' ) ); ?></p>
25
 
26
+ <p><?php echo sprintf( esc_html( __( 'Contact Form 7 supports spam-filtering with %1$s. Intelligent %2$s blocks annoying spambots. Plus, using %3$s, you can block messages containing specified keywords or those sent from specified IP addresses.', 'contact-form-7' ) ), wpcf7_link( __( 'https://contactform7.com/spam-filtering-with-akismet/', 'contact-form-7' ), __( 'Akismet', 'contact-form-7' ) ), wpcf7_link( __( 'https://contactform7.com/recaptcha/', 'contact-form-7' ), __( 'reCAPTCHA', 'contact-form-7' ) ), wpcf7_link( __( 'https://contactform7.com/comment-blacklist/', 'contact-form-7' ), __( 'comment blacklist', 'contact-form-7' ) ) ); ?></p>
27
  </div>
28
 
29
  <div class="welcome-panel-column">
31
 
32
  <p><?php echo esc_html( __( "Contact Form 7 doesn&#8217;t store submitted messages anywhere. Therefore, you may lose important messages forever if your mail server has issues or you make a mistake in mail configuration.", 'contact-form-7' ) ); ?></p>
33
 
34
+ <p><?php echo sprintf( esc_html( __( 'Install a message storage plugin before this happens to you. %s saves all messages through contact forms into the database. Flamingo is a free WordPress plugin created by the same author as Contact Form 7.', 'contact-form-7' ) ), wpcf7_link( __( 'https://contactform7.com/save-submitted-messages-with-flamingo/', 'contact-form-7' ), __( 'Flamingo', 'contact-form-7' ) ) ); ?></p>
35
  </div>
36
 
37
  </div>
admin/js/scripts.js CHANGED
@@ -1,13 +1,13 @@
1
- (function($) {
2
 
3
  'use strict';
4
 
5
- if (typeof _wpcf7 == 'undefined' || _wpcf7 === null) {
6
- _wpcf7 = {};
7
  }
8
 
9
- $(function() {
10
- var welcomePanel = $('#welcome-panel');
11
  var updateWelcomePanel;
12
 
13
  updateWelcomePanel = function( visible ) {
@@ -15,150 +15,267 @@
15
  action: 'wpcf7-update-welcome-panel',
16
  visible: visible,
17
  welcomepanelnonce: $( '#welcomepanelnonce' ).val()
18
- });
19
  };
20
 
21
- $('a.welcome-panel-close', welcomePanel).click(function(event) {
22
  event.preventDefault();
23
- welcomePanel.addClass('hidden');
24
  updateWelcomePanel( 0 );
25
- });
26
 
27
- $('#contact-form-editor').tabs({
28
  active: _wpcf7.activeTab,
29
- activate: function(event, ui) {
30
- $('#active-tab').val(ui.newTab.index());
31
  }
32
- });
33
-
34
- $('#contact-form-editor-tabs').focusin(function(event) {
35
- $('#contact-form-editor .keyboard-interaction').css(
36
- 'visibility', 'visible');
37
- }).focusout(function(event) {
38
- $('#contact-form-editor .keyboard-interaction').css(
39
- 'visibility', 'hidden');
40
- });
41
-
42
- $('input:checkbox.toggle-form-table').click(function(event) {
43
- $(this).wpcf7ToggleFormTable();
44
- }).wpcf7ToggleFormTable();
45
-
46
- if ('' == $('#title').val()) {
47
- $('#title').focus();
48
  }
49
 
50
  $.wpcf7TitleHint();
51
 
52
- $('.contact-form-editor-box-mail span.mailtag').click(function(event) {
53
  var range = document.createRange();
54
- range.selectNodeContents(this);
55
- window.getSelection().addRange(range);
56
- });
57
 
58
- $('[data-config-field]').each(function() {
59
- var section = $(this).attr('data-config-field');
60
-
61
- if (_wpcf7.configErrors[section]) {
62
- var $list = $('<ul></ul>').attr({
63
- 'role': 'alert',
64
- 'class': 'config-error'
65
- });
66
 
67
- $.each(_wpcf7.configErrors[section], function(i, val) {
68
- var $li = $('<li></li>').text(val.message);
69
 
70
- if (val.link) {
71
- var $link = $('<a></a>').attr({
72
- 'href': val.link,
73
- 'class': 'external'
74
- }).text(_wpcf7.howToCorrectLink);
75
 
76
- $li = $li.append(' ').append($link);
77
- }
78
 
79
- $li.appendTo($list);
 
 
 
80
  });
 
81
 
82
- $(this).after($list).attr({'aria-invalid': 'true'});
83
- }
84
- });
 
 
 
 
 
 
 
 
 
 
 
 
85
 
86
- $(window).on('beforeunload', function(event) {
87
  var changed = false;
88
 
89
- $('#wpcf7-admin-form-element :input[type!="hidden"]').each(function() {
90
- if ($(this).is(':checkbox, :radio')) {
91
- if (this.defaultChecked != $(this).is(':checked')) {
92
  changed = true;
93
  }
94
- } else if ($(this).is('select')) {
95
- $(this).find('option').each(function() {
96
- if (this.defaultSelected != $(this).is(':selected')) {
97
  changed = true;
98
  }
99
  });
100
  } else {
101
- if (this.defaultValue != $(this).val()) {
102
  changed = true;
103
  }
104
  }
105
- });
106
 
107
- if (changed) {
108
  event.returnValue = _wpcf7.saveAlert;
109
  return _wpcf7.saveAlert;
110
  }
111
- });
112
 
113
- $('#wpcf7-admin-form-element').submit(function() {
114
- if ('copy' != this.action.value) {
115
- $(window).off('beforeunload');
116
  }
117
 
118
- if ('save' == this.action.value) {
119
- $('#publishing-action .spinner').addClass('is-active');
120
  }
121
- });
122
- });
123
 
124
  $.fn.wpcf7ToggleFormTable = function() {
125
- return this.each(function() {
126
- var formtable = $(this).closest('.contact-form-editor-box-mail').find('fieldset');
127
 
128
- if ($(this).is(':checked')) {
129
- formtable.removeClass('hidden');
130
  } else {
131
- formtable.addClass('hidden');
132
  }
133
- });
134
  };
135
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  /**
137
  * Copied from wptitlehint() in wp-admin/js/post.js
138
  */
139
  $.wpcf7TitleHint = function() {
140
- var title = $('#title');
141
- var titleprompt = $('#title-prompt-text');
142
 
143
- if ('' == title.val()) {
144
- titleprompt.removeClass('screen-reader-text');
145
  }
146
 
147
- titleprompt.click(function() {
148
- $(this).addClass('screen-reader-text');
149
  title.focus();
150
- });
151
 
152
- title.blur(function() {
153
- if ('' == $(this).val()) {
154
- titleprompt.removeClass('screen-reader-text');
155
  }
156
- }).focus(function() {
157
- titleprompt.addClass('screen-reader-text');
158
- }).keydown(function(e) {
159
- titleprompt.addClass('screen-reader-text');
160
- $(this).unbind(e);
161
- });
162
  };
163
 
164
- })(jQuery);
1
+ ( function( $ ) {
2
 
3
  'use strict';
4
 
5
+ if ( typeof _wpcf7 === 'undefined' || _wpcf7 === null ) {
6
+ return;
7
  }
8
 
9
+ $( function() {
10
+ var welcomePanel = $( '#welcome-panel' );
11
  var updateWelcomePanel;
12
 
13
  updateWelcomePanel = function( visible ) {
15
  action: 'wpcf7-update-welcome-panel',
16
  visible: visible,
17
  welcomepanelnonce: $( '#welcomepanelnonce' ).val()
18
+ } );
19
  };
20
 
21
+ $( 'a.welcome-panel-close', welcomePanel ).click( function( event ) {
22
  event.preventDefault();
23
+ welcomePanel.addClass( 'hidden' );
24
  updateWelcomePanel( 0 );
25
+ } );
26
 
27
+ $( '#contact-form-editor' ).tabs( {
28
  active: _wpcf7.activeTab,
29
+ activate: function( event, ui ) {
30
+ $( '#active-tab' ).val( ui.newTab.index() );
31
  }
32
+ } );
33
+
34
+ $( '#contact-form-editor-tabs' ).focusin( function( event ) {
35
+ $( '#contact-form-editor .keyboard-interaction' ).css(
36
+ 'visibility', 'visible' );
37
+ } ).focusout( function( event ) {
38
+ $( '#contact-form-editor .keyboard-interaction' ).css(
39
+ 'visibility', 'hidden' );
40
+ } );
41
+
42
+ $( 'input:checkbox.toggle-form-table' ).click( function( event ) {
43
+ $( this ).wpcf7ToggleFormTable();
44
+ } ).wpcf7ToggleFormTable();
45
+
46
+ if ( '' == $( '#title' ).val() ) {
47
+ $( '#title' ).focus();
48
  }
49
 
50
  $.wpcf7TitleHint();
51
 
52
+ $( '.contact-form-editor-box-mail span.mailtag' ).click( function( event ) {
53
  var range = document.createRange();
54
+ range.selectNodeContents( this );
55
+ window.getSelection().addRange( range );
56
+ } );
57
 
58
+ $.wpcf7UpdateConfigErrors();
 
 
 
 
 
 
 
59
 
60
+ $( '[data-config-field]' ).change( function() {
61
+ var postId = $( '#post_ID' ).val();
62
 
63
+ if ( ! postId || -1 == postId ) {
64
+ return;
65
+ }
 
 
66
 
67
+ var data = [];
 
68
 
69
+ $( this ).closest( 'form' ).find( '[data-config-field]' ).each( function() {
70
+ data.push( {
71
+ 'name': $( this ).attr( 'name' ).replace( /^wpcf7-/, '' ).replace( /-/g, '_' ),
72
+ 'value': $( this ).val()
73
  });
74
+ });
75
 
76
+ data.push( { 'name': 'context', 'value': 'dry-run' } );
77
+
78
+ $.ajax( {
79
+ method: 'POST',
80
+ url: _wpcf7.apiSettings.root +
81
+ 'contact-form-7/v1/contact-forms/' + postId,
82
+ beforeSend: function( xhr ) {
83
+ xhr.setRequestHeader( 'X-WP-Nonce', _wpcf7.apiSettings.nonce );
84
+ },
85
+ data: data
86
+ } ).done( function( response ) {
87
+ _wpcf7.configValidator.errors = response.config_errors;
88
+ $.wpcf7UpdateConfigErrors();
89
+ } );
90
+ } );
91
 
92
+ $( window ).on( 'beforeunload', function( event ) {
93
  var changed = false;
94
 
95
+ $( '#wpcf7-admin-form-element :input[type!="hidden"]' ).each( function() {
96
+ if ( $( this ).is( ':checkbox, :radio' ) ) {
97
+ if ( this.defaultChecked != $( this ).is( ':checked' ) ) {
98
  changed = true;
99
  }
100
+ } else if ( $( this ).is( 'select' ) ) {
101
+ $( this ).find( 'option' ).each( function() {
102
+ if ( this.defaultSelected != $( this ).is( ':selected' ) ) {
103
  changed = true;
104
  }
105
  });
106
  } else {
107
+ if ( this.defaultValue != $( this ).val() ) {
108
  changed = true;
109
  }
110
  }
111
+ } );
112
 
113
+ if ( changed ) {
114
  event.returnValue = _wpcf7.saveAlert;
115
  return _wpcf7.saveAlert;
116
  }
117
+ } );
118
 
119
+ $( '#wpcf7-admin-form-element' ).submit( function() {
120
+ if ( 'copy' != this.action.value ) {
121
+ $( window ).off( 'beforeunload' );
122
  }
123
 
124
+ if ( 'save' == this.action.value ) {
125
+ $( '#publishing-action .spinner' ).addClass( 'is-active' );
126
  }
127
+ } );
128
+ } );
129
 
130
  $.fn.wpcf7ToggleFormTable = function() {
131
+ return this.each( function() {
132
+ var formtable = $( this ).closest( '.contact-form-editor-box-mail' ).find( 'fieldset' );
133
 
134
+ if ( $( this ).is( ':checked' ) ) {
135
+ formtable.removeClass( 'hidden' );
136
  } else {
137
+ formtable.addClass( 'hidden' );
138
  }
139
+ } );
140
  };
141
 
142
+ $.wpcf7UpdateConfigErrors = function() {
143
+ var errors = _wpcf7.configValidator.errors;
144
+ var errorCount = {
145
+ total: 0,
146
+ };
147
+
148
+ $( '[data-config-field]' ).each( function() {
149
+ $( this ).removeAttr( 'aria-invalid' );
150
+ $( this ).next( 'ul.config-error' ).remove();
151
+
152
+ var section = $( this ).attr( 'data-config-field' );
153
+
154
+ if ( errors[ section ] ) {
155
+ var $list = $( '<ul></ul>' ).attr( {
156
+ 'role': 'alert',
157
+ 'class': 'config-error'
158
+ } );
159
+
160
+ $.each( errors[ section ], function( i, val ) {
161
+ var $li = $( '<li></li>' ).text( val.message );
162
+
163
+ if ( val.link ) {
164
+ var $link = $( '<a></a>' ).attr( {
165
+ 'href': val.link,
166
+ 'class': 'external dashicons dashicons-external'
167
+ } ).append( $( '<span></span>' ).attr( {
168
+ 'class': 'screen-reader-text'
169
+ } ).text( _wpcf7.configValidator.howToCorrect ) );
170
+
171
+ $li = $li.append( ' ' ).append( $link );
172
+ }
173
+
174
+ $li.appendTo( $list );
175
+
176
+ var tab = section
177
+ .replace( /^mail_\d+\./, 'mail.' ).replace( /\..*$/, '' );
178
+
179
+ if ( ! errorCount[tab] ) {
180
+ errorCount[tab] = 0;
181
+ }
182
+
183
+ errorCount[tab] += 1;
184
+
185
+ errorCount.total += 1;
186
+ } );
187
+
188
+ $( this ).after( $list ).attr( { 'aria-invalid': 'true' } );
189
+ }
190
+ } );
191
+
192
+ $( '#contact-form-editor-tabs > li' ).each( function() {
193
+ var $item = $( this );
194
+ $item.find( 'span.dashicons' ).remove();
195
+ var tab = $item.attr( 'id' ).replace( /-panel-tab$/, '' );
196
+
197
+ $.each( errors, function( key, val ) {
198
+ key = key.replace( /^mail_\d+\./, 'mail.' );
199
+
200
+ if ( key.replace( /\..*$/, '' ) == tab ) {
201
+ var $mark = $( '<span class="dashicons dashicons-warning"></span>' );
202
+ $item.find( 'a.ui-tabs-anchor' ).first().append( $mark );
203
+ return false;
204
+ }
205
+ } );
206
+
207
+ var $tabPanelError = $( '#' + tab + '-panel > div.config-error:first' );
208
+ $tabPanelError.empty();
209
+
210
+ if ( errorCount[tab] ) {
211
+ $tabPanelError
212
+ .append( '<span class="dashicons dashicons-warning"></span> ' );
213
+
214
+ if ( 1 < errorCount[tab] ) {
215
+ var manyErrorsInTab = _wpcf7.configValidator.manyErrorsInTab
216
+ .replace( '%d', errorCount[tab] );
217
+ $tabPanelError.append( manyErrorsInTab );
218
+ } else {
219
+ $tabPanelError.append( _wpcf7.configValidator.oneErrorInTab );
220
+ }
221
+ }
222
+ } );
223
+
224
+ $( '#misc-publishing-actions .misc-pub-section.config-error' )
225
+ .remove();
226
+
227
+ if ( errorCount.total ) {
228
+ var $warning = $( '<div></div>' )
229
+ .addClass( 'misc-pub-section config-error' )
230
+ .append( '<span class="dashicons dashicons-warning"></span> ' );
231
+
232
+ if ( 1 < errorCount.total ) {
233
+ $warning.append(
234
+ _wpcf7.configValidator.manyErrors.replace( '%d', errorCount.total )
235
+ );
236
+ } else {
237
+ $warning.append( _wpcf7.configValidator.oneError );
238
+ }
239
+
240
+ var $link = $( '<a></a>' ).attr( {
241
+ 'href': _wpcf7.configValidator.docUrl,
242
+ 'class': 'external dashicons dashicons-external'
243
+ } ).append( $( '<span></span>' ).attr( {
244
+ 'class': 'screen-reader-text'
245
+ } ).text( _wpcf7.configValidator.howToCorrect ) );
246
+
247
+ $warning.append( ' ' ).append( $link );
248
+
249
+ $( '#misc-publishing-actions' ).append( $warning );
250
+ }
251
+ }
252
+
253
  /**
254
  * Copied from wptitlehint() in wp-admin/js/post.js
255
  */
256
  $.wpcf7TitleHint = function() {
257
+ var title = $( '#title' );
258
+ var titleprompt = $( '#title-prompt-text' );
259
 
260
+ if ( '' == title.val() ) {
261
+ titleprompt.removeClass( 'screen-reader-text' );
262
  }
263
 
264
+ titleprompt.click( function() {
265
+ $( this ).addClass( 'screen-reader-text' );
266
  title.focus();
267
+ } );
268
 
269
+ title.blur( function() {
270
+ if ( '' == $(this).val() ) {
271
+ titleprompt.removeClass( 'screen-reader-text' );
272
  }
273
+ } ).focus( function() {
274
+ titleprompt.addClass( 'screen-reader-text' );
275
+ } ).keydown( function( e ) {
276
+ titleprompt.addClass( 'screen-reader-text' );
277
+ $( this ).unbind( e );
278
+ } );
279
  };
280
 
281
+ } )( jQuery );
admin/js/tag-generator.js CHANGED
@@ -1,234 +1,240 @@
1
- (function($) {
2
 
3
  'use strict';
4
 
5
- if (typeof _wpcf7 == 'undefined' || _wpcf7 === null) {
6
- _wpcf7 = {};
7
  }
8
 
9
  _wpcf7.taggen = {};
10
 
11
- $(function() {
12
- $('form.tag-generator-panel').each(function() {
13
- _wpcf7.taggen.update($(this));
14
- });
15
- });
16
 
17
- $('form.tag-generator-panel').submit(function(event) {
18
  return false;
19
- });
20
-
21
- $('form.tag-generator-panel .control-box :input').change(function(event) {
22
- var form = $(this).closest('form.tag-generator-panel');
23
- _wpcf7.taggen.normalize($(this));
24
- _wpcf7.taggen.update(form);
25
- });
26
-
27
- $('input.insert-tag').click(function(event) {
28
- var form = $(this).closest('form.tag-generator-panel');
29
- var tag = form.find('input.tag').val();
30
- _wpcf7.taggen.insert(tag);
31
  tb_remove(); // close thickbox
32
  return false;
33
- });
34
 
35
- _wpcf7.taggen.update = function($form) {
36
- var id = $form.attr('data-id');
37
  var name = '';
38
- var name_fields = $form.find('input[name="name"]');
39
 
40
- if (name_fields.length) {
41
  name = name_fields.val();
42
 
43
- if ('' == name) {
44
- name = id + '-' + Math.floor(Math.random() * 1000);
45
- name_fields.val(name);
46
  }
47
  }
48
 
49
- if ($.isFunction(_wpcf7.taggen.update[id])) {
50
- return _wpcf7.taggen.update[id].call(this, $form);
51
  }
52
 
53
- $form.find('input.tag').each(function() {
54
- var tag_type = $(this).attr('name');
55
 
56
- if ($form.find(':input[name="tagtype"]').length) {
57
- tag_type = $form.find(':input[name="tagtype"]').val();
58
  }
59
 
60
- if ($form.find(':input[name="required"]').is(':checked')) {
61
  tag_type += '*';
62
  }
63
 
64
- var components = _wpcf7.taggen.compose(tag_type, $form);
65
- $(this).val(components);
66
- });
67
 
68
- $form.find('span.mail-tag').text('[' + name + ']');
69
-
70
- $form.find('input.mail-tag').each(function() {
71
- $(this).val('[' + name + ']');
72
- });
73
 
 
 
 
74
  };
75
 
76
- _wpcf7.taggen.update.captcha = function($form) {
77
- var captchac = _wpcf7.taggen.compose('captchac', $form);
78
- var captchar = _wpcf7.taggen.compose('captchar', $form);
79
 
80
- $form.find('input.tag').val(captchac + ' ' + captchar);
81
  };
82
 
83
- _wpcf7.taggen.compose = function(tagType, $form) {
84
- var name = $form.find('input[name="name"]').val();
85
- var scope = $form.find('.scope.' + tagType);
86
 
87
- if (! scope.length) {
88
  scope = $form;
89
  }
90
 
91
  var options = [];
92
 
93
- scope.find('input.option').not(':checkbox,:radio').each(function(i) {
94
- var val = $(this).val();
95
 
96
- if (! val) {
97
  return;
98
  }
99
 
100
- if ($(this).hasClass('filetype')) {
101
- val = val.split(/[,|\s]+/).join('|');
102
  }
103
 
104
- if ($(this).hasClass('color')) {
105
  val = '#' + val;
106
  }
107
 
108
- if ('class' == $(this).attr('name')) {
109
- $.each(val.split(' '), function(i, n) { options.push('class:' + n) });
 
 
110
  } else {
111
- options.push($(this).attr('name') + ':' + val);
112
  }
113
- });
114
 
115
- scope.find('input:checkbox.option').each(function(i) {
116
- if ($(this).is(':checked')) {
117
- options.push($(this).attr('name'));
118
  }
119
- });
120
 
121
- scope.find('input:radio.option').each(function(i) {
122
- if ($(this).is(':checked') && ! $(this).hasClass('default')) {
123
- options.push($(this).attr('name') + ':' + $(this).val());
124
  }
125
- });
126
 
127
- if ('radio' == tagType) {
128
- options.push('default:1');
129
  }
130
 
131
- options = (options.length > 0) ? options.join(' ') : '';
132
 
133
  var value = '';
134
 
135
- if (scope.find(':input[name="values"]').val()) {
136
- $.each(scope.find(':input[name="values"]').val().split("\n"), function(i, n) {
137
- value += ' "' + n.replace(/["]/g, '&quot;') + '"';
138
- });
 
 
 
139
  }
140
 
141
  var components = [];
142
 
143
- $.each([tagType, name, options, value], function(i, v) {
144
- v = $.trim(v);
145
 
146
- if ('' != v) {
147
- components.push(v);
148
  }
149
- });
150
 
151
- components = $.trim(components.join(' '));
152
  return '[' + components + ']';
153
- }
154
 
155
- _wpcf7.taggen.normalize = function($input) {
156
  var val = $input.val();
157
 
158
- if ($input.is('input[name="name"]')) {
159
- val = val.replace(/[^0-9a-zA-Z:._-]/g, '').replace(/^[^a-zA-Z]+/, '');
160
  }
161
 
162
- if ($input.is('.numeric')) {
163
- val = val.replace(/[^0-9.-]/g, '');
164
  }
165
 
166
- if ($input.is('.idvalue')) {
167
- val = val.replace(/[^-0-9a-zA-Z_]/g, '');
168
  }
169
 
170
- if ($input.is('.classvalue')) {
171
- val = $.map(val.split(' '), function(n) {
172
- return n.replace(/[^-0-9a-zA-Z_]/g, '');
173
- }).join(' ');
174
 
175
- val = $.trim(val.replace(/\s+/g, ' '));
176
  }
177
 
178
- if ($input.is('.color')) {
179
- val = val.replace(/[^0-9a-fA-F]/g, '');
180
  }
181
 
182
- if ($input.is('.filesize')) {
183
- val = val.replace(/[^0-9kKmMbB]/g, '');
184
  }
185
 
186
- if ($input.is('.filetype')) {
187
- val = val.replace(/[^0-9a-zA-Z.,|\s]/g, '');
188
  }
189
 
190
- if ($input.is('.date')) {
191
- if (! val.match(/^\d{4}-\d{2}-\d{2}$/)) { // 'yyyy-mm-dd' ISO 8601 format
 
192
  val = '';
193
  }
194
  }
195
 
196
- if ($input.is(':input[name="values"]')) {
197
- val = $.trim(val);
198
  }
199
 
200
- $input.val(val);
201
 
202
- if ($input.is(':checkbox.exclusive')) {
203
- _wpcf7.taggen.exclusiveCheckbox($input);
204
  }
205
- }
206
 
207
- _wpcf7.taggen.exclusiveCheckbox = function($cb) {
208
- if ($cb.is(':checked')) {
209
- $cb.siblings(':checkbox.exclusive').prop('checked', false);
210
  }
211
  };
212
 
213
- _wpcf7.taggen.insert = function(content) {
214
- $('textarea#wpcf7-form').each(function() {
215
  this.focus();
216
 
217
- if (document.selection) { // IE
218
  var selection = document.selection.createRange();
219
  selection.text = content;
220
- } else if (this.selectionEnd || 0 === this.selectionEnd) {
221
- var val = $(this).val();
222
  var end = this.selectionEnd;
223
- $(this).val(val.substring(0, end) + content + val.substring(end, val.length));
 
224
  this.selectionStart = end + content.length;
225
  this.selectionEnd = end + content.length;
226
  } else {
227
- $(this).val($(this).val() + content);
228
  }
229
 
230
  this.focus();
231
- });
232
  };
233
 
234
- })(jQuery);
1
+ ( function( $ ) {
2
 
3
  'use strict';
4
 
5
+ if ( typeof _wpcf7 === 'undefined' || _wpcf7 === null ) {
6
+ return;
7
  }
8
 
9
  _wpcf7.taggen = {};
10
 
11
+ $( function() {
12
+ $( 'form.tag-generator-panel' ).each( function() {
13
+ _wpcf7.taggen.update( $( this ) );
14
+ } );
15
+ } );
16
 
17
+ $( 'form.tag-generator-panel' ).submit( function() {
18
  return false;
19
+ } );
20
+
21
+ $( 'form.tag-generator-panel .control-box :input' ).change( function() {
22
+ var $form = $( this ).closest( 'form.tag-generator-panel' );
23
+ _wpcf7.taggen.normalize( $( this ) );
24
+ _wpcf7.taggen.update( $form );
25
+ } );
26
+
27
+ $( 'input.insert-tag' ).click( function() {
28
+ var $form = $( this ).closest( 'form.tag-generator-panel' );
29
+ var tag = $form.find( 'input.tag' ).val();
30
+ _wpcf7.taggen.insert( tag );
31
  tb_remove(); // close thickbox
32
  return false;
33
+ } );
34
 
35
+ _wpcf7.taggen.update = function( $form ) {
36
+ var id = $form.attr( 'data-id' );
37
  var name = '';
38
+ var name_fields = $form.find( 'input[name="name"]' );
39
 
40
+ if ( name_fields.length ) {
41
  name = name_fields.val();
42
 
43
+ if ( '' === name ) {
44
+ name = id + '-' + Math.floor( Math.random() * 1000 );
45
+ name_fields.val( name );
46
  }
47
  }
48
 
49
+ if ( $.isFunction( _wpcf7.taggen.update[ id ] ) ) {
50
+ return _wpcf7.taggen.update[ id ].call( this, $form );
51
  }
52
 
53
+ $form.find( 'input.tag' ).each( function() {
54
+ var tag_type = $( this ).attr( 'name' );
55
 
56
+ if ( $form.find( ':input[name="tagtype"]' ).length ) {
57
+ tag_type = $form.find( ':input[name="tagtype"]' ).val();
58
  }
59
 
60
+ if ( $form.find( ':input[name="required"]' ).is( ':checked' ) ) {
61
  tag_type += '*';
62
  }
63
 
64
+ var components = _wpcf7.taggen.compose( tag_type, $form );
65
+ $( this ).val( components );
66
+ } );
67
 
68
+ $form.find( 'span.mail-tag' ).text( '[' + name + ']' );
 
 
 
 
69
 
70
+ $form.find( 'input.mail-tag' ).each( function() {
71
+ $( this ).val( '[' + name + ']' );
72
+ } );
73
  };
74
 
75
+ _wpcf7.taggen.update.captcha = function( $form ) {
76
+ var captchac = _wpcf7.taggen.compose( 'captchac', $form );
77
+ var captchar = _wpcf7.taggen.compose( 'captchar', $form );
78
 
79
+ $form.find( 'input.tag' ).val( captchac + ' ' + captchar );
80
  };
81
 
82
+ _wpcf7.taggen.compose = function( tagType, $form ) {
83
+ var name = $form.find( 'input[name="name"]' ).val();
84
+ var scope = $form.find( '.scope.' + tagType );
85
 
86
+ if ( ! scope.length ) {
87
  scope = $form;
88
  }
89
 
90
  var options = [];
91
 
92
+ scope.find( 'input.option' ).not( ':checkbox,:radio' ).each( function( i ) {
93
+ var val = $( this ).val();
94
 
95
+ if ( ! val ) {
96
  return;
97
  }
98
 
99
+ if ( $( this ).hasClass( 'filetype' ) ) {
100
+ val = val.split( /[,|\s]+/ ).join( '|' );
101
  }
102
 
103
+ if ( $( this ).hasClass( 'color' ) ) {
104
  val = '#' + val;
105
  }
106
 
107
+ if ( 'class' == $( this ).attr( 'name' ) ) {
108
+ $.each( val.split( ' ' ), function( i, n ) {
109
+ options.push( 'class:' + n );
110
+ } );
111
  } else {
112
+ options.push( $( this ).attr( 'name' ) + ':' + val );
113
  }
114
+ } );
115
 
116
+ scope.find( 'input:checkbox.option' ).each( function( i ) {
117
+ if ( $( this ).is( ':checked' ) ) {
118
+ options.push( $( this ).attr( 'name' ) );
119
  }
120
+ } );
121
 
122
+ scope.find( 'input:radio.option' ).each( function( i ) {
123
+ if ( $( this ).is( ':checked' ) && ! $( this ).hasClass( 'default' ) ) {
124
+ options.push( $( this ).attr( 'name' ) + ':' + $( this ).val() );
125
  }
126
+ } );
127
 
128
+ if ( 'radio' == tagType ) {
129
+ options.push( 'default:1' );
130
  }
131
 
132
+ options = ( options.length > 0 ) ? options.join( ' ' ) : '';
133
 
134
  var value = '';
135
 
136
+ if ( scope.find( ':input[name="values"]' ).val() ) {
137
+ $.each(
138
+ scope.find( ':input[name="values"]' ).val().split( "\n" ),
139
+ function( i, n ) {
140
+ value += ' "' + n.replace( /["]/g, '&quot;' ) + '"';
141
+ }
142
+ );
143
  }
144
 
145
  var components = [];
146
 
147
+ $.each( [ tagType, name, options, value ], function( i, v ) {
148
+ v = $.trim( v );
149
 
150
+ if ( '' != v ) {
151
+ components.push( v );
152
  }
153
+ } );
154
 
155
+ components = $.trim( components.join( ' ' ) );
156
  return '[' + components + ']';
157
+ };
158
 
159
+ _wpcf7.taggen.normalize = function( $input ) {
160
  var val = $input.val();
161
 
162
+ if ( $input.is( 'input[name="name"]' ) ) {
163
+ val = val.replace( /[^0-9a-zA-Z:._-]/g, '' ).replace( /^[^a-zA-Z]+/, '' );
164
  }
165
 
166
+ if ( $input.is( '.numeric' ) ) {
167
+ val = val.replace( /[^0-9.-]/g, '' );
168
  }
169
 
170
+ if ( $input.is( '.idvalue' ) ) {
171
+ val = val.replace( /[^-0-9a-zA-Z_]/g, '' );
172
  }
173
 
174
+ if ( $input.is( '.classvalue' ) ) {
175
+ val = $.map( val.split( ' ' ), function( n ) {
176
+ return n.replace( /[^-0-9a-zA-Z_]/g, '' );
177
+ } ).join( ' ' );
178
 
179
+ val = $.trim( val.replace( /\s+/g, ' ' ) );
180
  }
181
 
182
+ if ( $input.is( '.color' ) ) {
183
+ val = val.replace( /[^0-9a-fA-F]/g, '' );
184
  }
185
 
186
+ if ( $input.is( '.filesize' ) ) {
187
+ val = val.replace( /[^0-9kKmMbB]/g, '' );
188
  }
189
 
190
+ if ( $input.is( '.filetype' ) ) {
191
+ val = val.replace( /[^0-9a-zA-Z.,|\s]/g, '' );
192
  }
193
 
194
+ if ( $input.is( '.date' ) ) {
195
+ // 'yyyy-mm-dd' ISO 8601 format
196
+ if ( ! val.match( /^\d{4}-\d{2}-\d{2}$/ ) ) {
197
  val = '';
198
  }
199
  }
200
 
201
+ if ( $input.is( ':input[name="values"]' ) ) {
202
+ val = $.trim( val );
203
  }
204
 
205
+ $input.val( val );
206
 
207
+ if ( $input.is( ':checkbox.exclusive' ) ) {
208
+ _wpcf7.taggen.exclusiveCheckbox( $input );
209
  }
210
+ };
211
 
212
+ _wpcf7.taggen.exclusiveCheckbox = function( $cb ) {
213
+ if ( $cb.is( ':checked' ) ) {
214
+ $cb.siblings( ':checkbox.exclusive' ).prop( 'checked', false );
215
  }
216
  };
217
 
218
+ _wpcf7.taggen.insert = function( content ) {
219
+ $( 'textarea#wpcf7-form' ).each( function() {
220
  this.focus();
221
 
222
+ if ( document.selection ) { // IE
223
  var selection = document.selection.createRange();
224
  selection.text = content;
225
+ } else if ( this.selectionEnd || 0 === this.selectionEnd ) {
226
+ var val = $( this ).val();
227
  var end = this.selectionEnd;
228
+ $( this ).val( val.substring( 0, end ) +
229
+ content + val.substring( end, val.length ) );
230
  this.selectionStart = end + content.length;
231
  this.selectionEnd = end + content.length;
232
  } else {
233
+ $( this ).val( $( this ).val() + content );
234
  }
235
 
236
  this.focus();
237
+ } );
238
  };
239
 
240
+ } )( jQuery );
includes/capabilities.php CHANGED
@@ -8,7 +8,8 @@ function wpcf7_map_meta_cap( $caps, $cap, $user_id, $args ) {
8
  'wpcf7_edit_contact_forms' => WPCF7_ADMIN_READ_WRITE_CAPABILITY,
9
  'wpcf7_read_contact_forms' => WPCF7_ADMIN_READ_CAPABILITY,
10
  'wpcf7_delete_contact_form' => WPCF7_ADMIN_READ_WRITE_CAPABILITY,
11
- 'wpcf7_manage_integration' => 'manage_options' );
 
12
 
13
  $meta_caps = apply_filters( 'wpcf7_map_meta_cap', $meta_caps );
14
 
8
  'wpcf7_edit_contact_forms' => WPCF7_ADMIN_READ_WRITE_CAPABILITY,
9
  'wpcf7_read_contact_forms' => WPCF7_ADMIN_READ_CAPABILITY,
10
  'wpcf7_delete_contact_form' => WPCF7_ADMIN_READ_WRITE_CAPABILITY,
11
+ 'wpcf7_manage_integration' => 'manage_options',
12
+ );
13
 
14
  $meta_caps = apply_filters( 'wpcf7_map_meta_cap', $meta_caps );
15
 
includes/config-validator.php CHANGED
@@ -4,38 +4,32 @@ class WPCF7_ConfigValidator {
4
 
5
  const error = 100;
6