Version Description
- Introduces the Constant Contact integration module.
- Updates the reCAPTCHA module to support reCAPTCHA v3.
- Adds Dark Mode style rules.
Download this release
Release Info
Developer | takayukister |
Plugin | Contact Form 7 |
Version | 5.1 |
Comparing to | |
See all releases |
Code changes from version 5.0.5 to 5.1
- admin/admin.php +180 -218
- admin/css/styles-dark-mode.css +72 -0
- admin/css/styles-rtl.css +0 -4
- admin/css/styles.css +35 -24
- admin/edit-contact-form.php +21 -7
- admin/includes/admin-functions.php +2 -2
- admin/includes/class-contact-forms-list-table.php +68 -37
- admin/includes/config-validator.php +135 -0
- admin/includes/editor.php +1 -1
- admin/includes/tag-generator.php +4 -2
- admin/includes/welcome-panel.php +5 -3
- admin/js/scripts.js +10 -6
- includes/capabilities.php +2 -0
- includes/config-validator.php +16 -11
- includes/contact-form-functions.php +2 -1
- includes/contact-form-template.php +2 -1
- includes/contact-form.php +20 -7
- includes/controller.php +4 -24
- includes/css/styles.css +0 -4
- includes/form-tag.php +11 -7
- includes/form-tags-manager.php +9 -7
- includes/formatting.php +4 -3
- includes/functions.php +44 -16
- includes/integration.php +188 -2
- includes/js/scripts.js +0 -7
- includes/l10n.php +5 -3
- includes/mail.php +11 -7
- includes/rest-api.php +1 -1
- includes/special-mail-tags.php +6 -3
- includes/submission.php +12 -10
- includes/upgrade.php +6 -2
- includes/validation.php +6 -3
- modules/acceptance.php +9 -6
- modules/akismet.php +3 -2
- modules/checkbox.php +14 -9
- modules/constant-contact.php +677 -0
- modules/count.php +3 -2
- modules/date.php +9 -8
- modules/file.php +31 -18
- modules/flamingo.php +13 -10
- modules/hidden.php +1 -1
- modules/number.php +9 -8
- modules/quiz.php +11 -8
- modules/really-simple-captcha.php +28 -19
- modules/recaptcha.php +301 -366
- modules/response.php +1 -1
- modules/select.php +7 -5
- modules/submit.php +2 -2
- modules/text.php +17 -16
- modules/textarea.php +15 -10
- readme.txt +10 -3
- settings.php +7 -6
- wp-contact-form-7.php +5 -4
admin/admin.php
CHANGED
@@ -4,60 +4,173 @@ require_once WPCF7_PLUGIN_DIR . '/admin/includes/admin-functions.php';
|
|
4 |
require_once WPCF7_PLUGIN_DIR . '/admin/includes/help-tabs.php';
|
5 |
require_once WPCF7_PLUGIN_DIR . '/admin/includes/tag-generator.php';
|
6 |
require_once WPCF7_PLUGIN_DIR . '/admin/includes/welcome-panel.php';
|
|
|
7 |
|
8 |
-
add_action( 'admin_init', 'wpcf7_admin_init' );
|
9 |
|
10 |
function wpcf7_admin_init() {
|
11 |
do_action( 'wpcf7_admin_init' );
|
12 |
}
|
13 |
|
14 |
-
add_action( 'admin_menu', 'wpcf7_admin_menu', 9 );
|
15 |
|
16 |
function wpcf7_admin_menu() {
|
17 |
global $_wp_last_object_menu;
|
18 |
|
19 |
$_wp_last_object_menu++;
|
20 |
|
|
|
|
|
21 |
add_menu_page( __( 'Contact Form 7', 'contact-form-7' ),
|
22 |
-
__( 'Contact', 'contact-form-7' )
|
|
|
23 |
'wpcf7_read_contact_forms', 'wpcf7',
|
24 |
'wpcf7_admin_management_page', 'dashicons-email',
|
25 |
$_wp_last_object_menu );
|
26 |
|
27 |
$edit = add_submenu_page( 'wpcf7',
|
28 |
__( 'Edit Contact Form', 'contact-form-7' ),
|
29 |
-
__( 'Contact Forms', 'contact-form-7' )
|
|
|
30 |
'wpcf7_read_contact_forms', 'wpcf7',
|
31 |
'wpcf7_admin_management_page' );
|
32 |
|
33 |
-
add_action( 'load-' . $edit, 'wpcf7_load_contact_form_admin' );
|
34 |
|
35 |
$addnew = add_submenu_page( 'wpcf7',
|
36 |
__( 'Add New Contact Form', 'contact-form-7' ),
|
37 |
-
__( 'Add New', 'contact-form-7' )
|
|
|
38 |
'wpcf7_edit_contact_forms', 'wpcf7-new',
|
39 |
'wpcf7_admin_add_new_page' );
|
40 |
|
41 |
-
add_action( 'load-' . $addnew, 'wpcf7_load_contact_form_admin' );
|
42 |
|
43 |
$integration = WPCF7_Integration::get_instance();
|
44 |
|
45 |
if ( $integration->service_exists() ) {
|
46 |
$integration = add_submenu_page( 'wpcf7',
|
47 |
__( 'Integration with Other Services', 'contact-form-7' ),
|
48 |
-
__( 'Integration', 'contact-form-7' )
|
|
|
49 |
'wpcf7_manage_integration', 'wpcf7-integration',
|
50 |
'wpcf7_admin_integration_page' );
|
51 |
|
52 |
-
add_action( 'load-' . $integration, 'wpcf7_load_integration_page' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
}
|
55 |
|
56 |
add_filter( 'set-screen-option', 'wpcf7_set_screen_options', 10, 3 );
|
57 |
|
58 |
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;
|
@@ -71,6 +184,11 @@ function wpcf7_load_contact_form_admin() {
|
|
71 |
|
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 );
|
@@ -107,7 +225,7 @@ function wpcf7_load_contact_form_admin() {
|
|
107 |
|
108 |
$contact_form = wpcf7_save_contact_form( $args );
|
109 |
|
110 |
-
if ( $contact_form
|
111 |
$config_validator = new WPCF7_ConfigValidator( $contact_form );
|
112 |
$config_validator->validate();
|
113 |
$config_validator->save();
|
@@ -204,47 +322,6 @@ function wpcf7_load_contact_form_admin() {
|
|
204 |
exit();
|
205 |
}
|
206 |
|
207 |
-
if ( 'validate' == $action && wpcf7_validate_configuration() ) {
|
208 |
-
if ( 'POST' == $_SERVER['REQUEST_METHOD'] ) {
|
209 |
-
check_admin_referer( 'wpcf7-bulk-validate' );
|
210 |
-
|
211 |
-
if ( ! current_user_can( 'wpcf7_edit_contact_forms' ) ) {
|
212 |
-
wp_die( __( "You are not allowed to validate configuration.", 'contact-form-7' ) );
|
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;
|
231 |
-
} else {
|
232 |
-
$result['count_invalid'] += 1;
|
233 |
-
}
|
234 |
-
}
|
235 |
-
|
236 |
-
WPCF7::update_option( 'bulk_validate', $result );
|
237 |
-
|
238 |
-
$query = array(
|
239 |
-
'message' => 'validated',
|
240 |
-
);
|
241 |
-
|
242 |
-
$redirect_to = add_query_arg( $query, menu_page_url( 'wpcf7', false ) );
|
243 |
-
wp_safe_redirect( $redirect_to );
|
244 |
-
exit();
|
245 |
-
}
|
246 |
-
}
|
247 |
-
|
248 |
$_GET['post'] = isset( $_GET['post'] ) ? $_GET['post'] : '';
|
249 |
|
250 |
$post = null;
|
@@ -261,7 +338,8 @@ function wpcf7_load_contact_form_admin() {
|
|
261 |
|
262 |
$help_tabs = new WPCF7_Help_Tabs( $current_screen );
|
263 |
|
264 |
-
if ( $post
|
|
|
265 |
$help_tabs->set_help_tabs( 'edit' );
|
266 |
} else {
|
267 |
$help_tabs->set_help_tabs( 'list' );
|
@@ -271,7 +349,7 @@ function wpcf7_load_contact_form_admin() {
|
|
271 |
}
|
272 |
|
273 |
add_filter( 'manage_' . $current_screen->id . '_columns',
|
274 |
-
array( 'WPCF7_Contact_Form_List_Table', 'define_columns' ) );
|
275 |
|
276 |
add_screen_option( 'per_page', array(
|
277 |
'default' => 20,
|
@@ -280,72 +358,6 @@ function wpcf7_load_contact_form_admin() {
|
|
280 |
}
|
281 |
}
|
282 |
|
283 |
-
add_action( 'admin_enqueue_scripts', 'wpcf7_admin_enqueue_scripts' );
|
284 |
-
|
285 |
-
function wpcf7_admin_enqueue_scripts( $hook_suffix ) {
|
286 |
-
if ( false === strpos( $hook_suffix, 'wpcf7' ) ) {
|
287 |
-
return;
|
288 |
-
}
|
289 |
-
|
290 |
-
wp_enqueue_style( 'contact-form-7-admin',
|
291 |
-
wpcf7_plugin_url( 'admin/css/styles.css' ),
|
292 |
-
array(), WPCF7_VERSION, 'all' );
|
293 |
-
|
294 |
-
if ( wpcf7_is_rtl() ) {
|
295 |
-
wp_enqueue_style( 'contact-form-7-admin-rtl',
|
296 |
-
wpcf7_plugin_url( 'admin/css/styles-rtl.css' ),
|
297 |
-
array(), WPCF7_VERSION, 'all' );
|
298 |
-
}
|
299 |
-
|
300 |
-
wp_enqueue_script( 'wpcf7-admin',
|
301 |
-
wpcf7_plugin_url( 'admin/js/scripts.js' ),
|
302 |
-
array( 'jquery', 'jquery-ui-tabs' ),
|
303 |
-
WPCF7_VERSION, true );
|
304 |
-
|
305 |
-
$args = array(
|
306 |
-
'apiSettings' => array(
|
307 |
-
'root' => esc_url_raw( rest_url( 'contact-form-7/v1' ) ),
|
308 |
-
'namespace' => 'contact-form-7/v1',
|
309 |
-
'nonce' => ( wp_installing() && ! is_multisite() )
|
310 |
-
? '' : wp_create_nonce( 'wp_rest' ),
|
311 |
-
),
|
312 |
-
'pluginUrl' => wpcf7_plugin_url(),
|
313 |
-
'saveAlert' => __(
|
314 |
-
"The changes you made will be lost if you navigate away from this page.",
|
315 |
-
'contact-form-7' ),
|
316 |
-
'activeTab' => isset( $_GET['active-tab'] )
|
317 |
-
? (int) $_GET['active-tab'] : 0,
|
318 |
-
'configValidator' => array(
|
319 |
-
'errors' => array(),
|
320 |
-
'howToCorrect' => __( "How to resolve?", 'contact-form-7' ),
|
321 |
-
'oneError' => __( '1 configuration error detected', 'contact-form-7' ),
|
322 |
-
'manyErrors' => __( '%d configuration errors detected', 'contact-form-7' ),
|
323 |
-
'oneErrorInTab' => __( '1 configuration error detected in this tab panel', 'contact-form-7' ),
|
324 |
-
'manyErrorsInTab' => __( '%d configuration errors detected in this tab panel', 'contact-form-7' ),
|
325 |
-
'docUrl' => WPCF7_ConfigValidator::get_doc_link(),
|
326 |
-
/* translators: screen reader text */
|
327 |
-
'iconAlt' => __( '(configuration error)', 'contact-form-7' ),
|
328 |
-
),
|
329 |
-
);
|
330 |
-
|
331 |
-
if ( ( $post = wpcf7_get_current_contact_form() )
|
332 |
-
&& current_user_can( 'wpcf7_edit_contact_form', $post->id() )
|
333 |
-
&& wpcf7_validate_configuration() ) {
|
334 |
-
$config_validator = new WPCF7_ConfigValidator( $post );
|
335 |
-
$config_validator->restore();
|
336 |
-
$args['configValidator']['errors'] =
|
337 |
-
$config_validator->collect_error_messages();
|
338 |
-
}
|
339 |
-
|
340 |
-
wp_localize_script( 'wpcf7-admin', 'wpcf7', $args );
|
341 |
-
|
342 |
-
add_thickbox();
|
343 |
-
|
344 |
-
wp_enqueue_script( 'wpcf7-admin-taggenerator',
|
345 |
-
wpcf7_plugin_url( 'admin/js/tag-generator.js' ),
|
346 |
-
array( 'jquery', 'thickbox', 'wpcf7-admin' ), WPCF7_VERSION, true );
|
347 |
-
}
|
348 |
-
|
349 |
function wpcf7_admin_management_page() {
|
350 |
if ( $post = wpcf7_get_current_contact_form() ) {
|
351 |
$post_id = $post->initial() ? -1 : $post->id();
|
@@ -356,8 +368,8 @@ function wpcf7_admin_management_page() {
|
|
356 |
}
|
357 |
|
358 |
if ( 'validate' == wpcf7_current_action()
|
359 |
-
|
360 |
-
|
361 |
wpcf7_admin_bulk_validate_page();
|
362 |
return;
|
363 |
}
|
@@ -366,7 +378,7 @@ function wpcf7_admin_management_page() {
|
|
366 |
$list_table->prepare_items();
|
367 |
|
368 |
?>
|
369 |
-
<div class="wrap">
|
370 |
|
371 |
<h1 class="wp-heading-inline"><?php
|
372 |
echo esc_html( __( 'Contact Forms', 'contact-form-7' ) );
|
@@ -374,9 +386,11 @@ function wpcf7_admin_management_page() {
|
|
374 |
|
375 |
<?php
|
376 |
if ( current_user_can( 'wpcf7_edit_contact_forms' ) ) {
|
377 |
-
echo
|
378 |
-
|
379 |
-
|
|
|
|
|
380 |
}
|
381 |
|
382 |
if ( ! empty( $_REQUEST['s'] ) ) {
|
@@ -389,45 +403,22 @@ function wpcf7_admin_management_page() {
|
|
389 |
|
390 |
<hr class="wp-header-end">
|
391 |
|
392 |
-
<?php do_action( 'wpcf7_admin_warnings' ); ?>
|
393 |
-
<?php wpcf7_welcome_panel(); ?>
|
394 |
-
<?php do_action( 'wpcf7_admin_notices' ); ?>
|
395 |
-
|
396 |
-
<form method="get" action="">
|
397 |
-
<input type="hidden" name="page" value="<?php echo esc_attr( $_REQUEST['page'] ); ?>" />
|
398 |
-
<?php $list_table->search_box( __( 'Search Contact Forms', 'contact-form-7' ), 'wpcf7-contact' ); ?>
|
399 |
-
<?php $list_table->display(); ?>
|
400 |
-
</form>
|
401 |
-
|
402 |
-
</div>
|
403 |
<?php
|
404 |
-
|
405 |
-
|
406 |
-
function wpcf7_admin_bulk_validate_page() {
|
407 |
-
$contact_forms = WPCF7_ContactForm::find();
|
408 |
-
$count = WPCF7_ContactForm::count();
|
409 |
|
410 |
-
|
411 |
-
/* translators: %s: number of contact forms */
|
412 |
-
_n(
|
413 |
-
"Validate %s Contact Form Now",
|
414 |
-
"Validate %s Contact Forms Now",
|
415 |
-
$count, 'contact-form-7' ),
|
416 |
-
number_format_i18n( $count ) );
|
417 |
|
|
|
|
|
418 |
?>
|
419 |
-
<div class="wrap">
|
420 |
|
421 |
-
<
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
<?php wp_nonce_field( 'wpcf7-bulk-validate' ); ?>
|
426 |
-
<p><input type="submit" class="button" value="<?php echo esc_attr( $submit_text ); ?>" /></p>
|
427 |
</form>
|
428 |
|
429 |
-
<?php echo wpcf7_link( __( 'https://contactform7.com/configuration-validator-faq/', 'contact-form-7' ), __( 'FAQ about Configuration Validator', 'contact-form-7' ) ); ?>
|
430 |
-
|
431 |
</div>
|
432 |
<?php
|
433 |
}
|
@@ -446,10 +437,15 @@ function wpcf7_admin_add_new_page() {
|
|
446 |
}
|
447 |
|
448 |
function wpcf7_load_integration_page() {
|
|
|
|
|
|
|
|
|
|
|
449 |
$integration = WPCF7_Integration::get_instance();
|
450 |
|
451 |
if ( isset( $_REQUEST['service'] )
|
452 |
-
|
453 |
$service = $integration->get_service( $_REQUEST['service'] );
|
454 |
$service->load( wpcf7_current_action() );
|
455 |
}
|
@@ -461,17 +457,23 @@ function wpcf7_load_integration_page() {
|
|
461 |
function wpcf7_admin_integration_page() {
|
462 |
$integration = WPCF7_Integration::get_instance();
|
463 |
|
|
|
|
|
|
|
|
|
464 |
?>
|
465 |
-
<div class="wrap">
|
466 |
|
467 |
<h1><?php echo esc_html( __( 'Integration with Other Services', 'contact-form-7' ) ); ?></h1>
|
468 |
|
469 |
-
<?php do_action( 'wpcf7_admin_warnings' ); ?>
|
470 |
-
<?php do_action( 'wpcf7_admin_notices' ); ?>
|
471 |
-
|
472 |
<?php
|
473 |
-
|
474 |
-
|
|
|
|
|
|
|
|
|
|
|
475 |
$message = isset( $_REQUEST['message'] ) ? $_REQUEST['message'] : '';
|
476 |
$service->admin_notice( $message );
|
477 |
$integration->list_services( array( 'include' => $_REQUEST['service'] ) );
|
@@ -486,9 +488,9 @@ function wpcf7_admin_integration_page() {
|
|
486 |
|
487 |
/* Misc */
|
488 |
|
489 |
-
add_action( 'wpcf7_admin_notices', 'wpcf7_admin_updated_message' );
|
490 |
|
491 |
-
function wpcf7_admin_updated_message() {
|
492 |
if ( empty( $_REQUEST['message'] ) ) {
|
493 |
return;
|
494 |
}
|
@@ -550,18 +552,19 @@ function wpcf7_plugin_action_links( $links, $file ) {
|
|
550 |
return $links;
|
551 |
}
|
552 |
|
553 |
-
$settings_link =
|
554 |
menu_page_url( 'wpcf7', false ),
|
555 |
-
|
|
|
556 |
|
557 |
array_unshift( $links, $settings_link );
|
558 |
|
559 |
return $links;
|
560 |
}
|
561 |
|
562 |
-
add_action( 'wpcf7_admin_warnings', 'wpcf7_old_wp_version_error' );
|
563 |
|
564 |
-
function wpcf7_old_wp_version_error() {
|
565 |
$wp_version = get_bloginfo( 'version' );
|
566 |
|
567 |
if ( ! version_compare( $wp_version, WPCF7_REQUIRED_WP_VERSION, '<' ) ) {
|
@@ -578,16 +581,16 @@ function wpcf7_old_wp_version_error() {
|
|
578 |
<?php
|
579 |
}
|
580 |
|
581 |
-
add_action( 'wpcf7_admin_warnings', 'wpcf7_not_allowed_to_edit' );
|
582 |
|
583 |
-
function wpcf7_not_allowed_to_edit() {
|
584 |
-
if (
|
|
|
|
|
585 |
return;
|
586 |
}
|
587 |
|
588 |
-
|
589 |
-
|
590 |
-
if ( current_user_can( 'wpcf7_edit_contact_form', $post_id ) ) {
|
591 |
return;
|
592 |
}
|
593 |
|
@@ -598,44 +601,3 @@ function wpcf7_not_allowed_to_edit() {
|
|
598 |
'<div class="notice notice-warning"><p>%s</p></div>',
|
599 |
esc_html( $message ) );
|
600 |
}
|
601 |
-
|
602 |
-
add_action( 'wpcf7_admin_warnings', 'wpcf7_notice_bulk_validate_config', 5 );
|
603 |
-
|
604 |
-
function wpcf7_notice_bulk_validate_config() {
|
605 |
-
if ( ! wpcf7_validate_configuration()
|
606 |
-
|| ! current_user_can( 'wpcf7_edit_contact_forms' ) ) {
|
607 |
-
return;
|
608 |
-
}
|
609 |
-
|
610 |
-
if ( isset( $_GET['page'] ) && 'wpcf7' == $_GET['page']
|
611 |
-
&& isset( $_GET['action'] ) && 'validate' == $_GET['action'] ) {
|
612 |
-
return;
|
613 |
-
}
|
614 |
-
|
615 |
-
$result = WPCF7::get_option( 'bulk_validate' );
|
616 |
-
$last_important_update = '5.0.4';
|
617 |
-
|
618 |
-
if ( ! empty( $result['version'] )
|
619 |
-
&& version_compare( $last_important_update, $result['version'], '<=' ) ) {
|
620 |
-
return;
|
621 |
-
}
|
622 |
-
|
623 |
-
$link = add_query_arg(
|
624 |
-
array( 'action' => 'validate' ),
|
625 |
-
menu_page_url( 'wpcf7', false )
|
626 |
-
);
|
627 |
-
|
628 |
-
$link = sprintf(
|
629 |
-
'<a href="%1$s">%2$s</a>',
|
630 |
-
esc_url( $link ),
|
631 |
-
esc_html( __( 'Validate Contact Form 7 Configuration', 'contact-form-7' ) )
|
632 |
-
);
|
633 |
-
|
634 |
-
$message = __( "Misconfiguration leads to mail delivery failure or other troubles. Validate your contact forms now.", 'contact-form-7' );
|
635 |
-
|
636 |
-
echo sprintf(
|
637 |
-
'<div class="notice notice-warning"><p>%1$s » %2$s</p></div>',
|
638 |
-
esc_html( $message ),
|
639 |
-
$link
|
640 |
-
);
|
641 |
-
}
|
4 |
require_once WPCF7_PLUGIN_DIR . '/admin/includes/help-tabs.php';
|
5 |
require_once WPCF7_PLUGIN_DIR . '/admin/includes/tag-generator.php';
|
6 |
require_once WPCF7_PLUGIN_DIR . '/admin/includes/welcome-panel.php';
|
7 |
+
require_once WPCF7_PLUGIN_DIR . '/admin/includes/config-validator.php';
|
8 |
|
9 |
+
add_action( 'admin_init', 'wpcf7_admin_init', 10, 0 );
|
10 |
|
11 |
function wpcf7_admin_init() {
|
12 |
do_action( 'wpcf7_admin_init' );
|
13 |
}
|
14 |
|
15 |
+
add_action( 'admin_menu', 'wpcf7_admin_menu', 9, 0 );
|
16 |
|
17 |
function wpcf7_admin_menu() {
|
18 |
global $_wp_last_object_menu;
|
19 |
|
20 |
$_wp_last_object_menu++;
|
21 |
|
22 |
+
do_action( 'wpcf7_admin_menu' );
|
23 |
+
|
24 |
add_menu_page( __( 'Contact Form 7', 'contact-form-7' ),
|
25 |
+
__( 'Contact', 'contact-form-7' )
|
26 |
+
. wpcf7_admin_menu_change_notice(),
|
27 |
'wpcf7_read_contact_forms', 'wpcf7',
|
28 |
'wpcf7_admin_management_page', 'dashicons-email',
|
29 |
$_wp_last_object_menu );
|
30 |
|
31 |
$edit = add_submenu_page( 'wpcf7',
|
32 |
__( 'Edit Contact Form', 'contact-form-7' ),
|
33 |
+
__( 'Contact Forms', 'contact-form-7' )
|
34 |
+
. wpcf7_admin_menu_change_notice( 'wpcf7' ),
|
35 |
'wpcf7_read_contact_forms', 'wpcf7',
|
36 |
'wpcf7_admin_management_page' );
|
37 |
|
38 |
+
add_action( 'load-' . $edit, 'wpcf7_load_contact_form_admin', 10, 0 );
|
39 |
|
40 |
$addnew = add_submenu_page( 'wpcf7',
|
41 |
__( 'Add New Contact Form', 'contact-form-7' ),
|
42 |
+
__( 'Add New', 'contact-form-7' )
|
43 |
+
. wpcf7_admin_menu_change_notice( 'wpcf7-new' ),
|
44 |
'wpcf7_edit_contact_forms', 'wpcf7-new',
|
45 |
'wpcf7_admin_add_new_page' );
|
46 |
|
47 |
+
add_action( 'load-' . $addnew, 'wpcf7_load_contact_form_admin', 10, 0 );
|
48 |
|
49 |
$integration = WPCF7_Integration::get_instance();
|
50 |
|
51 |
if ( $integration->service_exists() ) {
|
52 |
$integration = add_submenu_page( 'wpcf7',
|
53 |
__( 'Integration with Other Services', 'contact-form-7' ),
|
54 |
+
__( 'Integration', 'contact-form-7' )
|
55 |
+
. wpcf7_admin_menu_change_notice( 'wpcf7-integration' ),
|
56 |
'wpcf7_manage_integration', 'wpcf7-integration',
|
57 |
'wpcf7_admin_integration_page' );
|
58 |
|
59 |
+
add_action( 'load-' . $integration, 'wpcf7_load_integration_page', 10, 0 );
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
function wpcf7_admin_menu_change_notice( $menu_slug = '' ) {
|
64 |
+
$counts = apply_filters( 'wpcf7_admin_menu_change_notice',
|
65 |
+
array(
|
66 |
+
'wpcf7' => 0,
|
67 |
+
'wpcf7-new' => 0,
|
68 |
+
'wpcf7-integration' => 0,
|
69 |
+
)
|
70 |
+
);
|
71 |
+
|
72 |
+
if ( empty( $menu_slug ) ) {
|
73 |
+
$count = absint( array_sum( $counts ) );
|
74 |
+
} elseif ( isset( $counts[$menu_slug] ) ) {
|
75 |
+
$count = absint( $counts[$menu_slug] );
|
76 |
+
} else {
|
77 |
+
$count = 0;
|
78 |
+
}
|
79 |
+
|
80 |
+
if ( $count ) {
|
81 |
+
return sprintf(
|
82 |
+
' <span class="update-plugins %1$d"><span class="plugin-count">%2$s</span></span>',
|
83 |
+
$count,
|
84 |
+
esc_html( number_format_i18n( $count ) )
|
85 |
+
);
|
86 |
+
}
|
87 |
+
|
88 |
+
return '';
|
89 |
+
}
|
90 |
+
|
91 |
+
add_action( 'admin_enqueue_scripts', 'wpcf7_admin_enqueue_scripts', 10, 1 );
|
92 |
+
|
93 |
+
function wpcf7_admin_enqueue_scripts( $hook_suffix ) {
|
94 |
+
if ( false === strpos( $hook_suffix, 'wpcf7' ) ) {
|
95 |
+
return;
|
96 |
+
}
|
97 |
+
|
98 |
+
wp_enqueue_style( 'contact-form-7-admin',
|
99 |
+
wpcf7_plugin_url( 'admin/css/styles.css' ),
|
100 |
+
array(), WPCF7_VERSION, 'all'
|
101 |
+
);
|
102 |
+
|
103 |
+
if ( wpcf7_is_rtl() ) {
|
104 |
+
wp_enqueue_style( 'contact-form-7-admin-rtl',
|
105 |
+
wpcf7_plugin_url( 'admin/css/styles-rtl.css' ),
|
106 |
+
array(), WPCF7_VERSION, 'all'
|
107 |
+
);
|
108 |
+
}
|
109 |
+
|
110 |
+
wp_enqueue_script( 'wpcf7-admin',
|
111 |
+
wpcf7_plugin_url( 'admin/js/scripts.js' ),
|
112 |
+
array( 'jquery', 'jquery-ui-tabs' ),
|
113 |
+
WPCF7_VERSION, true
|
114 |
+
);
|
115 |
+
|
116 |
+
$args = array(
|
117 |
+
'apiSettings' => array(
|
118 |
+
'root' => esc_url_raw( rest_url( 'contact-form-7/v1' ) ),
|
119 |
+
'namespace' => 'contact-form-7/v1',
|
120 |
+
'nonce' => ( wp_installing() && ! is_multisite() )
|
121 |
+
? '' : wp_create_nonce( 'wp_rest' ),
|
122 |
+
),
|
123 |
+
'pluginUrl' => wpcf7_plugin_url(),
|
124 |
+
'saveAlert' => __(
|
125 |
+
"The changes you made will be lost if you navigate away from this page.",
|
126 |
+
'contact-form-7' ),
|
127 |
+
'activeTab' => isset( $_GET['active-tab'] )
|
128 |
+
? (int) $_GET['active-tab'] : 0,
|
129 |
+
'configValidator' => array(
|
130 |
+
'errors' => array(),
|
131 |
+
'howToCorrect' => __( "How to resolve?", 'contact-form-7' ),
|
132 |
+
'oneError' => __( '1 configuration error detected', 'contact-form-7' ),
|
133 |
+
'manyErrors' => __( '%d configuration errors detected', 'contact-form-7' ),
|
134 |
+
'oneErrorInTab' => __( '1 configuration error detected in this tab panel', 'contact-form-7' ),
|
135 |
+
'manyErrorsInTab' => __( '%d configuration errors detected in this tab panel', 'contact-form-7' ),
|
136 |
+
'docUrl' => WPCF7_ConfigValidator::get_doc_link(),
|
137 |
+
/* translators: screen reader text */
|
138 |
+
'iconAlt' => __( '(configuration error)', 'contact-form-7' ),
|
139 |
+
),
|
140 |
+
);
|
141 |
+
|
142 |
+
if ( $post = wpcf7_get_current_contact_form()
|
143 |
+
and current_user_can( 'wpcf7_edit_contact_form', $post->id() )
|
144 |
+
and wpcf7_validate_configuration() ) {
|
145 |
+
$config_validator = new WPCF7_ConfigValidator( $post );
|
146 |
+
$config_validator->restore();
|
147 |
+
$args['configValidator']['errors'] =
|
148 |
+
$config_validator->collect_error_messages();
|
149 |
}
|
150 |
+
|
151 |
+
wp_localize_script( 'wpcf7-admin', 'wpcf7', $args );
|
152 |
+
|
153 |
+
add_thickbox();
|
154 |
+
|
155 |
+
wp_enqueue_script( 'wpcf7-admin-taggenerator',
|
156 |
+
wpcf7_plugin_url( 'admin/js/tag-generator.js' ),
|
157 |
+
array( 'jquery', 'thickbox', 'wpcf7-admin' ), WPCF7_VERSION, true );
|
158 |
+
}
|
159 |
+
|
160 |
+
add_action( 'doing_dark_mode', 'wpcf7_dark_mode_support', 10, 1 );
|
161 |
+
|
162 |
+
function wpcf7_dark_mode_support( $user_id ) {
|
163 |
+
wp_enqueue_style( 'contact-form-7-admin-dark-mode',
|
164 |
+
wpcf7_plugin_url( 'admin/css/styles-dark-mode.css' ),
|
165 |
+
array( 'contact-form-7-admin' ), WPCF7_VERSION, 'screen' );
|
166 |
}
|
167 |
|
168 |
add_filter( 'set-screen-option', 'wpcf7_set_screen_options', 10, 3 );
|
169 |
|
170 |
function wpcf7_set_screen_options( $result, $option, $value ) {
|
171 |
$wpcf7_screens = array(
|
172 |
+
'cfseven_contact_forms_per_page',
|
173 |
+
);
|
174 |
|
175 |
if ( in_array( $option, $wpcf7_screens ) ) {
|
176 |
$result = $value;
|
184 |
|
185 |
$action = wpcf7_current_action();
|
186 |
|
187 |
+
do_action( 'wpcf7_admin_load',
|
188 |
+
isset( $_GET['page'] ) ? trim( $_GET['page'] ) : '',
|
189 |
+
$action
|
190 |
+
);
|
191 |
+
|
192 |
if ( 'save' == $action ) {
|
193 |
$id = isset( $_POST['post_ID'] ) ? $_POST['post_ID'] : '-1';
|
194 |
check_admin_referer( 'wpcf7-save-contact-form_' . $id );
|
225 |
|
226 |
$contact_form = wpcf7_save_contact_form( $args );
|
227 |
|
228 |
+
if ( $contact_form and wpcf7_validate_configuration() ) {
|
229 |
$config_validator = new WPCF7_ConfigValidator( $contact_form );
|
230 |
$config_validator->validate();
|
231 |
$config_validator->save();
|
322 |
exit();
|
323 |
}
|
324 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
325 |
$_GET['post'] = isset( $_GET['post'] ) ? $_GET['post'] : '';
|
326 |
|
327 |
$post = null;
|
338 |
|
339 |
$help_tabs = new WPCF7_Help_Tabs( $current_screen );
|
340 |
|
341 |
+
if ( $post
|
342 |
+
and current_user_can( 'wpcf7_edit_contact_form', $post->id() ) ) {
|
343 |
$help_tabs->set_help_tabs( 'edit' );
|
344 |
} else {
|
345 |
$help_tabs->set_help_tabs( 'list' );
|
349 |
}
|
350 |
|
351 |
add_filter( 'manage_' . $current_screen->id . '_columns',
|
352 |
+
array( 'WPCF7_Contact_Form_List_Table', 'define_columns' ), 10, 0 );
|
353 |
|
354 |
add_screen_option( 'per_page', array(
|
355 |
'default' => 20,
|
358 |
}
|
359 |
}
|
360 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
361 |
function wpcf7_admin_management_page() {
|
362 |
if ( $post = wpcf7_get_current_contact_form() ) {
|
363 |
$post_id = $post->initial() ? -1 : $post->id();
|
368 |
}
|
369 |
|
370 |
if ( 'validate' == wpcf7_current_action()
|
371 |
+
and wpcf7_validate_configuration()
|
372 |
+
and current_user_can( 'wpcf7_edit_contact_forms' ) ) {
|
373 |
wpcf7_admin_bulk_validate_page();
|
374 |
return;
|
375 |
}
|
378 |
$list_table->prepare_items();
|
379 |
|
380 |
?>
|
381 |
+
<div class="wrap" id="wpcf7-contact-form-list-table">
|
382 |
|
383 |
<h1 class="wp-heading-inline"><?php
|
384 |
echo esc_html( __( 'Contact Forms', 'contact-form-7' ) );
|
386 |
|
387 |
<?php
|
388 |
if ( current_user_can( 'wpcf7_edit_contact_forms' ) ) {
|
389 |
+
echo wpcf7_link(
|
390 |
+
menu_page_url( 'wpcf7-new', false ),
|
391 |
+
__( 'Add New', 'contact-form-7' ),
|
392 |
+
array( 'class' => 'page-title-action' )
|
393 |
+
);
|
394 |
}
|
395 |
|
396 |
if ( ! empty( $_REQUEST['s'] ) ) {
|
403 |
|
404 |
<hr class="wp-header-end">
|
405 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
406 |
<?php
|
407 |
+
do_action( 'wpcf7_admin_warnings',
|
408 |
+
'wpcf7', wpcf7_current_action(), null );
|
|
|
|
|
|
|
409 |
|
410 |
+
wpcf7_welcome_panel();
|
|
|
|
|
|
|
|
|
|
|
|
|
411 |
|
412 |
+
do_action( 'wpcf7_admin_notices',
|
413 |
+
'wpcf7', wpcf7_current_action(), null );
|
414 |
?>
|
|
|
415 |
|
416 |
+
<form method="get" action="">
|
417 |
+
<input type="hidden" name="page" value="<?php echo esc_attr( $_REQUEST['page'] ); ?>" />
|
418 |
+
<?php $list_table->search_box( __( 'Search Contact Forms', 'contact-form-7' ), 'wpcf7-contact' ); ?>
|
419 |
+
<?php $list_table->display(); ?>
|
|
|
|
|
420 |
</form>
|
421 |
|
|
|
|
|
422 |
</div>
|
423 |
<?php
|
424 |
}
|
437 |
}
|
438 |
|
439 |
function wpcf7_load_integration_page() {
|
440 |
+
do_action( 'wpcf7_admin_load',
|
441 |
+
isset( $_GET['page'] ) ? trim( $_GET['page'] ) : '',
|
442 |
+
wpcf7_current_action()
|
443 |
+
);
|
444 |
+
|
445 |
$integration = WPCF7_Integration::get_instance();
|
446 |
|
447 |
if ( isset( $_REQUEST['service'] )
|
448 |
+
and $integration->service_exists( $_REQUEST['service'] ) ) {
|
449 |
$service = $integration->get_service( $_REQUEST['service'] );
|
450 |
$service->load( wpcf7_current_action() );
|
451 |
}
|
457 |
function wpcf7_admin_integration_page() {
|
458 |
$integration = WPCF7_Integration::get_instance();
|
459 |
|
460 |
+
$service = isset( $_REQUEST['service'] )
|
461 |
+
? $integration->get_service( $_REQUEST['service'] )
|
462 |
+
: null;
|
463 |
+
|
464 |
?>
|
465 |
+
<div class="wrap" id="wpcf7-integration">
|
466 |
|
467 |
<h1><?php echo esc_html( __( 'Integration with Other Services', 'contact-form-7' ) ); ?></h1>
|
468 |
|
|
|
|
|
|
|
469 |
<?php
|
470 |
+
do_action( 'wpcf7_admin_warnings',
|
471 |
+
'wpcf7-integration', wpcf7_current_action(), $service );
|
472 |
+
|
473 |
+
do_action( 'wpcf7_admin_notices',
|
474 |
+
'wpcf7-integration', wpcf7_current_action(), $service );
|
475 |
+
|
476 |
+
if ( $service ) {
|
477 |
$message = isset( $_REQUEST['message'] ) ? $_REQUEST['message'] : '';
|
478 |
$service->admin_notice( $message );
|
479 |
$integration->list_services( array( 'include' => $_REQUEST['service'] ) );
|
488 |
|
489 |
/* Misc */
|
490 |
|
491 |
+
add_action( 'wpcf7_admin_notices', 'wpcf7_admin_updated_message', 10, 3 );
|
492 |
|
493 |
+
function wpcf7_admin_updated_message( $page, $action, $object ) {
|
494 |
if ( empty( $_REQUEST['message'] ) ) {
|
495 |
return;
|
496 |
}
|
552 |
return $links;
|
553 |
}
|
554 |
|
555 |
+
$settings_link = wpcf7_link(
|
556 |
menu_page_url( 'wpcf7', false ),
|
557 |
+
__( 'Settings', 'contact-form-7' )
|
558 |
+
);
|
559 |
|
560 |
array_unshift( $links, $settings_link );
|
561 |
|
562 |
return $links;
|
563 |
}
|
564 |
|
565 |
+
add_action( 'wpcf7_admin_warnings', 'wpcf7_old_wp_version_error', 10, 3 );
|
566 |
|
567 |
+
function wpcf7_old_wp_version_error( $page, $action, $object ) {
|
568 |
$wp_version = get_bloginfo( 'version' );
|
569 |
|
570 |
if ( ! version_compare( $wp_version, WPCF7_REQUIRED_WP_VERSION, '<' ) ) {
|
581 |
<?php
|
582 |
}
|
583 |
|
584 |
+
add_action( 'wpcf7_admin_warnings', 'wpcf7_not_allowed_to_edit', 10, 3 );
|
585 |
|
586 |
+
function wpcf7_not_allowed_to_edit( $page, $action, $object ) {
|
587 |
+
if ( $object instanceof WPCF7_ContactForm ) {
|
588 |
+
$contact_form = $object;
|
589 |
+
} else {
|
590 |
return;
|
591 |
}
|
592 |
|
593 |
+
if ( current_user_can( 'wpcf7_edit_contact_form', $contact_form->id() ) ) {
|
|
|
|
|
594 |
return;
|
595 |
}
|
596 |
|
601 |
'<div class="notice notice-warning"><p>%s</p></div>',
|
602 |
esc_html( $message ) );
|
603 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/css/styles-dark-mode.css
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#wpcf7-contact-form-list-table span.shortcode input,
|
2 |
+
#wpcf7-contact-form-editor span.shortcode input {
|
3 |
+
color: #fff;
|
4 |
+
}
|
5 |
+
|
6 |
+
div.config-error, span.config-error, ul.config-error {
|
7 |
+
color: #bbc8d4;
|
8 |
+
}
|
9 |
+
|
10 |
+
.keyboard-interaction {
|
11 |
+
color: #bbc8d4;
|
12 |
+
}
|
13 |
+
|
14 |
+
#contact-form-editor .contact-form-editor-panel {
|
15 |
+
background-color: #32373c;
|
16 |
+
}
|
17 |
+
|
18 |
+
#contact-form-editor-tabs {
|
19 |
+
border-bottom: 1px solid #aaa;
|
20 |
+
}
|
21 |
+
|
22 |
+
#contact-form-editor-tabs li {
|
23 |
+
border: 1px solid #ccc;
|
24 |
+
border-bottom: 1px solid #aaa;
|
25 |
+
background-color: #37444c;
|
26 |
+
}
|
27 |
+
|
28 |
+
#contact-form-editor-tabs li:hover {
|
29 |
+
background-color: #000;
|
30 |
+
}
|
31 |
+
|
32 |
+
#contact-form-editor-tabs li.ui-tabs-active,
|
33 |
+
#contact-form-editor-tabs li.ui-tabs-active:hover {
|
34 |
+
border-top: 1px solid #aaa;
|
35 |
+
border-right: 1px solid #aaa;
|
36 |
+
border-left: 1px solid #aaa;
|
37 |
+
border-bottom: 1px solid #32373c;
|
38 |
+
background-color: #32373c;
|
39 |
+
}
|
40 |
+
|
41 |
+
#contact-form-editor-tabs li a {
|
42 |
+
color: #bbc8d4;
|
43 |
+
}
|
44 |
+
|
45 |
+
#contact-form-editor-tabs li.ui-tabs-active a {
|
46 |
+
color: #fff;
|
47 |
+
}
|
48 |
+
|
49 |
+
#contact-form-editor-tabs li a:hover {
|
50 |
+
color: #fff;
|
51 |
+
}
|
52 |
+
|
53 |
+
.contact-form-editor-box-mail span.mailtag {
|
54 |
+
color: #ddd;
|
55 |
+
}
|
56 |
+
|
57 |
+
.contact-form-editor-box-mail span.mailtag.used {
|
58 |
+
color: #999;
|
59 |
+
}
|
60 |
+
|
61 |
+
#mail-panel .contact-form-editor-box-mail table.form-table tr th,
|
62 |
+
#mail-panel .contact-form-editor-box-mail table.form-table tr td {
|
63 |
+
background-color: #32373c;
|
64 |
+
}
|
65 |
+
|
66 |
+
div.wrap#wpcf7-integration .card.active {
|
67 |
+
border-color: #00a0d2;
|
68 |
+
}
|
69 |
+
|
70 |
+
div.wrap#wpcf7-integration .card .infobox {
|
71 |
+
color: #aaa;
|
72 |
+
}
|
admin/css/styles-rtl.css
CHANGED
@@ -5,10 +5,6 @@
|
|
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 |
*/
|
5 |
padding: 9px 10px 0 15px;
|
6 |
}
|
7 |
|
|
|
|
|
|
|
|
|
8 |
/*
|
9 |
* Form Tab
|
10 |
*/
|
admin/css/styles.css
CHANGED
@@ -16,9 +16,7 @@ span.shortcode.old {
|
|
16 |
color: #fff;
|
17 |
}
|
18 |
|
19 |
-
span.shortcode
|
20 |
-
background: inherit;
|
21 |
-
color: inherit;
|
22 |
font-size: 12px;
|
23 |
border: none;
|
24 |
box-shadow: none;
|
@@ -26,6 +24,19 @@ span.shortcode > input {
|
|
26 |
margin: 0;
|
27 |
}
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
#submitpost input.copy {
|
30 |
margin-bottom: 10px;
|
31 |
}
|
@@ -72,15 +83,30 @@ ul.config-error li {
|
|
72 |
margin: 0;
|
73 |
}
|
74 |
|
75 |
-
div.config-error span.dashicons,
|
76 |
-
ul.config-error li span.dashicons {
|
77 |
-
color: #82878c;
|
78 |
-
}
|
79 |
-
|
80 |
[data-config-field][aria-invalid="true"] {
|
81 |
border-color: #d00;
|
82 |
}
|
83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
/*
|
85 |
* Tabs
|
86 |
*/
|
@@ -132,22 +158,11 @@ ul.config-error li span.dashicons {
|
|
132 |
color: #000;
|
133 |
}
|
134 |
|
135 |
-
#contact-form-editor-tabs li a span.dashicons {
|
136 |
-
font-style: normal;
|
137 |
-
padding: 6px 0 4px 4px;
|
138 |
-
color: #82878c;
|
139 |
-
}
|
140 |
-
|
141 |
-
#contact-form-editor-tabs li a span.dashicons-warning,
|
142 |
-
#contact-form-editor .contact-form-editor-panel > div.config-error span.dashicons-warning {
|
143 |
-
color: #ca4a1f;
|
144 |
-
}
|
145 |
-
|
146 |
#contact-form-editor .contact-form-editor-panel > div.config-error {
|
147 |
margin-bottom: 1.4em;
|
148 |
}
|
149 |
|
150 |
-
#contact-form-editor-tabs li.ui-tabs-active a
|
151 |
display: none;
|
152 |
}
|
153 |
|
@@ -327,10 +342,6 @@ ul.config-error li span.dashicons {
|
|
327 |
width: 38%;
|
328 |
}
|
329 |
|
330 |
-
.wp-list-table .config-error span.dashicons-warning {
|
331 |
-
color: #ca4a1f;
|
332 |
-
}
|
333 |
-
|
334 |
/*
|
335 |
* Welcome Panel
|
336 |
*/
|
16 |
color: #fff;
|
17 |
}
|
18 |
|
19 |
+
span.shortcode input {
|
|
|
|
|
20 |
font-size: 12px;
|
21 |
border: none;
|
22 |
box-shadow: none;
|
24 |
margin: 0;
|
25 |
}
|
26 |
|
27 |
+
#wpcf7-contact-form-list-table span.shortcode input,
|
28 |
+
#wpcf7-contact-form-editor span.shortcode input {
|
29 |
+
background: transparent;
|
30 |
+
}
|
31 |
+
|
32 |
+
#wpcf7-contact-form-list-table span.shortcode input {
|
33 |
+
color: #444;
|
34 |
+
}
|
35 |
+
|
36 |
+
#wpcf7-contact-form-editor span.shortcode input {
|
37 |
+
color: #fff;
|
38 |
+
}
|
39 |
+
|
40 |
#submitpost input.copy {
|
41 |
margin-bottom: 10px;
|
42 |
}
|
83 |
margin: 0;
|
84 |
}
|
85 |
|
|
|
|
|
|
|
|
|
|
|
86 |
[data-config-field][aria-invalid="true"] {
|
87 |
border-color: #d00;
|
88 |
}
|
89 |
|
90 |
+
#contact-form-editor-tabs li a .icon-in-circle,
|
91 |
+
#contact-form-editor .config-error .icon-in-circle,
|
92 |
+
.wp-list-table .config-error .icon-in-circle,
|
93 |
+
.icon-in-circle {
|
94 |
+
display: inline-block;
|
95 |
+
vertical-align: text-top;
|
96 |
+
margin: 1px 6px 0;
|
97 |
+
padding: 0 5px;
|
98 |
+
min-width: 7px;
|
99 |
+
height: 17px;
|
100 |
+
border-radius: 11px;
|
101 |
+
background-color: #ca4a1f;
|
102 |
+
color: #fff;
|
103 |
+
font-size: 12px;
|
104 |
+
font-weight: bold;
|
105 |
+
line-height: 17px;
|
106 |
+
text-align: center;
|
107 |
+
z-index: 26;
|
108 |
+
}
|
109 |
+
|
110 |
/*
|
111 |
* Tabs
|
112 |
*/
|
158 |
color: #000;
|
159 |
}
|
160 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
#contact-form-editor .contact-form-editor-panel > div.config-error {
|
162 |
margin-bottom: 1.4em;
|
163 |
}
|
164 |
|
165 |
+
#contact-form-editor-tabs li.ui-tabs-active a .icon-in-circle {
|
166 |
display: none;
|
167 |
}
|
168 |
|
342 |
width: 38%;
|
343 |
}
|
344 |
|
|
|
|
|
|
|
|
|
345 |
/*
|
346 |
* Welcome Panel
|
347 |
*/
|
admin/edit-contact-form.php
CHANGED
@@ -29,7 +29,7 @@ function wpcf7_admin_save_button( $post_id ) {
|
|
29 |
echo $button;
|
30 |
}
|
31 |
|
32 |
-
?><div class="wrap">
|
33 |
|
34 |
<h1 class="wp-heading-inline"><?php
|
35 |
if ( $post->initial() ) {
|
@@ -40,17 +40,31 @@ function wpcf7_admin_save_button( $post_id ) {
|
|
40 |
?></h1>
|
41 |
|
42 |
<?php
|
43 |
-
if ( ! $post->initial()
|
44 |
-
|
45 |
-
|
46 |
-
|
|
|
|
|
|
|
47 |
}
|
48 |
?>
|
49 |
|
50 |
<hr class="wp-header-end">
|
51 |
|
52 |
-
<?php
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
<?php
|
56 |
if ( $post ) :
|
29 |
echo $button;
|
30 |
}
|
31 |
|
32 |
+
?><div class="wrap" id="wpcf7-contact-form-editor">
|
33 |
|
34 |
<h1 class="wp-heading-inline"><?php
|
35 |
if ( $post->initial() ) {
|
40 |
?></h1>
|
41 |
|
42 |
<?php
|
43 |
+
if ( ! $post->initial()
|
44 |
+
and current_user_can( 'wpcf7_edit_contact_forms' ) ) {
|
45 |
+
echo wpcf7_link(
|
46 |
+
menu_page_url( 'wpcf7-new', false ),
|
47 |
+
__( 'Add New', 'contact-form-7' ),
|
48 |
+
array( 'class' => 'page-title-action' )
|
49 |
+
);
|
50 |
}
|
51 |
?>
|
52 |
|
53 |
<hr class="wp-header-end">
|
54 |
|
55 |
+
<?php
|
56 |
+
do_action( 'wpcf7_admin_warnings',
|
57 |
+
$post->initial() ? 'wpcf7-new' : 'wpcf7',
|
58 |
+
wpcf7_current_action(),
|
59 |
+
$post
|
60 |
+
);
|
61 |
+
|
62 |
+
do_action( 'wpcf7_admin_notices',
|
63 |
+
$post->initial() ? 'wpcf7-new' : 'wpcf7',
|
64 |
+
wpcf7_current_action(),
|
65 |
+
$post
|
66 |
+
);
|
67 |
+
?>
|
68 |
|
69 |
<?php
|
70 |
if ( $post ) :
|
admin/includes/admin-functions.php
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
<?php
|
2 |
|
3 |
function wpcf7_current_action() {
|
4 |
-
if ( isset( $_REQUEST['action'] )
|
5 |
return $_REQUEST['action'];
|
6 |
}
|
7 |
|
8 |
-
if ( isset( $_REQUEST['action2'] )
|
9 |
return $_REQUEST['action2'];
|
10 |
}
|
11 |
|
1 |
<?php
|
2 |
|
3 |
function wpcf7_current_action() {
|
4 |
+
if ( isset( $_REQUEST['action'] ) and -1 != $_REQUEST['action'] ) {
|
5 |
return $_REQUEST['action'];
|
6 |
}
|
7 |
|
8 |
+
if ( isset( $_REQUEST['action2'] ) and -1 != $_REQUEST['action2'] ) {
|
9 |
return $_REQUEST['action2'];
|
10 |
}
|
11 |
|
admin/includes/class-contact-forms-list-table.php
CHANGED
@@ -18,7 +18,7 @@ class WPCF7_Contact_Form_List_Table extends WP_List_Table {
|
|
18 |
return $columns;
|
19 |
}
|
20 |
|
21 |
-
function __construct() {
|
22 |
parent::__construct( array(
|
23 |
'singular' => 'post',
|
24 |
'plural' => 'posts',
|
@@ -26,12 +26,10 @@ class WPCF7_Contact_Form_List_Table extends WP_List_Table {
|
|
26 |
) );
|
27 |
}
|
28 |
|
29 |
-
function prepare_items() {
|
30 |
$current_screen = get_current_screen();
|
31 |
$per_page = $this->get_items_per_page( 'cfseven_contact_forms_per_page' );
|
32 |
|
33 |
-
$this->_column_headers = $this->get_column_info();
|
34 |
-
|
35 |
$args = array(
|
36 |
'posts_per_page' => $per_page,
|
37 |
'orderby' => 'title',
|
@@ -73,11 +71,11 @@ class WPCF7_Contact_Form_List_Table extends WP_List_Table {
|
|
73 |
) );
|
74 |
}
|
75 |
|
76 |
-
function get_columns() {
|
77 |
return get_column_headers( get_current_screen() );
|
78 |
}
|
79 |
|
80 |
-
function get_sortable_columns() {
|
81 |
$columns = array(
|
82 |
'title' => array( 'title', true ),
|
83 |
'author' => array( 'author', false ),
|
@@ -87,7 +85,7 @@ class WPCF7_Contact_Form_List_Table extends WP_List_Table {
|
|
87 |
return $columns;
|
88 |
}
|
89 |
|
90 |
-
function get_bulk_actions() {
|
91 |
$actions = array(
|
92 |
'delete' => __( 'Delete', 'contact-form-7' ),
|
93 |
);
|
@@ -95,23 +93,29 @@ class WPCF7_Contact_Form_List_Table extends WP_List_Table {
|
|
95 |
return $actions;
|
96 |
}
|
97 |
|
98 |
-
function column_default( $item, $column_name ) {
|
99 |
return '';
|
100 |
}
|
101 |
|
102 |
-
function column_cb( $item ) {
|
103 |
return sprintf(
|
104 |
'<input type="checkbox" name="%1$s[]" value="%2$s" />',
|
105 |
$this->_args['singular'],
|
106 |
-
$item->id()
|
|
|
107 |
}
|
108 |
|
109 |
-
function column_title( $item ) {
|
110 |
-
$
|
111 |
-
|
|
|
|
|
|
|
|
|
|
|
112 |
|
113 |
$output = sprintf(
|
114 |
-
'<a class="row-title" href="%1$s"
|
115 |
esc_url( $edit_link ),
|
116 |
/* translators: %s: title of contact form */
|
117 |
esc_attr( sprintf( __( 'Edit “%s”', 'contact-form-7' ),
|
@@ -122,7 +126,7 @@ class WPCF7_Contact_Form_List_Table extends WP_List_Table {
|
|
122 |
$output = sprintf( '<strong>%s</strong>', $output );
|
123 |
|
124 |
if ( wpcf7_validate_configuration()
|
125 |
-
|
126 |
$config_validator = new WPCF7_ConfigValidator( $item );
|
127 |
$config_validator->restore();
|
128 |
|
@@ -133,37 +137,59 @@ class WPCF7_Contact_Form_List_Table extends WP_List_Table {
|
|
133 |
'%s configuration error detected',
|
134 |
'%s configuration errors detected',
|
135 |
$count_errors, 'contact-form-7' ),
|
136 |
-
number_format_i18n( $count_errors )
|
|
|
|
|
137 |
$output .= sprintf(
|
138 |
-
'<div class="config-error"><span class="
|
139 |
-
$error_notice
|
|
|
140 |
}
|
141 |
}
|
142 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
$actions = array(
|
144 |
-
'edit' =>
|
145 |
-
|
146 |
-
esc_html( __( 'Edit', 'contact-form-7' ) ) ) );
|
147 |
|
148 |
if ( current_user_can( 'wpcf7_edit_contact_form', $item->id() ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
$copy_link = wp_nonce_url(
|
150 |
-
|
151 |
-
'wpcf7-copy-contact-form_' . absint( $item->id() )
|
|
|
152 |
|
153 |
$actions = array_merge( $actions, array(
|
154 |
-
'copy' =>
|
155 |
-
esc_url( $copy_link ),
|
156 |
-
esc_html( __( 'Duplicate', 'contact-form-7' ) )
|
157 |
-
),
|
158 |
) );
|
159 |
}
|
160 |
|
161 |
-
|
162 |
-
|
163 |
-
return $output;
|
164 |
}
|
165 |
|
166 |
-
function column_author( $item ) {
|
167 |
$post = get_post( $item->id() );
|
168 |
|
169 |
if ( ! $post ) {
|
@@ -179,7 +205,7 @@ class WPCF7_Contact_Form_List_Table extends WP_List_Table {
|
|
179 |
return esc_html( $author->display_name );
|
180 |
}
|
181 |
|
182 |
-
function column_shortcode( $item ) {
|
183 |
$shortcodes = array( $item->shortcode() );
|
184 |
|
185 |
$output = '';
|
@@ -194,7 +220,7 @@ class WPCF7_Contact_Form_List_Table extends WP_List_Table {
|
|
194 |
return trim( $output );
|
195 |
}
|
196 |
|
197 |
-
function column_date( $item ) {
|
198 |
$post = get_post( $item->id() );
|
199 |
|
200 |
if ( ! $post ) {
|
@@ -209,14 +235,19 @@ class WPCF7_Contact_Form_List_Table extends WP_List_Table {
|
|
209 |
|
210 |
$time_diff = time() - $time;
|
211 |
|
212 |
-
if ( $time_diff > 0
|
213 |
-
/* translators: %s: time since the creation of the contact form */
|
214 |
$h_time = sprintf(
|
215 |
-
|
|
|
|
|
|
|
216 |
} else {
|
217 |
$h_time = mysql2date( __( 'Y/m/d', 'contact-form-7' ), $m_time );
|
218 |
}
|
219 |
|
220 |
-
return '<abbr title="
|
|
|
|
|
|
|
221 |
}
|
222 |
}
|
18 |
return $columns;
|
19 |
}
|
20 |
|
21 |
+
public function __construct() {
|
22 |
parent::__construct( array(
|
23 |
'singular' => 'post',
|
24 |
'plural' => 'posts',
|
26 |
) );
|
27 |
}
|
28 |
|
29 |
+
public function prepare_items() {
|
30 |
$current_screen = get_current_screen();
|
31 |
$per_page = $this->get_items_per_page( 'cfseven_contact_forms_per_page' );
|
32 |
|
|
|
|
|
33 |
$args = array(
|
34 |
'posts_per_page' => $per_page,
|
35 |
'orderby' => 'title',
|
71 |
) );
|
72 |
}
|
73 |
|
74 |
+
public function get_columns() {
|
75 |
return get_column_headers( get_current_screen() );
|
76 |
}
|
77 |
|
78 |
+
protected function get_sortable_columns() {
|
79 |
$columns = array(
|
80 |
'title' => array( 'title', true ),
|
81 |
'author' => array( 'author', false ),
|
85 |
return $columns;
|
86 |
}
|
87 |
|
88 |
+
protected function get_bulk_actions() {
|
89 |
$actions = array(
|
90 |
'delete' => __( 'Delete', 'contact-form-7' ),
|
91 |
);
|
93 |
return $actions;
|
94 |
}
|
95 |
|
96 |
+
protected function column_default( $item, $column_name ) {
|
97 |
return '';
|
98 |
}
|
99 |
|
100 |
+
public function column_cb( $item ) {
|
101 |
return sprintf(
|
102 |
'<input type="checkbox" name="%1$s[]" value="%2$s" />',
|
103 |
$this->_args['singular'],
|
104 |
+
$item->id()
|
105 |
+
);
|
106 |
}
|
107 |
|
108 |
+
public function column_title( $item ) {
|
109 |
+
$edit_link = add_query_arg(
|
110 |
+
array(
|
111 |
+
'post' => absint( $item->id() ),
|
112 |
+
'action' => 'edit',
|
113 |
+
),
|
114 |
+
menu_page_url( 'wpcf7', false )
|
115 |
+
);
|
116 |
|
117 |
$output = sprintf(
|
118 |
+
'<a class="row-title" href="%1$s" aria-label="%2$s">%3$s</a>',
|
119 |
esc_url( $edit_link ),
|
120 |
/* translators: %s: title of contact form */
|
121 |
esc_attr( sprintf( __( 'Edit “%s”', 'contact-form-7' ),
|
126 |
$output = sprintf( '<strong>%s</strong>', $output );
|
127 |
|
128 |
if ( wpcf7_validate_configuration()
|
129 |
+
and current_user_can( 'wpcf7_edit_contact_form', $item->id() ) ) {
|
130 |
$config_validator = new WPCF7_ConfigValidator( $item );
|
131 |
$config_validator->restore();
|
132 |
|
137 |
'%s configuration error detected',
|
138 |
'%s configuration errors detected',
|
139 |
$count_errors, 'contact-form-7' ),
|
140 |
+
number_format_i18n( $count_errors )
|
141 |
+
);
|
142 |
+
|
143 |
$output .= sprintf(
|
144 |
+
'<div class="config-error"><span class="icon-in-circle" aria-hidden="true">!</span> %s</div>',
|
145 |
+
$error_notice
|
146 |
+
);
|
147 |
}
|
148 |
}
|
149 |
|
150 |
+
return $output;
|
151 |
+
}
|
152 |
+
|
153 |
+
protected function handle_row_actions( $item, $column_name, $primary ) {
|
154 |
+
if ( $column_name !== $primary ) {
|
155 |
+
return '';
|
156 |
+
}
|
157 |
+
|
158 |
+
$edit_link = add_query_arg(
|
159 |
+
array(
|
160 |
+
'post' => absint( $item->id() ),
|
161 |
+
'action' => 'edit',
|
162 |
+
),
|
163 |
+
menu_page_url( 'wpcf7', false )
|
164 |
+
);
|
165 |
+
|
166 |
$actions = array(
|
167 |
+
'edit' => wpcf7_link( $edit_link, __( 'Edit', 'contact-form-7' ) ),
|
168 |
+
);
|
|
|
169 |
|
170 |
if ( current_user_can( 'wpcf7_edit_contact_form', $item->id() ) ) {
|
171 |
+
$copy_link = add_query_arg(
|
172 |
+
array(
|
173 |
+
'post' => absint( $item->id() ),
|
174 |
+
'action' => 'copy',
|
175 |
+
),
|
176 |
+
menu_page_url( 'wpcf7', false )
|
177 |
+
);
|
178 |
+
|
179 |
$copy_link = wp_nonce_url(
|
180 |
+
$copy_link,
|
181 |
+
'wpcf7-copy-contact-form_' . absint( $item->id() )
|
182 |
+
);
|
183 |
|
184 |
$actions = array_merge( $actions, array(
|
185 |
+
'copy' => wpcf7_link( $copy_link, __( 'Duplicate', 'contact-form-7' ) ),
|
|
|
|
|
|
|
186 |
) );
|
187 |
}
|
188 |
|
189 |
+
return $this->row_actions( $actions );
|
|
|
|
|
190 |
}
|
191 |
|
192 |
+
public function column_author( $item ) {
|
193 |
$post = get_post( $item->id() );
|
194 |
|
195 |
if ( ! $post ) {
|
205 |
return esc_html( $author->display_name );
|
206 |
}
|
207 |
|
208 |
+
public function column_shortcode( $item ) {
|
209 |
$shortcodes = array( $item->shortcode() );
|
210 |
|
211 |
$output = '';
|
220 |
return trim( $output );
|
221 |
}
|
222 |
|
223 |
+
public function column_date( $item ) {
|
224 |
$post = get_post( $item->id() );
|
225 |
|
226 |
if ( ! $post ) {
|
235 |
|
236 |
$time_diff = time() - $time;
|
237 |
|
238 |
+
if ( $time_diff > 0 and $time_diff < 24*60*60 ) {
|
|
|
239 |
$h_time = sprintf(
|
240 |
+
/* translators: %s: time since the creation of the contact form */
|
241 |
+
__( '%s ago', 'contact-form-7' ),
|
242 |
+
human_time_diff( $time )
|
243 |
+
);
|
244 |
} else {
|
245 |
$h_time = mysql2date( __( 'Y/m/d', 'contact-form-7' ), $m_time );
|
246 |
}
|
247 |
|
248 |
+
return sprintf( '<abbr title="%2$s">%1$s</abbr>',
|
249 |
+
esc_html( $h_time ),
|
250 |
+
esc_attr( $t_time )
|
251 |
+
);
|
252 |
}
|
253 |
}
|
admin/includes/config-validator.php
ADDED
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
add_action( 'wpcf7_admin_menu', 'wpcf7_admin_init_bulk_cv', 10, 0 );
|
4 |
+
|
5 |
+
function wpcf7_admin_init_bulk_cv() {
|
6 |
+
if ( ! wpcf7_validate_configuration()
|
7 |
+
or ! current_user_can( 'wpcf7_edit_contact_forms' ) ) {
|
8 |
+
return;
|
9 |
+
}
|
10 |
+
|
11 |
+
$result = WPCF7::get_option( 'bulk_validate' );
|
12 |
+
$last_important_update = '5.0.4';
|
13 |
+
|
14 |
+
if ( ! empty( $result['version'] )
|
15 |
+
and version_compare( $last_important_update, $result['version'], '<=' ) ) {
|
16 |
+
return;
|
17 |
+
}
|
18 |
+
|
19 |
+
add_filter( 'wpcf7_admin_menu_change_notice',
|
20 |
+
'wpcf7_admin_menu_change_notice_bulk_cv', 10, 1 );
|
21 |
+
|
22 |
+
add_action( 'wpcf7_admin_warnings',
|
23 |
+
'wpcf7_admin_warnings_bulk_cv', 5, 3 );
|
24 |
+
}
|
25 |
+
|
26 |
+
function wpcf7_admin_menu_change_notice_bulk_cv( $counts ) {
|
27 |
+
$counts['wpcf7'] += 1;
|
28 |
+
return $counts;
|
29 |
+
}
|
30 |
+
|
31 |
+
function wpcf7_admin_warnings_bulk_cv( $page, $action, $object ) {
|
32 |
+
if ( 'wpcf7' === $page and 'validate' === $action ) {
|
33 |
+
return;
|
34 |
+
}
|
35 |
+
|
36 |
+
$link = wpcf7_link(
|
37 |
+
add_query_arg(
|
38 |
+
array( 'action' => 'validate' ),
|
39 |
+
menu_page_url( 'wpcf7', false )
|
40 |
+
),
|
41 |
+
__( 'Validate Contact Form 7 Configuration', 'contact-form-7' )
|
42 |
+
);
|
43 |
+
|
44 |
+
$message = __( "Misconfiguration leads to mail delivery failure or other troubles. Validate your contact forms now.", 'contact-form-7' );
|
45 |
+
|
46 |
+
echo sprintf(
|
47 |
+
'<div class="notice notice-warning"><p>%1$s » %2$s</p></div>',
|
48 |
+
esc_html( $message ),
|
49 |
+
$link
|
50 |
+
);
|
51 |
+
}
|
52 |
+
|
53 |
+
add_action( 'wpcf7_admin_load', 'wpcf7_load_bulk_validate_page', 10, 2 );
|
54 |
+
|
55 |
+
function wpcf7_load_bulk_validate_page( $page, $action ) {
|
56 |
+
if ( 'wpcf7' != $page
|
57 |
+
or 'validate' != $action
|
58 |
+
or ! wpcf7_validate_configuration()
|
59 |
+
or 'POST' != $_SERVER['REQUEST_METHOD'] ) {
|
60 |
+
return;
|
61 |
+
}
|
62 |
+
|
63 |
+
check_admin_referer( 'wpcf7-bulk-validate' );
|
64 |
+
|
65 |
+
if ( ! current_user_can( 'wpcf7_edit_contact_forms' ) ) {
|
66 |
+
wp_die( __( "You are not allowed to validate configuration.", 'contact-form-7' ) );
|
67 |
+
}
|
68 |
+
|
69 |
+
$contact_forms = WPCF7_ContactForm::find();
|
70 |
+
|
71 |
+
$result = array(
|
72 |
+
'timestamp' => current_time( 'timestamp' ),
|
73 |
+
'version' => WPCF7_VERSION,
|
74 |
+
'count_valid' => 0,
|
75 |
+
'count_invalid' => 0,
|
76 |
+
);
|
77 |
+
|
78 |
+
foreach ( $contact_forms as $contact_form ) {
|
79 |
+
$config_validator = new WPCF7_ConfigValidator( $contact_form );
|
80 |
+
$config_validator->validate();
|
81 |
+
$config_validator->save();
|
82 |
+
|
83 |
+
if ( $config_validator->is_valid() ) {
|
84 |
+
$result['count_valid'] += 1;
|
85 |
+
} else {
|
86 |
+
$result['count_invalid'] += 1;
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
WPCF7::update_option( 'bulk_validate', $result );
|
91 |
+
|
92 |
+
$redirect_to = add_query_arg(
|
93 |
+
array(
|
94 |
+
'message' => 'validated',
|
95 |
+
),
|
96 |
+
menu_page_url( 'wpcf7', false )
|
97 |
+
);
|
98 |
+
|
99 |
+
wp_safe_redirect( $redirect_to );
|
100 |
+
exit();
|
101 |
+
}
|
102 |
+
|
103 |
+
function wpcf7_admin_bulk_validate_page() {
|
104 |
+
$contact_forms = WPCF7_ContactForm::find();
|
105 |
+
$count = WPCF7_ContactForm::count();
|
106 |
+
|
107 |
+
$submit_text = sprintf(
|
108 |
+
/* translators: %s: number of contact forms */
|
109 |
+
_n(
|
110 |
+
"Validate %s Contact Form Now",
|
111 |
+
"Validate %s Contact Forms Now",
|
112 |
+
$count, 'contact-form-7' ),
|
113 |
+
number_format_i18n( $count ) );
|
114 |
+
|
115 |
+
?>
|
116 |
+
<div class="wrap">
|
117 |
+
|
118 |
+
<h1><?php echo esc_html( __( 'Validate Configuration', 'contact-form-7' ) ); ?></h1>
|
119 |
+
|
120 |
+
<form method="post" action="">
|
121 |
+
<input type="hidden" name="action" value="validate" />
|
122 |
+
<?php wp_nonce_field( 'wpcf7-bulk-validate' ); ?>
|
123 |
+
<p><input type="submit" class="button" value="<?php echo esc_attr( $submit_text ); ?>" /></p>
|
124 |
+
</form>
|
125 |
+
|
126 |
+
<?php
|
127 |
+
echo wpcf7_link(
|
128 |
+
__( 'https://contactform7.com/configuration-validator-faq/', 'contact-form-7' ),
|
129 |
+
__( 'FAQ about Configuration Validator', 'contact-form-7' )
|
130 |
+
);
|
131 |
+
?>
|
132 |
+
|
133 |
+
</div>
|
134 |
+
<?php
|
135 |
+
}
|
admin/includes/editor.php
CHANGED
@@ -214,7 +214,7 @@ function wpcf7_editor_panel_messages( $post ) {
|
|
214 |
$messages = wpcf7_messages();
|
215 |
|
216 |
if ( isset( $messages['captcha_not_match'] )
|
217 |
-
|
218 |
unset( $messages['captcha_not_match'] );
|
219 |
}
|
220 |
|
214 |
$messages = wpcf7_messages();
|
215 |
|
216 |
if ( isset( $messages['captcha_not_match'] )
|
217 |
+
and ! wpcf7_use_really_simple_captcha() ) {
|
218 |
unset( $messages['captcha_not_match'] );
|
219 |
}
|
220 |
|
admin/includes/tag-generator.php
CHANGED
@@ -19,7 +19,8 @@ class WPCF7_TagGenerator {
|
|
19 |
public function add( $id, $title, $callback, $options = array() ) {
|
20 |
$id = trim( $id );
|
21 |
|
22 |
-
if ( '' === $id
|
|
|
23 |
return false;
|
24 |
}
|
25 |
|
@@ -44,7 +45,8 @@ class WPCF7_TagGenerator {
|
|
44 |
esc_attr( sprintf(
|
45 |
__( 'Form-tag Generator: %s', 'contact-form-7' ),
|
46 |
$panel['title'] ) ),
|
47 |
-
esc_html( $panel['title'] )
|
|
|
48 |
}
|
49 |
|
50 |
echo '</span>';
|
19 |
public function add( $id, $title, $callback, $options = array() ) {
|
20 |
$id = trim( $id );
|
21 |
|
22 |
+
if ( '' === $id
|
23 |
+
or ! wpcf7_is_name( $id ) ) {
|
24 |
return false;
|
25 |
}
|
26 |
|
45 |
esc_attr( sprintf(
|
46 |
__( 'Form-tag Generator: %s', 'contact-form-7' ),
|
47 |
$panel['title'] ) ),
|
48 |
+
esc_html( $panel['title'] )
|
49 |
+
);
|
50 |
}
|
51 |
|
52 |
echo '</span>';
|
admin/includes/welcome-panel.php
CHANGED
@@ -52,7 +52,8 @@ function wpcf7_welcome_panel() {
|
|
52 |
<?php
|
53 |
}
|
54 |
|
55 |
-
add_action( 'wp_ajax_wpcf7-update-welcome-panel',
|
|
|
56 |
|
57 |
function wpcf7_admin_ajax_welcome_panel() {
|
58 |
check_ajax_referer( 'wpcf7-welcome-panel-nonce', 'welcomepanelnonce' );
|
@@ -60,7 +61,7 @@ function wpcf7_admin_ajax_welcome_panel() {
|
|
60 |
$vers = get_user_meta( get_current_user_id(),
|
61 |
'wpcf7_hide_welcome_panel_on', true );
|
62 |
|
63 |
-
if ( empty( $vers )
|
64 |
$vers = array();
|
65 |
}
|
66 |
|
@@ -70,7 +71,8 @@ function wpcf7_admin_ajax_welcome_panel() {
|
|
70 |
|
71 |
$vers = array_unique( $vers );
|
72 |
|
73 |
-
update_user_meta( get_current_user_id(),
|
|
|
74 |
|
75 |
wp_die( 1 );
|
76 |
}
|
52 |
<?php
|
53 |
}
|
54 |
|
55 |
+
add_action( 'wp_ajax_wpcf7-update-welcome-panel',
|
56 |
+
'wpcf7_admin_ajax_welcome_panel', 10, 0 );
|
57 |
|
58 |
function wpcf7_admin_ajax_welcome_panel() {
|
59 |
check_ajax_referer( 'wpcf7-welcome-panel-nonce', 'welcomepanelnonce' );
|
61 |
$vers = get_user_meta( get_current_user_id(),
|
62 |
'wpcf7_hide_welcome_panel_on', true );
|
63 |
|
64 |
+
if ( empty( $vers ) or ! is_array( $vers ) ) {
|
65 |
$vers = array();
|
66 |
}
|
67 |
|
71 |
|
72 |
$vers = array_unique( $vers );
|
73 |
|
74 |
+
update_user_meta( get_current_user_id(),
|
75 |
+
'wpcf7_hide_welcome_panel_on', $vers );
|
76 |
|
77 |
wp_die( 1 );
|
78 |
}
|
admin/js/scripts.js
CHANGED
@@ -158,7 +158,7 @@
|
|
158 |
|
159 |
$.each( errors[ section ], function( i, val ) {
|
160 |
var $li = $( '<li></li>' ).append(
|
161 |
-
|
162 |
).append(
|
163 |
$( '<span class="screen-reader-text"></span>' ).text( wpcf7.configValidator.iconAlt )
|
164 |
).append( ' ' );
|
@@ -191,14 +191,14 @@
|
|
191 |
|
192 |
$( '#contact-form-editor-tabs > li' ).each( function() {
|
193 |
var $item = $( this );
|
194 |
-
$item.find( '
|
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.replace( '-', '_' ) ) {
|
201 |
-
var $mark =
|
202 |
$item.find( 'a.ui-tabs-anchor' ).first().append( $mark );
|
203 |
return false;
|
204 |
}
|
@@ -208,8 +208,7 @@
|
|
208 |
$tabPanelError.empty();
|
209 |
|
210 |
if ( errorCount[ tab.replace( '-', '_' ) ] ) {
|
211 |
-
$tabPanelError
|
212 |
-
.append( '<span class="dashicons dashicons-warning" aria-hidden="true"></span> ' );
|
213 |
|
214 |
if ( 1 < errorCount[ tab.replace( '-', '_' ) ] ) {
|
215 |
var manyErrorsInTab = wpcf7.configValidator.manyErrorsInTab
|
@@ -226,7 +225,7 @@
|
|
226 |
if ( errorCount.total ) {
|
227 |
var $warning = $( '<div></div>' )
|
228 |
.addClass( 'misc-pub-section config-error' )
|
229 |
-
.append(
|
230 |
|
231 |
if ( 1 < errorCount.total ) {
|
232 |
$warning.append(
|
@@ -274,6 +273,11 @@
|
|
274 |
} );
|
275 |
};
|
276 |
|
|
|
|
|
|
|
|
|
|
|
277 |
wpcf7.apiSettings.getRoute = function( path ) {
|
278 |
var url = wpcf7.apiSettings.root;
|
279 |
|
158 |
|
159 |
$.each( errors[ section ], function( i, val ) {
|
160 |
var $li = $( '<li></li>' ).append(
|
161 |
+
wpcf7.iconInCircle( '!' )
|
162 |
).append(
|
163 |
$( '<span class="screen-reader-text"></span>' ).text( wpcf7.configValidator.iconAlt )
|
164 |
).append( ' ' );
|
191 |
|
192 |
$( '#contact-form-editor-tabs > li' ).each( function() {
|
193 |
var $item = $( this );
|
194 |
+
$item.find( '.icon-in-circle' ).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.replace( '-', '_' ) ) {
|
201 |
+
var $mark = wpcf7.iconInCircle( '!' );
|
202 |
$item.find( 'a.ui-tabs-anchor' ).first().append( $mark );
|
203 |
return false;
|
204 |
}
|
208 |
$tabPanelError.empty();
|
209 |
|
210 |
if ( errorCount[ tab.replace( '-', '_' ) ] ) {
|
211 |
+
$tabPanelError.append( wpcf7.iconInCircle( '!' ) );
|
|
|
212 |
|
213 |
if ( 1 < errorCount[ tab.replace( '-', '_' ) ] ) {
|
214 |
var manyErrorsInTab = wpcf7.configValidator.manyErrorsInTab
|
225 |
if ( errorCount.total ) {
|
226 |
var $warning = $( '<div></div>' )
|
227 |
.addClass( 'misc-pub-section config-error' )
|
228 |
+
.append( wpcf7.iconInCircle( '!' ) );
|
229 |
|
230 |
if ( 1 < errorCount.total ) {
|
231 |
$warning.append(
|
273 |
} );
|
274 |
};
|
275 |
|
276 |
+
wpcf7.iconInCircle = function( icon ) {
|
277 |
+
var $span = $( '<span class="icon-in-circle" aria-hidden="true"></span>' );
|
278 |
+
return $span.text( icon );
|
279 |
+
};
|
280 |
+
|
281 |
wpcf7.apiSettings.getRoute = function( path ) {
|
282 |
var url = wpcf7.apiSettings.root;
|
283 |
|
includes/capabilities.php
CHANGED
@@ -6,8 +6,10 @@ function wpcf7_map_meta_cap( $caps, $cap, $user_id, $args ) {
|
|
6 |
$meta_caps = array(
|
7 |
'wpcf7_edit_contact_form' => WPCF7_ADMIN_READ_WRITE_CAPABILITY,
|
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 |
'wpcf7_submit' => 'read',
|
13 |
);
|
6 |
$meta_caps = array(
|
7 |
'wpcf7_edit_contact_form' => WPCF7_ADMIN_READ_WRITE_CAPABILITY,
|
8 |
'wpcf7_edit_contact_forms' => WPCF7_ADMIN_READ_WRITE_CAPABILITY,
|
9 |
+
'wpcf7_read_contact_form' => WPCF7_ADMIN_READ_CAPABILITY,
|
10 |
'wpcf7_read_contact_forms' => WPCF7_ADMIN_READ_CAPABILITY,
|
11 |
'wpcf7_delete_contact_form' => WPCF7_ADMIN_READ_WRITE_CAPABILITY,
|
12 |
+
'wpcf7_delete_contact_forms' => WPCF7_ADMIN_READ_WRITE_CAPABILITY,
|
13 |
'wpcf7_manage_integration' => 'manage_options',
|
14 |
'wpcf7_submit' => 'read',
|
15 |
);
|
includes/config-validator.php
CHANGED
@@ -56,8 +56,8 @@ class WPCF7_ConfigValidator {
|
|
56 |
}
|
57 |
|
58 |
if ( $args['section']
|
59 |
-
|
60 |
-
|
61 |
continue;
|
62 |
}
|
63 |
|
@@ -66,7 +66,7 @@ class WPCF7_ConfigValidator {
|
|
66 |
continue;
|
67 |
}
|
68 |
|
69 |
-
if ( $args['code']
|
70 |
continue;
|
71 |
}
|
72 |
|
@@ -170,7 +170,8 @@ class WPCF7_ConfigValidator {
|
|
170 |
}
|
171 |
|
172 |
foreach ( (array) $this->errors[$section] as $key => $error ) {
|
173 |
-
if ( isset( $error['code'] )
|
|
|
174 |
unset( $this->errors[$section][$key] );
|
175 |
}
|
176 |
}
|
@@ -269,7 +270,7 @@ class WPCF7_ConfigValidator {
|
|
269 |
$last_item = array_pop( $form_tag->values );
|
270 |
}
|
271 |
|
272 |
-
if ( $last_item
|
273 |
return $example_email;
|
274 |
} else {
|
275 |
return $example_text;
|
@@ -407,7 +408,8 @@ class WPCF7_ConfigValidator {
|
|
407 |
return;
|
408 |
}
|
409 |
|
410 |
-
if ( 'mail' != $template
|
|
|
411 |
return;
|
412 |
}
|
413 |
|
@@ -436,7 +438,7 @@ class WPCF7_ConfigValidator {
|
|
436 |
$sender = wpcf7_strip_newline( $sender );
|
437 |
|
438 |
if ( ! $this->detect_invalid_mailbox_syntax( sprintf( '%s.sender', $template ), $sender )
|
439 |
-
|
440 |
$this->add_error( sprintf( '%s.sender', $template ),
|
441 |
self::error_email_not_in_site_domain, array(
|
442 |
'link' => self::get_doc_link( 'email_not_in_site_domain' ),
|
@@ -508,7 +510,8 @@ class WPCF7_ConfigValidator {
|
|
508 |
foreach ( explode( "\n", $components['attachments'] ) as $line ) {
|
509 |
$line = trim( $line );
|
510 |
|
511 |
-
if ( '' === $line
|
|
|
512 |
continue;
|
513 |
}
|
514 |
|
@@ -516,7 +519,8 @@ class WPCF7_ConfigValidator {
|
|
516 |
sprintf( '%s.attachments', $template ), $line
|
517 |
);
|
518 |
|
519 |
-
if ( ! $has_file_not_found
|
|
|
520 |
$has_file_not_in_content_dir = $this->detect_file_not_in_content_dir(
|
521 |
sprintf( '%s.attachments', $template ), $line
|
522 |
);
|
@@ -555,7 +559,8 @@ class WPCF7_ConfigValidator {
|
|
555 |
public function detect_file_not_found( $section, $content ) {
|
556 |
$path = path_join( WP_CONTENT_DIR, $content );
|
557 |
|
558 |
-
if ( ! is_readable( $path )
|
|
|
559 |
return $this->add_error( $section,
|
560 |
self::error_file_not_found,
|
561 |
array(
|
@@ -595,7 +600,7 @@ class WPCF7_ConfigValidator {
|
|
595 |
}
|
596 |
|
597 |
if ( isset( $messages['captcha_not_match'] )
|
598 |
-
|
599 |
unset( $messages['captcha_not_match'] );
|
600 |
}
|
601 |
|
56 |
}
|
57 |
|
58 |
if ( $args['section']
|
59 |
+
and $key != $args['section']
|
60 |
+
and preg_replace( '/\..*$/', '', $key, 1 ) != $args['section'] ) {
|
61 |
continue;
|
62 |
}
|
63 |
|
66 |
continue;
|
67 |
}
|
68 |
|
69 |
+
if ( $args['code'] and $error['code'] != $args['code'] ) {
|
70 |
continue;
|
71 |
}
|
72 |
|
170 |
}
|
171 |
|
172 |
foreach ( (array) $this->errors[$section] as $key => $error ) {
|
173 |
+
if ( isset( $error['code'] )
|
174 |
+
and $error['code'] == $code ) {
|
175 |
unset( $this->errors[$section][$key] );
|
176 |
}
|
177 |
}
|
270 |
$last_item = array_pop( $form_tag->values );
|
271 |
}
|
272 |
|
273 |
+
if ( $last_item and wpcf7_is_mailbox_list( $last_item ) ) {
|
274 |
return $example_email;
|
275 |
} else {
|
276 |
return $example_text;
|
408 |
return;
|
409 |
}
|
410 |
|
411 |
+
if ( 'mail' != $template
|
412 |
+
and empty( $components['active'] ) ) {
|
413 |
return;
|
414 |
}
|
415 |
|
438 |
$sender = wpcf7_strip_newline( $sender );
|
439 |
|
440 |
if ( ! $this->detect_invalid_mailbox_syntax( sprintf( '%s.sender', $template ), $sender )
|
441 |
+
and ! wpcf7_is_email_in_site_domain( $sender ) ) {
|
442 |
$this->add_error( sprintf( '%s.sender', $template ),
|
443 |
self::error_email_not_in_site_domain, array(
|
444 |
'link' => self::get_doc_link( 'email_not_in_site_domain' ),
|
510 |
foreach ( explode( "\n", $components['attachments'] ) as $line ) {
|
511 |
$line = trim( $line );
|
512 |
|
513 |
+
if ( '' === $line
|
514 |
+
or '[' == substr( $line, 0, 1 ) ) {
|
515 |
continue;
|
516 |
}
|
517 |
|
519 |
sprintf( '%s.attachments', $template ), $line
|
520 |
);
|
521 |
|
522 |
+
if ( ! $has_file_not_found
|
523 |
+
and ! $has_file_not_in_content_dir ) {
|
524 |
$has_file_not_in_content_dir = $this->detect_file_not_in_content_dir(
|
525 |
sprintf( '%s.attachments', $template ), $line
|
526 |
);
|
559 |
public function detect_file_not_found( $section, $content ) {
|
560 |
$path = path_join( WP_CONTENT_DIR, $content );
|
561 |
|
562 |
+
if ( ! is_readable( $path )
|
563 |
+
or ! is_file( $path ) ) {
|
564 |
return $this->add_error( $section,
|
565 |
self::error_file_not_found,
|
566 |
array(
|
600 |
}
|
601 |
|
602 |
if ( isset( $messages['captcha_not_match'] )
|
603 |
+
and ! wpcf7_use_really_simple_captcha() ) {
|
604 |
unset( $messages['captcha_not_match'] );
|
605 |
}
|
606 |
|
includes/contact-form-functions.php
CHANGED
@@ -46,7 +46,8 @@ function wpcf7_get_hangover( $name, $default = null ) {
|
|
46 |
|
47 |
$submission = WPCF7_Submission::get_instance();
|
48 |
|
49 |
-
if ( ! $submission
|
|
|
50 |
return $default;
|
51 |
}
|
52 |
|
46 |
|
47 |
$submission = WPCF7_Submission::get_instance();
|
48 |
|
49 |
+
if ( ! $submission
|
50 |
+
or $submission->is( 'mail_sent' ) ) {
|
51 |
return $default;
|
52 |
}
|
53 |
|
includes/contact-form-template.php
CHANGED
@@ -51,7 +51,8 @@ class WPCF7_ContactFormTemplate {
|
|
51 |
sprintf(
|
52 |
_x( '%1$s "%2$s"', 'mail subject', 'contact-form-7' ),
|
53 |
get_bloginfo( 'name' ), '[your-subject]' ),
|
54 |
-
'sender' => sprintf( '
|
|
|
55 |
'body' =>
|
56 |
/* translators: %s: [your-name] <[your-email]> */
|
57 |
sprintf( __( 'From: %s', 'contact-form-7' ),
|
51 |
sprintf(
|
52 |
_x( '%1$s "%2$s"', 'mail subject', 'contact-form-7' ),
|
53 |
get_bloginfo( 'name' ), '[your-subject]' ),
|
54 |
+
'sender' => sprintf( '%s <%s>',
|
55 |
+
get_bloginfo( 'name' ), self::from_email() ),
|
56 |
'body' =>
|
57 |
/* translators: %s: [your-name] <[your-email]> */
|
58 |
sprintf( __( 'From: %s', 'contact-form-7' ),
|
includes/contact-form.php
CHANGED
@@ -35,6 +35,15 @@ class WPCF7_ContactForm {
|
|
35 |
'query_var' => false,
|
36 |
'public' => false,
|
37 |
'capability_type' => 'page',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
) );
|
39 |
}
|
40 |
|
@@ -105,7 +114,8 @@ class WPCF7_ContactForm {
|
|
105 |
public static function get_instance( $post ) {
|
106 |
$post = get_post( $post );
|
107 |
|
108 |
-
if ( ! $post
|
|
|
109 |
return false;
|
110 |
}
|
111 |
|
@@ -131,7 +141,8 @@ class WPCF7_ContactForm {
|
|
131 |
private function __construct( $post = null ) {
|
132 |
$post = get_post( $post );
|
133 |
|
134 |
-
if ( $post
|
|
|
135 |
$this->id = $post->ID;
|
136 |
$this->name = $post->post_name;
|
137 |
$this->title = $post->post_title;
|
@@ -292,7 +303,7 @@ class WPCF7_ContactForm {
|
|
292 |
}
|
293 |
|
294 |
if ( $this->is_true( 'subscribers_only' )
|
295 |
-
|
296 |
$notice = __(
|
297 |
"This contact form is available only for logged in users.",
|
298 |
'contact-form-7' );
|
@@ -702,7 +713,7 @@ class WPCF7_ContactForm {
|
|
702 |
) );
|
703 |
|
704 |
if ( $this->is_true( 'subscribers_only' )
|
705 |
-
|
706 |
$result = array(
|
707 |
'contact_form_id' => $this->id(),
|
708 |
'status' => 'error',
|
@@ -770,7 +781,7 @@ class WPCF7_ContactForm {
|
|
770 |
continue;
|
771 |
}
|
772 |
|
773 |
-
if ( ! $max
|
774 |
$values[] = trim( $matches[2] );
|
775 |
$count += 1;
|
776 |
}
|
@@ -811,7 +822,8 @@ class WPCF7_ContactForm {
|
|
811 |
private function upgrade() {
|
812 |
$mail = $this->prop( 'mail' );
|
813 |
|
814 |
-
if ( is_array( $mail )
|
|
|
815 |
$mail['recipient'] = get_option( 'admin_email' );
|
816 |
}
|
817 |
|
@@ -917,6 +929,7 @@ class WPCF7_ContactForm {
|
|
917 |
$this->id, $title );
|
918 |
}
|
919 |
|
920 |
-
return apply_filters( 'wpcf7_contact_form_shortcode',
|
|
|
921 |
}
|
922 |
}
|
35 |
'query_var' => false,
|
36 |
'public' => false,
|
37 |
'capability_type' => 'page',
|
38 |
+
'capabilities' => array(
|
39 |
+
'edit_post' => 'wpcf7_edit_contact_form',
|
40 |
+
'read_post' => 'wpcf7_read_contact_form',
|
41 |
+
'delete_post' => 'wpcf7_delete_contact_form',
|
42 |
+
'edit_posts' => 'wpcf7_edit_contact_forms',
|
43 |
+
'edit_others_posts' => 'wpcf7_edit_contact_forms',
|
44 |
+
'publish_posts' => 'wpcf7_edit_contact_forms',
|
45 |
+
'read_private_posts' => 'wpcf7_edit_contact_forms',
|
46 |
+
),
|
47 |
) );
|
48 |
}
|
49 |
|
114 |
public static function get_instance( $post ) {
|
115 |
$post = get_post( $post );
|
116 |
|
117 |
+
if ( ! $post
|
118 |
+
or self::post_type != get_post_type( $post ) ) {
|
119 |
return false;
|
120 |
}
|
121 |
|
141 |
private function __construct( $post = null ) {
|
142 |
$post = get_post( $post );
|
143 |
|
144 |
+
if ( $post
|
145 |
+
and self::post_type == get_post_type( $post ) ) {
|
146 |
$this->id = $post->ID;
|
147 |
$this->name = $post->post_name;
|
148 |
$this->title = $post->post_title;
|
303 |
}
|
304 |
|
305 |
if ( $this->is_true( 'subscribers_only' )
|
306 |
+
and ! current_user_can( 'wpcf7_submit', $this->id() ) ) {
|
307 |
$notice = __(
|
308 |
"This contact form is available only for logged in users.",
|
309 |
'contact-form-7' );
|
713 |
) );
|
714 |
|
715 |
if ( $this->is_true( 'subscribers_only' )
|
716 |
+
and ! current_user_can( 'wpcf7_submit', $this->id() ) ) {
|
717 |
$result = array(
|
718 |
'contact_form_id' => $this->id(),
|
719 |
'status' => 'error',
|
781 |
continue;
|
782 |
}
|
783 |
|
784 |
+
if ( ! $max or $count < (int) $max ) {
|
785 |
$values[] = trim( $matches[2] );
|
786 |
$count += 1;
|
787 |
}
|
822 |
private function upgrade() {
|
823 |
$mail = $this->prop( 'mail' );
|
824 |
|
825 |
+
if ( is_array( $mail )
|
826 |
+
and ! isset( $mail['recipient'] ) ) {
|
827 |
$mail['recipient'] = get_option( 'admin_email' );
|
828 |
}
|
829 |
|
929 |
$this->id, $title );
|
930 |
}
|
931 |
|
932 |
+
return apply_filters( 'wpcf7_contact_form_shortcode',
|
933 |
+
$shortcode, $args, $this );
|
934 |
}
|
935 |
}
|
includes/controller.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
add_action( 'parse_request', 'wpcf7_control_init', 20 );
|
4 |
|
5 |
function wpcf7_control_init() {
|
6 |
if ( WPCF7_Submission::is_restful() ) {
|
@@ -16,21 +16,7 @@ function wpcf7_control_init() {
|
|
16 |
}
|
17 |
}
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
function wpcf7_widget_text_filter( $content ) {
|
22 |
-
$pattern = '/\[[\r\n\t ]*contact-form(-7)?[\r\n\t ].*?\]/';
|
23 |
-
|
24 |
-
if ( ! preg_match( $pattern, $content ) ) {
|
25 |
-
return $content;
|
26 |
-
}
|
27 |
-
|
28 |
-
$content = do_shortcode( $content );
|
29 |
-
|
30 |
-
return $content;
|
31 |
-
}
|
32 |
-
|
33 |
-
add_action( 'wp_enqueue_scripts', 'wpcf7_do_enqueue_scripts' );
|
34 |
|
35 |
function wpcf7_do_enqueue_scripts() {
|
36 |
if ( wpcf7_load_js() ) {
|
@@ -58,15 +44,9 @@ function wpcf7_enqueue_scripts() {
|
|
58 |
'root' => esc_url_raw( rest_url( 'contact-form-7/v1' ) ),
|
59 |
'namespace' => 'contact-form-7/v1',
|
60 |
),
|
61 |
-
'recaptcha' => array(
|
62 |
-
'messages' => array(
|
63 |
-
'empty' =>
|
64 |
-
__( 'Please verify that you are not a robot.', 'contact-form-7' ),
|
65 |
-
),
|
66 |
-
),
|
67 |
);
|
68 |
|
69 |
-
if ( defined( 'WP_CACHE' )
|
70 |
$wpcf7['cached'] = 1;
|
71 |
}
|
72 |
|
@@ -103,7 +83,7 @@ function wpcf7_style_is() {
|
|
103 |
|
104 |
/* HTML5 Fallback */
|
105 |
|
106 |
-
add_action( 'wp_enqueue_scripts', 'wpcf7_html5_fallback', 20 );
|
107 |
|
108 |
function wpcf7_html5_fallback() {
|
109 |
if ( ! wpcf7_support_html5_fallback() ) {
|
1 |
<?php
|
2 |
|
3 |
+
add_action( 'parse_request', 'wpcf7_control_init', 20, 0 );
|
4 |
|
5 |
function wpcf7_control_init() {
|
6 |
if ( WPCF7_Submission::is_restful() ) {
|
16 |
}
|
17 |
}
|
18 |
|
19 |
+
add_action( 'wp_enqueue_scripts', 'wpcf7_do_enqueue_scripts', 10, 0 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
function wpcf7_do_enqueue_scripts() {
|
22 |
if ( wpcf7_load_js() ) {
|
44 |
'root' => esc_url_raw( rest_url( 'contact-form-7/v1' ) ),
|
45 |
'namespace' => 'contact-form-7/v1',
|
46 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
);
|
48 |
|
49 |
+
if ( defined( 'WP_CACHE' ) and WP_CACHE ) {
|
50 |
$wpcf7['cached'] = 1;
|
51 |
}
|
52 |
|
83 |
|
84 |
/* HTML5 Fallback */
|
85 |
|
86 |
+
add_action( 'wp_enqueue_scripts', 'wpcf7_html5_fallback', 20, 0 );
|
87 |
|
88 |
function wpcf7_html5_fallback() {
|
89 |
if ( ! wpcf7_support_html5_fallback() ) {
|
includes/css/styles.css
CHANGED
@@ -97,10 +97,6 @@ div.wpcf7 .placeheld {
|
|
97 |
color: #888;
|
98 |
}
|
99 |
|
100 |
-
div.wpcf7 .wpcf7-recaptcha iframe {
|
101 |
-
margin-bottom: 0;
|
102 |
-
}
|
103 |
-
|
104 |
div.wpcf7 input[type="file"] {
|
105 |
cursor: pointer;
|
106 |
}
|
97 |
color: #888;
|
98 |
}
|
99 |
|
|
|
|
|
|
|
|
|
100 |
div.wpcf7 input[type="file"] {
|
101 |
cursor: pointer;
|
102 |
}
|
includes/form-tag.php
CHANGED
@@ -14,7 +14,8 @@ class WPCF7_FormTag implements ArrayAccess {
|
|
14 |
public $content = '';
|
15 |
|
16 |
public function __construct( $tag = array() ) {
|
17 |
-
if ( is_array( $tag )
|
|
|
18 |
foreach ( $tag as $key => $value ) {
|
19 |
if ( property_exists( __CLASS__, $key ) ) {
|
20 |
$this->{$key} = $value;
|
@@ -104,7 +105,8 @@ class WPCF7_FormTag implements ArrayAccess {
|
|
104 |
$matches_a = $this->get_all_match_options( '%^([0-9]*)/[0-9]*$%' );
|
105 |
|
106 |
foreach ( (array) $matches_a as $matches ) {
|
107 |
-
if ( isset( $matches[1] )
|
|
|
108 |
return $matches[1];
|
109 |
}
|
110 |
}
|
@@ -171,7 +173,8 @@ class WPCF7_FormTag implements ArrayAccess {
|
|
171 |
'%^([0-9]*)x([0-9]*)(?:/[0-9]+)?$%' );
|
172 |
|
173 |
foreach ( (array) $matches_a as $matches ) {
|
174 |
-
if ( isset( $matches[2] )
|
|
|
175 |
return $matches[2];
|
176 |
}
|
177 |
}
|
@@ -218,7 +221,8 @@ class WPCF7_FormTag implements ArrayAccess {
|
|
218 |
foreach ( $options as $opt ) {
|
219 |
$opt = sanitize_key( $opt );
|
220 |
|
221 |
-
if ( 'user_' == substr( $opt, 0, 5 )
|
|
|
222 |
$primary_props = array( 'user_login', 'user_email', 'user_url' );
|
223 |
$opt = in_array( $opt, $primary_props ) ? $opt : substr( $opt, 5 );
|
224 |
|
@@ -233,7 +237,7 @@ class WPCF7_FormTag implements ArrayAccess {
|
|
233 |
}
|
234 |
}
|
235 |
|
236 |
-
} elseif ( 'post_meta' == $opt
|
237 |
if ( $args['multiple'] ) {
|
238 |
$values = array_merge( $values,
|
239 |
get_post_meta( get_the_ID(), $this->name ) );
|
@@ -245,7 +249,7 @@ class WPCF7_FormTag implements ArrayAccess {
|
|
245 |
}
|
246 |
}
|
247 |
|
248 |
-
} elseif ( 'get' == $opt
|
249 |
$vals = (array) $_GET[$this->name];
|
250 |
$vals = array_map( 'wpcf7_sanitize_query_var', $vals );
|
251 |
|
@@ -259,7 +263,7 @@ class WPCF7_FormTag implements ArrayAccess {
|
|
259 |
}
|
260 |
}
|
261 |
|
262 |
-
} elseif ( 'post' == $opt
|
263 |
$vals = (array) $_POST[$this->name];
|
264 |
$vals = array_map( 'wpcf7_sanitize_query_var', $vals );
|
265 |
|
14 |
public $content = '';
|
15 |
|
16 |
public function __construct( $tag = array() ) {
|
17 |
+
if ( is_array( $tag )
|
18 |
+
or $tag instanceof self ) {
|
19 |
foreach ( $tag as $key => $value ) {
|
20 |
if ( property_exists( __CLASS__, $key ) ) {
|
21 |
$this->{$key} = $value;
|
105 |
$matches_a = $this->get_all_match_options( '%^([0-9]*)/[0-9]*$%' );
|
106 |
|
107 |
foreach ( (array) $matches_a as $matches ) {
|
108 |
+
if ( isset( $matches[1] )
|
109 |
+
and '' !== $matches[1] ) {
|
110 |
return $matches[1];
|
111 |
}
|
112 |
}
|
173 |
'%^([0-9]*)x([0-9]*)(?:/[0-9]+)?$%' );
|
174 |
|
175 |
foreach ( (array) $matches_a as $matches ) {
|
176 |
+
if ( isset( $matches[2] )
|
177 |
+
and '' !== $matches[2] ) {
|
178 |
return $matches[2];
|
179 |
}
|
180 |
}
|
221 |
foreach ( $options as $opt ) {
|
222 |
$opt = sanitize_key( $opt );
|
223 |
|
224 |
+
if ( 'user_' == substr( $opt, 0, 5 )
|
225 |
+
and is_user_logged_in() ) {
|
226 |
$primary_props = array( 'user_login', 'user_email', 'user_url' );
|
227 |
$opt = in_array( $opt, $primary_props ) ? $opt : substr( $opt, 5 );
|
228 |
|
237 |
}
|
238 |
}
|
239 |
|
240 |
+
} elseif ( 'post_meta' == $opt and in_the_loop() ) {
|
241 |
if ( $args['multiple'] ) {
|
242 |
$values = array_merge( $values,
|
243 |
get_post_meta( get_the_ID(), $this->name ) );
|
249 |
}
|
250 |
}
|
251 |
|
252 |
+
} elseif ( 'get' == $opt and isset( $_GET[$this->name] ) ) {
|
253 |
$vals = (array) $_GET[$this->name];
|
254 |
$vals = array_map( 'wpcf7_sanitize_query_var', $vals );
|
255 |
|
263 |
}
|
264 |
}
|
265 |
|
266 |
+
} elseif ( 'post' == $opt and isset( $_POST[$this->name] ) ) {
|
267 |
$vals = (array) $_POST[$this->name];
|
268 |
$vals = array_map( 'wpcf7_sanitize_query_var', $vals );
|
269 |
|
includes/form-tags-manager.php
CHANGED
@@ -141,7 +141,8 @@ class WPCF7_FormTagsManager {
|
|
141 |
|
142 |
private function normalize_callback( $m ) {
|
143 |
// allow [[foo]] syntax for escaping a tag
|
144 |
-
if ( $m[1] == '['
|
|
|
145 |
return $m[0];
|
146 |
}
|
147 |
|
@@ -230,20 +231,20 @@ class WPCF7_FormTagsManager {
|
|
230 |
foreach ( $tags as $tag ) {
|
231 |
$tag = new WPCF7_FormTag( $tag );
|
232 |
|
233 |
-
if ( $type
|
234 |
continue;
|
235 |
}
|
236 |
|
237 |
-
if ( $name
|
238 |
continue;
|
239 |
}
|
240 |
|
241 |
if ( $feature ) {
|
242 |
if ( ! $this->tag_type_supports( $tag->type, $feature )
|
243 |
-
|
244 |
continue;
|
245 |
} elseif ( $this->tag_type_supports( $tag->type, $feature )
|
246 |
-
|
247 |
continue;
|
248 |
}
|
249 |
}
|
@@ -270,7 +271,8 @@ class WPCF7_FormTagsManager {
|
|
270 |
|
271 |
private function scan_callback( $m, $replace = false ) {
|
272 |
// allow [[foo]] syntax for escaping a tag
|
273 |
-
if ( $m[1] == '['
|
|
|
274 |
return substr( $m[0], 1, -1 );
|
275 |
}
|
276 |
|
@@ -293,7 +295,7 @@ class WPCF7_FormTagsManager {
|
|
293 |
if ( is_array( $attr ) ) {
|
294 |
if ( is_array( $attr['options'] ) ) {
|
295 |
if ( $this->tag_type_supports( $tag, 'name-attr' )
|
296 |
-
|
297 |
$scanned_tag['name'] = array_shift( $attr['options'] );
|
298 |
|
299 |
if ( ! wpcf7_is_name( $scanned_tag['name'] ) ) {
|
141 |
|
142 |
private function normalize_callback( $m ) {
|
143 |
// allow [[foo]] syntax for escaping a tag
|
144 |
+
if ( $m[1] == '['
|
145 |
+
and $m[6] == ']' ) {
|
146 |
return $m[0];
|
147 |
}
|
148 |
|
231 |
foreach ( $tags as $tag ) {
|
232 |
$tag = new WPCF7_FormTag( $tag );
|
233 |
|
234 |
+
if ( $type and ! in_array( $tag->type, $type, true ) ) {
|
235 |
continue;
|
236 |
}
|
237 |
|
238 |
+
if ( $name and ! in_array( $tag->name, $name, true ) ) {
|
239 |
continue;
|
240 |
}
|
241 |
|
242 |
if ( $feature ) {
|
243 |
if ( ! $this->tag_type_supports( $tag->type, $feature )
|
244 |
+
and ! $feature_negative ) {
|
245 |
continue;
|
246 |
} elseif ( $this->tag_type_supports( $tag->type, $feature )
|
247 |
+
and $feature_negative ) {
|
248 |
continue;
|
249 |
}
|
250 |
}
|
271 |
|
272 |
private function scan_callback( $m, $replace = false ) {
|
273 |
// allow [[foo]] syntax for escaping a tag
|
274 |
+
if ( $m[1] == '['
|
275 |
+
and $m[6] == ']' ) {
|
276 |
return substr( $m[0], 1, -1 );
|
277 |
}
|
278 |
|
295 |
if ( is_array( $attr ) ) {
|
296 |
if ( is_array( $attr['options'] ) ) {
|
297 |
if ( $this->tag_type_supports( $tag, 'name-attr' )
|
298 |
+
and ! empty( $attr['options'] ) ) {
|
299 |
$scanned_tag['name'] = array_shift( $attr['options'] );
|
300 |
|
301 |
if ( ! wpcf7_is_name( $scanned_tag['name'] ) ) {
|
includes/formatting.php
CHANGED
@@ -164,7 +164,7 @@ function wpcf7_strip_newline( $str ) {
|
|
164 |
|
165 |
function wpcf7_canonicalize( $text, $strto = 'lower' ) {
|
166 |
if ( function_exists( 'mb_convert_kana' )
|
167 |
-
|
168 |
$text = mb_convert_kana( $text, 'asKV', 'UTF-8' );
|
169 |
}
|
170 |
|
@@ -310,7 +310,8 @@ function wpcf7_is_email_in_site_domain( $email ) {
|
|
310 |
$home_url = home_url();
|
311 |
|
312 |
// for interoperability with WordPress MU Domain Mapping plugin
|
313 |
-
if ( is_multisite()
|
|
|
314 |
$domain_mapping_siteurl = domain_mapping_siteurl( false );
|
315 |
|
316 |
if ( $domain_mapping_siteurl ) {
|
@@ -322,7 +323,7 @@ function wpcf7_is_email_in_site_domain( $email ) {
|
|
322 |
$site_domain = strtolower( $matches[1] );
|
323 |
|
324 |
if ( $site_domain != strtolower( $_SERVER['SERVER_NAME'] )
|
325 |
-
|
326 |
return true;
|
327 |
}
|
328 |
}
|
164 |
|
165 |
function wpcf7_canonicalize( $text, $strto = 'lower' ) {
|
166 |
if ( function_exists( 'mb_convert_kana' )
|
167 |
+
and 'UTF-8' == get_option( 'blog_charset' ) ) {
|
168 |
$text = mb_convert_kana( $text, 'asKV', 'UTF-8' );
|
169 |
}
|
170 |
|
310 |
$home_url = home_url();
|
311 |
|
312 |
// for interoperability with WordPress MU Domain Mapping plugin
|
313 |
+
if ( is_multisite()
|
314 |
+
and function_exists( 'domain_mapping_siteurl' ) ) {
|
315 |
$domain_mapping_siteurl = domain_mapping_siteurl( false );
|
316 |
|
317 |
if ( $domain_mapping_siteurl ) {
|
323 |
$site_domain = strtolower( $matches[1] );
|
324 |
|
325 |
if ( $site_domain != strtolower( $_SERVER['SERVER_NAME'] )
|
326 |
+
and wpcf7_is_email_in_domain( $email, $site_domain ) ) {
|
327 |
return true;
|
328 |
}
|
329 |
}
|
includes/functions.php
CHANGED
@@ -7,7 +7,8 @@ function wpcf7_plugin_path( $path = '' ) {
|
|
7 |
function wpcf7_plugin_url( $path = '' ) {
|
8 |
$url = plugins_url( $path, WPCF7_PLUGIN );
|
9 |
|
10 |
-
if ( is_ssl()
|
|
|
11 |
$url = 'https:' . substr( $url, 5 );
|
12 |
}
|
13 |
|
@@ -51,7 +52,8 @@ function wpcf7_blacklist_check( $target ) {
|
|
51 |
foreach ( (array) $words as $word ) {
|
52 |
$word = trim( $word );
|
53 |
|
54 |
-
if ( empty( $word )
|
|
|
55 |
continue;
|
56 |
}
|
57 |
|
@@ -253,17 +255,23 @@ function wpcf7_enctype_value( $enctype ) {
|
|
253 |
|
254 |
function wpcf7_rmdir_p( $dir ) {
|
255 |
if ( is_file( $dir ) ) {
|
256 |
-
|
257 |
-
$stat = stat( $dir );
|
258 |
-
$perms = $stat['mode'];
|
259 |
-
chmod( $dir, $perms | 0200 ); // add write for owner
|
260 |
|
261 |
-
|
262 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
263 |
}
|
|
|
|
|
264 |
}
|
265 |
|
266 |
-
return
|
267 |
}
|
268 |
|
269 |
if ( ! is_dir( $dir ) ) {
|
@@ -272,7 +280,8 @@ function wpcf7_rmdir_p( $dir ) {
|
|
272 |
|
273 |
if ( $handle = opendir( $dir ) ) {
|
274 |
while ( false !== ( $file = readdir( $handle ) ) ) {
|
275 |
-
if ( $file == "."
|
|
|
276 |
continue;
|
277 |
}
|
278 |
|
@@ -283,7 +292,7 @@ function wpcf7_rmdir_p( $dir ) {
|
|
283 |
}
|
284 |
|
285 |
if ( false !== ( $files = scandir( $dir ) )
|
286 |
-
|
287 |
return rmdir( $dir );
|
288 |
}
|
289 |
|
@@ -308,7 +317,7 @@ function wpcf7_build_query( $args, $key = '' ) {
|
|
308 |
$v = '0';
|
309 |
}
|
310 |
|
311 |
-
if ( is_array( $v )
|
312 |
array_push( $ret, wpcf7_build_query( $v, $k ) );
|
313 |
} else {
|
314 |
array_push( $ret, $k . '=' . urlencode( $v ) );
|
@@ -360,7 +369,7 @@ function wpcf7_is_localhost() {
|
|
360 |
function wpcf7_deprecated_function( $function, $version, $replacement ) {
|
361 |
$trigger_error = apply_filters( 'deprecated_function_trigger_error', true );
|
362 |
|
363 |
-
if ( WP_DEBUG
|
364 |
if ( function_exists( '__' ) ) {
|
365 |
trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Contact Form 7 version %2$s! Use %3$s instead.', 'contact-form-7' ), $function, $version, $replacement ) );
|
366 |
} else {
|
@@ -369,8 +378,27 @@ function wpcf7_deprecated_function( $function, $version, $replacement ) {
|
|
369 |
}
|
370 |
}
|
371 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
372 |
function wpcf7_anonymize_ip_addr( $ip_addr ) {
|
373 |
-
if ( ! function_exists( 'inet_ntop' )
|
|
|
374 |
return $ip_addr;
|
375 |
}
|
376 |
|
@@ -392,12 +420,12 @@ function wpcf7_anonymize_ip_addr( $ip_addr ) {
|
|
392 |
}
|
393 |
|
394 |
function wpcf7_is_file_path_in_content_dir( $path ) {
|
395 |
-
if ( 0 === strpos( realpath( $path ), WP_CONTENT_DIR ) ) {
|
396 |
return true;
|
397 |
}
|
398 |
|
399 |
if ( defined( 'UPLOADS' )
|
400 |
-
and 0 === strpos( realpath( $path ), ABSPATH . UPLOADS ) ) {
|
401 |
return true;
|
402 |
}
|
403 |
|
7 |
function wpcf7_plugin_url( $path = '' ) {
|
8 |
$url = plugins_url( $path, WPCF7_PLUGIN );
|
9 |
|
10 |
+
if ( is_ssl()
|
11 |
+
and 'http:' == substr( $url, 0, 5 ) ) {
|
12 |
$url = 'https:' . substr( $url, 5 );
|
13 |
}
|
14 |
|
52 |
foreach ( (array) $words as $word ) {
|
53 |
$word = trim( $word );
|
54 |
|
55 |
+
if ( empty( $word )
|
56 |
+
or 256 < strlen( $word ) ) {
|
57 |
continue;
|
58 |
}
|
59 |
|
255 |
|
256 |
function wpcf7_rmdir_p( $dir ) {
|
257 |
if ( is_file( $dir ) ) {
|
258 |
+
$file = $dir;
|
|
|
|
|
|
|
259 |
|
260 |
+
if ( @unlink( $file ) ) {
|
261 |
+
return true;
|
262 |
+
}
|
263 |
+
|
264 |
+
$stat = stat( $file );
|
265 |
+
|
266 |
+
if ( @chmod( $file, $stat['mode'] | 0200 ) ) { // add write for owner
|
267 |
+
if ( @unlink( $file ) ) {
|
268 |
+
return true;
|
269 |
}
|
270 |
+
|
271 |
+
@chmod( $file, $stat['mode'] );
|
272 |
}
|
273 |
|
274 |
+
return false;
|
275 |
}
|
276 |
|
277 |
if ( ! is_dir( $dir ) ) {
|
280 |
|
281 |
if ( $handle = opendir( $dir ) ) {
|
282 |
while ( false !== ( $file = readdir( $handle ) ) ) {
|
283 |
+
if ( $file == "."
|
284 |
+
or $file == ".." ) {
|
285 |
continue;
|
286 |
}
|
287 |
|
292 |
}
|
293 |
|
294 |
if ( false !== ( $files = scandir( $dir ) )
|
295 |
+
and ! array_diff( $files, array( '.', '..' ) ) ) {
|
296 |
return rmdir( $dir );
|
297 |
}
|
298 |
|
317 |
$v = '0';
|
318 |
}
|
319 |
|
320 |
+
if ( is_array( $v ) or is_object( $v ) ) {
|
321 |
array_push( $ret, wpcf7_build_query( $v, $k ) );
|
322 |
} else {
|
323 |
array_push( $ret, $k . '=' . urlencode( $v ) );
|
369 |
function wpcf7_deprecated_function( $function, $version, $replacement ) {
|
370 |
$trigger_error = apply_filters( 'deprecated_function_trigger_error', true );
|
371 |
|
372 |
+
if ( WP_DEBUG and $trigger_error ) {
|
373 |
if ( function_exists( '__' ) ) {
|
374 |
trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Contact Form 7 version %2$s! Use %3$s instead.', 'contact-form-7' ), $function, $version, $replacement ) );
|
375 |
} else {
|
378 |
}
|
379 |
}
|
380 |
|
381 |
+
function wpcf7_log_remote_request( $url, $request, $response ) {
|
382 |
+
$log = sprintf(
|
383 |
+
/* translators: 1: response code, 2: response message, 3: URL */
|
384 |
+
__( 'HTTP Response: %1$s %2$s from %3$s', 'contact-form-7' ),
|
385 |
+
(int) wp_remote_retrieve_response_code( $response ),
|
386 |
+
wp_remote_retrieve_response_message( $response ),
|
387 |
+
$url
|
388 |
+
);
|
389 |
+
|
390 |
+
$log = apply_filters( 'wpcf7_log_remote_request',
|
391 |
+
$log, $url, $request, $response
|
392 |
+
);
|
393 |
+
|
394 |
+
if ( $log ) {
|
395 |
+
trigger_error( $log );
|
396 |
+
}
|
397 |
+
}
|
398 |
+
|
399 |
function wpcf7_anonymize_ip_addr( $ip_addr ) {
|
400 |
+
if ( ! function_exists( 'inet_ntop' )
|
401 |
+
or ! function_exists( 'inet_pton' ) ) {
|
402 |
return $ip_addr;
|
403 |
}
|
404 |
|
420 |
}
|
421 |
|
422 |
function wpcf7_is_file_path_in_content_dir( $path ) {
|
423 |
+
if ( 0 === strpos( realpath( $path ), realpath( WP_CONTENT_DIR ) ) ) {
|
424 |
return true;
|
425 |
}
|
426 |
|
427 |
if ( defined( 'UPLOADS' )
|
428 |
+
and 0 === strpos( realpath( $path ), realpath( ABSPATH . UPLOADS ) ) ) {
|
429 |
return true;
|
430 |
}
|
431 |
|
includes/integration.php
CHANGED
@@ -20,7 +20,8 @@ class WPCF7_Integration {
|
|
20 |
public function add_service( $name, WPCF7_Service $service ) {
|
21 |
$name = sanitize_key( $name );
|
22 |
|
23 |
-
if ( empty( $name )
|
|
|
24 |
return false;
|
25 |
}
|
26 |
|
@@ -30,7 +31,8 @@ class WPCF7_Integration {
|
|
30 |
public function add_category( $name, $title ) {
|
31 |
$name = sanitize_key( $name );
|
32 |
|
33 |
-
if ( empty( $name )
|
|
|
34 |
return false;
|
35 |
}
|
36 |
|
@@ -133,3 +135,187 @@ abstract class WPCF7_Service {
|
|
133 |
}
|
134 |
|
135 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
public function add_service( $name, WPCF7_Service $service ) {
|
21 |
$name = sanitize_key( $name );
|
22 |
|
23 |
+
if ( empty( $name )
|
24 |
+
or isset( $this->services[$name] ) ) {
|
25 |
return false;
|
26 |
}
|
27 |
|
31 |
public function add_category( $name, $title ) {
|
32 |
$name = sanitize_key( $name );
|
33 |
|
34 |
+
if ( empty( $name )
|
35 |
+
or isset( $this->categories[$name] ) ) {
|
36 |
return false;
|
37 |
}
|
38 |
|
135 |
}
|
136 |
|
137 |
}
|
138 |
+
|
139 |
+
class WPCF7_Service_OAuth2 extends WPCF7_Service {
|
140 |
+
|
141 |
+
protected $client_id = '';
|
142 |
+
protected $client_secret = '';
|
143 |
+
protected $access_token = '';
|
144 |
+
protected $refresh_token = '';
|
145 |
+
protected $authorization_endpoint = 'https://example.com/authorization';
|
146 |
+
protected $token_endpoint = 'https://example.com/token';
|
147 |
+
|
148 |
+
public function get_title() {
|
149 |
+
return '';
|
150 |
+
}
|
151 |
+
|
152 |
+
public function is_active() {
|
153 |
+
return ! empty( $this->access_token );
|
154 |
+
}
|
155 |
+
|
156 |
+
protected function save_data() {
|
157 |
+
}
|
158 |
+
|
159 |
+
protected function reset_data() {
|
160 |
+
}
|
161 |
+
|
162 |
+
protected function get_redirect_uri() {
|
163 |
+
return admin_url();
|
164 |
+
}
|
165 |
+
|
166 |
+
protected function menu_page_url( $args = '' ) {
|
167 |
+
return menu_page_url( 'wpcf7-integration', false );
|
168 |
+
}
|
169 |
+
|
170 |
+
public function load( $action = '' ) {
|
171 |
+
if ( 'auth_redirect' == $action ) {
|
172 |
+
$code = isset( $_GET['code'] ) ? $_GET['code'] : '';
|
173 |
+
|
174 |
+
if ( $code ) {
|
175 |
+
$this->request_token( $code );
|
176 |
+
}
|
177 |
+
|
178 |
+
wp_safe_redirect( $this->menu_page_url( 'action=setup' ) );
|
179 |
+
exit();
|
180 |
+
}
|
181 |
+
}
|
182 |
+
|
183 |
+
protected function authorize( $scope = '' ) {
|
184 |
+
$endpoint = add_query_arg(
|
185 |
+
array(
|
186 |
+
'response_type' => 'code',
|
187 |
+
'client_id' => $this->client_id,
|
188 |
+
'redirect_uri' => urlencode( $this->get_redirect_uri() ),
|
189 |
+
'scope' => $scope,
|
190 |
+
),
|
191 |
+
$this->authorization_endpoint
|
192 |
+
);
|
193 |
+
|
194 |
+
if ( wp_redirect( esc_url_raw( $endpoint ) ) ) {
|
195 |
+
exit();
|
196 |
+
}
|
197 |
+
}
|
198 |
+
|
199 |
+
protected function get_http_authorization_header( $scheme = 'basic' ) {
|
200 |
+
$scheme = strtolower( trim( $scheme ) );
|
201 |
+
|
202 |
+
switch ( $scheme ) {
|
203 |
+
case 'bearer':
|
204 |
+
return sprintf( 'Bearer %s', $this->access_token );
|
205 |
+
case 'basic':
|
206 |
+
default:
|
207 |
+
return sprintf( 'Basic %s',
|
208 |
+
base64_encode( $this->client_id . ':' . $this->client_secret )
|
209 |
+
);
|
210 |
+
}
|
211 |
+
}
|
212 |
+
|
213 |
+
protected function request_token( $authorization_code ) {
|
214 |
+
$endpoint = add_query_arg(
|
215 |
+
array(
|
216 |
+
'code' => $authorization_code,
|
217 |
+
'redirect_uri' => urlencode( $this->get_redirect_uri() ),
|
218 |
+
'grant_type' => 'authorization_code',
|
219 |
+
),
|
220 |
+
$this->token_endpoint
|
221 |
+
);
|
222 |
+
|
223 |
+
$request = array(
|
224 |
+
'headers' => array(
|
225 |
+
'Authorization' => $this->get_http_authorization_header( 'basic' ),
|
226 |
+
),
|
227 |
+
);
|
228 |
+
|
229 |
+
$response = wp_remote_post( esc_url_raw( $endpoint ), $request );
|
230 |
+
|
231 |
+
if ( WP_DEBUG
|
232 |
+
and 400 <= (int) wp_remote_retrieve_response_code( $response ) ) {
|
233 |
+
$this->log( $endpoint, $request, $response );
|
234 |
+
}
|
235 |
+
|
236 |
+
$response_body = wp_remote_retrieve_body( $response );
|
237 |
+
|
238 |
+
if ( empty( $response_body ) ) {
|
239 |
+
return $response;
|
240 |
+
}
|
241 |
+
|
242 |
+
$response_body = json_decode( $response_body, true );
|
243 |
+
|
244 |
+
$this->access_token = isset( $response_body['access_token'] )
|
245 |
+
? $response_body['access_token'] : null;
|
246 |
+
|
247 |
+
$this->refresh_token = isset( $response_body['refresh_token'] )
|
248 |
+
? $response_body['refresh_token'] : null;
|
249 |
+
|
250 |
+
$this->save_data();
|
251 |
+
|
252 |
+
return $response;
|
253 |
+
}
|
254 |
+
|
255 |
+
protected function refresh_token() {
|
256 |
+
$endpoint = add_query_arg(
|
257 |
+
array(
|
258 |
+
'refresh_token' => $this->refresh_token,
|
259 |
+
'grant_type' => 'refresh_token',
|
260 |
+
),
|
261 |
+
$this->token_endpoint
|
262 |
+
);
|
263 |
+
|
264 |
+
$request = array(
|
265 |
+
'headers' => array(
|
266 |
+
'Authorization' => $this->get_http_authorization_header( 'basic' ),
|
267 |
+
),
|
268 |
+
);
|
269 |
+
|
270 |
+
$response = wp_remote_post( esc_url_raw( $endpoint ), $request );
|
271 |
+
|
272 |
+
if ( WP_DEBUG
|
273 |
+
and 400 <= (int) wp_remote_retrieve_response_code( $response ) ) {
|
274 |
+
$this->log( $endpoint, $request, $response );
|
275 |
+
}
|
276 |
+
|
277 |
+
$response_body = wp_remote_retrieve_body( $response );
|
278 |
+
|
279 |
+
if ( empty( $response_body ) ) {
|
280 |
+
return $response;
|
281 |
+
}
|
282 |
+
|
283 |
+
$response_body = json_decode( $response_body, true );
|
284 |
+
|
285 |
+
$this->access_token = isset( $response_body['access_token'] )
|
286 |
+
? $response_body['access_token'] : null;
|
287 |
+
|
288 |
+
$this->refresh_token = isset( $response_body['refresh_token'] )
|
289 |
+
? $response_body['refresh_token'] : null;
|
290 |
+
|
291 |
+
$this->save_data();
|
292 |
+
|
293 |
+
return $response;
|
294 |
+
}
|
295 |
+
|
296 |
+
protected function remote_request( $url, $args = array() ) {
|
297 |
+
$request = $args = wp_parse_args( $args, array(
|
298 |
+
'refresh_token' => true,
|
299 |
+
) );
|
300 |
+
|
301 |
+
unset( $request['refresh_token'] );
|
302 |
+
|
303 |
+
$response = wp_remote_request( esc_url_raw( $url ), $request );
|
304 |
+
|
305 |
+
if ( 401 === wp_remote_retrieve_response_code( $response )
|
306 |
+
and $args['refresh_token'] ) {
|
307 |
+
$this->refresh_token();
|
308 |
+
|
309 |
+
$response = $this->remote_request( $url,
|
310 |
+
array_merge( $args, array( 'refresh_token' => false ) )
|
311 |
+
);
|
312 |
+
}
|
313 |
+
|
314 |
+
return $response;
|
315 |
+
}
|
316 |
+
|
317 |
+
protected function log( $url, $request, $response ) {
|
318 |
+
wpcf7_log_remote_request( $url, $request, $response );
|
319 |
+
}
|
320 |
+
|
321 |
+
}
|
includes/js/scripts.js
CHANGED
@@ -266,13 +266,6 @@
|
|
266 |
$message.addClass( 'wpcf7-spam-blocked' );
|
267 |
$form.addClass( 'spam' );
|
268 |
|
269 |
-
$( '[name="g-recaptcha-response"]', $form ).each( function() {
|
270 |
-
if ( '' === $( this ).val() ) {
|
271 |
-
var $recaptcha = $( this ).closest( '.wpcf7-form-control-wrap' );
|
272 |
-
wpcf7.notValidTip( $recaptcha, wpcf7.recaptcha.messages.empty );
|
273 |
-
}
|
274 |
-
} );
|
275 |
-
|
276 |
wpcf7.triggerEvent( data.into, 'spam', detail );
|
277 |
break;
|
278 |
case 'aborted':
|
266 |
$message.addClass( 'wpcf7-spam-blocked' );
|
267 |
$form.addClass( 'spam' );
|
268 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
269 |
wpcf7.triggerEvent( data.into, 'spam', detail );
|
270 |
break;
|
271 |
case 'aborted':
|
includes/l10n.php
CHANGED
@@ -18,13 +18,14 @@ function wpcf7_l10n() {
|
|
18 |
'version' => WPCF7_VERSION,
|
19 |
) );
|
20 |
|
21 |
-
if ( is_wp_error( $api )
|
|
|
22 |
return $l10n;
|
23 |
}
|
24 |
|
25 |
foreach ( (array) $api['translations'] as $translation ) {
|
26 |
if ( ! empty( $translation['language'] )
|
27 |
-
|
28 |
$l10n[$translation['language']] = $translation['english_name'];
|
29 |
}
|
30 |
}
|
@@ -49,7 +50,8 @@ function wpcf7_is_rtl( $locale = '' ) {
|
|
49 |
'ug_CN' => 'Uighur',
|
50 |
);
|
51 |
|
52 |
-
if ( empty( $locale )
|
|
|
53 |
return is_rtl();
|
54 |
}
|
55 |
|
18 |
'version' => WPCF7_VERSION,
|
19 |
) );
|
20 |
|
21 |
+
if ( is_wp_error( $api )
|
22 |
+
or empty( $api['translations'] ) ) {
|
23 |
return $l10n;
|
24 |
}
|
25 |
|
26 |
foreach ( (array) $api['translations'] as $translation ) {
|
27 |
if ( ! empty( $translation['language'] )
|
28 |
+
and ! empty( $translation['english_name'] ) ) {
|
29 |
$l10n[$translation['language']] = $translation['english_name'];
|
30 |
}
|
31 |
}
|
50 |
'ug_CN' => 'Uighur',
|
51 |
);
|
52 |
|
53 |
+
if ( empty( $locale )
|
54 |
+
and function_exists( 'is_rtl' ) ) {
|
55 |
return is_rtl();
|
56 |
}
|
57 |
|
includes/mail.php
CHANGED
@@ -57,7 +57,7 @@ class WPCF7_Mail {
|
|
57 |
) );
|
58 |
|
59 |
if ( $use_html
|
60 |
-
|
61 |
$component = $this->htmlize( $component );
|
62 |
}
|
63 |
}
|
@@ -159,7 +159,7 @@ class WPCF7_Mail {
|
|
159 |
|
160 |
foreach ( (array) $uploaded_files as $name => $path ) {
|
161 |
if ( false !== strpos( $template, "[${name}]" )
|
162 |
-
|
163 |
$attachments[] = $path;
|
164 |
}
|
165 |
}
|
@@ -179,7 +179,8 @@ class WPCF7_Mail {
|
|
179 |
continue;
|
180 |
}
|
181 |
|
182 |
-
if ( is_readable( $path )
|
|
|
183 |
$attachments[] = $path;
|
184 |
}
|
185 |
}
|
@@ -211,7 +212,8 @@ function wpcf7_mail_replace_tags( $content, $args = '' ) {
|
|
211 |
if ( $args['exclude_blank'] ) {
|
212 |
$replaced_tags = $line->get_replaced_tags();
|
213 |
|
214 |
-
if ( empty( $replaced_tags )
|
|
|
215 |
$content[$num] = $replaced;
|
216 |
} else {
|
217 |
unset( $content[$num] ); // Remove a line.
|
@@ -226,7 +228,7 @@ function wpcf7_mail_replace_tags( $content, $args = '' ) {
|
|
226 |
return $content;
|
227 |
}
|
228 |
|
229 |
-
add_action( 'phpmailer_init', 'wpcf7_phpmailer_init' );
|
230 |
|
231 |
function wpcf7_phpmailer_init( $phpmailer ) {
|
232 |
$custom_headers = $phpmailer->getCustomHeaders();
|
@@ -266,7 +268,8 @@ class WPCF7_MailTaggedText {
|
|
266 |
|
267 |
$this->html = (bool) $args['html'];
|
268 |
|
269 |
-
if ( null !== $args['callback']
|
|
|
270 |
$this->callback = $args['callback'];
|
271 |
} elseif ( $this->html ) {
|
272 |
$this->callback = array( $this, 'replace_tags_callback_html' );
|
@@ -296,7 +299,8 @@ class WPCF7_MailTaggedText {
|
|
296 |
|
297 |
private function replace_tags_callback( $matches, $html = false ) {
|
298 |
// allow [[foo]] syntax for escaping a tag
|
299 |
-
if ( $matches[1] == '['
|
|
|
300 |
return substr( $matches[0], 1, -1 );
|
301 |
}
|
302 |
|
57 |
) );
|
58 |
|
59 |
if ( $use_html
|
60 |
+
and ! preg_match( '%<html[>\s].*</html>%is', $component ) ) {
|
61 |
$component = $this->htmlize( $component );
|
62 |
}
|
63 |
}
|
159 |
|
160 |
foreach ( (array) $uploaded_files as $name => $path ) {
|
161 |
if ( false !== strpos( $template, "[${name}]" )
|
162 |
+
and ! empty( $path ) ) {
|
163 |
$attachments[] = $path;
|
164 |
}
|
165 |
}
|
179 |
continue;
|
180 |
}
|
181 |
|
182 |
+
if ( is_readable( $path )
|
183 |
+
and is_file( $path ) ) {
|
184 |
$attachments[] = $path;
|
185 |
}
|
186 |
}
|
212 |
if ( $args['exclude_blank'] ) {
|
213 |
$replaced_tags = $line->get_replaced_tags();
|
214 |
|
215 |
+
if ( empty( $replaced_tags )
|
216 |
+
or array_filter( $replaced_tags ) ) {
|
217 |
$content[$num] = $replaced;
|
218 |
} else {
|
219 |
unset( $content[$num] ); // Remove a line.
|
228 |
return $content;
|
229 |
}
|
230 |
|
231 |
+
add_action( 'phpmailer_init', 'wpcf7_phpmailer_init', 10, 1 );
|
232 |
|
233 |
function wpcf7_phpmailer_init( $phpmailer ) {
|
234 |
$custom_headers = $phpmailer->getCustomHeaders();
|
268 |
|
269 |
$this->html = (bool) $args['html'];
|
270 |
|
271 |
+
if ( null !== $args['callback']
|
272 |
+
and is_callable( $args['callback'] ) ) {
|
273 |
$this->callback = $args['callback'];
|
274 |
} elseif ( $this->html ) {
|
275 |
$this->callback = array( $this, 'replace_tags_callback_html' );
|
299 |
|
300 |
private function replace_tags_callback( $matches, $html = false ) {
|
301 |
// allow [[foo]] syntax for escaping a tag
|
302 |
+
if ( $matches[1] == '['
|
303 |
+
and $matches[4] == ']' ) {
|
304 |
return substr( $matches[0], 1, -1 );
|
305 |
}
|
306 |
|
includes/rest-api.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
add_action( 'rest_api_init', 'wpcf7_rest_api_init' );
|
4 |
|
5 |
function wpcf7_rest_api_init() {
|
6 |
$namespace = 'contact-form-7/v1';
|
1 |
<?php
|
2 |
|
3 |
+
add_action( 'rest_api_init', 'wpcf7_rest_api_init', 10, 0 );
|
4 |
|
5 |
function wpcf7_rest_api_init() {
|
6 |
$namespace = 'contact-form-7/v1';
|
includes/special-mail-tags.php
CHANGED
@@ -39,7 +39,8 @@ function wpcf7_special_mail_tag( $output, $name, $html ) {
|
|
39 |
}
|
40 |
}
|
41 |
|
42 |
-
if ( '_date' == $name
|
|
|
43 |
if ( $timestamp = $submission->get_meta( 'timestamp' ) ) {
|
44 |
if ( '_date' == $name ) {
|
45 |
return date_i18n( get_option( 'date_format' ), $timestamp );
|
@@ -75,7 +76,8 @@ function wpcf7_post_related_smt( $output, $name, $html ) {
|
|
75 |
|
76 |
$post_id = (int) $submission->get_meta( 'container_post_id' );
|
77 |
|
78 |
-
if ( ! $post_id
|
|
|
79 |
return '';
|
80 |
}
|
81 |
|
@@ -135,7 +137,8 @@ function wpcf7_site_related_smt( $output, $name, $html ) {
|
|
135 |
add_filter( 'wpcf7_special_mail_tags', 'wpcf7_user_related_smt', 10, 3 );
|
136 |
|
137 |
function wpcf7_user_related_smt( $output, $name, $html ) {
|
138 |
-
if ( '_user_' != substr( $name, 0, 6 )
|
|
|
139 |
return $output;
|
140 |
}
|
141 |
|
39 |
}
|
40 |
}
|
41 |
|
42 |
+
if ( '_date' == $name
|
43 |
+
or '_time' == $name ) {
|
44 |
if ( $timestamp = $submission->get_meta( 'timestamp' ) ) {
|
45 |
if ( '_date' == $name ) {
|
46 |
return date_i18n( get_option( 'date_format' ), $timestamp );
|
76 |
|
77 |
$post_id = (int) $submission->get_meta( 'container_post_id' );
|
78 |
|
79 |
+
if ( ! $post_id
|
80 |
+
or ! $post = get_post( $post_id ) ) {
|
81 |
return '';
|
82 |
}
|
83 |
|
137 |
add_filter( 'wpcf7_special_mail_tags', 'wpcf7_user_related_smt', 10, 3 );
|
138 |
|
139 |
function wpcf7_user_related_smt( $output, $name, $html ) {
|
140 |
+
if ( '_user_' != substr( $name, 0, 6 )
|
141 |
+
or '_user_agent' == $name ) {
|
142 |
return $output;
|
143 |
}
|
144 |
|
includes/submission.php
CHANGED
@@ -119,8 +119,8 @@ class WPCF7_Submission {
|
|
119 |
}
|
120 |
|
121 |
if ( WPCF7_USE_PIPE
|
122 |
-
|
123 |
-
|
124 |
if ( is_array( $value_orig ) ) {
|
125 |
$value = array();
|
126 |
|
@@ -138,7 +138,7 @@ class WPCF7_Submission {
|
|
138 |
$posted_data[$name] = $value;
|
139 |
|
140 |
if ( $tag->has_option( 'consent_for:storage' )
|
141 |
-
|
142 |
$this->meta['do_not_store'] = true;
|
143 |
}
|
144 |
}
|
@@ -228,7 +228,7 @@ class WPCF7_Submission {
|
|
228 |
$ip_addr = '';
|
229 |
|
230 |
if ( isset( $_SERVER['REMOTE_ADDR'] )
|
231 |
-
|
232 |
$ip_addr = $_SERVER['REMOTE_ADDR'];
|
233 |
}
|
234 |
|
@@ -242,7 +242,8 @@ class WPCF7_Submission {
|
|
242 |
$referer = isset( $_SERVER['HTTP_REFERER'] )
|
243 |
? trim( $_SERVER['HTTP_REFERER'] ) : '';
|
244 |
|
245 |
-
if ( $referer
|
|
|
246 |
return esc_url_raw( $referer );
|
247 |
}
|
248 |
}
|
@@ -292,7 +293,7 @@ class WPCF7_Submission {
|
|
292 |
$spam = false;
|
293 |
|
294 |
if ( $this->contact_form->is_true( 'subscribers_only' )
|
295 |
-
|
296 |
return $spam;
|
297 |
}
|
298 |
|
@@ -360,7 +361,8 @@ class WPCF7_Submission {
|
|
360 |
if ( $result ) {
|
361 |
$additional_mail = array();
|
362 |
|
363 |
-
if (
|
|
|
364 |
$additional_mail['mail_2'] = $mail_2;
|
365 |
}
|
366 |
|
@@ -393,9 +395,9 @@ class WPCF7_Submission {
|
|
393 |
foreach ( (array) $this->uploaded_files as $name => $path ) {
|
394 |
wpcf7_rmdir_p( $path );
|
395 |
|
396 |
-
if (
|
397 |
-
|
398 |
-
|
399 |
// remove parent dir if it's empty.
|
400 |
rmdir( $dir );
|
401 |
}
|
119 |
}
|
120 |
|
121 |
if ( WPCF7_USE_PIPE
|
122 |
+
and $pipes instanceof WPCF7_Pipes
|
123 |
+
and ! $pipes->zero() ) {
|
124 |
if ( is_array( $value_orig ) ) {
|
125 |
$value = array();
|
126 |
|
138 |
$posted_data[$name] = $value;
|
139 |
|
140 |
if ( $tag->has_option( 'consent_for:storage' )
|
141 |
+
and empty( $posted_data[$name] ) ) {
|
142 |
$this->meta['do_not_store'] = true;
|
143 |
}
|
144 |
}
|
228 |
$ip_addr = '';
|
229 |
|
230 |
if ( isset( $_SERVER['REMOTE_ADDR'] )
|
231 |
+
and WP_Http::is_ip_address( $_SERVER['REMOTE_ADDR'] ) ) {
|
232 |
$ip_addr = $_SERVER['REMOTE_ADDR'];
|
233 |
}
|
234 |
|
242 |
$referer = isset( $_SERVER['HTTP_REFERER'] )
|
243 |
? trim( $_SERVER['HTTP_REFERER'] ) : '';
|
244 |
|
245 |
+
if ( $referer
|
246 |
+
and 0 === strpos( $referer, $home_url ) ) {
|
247 |
return esc_url_raw( $referer );
|
248 |
}
|
249 |
}
|
293 |
$spam = false;
|
294 |
|
295 |
if ( $this->contact_form->is_true( 'subscribers_only' )
|
296 |
+
and current_user_can( 'wpcf7_submit', $this->contact_form->id() ) ) {
|
297 |
return $spam;
|
298 |
}
|
299 |
|
361 |
if ( $result ) {
|
362 |
$additional_mail = array();
|
363 |
|
364 |
+
if ( $mail_2 = $contact_form->prop( 'mail_2' )
|
365 |
+
and $mail_2['active'] ) {
|
366 |
$additional_mail['mail_2'] = $mail_2;
|
367 |
}
|
368 |
|
395 |
foreach ( (array) $this->uploaded_files as $name => $path ) {
|
396 |
wpcf7_rmdir_p( $path );
|
397 |
|
398 |
+
if ( $dir = dirname( $path )
|
399 |
+
and false !== ( $files = scandir( $dir ) )
|
400 |
+
and ! array_diff( $files, array( '.', '..' ) ) ) {
|
401 |
// remove parent dir if it's empty.
|
402 |
rmdir( $dir );
|
403 |
}
|
includes/upgrade.php
CHANGED
@@ -15,9 +15,13 @@ function wpcf7_convert_to_cpt( $new_ver, $old_ver ) {
|
|
15 |
|
16 |
if ( $wpdb->get_var( "SHOW TABLES LIKE '$table_name'" ) ) {
|
17 |
$old_rows = $wpdb->get_results( "SELECT * FROM $table_name" );
|
18 |
-
} elseif (
|
|
|
19 |
foreach ( (array) $opt['contact_forms'] as $key => $value ) {
|
20 |
-
$old_rows[] = (object) array_merge(
|
|
|
|
|
|
|
21 |
}
|
22 |
}
|
23 |
|
15 |
|
16 |
if ( $wpdb->get_var( "SHOW TABLES LIKE '$table_name'" ) ) {
|
17 |
$old_rows = $wpdb->get_results( "SELECT * FROM $table_name" );
|
18 |
+
} elseif ( $opt = get_option( 'wpcf7' )
|
19 |
+
and ! empty( $opt['contact_forms'] ) ) {
|
20 |
foreach ( (array) $opt['contact_forms'] as $key => $value ) {
|
21 |
+
$old_rows[] = (object) array_merge(
|
22 |
+
$value,
|
23 |
+
array( 'cf7_unit_id' => $key )
|
24 |
+
);
|
25 |
}
|
26 |
}
|
27 |
|
includes/validation.php
CHANGED
@@ -24,14 +24,16 @@ class WPCF7_Validation implements ArrayAccess {
|
|
24 |
|
25 |
$name = ! empty( $tag ) ? $tag->name : null;
|
26 |
|
27 |
-
if ( empty( $name )
|
|
|
28 |
return;
|
29 |
}
|
30 |
|
31 |
if ( $this->is_valid( $name ) ) {
|
32 |
$id = $tag->get_id_option();
|
33 |
|
34 |
-
if ( empty( $id )
|
|
|
35 |
$id = null;
|
36 |
}
|
37 |
|
@@ -59,7 +61,8 @@ class WPCF7_Validation implements ArrayAccess {
|
|
59 |
$this->container[$offset] = $value;
|
60 |
}
|
61 |
|
62 |
-
if ( 'reason' == $offset
|
|
|
63 |
foreach ( $value as $k => $v ) {
|
64 |
$this->invalidate( $k, $v );
|
65 |
}
|
24 |
|
25 |
$name = ! empty( $tag ) ? $tag->name : null;
|
26 |
|
27 |
+
if ( empty( $name )
|
28 |
+
or ! wpcf7_is_name( $name ) ) {
|
29 |
return;
|
30 |
}
|
31 |
|
32 |
if ( $this->is_valid( $name ) ) {
|
33 |
$id = $tag->get_id_option();
|
34 |
|
35 |
+
if ( empty( $id )
|
36 |
+
or ! wpcf7_is_name( $id ) ) {
|
37 |
$id = null;
|
38 |
}
|
39 |
|
61 |
$this->container[$offset] = $value;
|
62 |
}
|
63 |
|
64 |
+
if ( 'reason' == $offset
|
65 |
+
and is_array( $value ) ) {
|
66 |
foreach ( $value as $k => $v ) {
|
67 |
$this->invalidate( $k, $v );
|
68 |
}
|
modules/acceptance.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
|
6 |
/* form_tag handler */
|
7 |
|
8 |
-
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_acceptance' );
|
9 |
|
10 |
function wpcf7_add_form_tag_acceptance() {
|
11 |
wpcf7_add_form_tag( 'acceptance',
|
@@ -103,7 +103,8 @@ function wpcf7_acceptance_validation_filter( $result, $tag ) {
|
|
103 |
|
104 |
$invert = $tag->has_option( 'invert' );
|
105 |
|
106 |
-
if ( $invert
|
|
|
107 |
$result->invalidate( $tag, wpcf7_get_message( 'accept_terms' ) );
|
108 |
}
|
109 |
|
@@ -133,7 +134,7 @@ function wpcf7_acceptance_filter( $accepted, $submission ) {
|
|
133 |
|
134 |
$content = trim( $content );
|
135 |
|
136 |
-
if ( $value
|
137 |
$submission->add_consent( $name, $content );
|
138 |
}
|
139 |
|
@@ -143,7 +144,8 @@ function wpcf7_acceptance_filter( $accepted, $submission ) {
|
|
143 |
|
144 |
$invert = $tag->has_option( 'invert' );
|
145 |
|
146 |
-
if ( $invert
|
|
|
147 |
$accepted = false;
|
148 |
}
|
149 |
}
|
@@ -151,7 +153,8 @@ function wpcf7_acceptance_filter( $accepted, $submission ) {
|
|
151 |
return $accepted;
|
152 |
}
|
153 |
|
154 |
-
add_filter( 'wpcf7_form_class_attr',
|
|
|
155 |
|
156 |
function wpcf7_acceptance_form_class_attr( $class ) {
|
157 |
if ( wpcf7_acceptance_as_validation() ) {
|
@@ -210,7 +213,7 @@ function wpcf7_acceptance_mail_tag( $replaced, $submitted, $html, $mail_tag ) {
|
|
210 |
|
211 |
/* Tag generator */
|
212 |
|
213 |
-
add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_acceptance', 35 );
|
214 |
|
215 |
function wpcf7_add_tag_generator_acceptance() {
|
216 |
$tag_generator = WPCF7_TagGenerator::get_instance();
|
5 |
|
6 |
/* form_tag handler */
|
7 |
|
8 |
+
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_acceptance', 10, 0 );
|
9 |
|
10 |
function wpcf7_add_form_tag_acceptance() {
|
11 |
wpcf7_add_form_tag( 'acceptance',
|
103 |
|
104 |
$invert = $tag->has_option( 'invert' );
|
105 |
|
106 |
+
if ( $invert and $value
|
107 |
+
or ! $invert and ! $value ) {
|
108 |
$result->invalidate( $tag, wpcf7_get_message( 'accept_terms' ) );
|
109 |
}
|
110 |
|
134 |
|
135 |
$content = trim( $content );
|
136 |
|
137 |
+
if ( $value and $content ) {
|
138 |
$submission->add_consent( $name, $content );
|
139 |
}
|
140 |
|
144 |
|
145 |
$invert = $tag->has_option( 'invert' );
|
146 |
|
147 |
+
if ( $invert and $value
|
148 |
+
or ! $invert and ! $value ) {
|
149 |
$accepted = false;
|
150 |
}
|
151 |
}
|
153 |
return $accepted;
|
154 |
}
|
155 |
|
156 |
+
add_filter( 'wpcf7_form_class_attr',
|
157 |
+
'wpcf7_acceptance_form_class_attr', 10, 1 );
|
158 |
|
159 |
function wpcf7_acceptance_form_class_attr( $class ) {
|
160 |
if ( wpcf7_acceptance_as_validation() ) {
|
213 |
|
214 |
/* Tag generator */
|
215 |
|
216 |
+
add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_acceptance', 35, 0 );
|
217 |
|
218 |
function wpcf7_add_tag_generator_acceptance() {
|
219 |
$tag_generator = WPCF7_TagGenerator::get_instance();
|
modules/akismet.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
** Akismet API: http://akismet.com/development/api/
|
5 |
**/
|
6 |
|
7 |
-
add_filter( 'wpcf7_spam', 'wpcf7_akismet' );
|
8 |
|
9 |
function wpcf7_akismet( $spam ) {
|
10 |
if ( $spam ) {
|
@@ -70,7 +70,8 @@ function wpcf7_akismet_submitted_params() {
|
|
70 |
$has_akismet_option = false;
|
71 |
|
72 |
foreach ( (array) $_POST as $key => $val ) {
|
73 |
-
if ( '_wpcf7' == substr( $key, 0, 6 )
|
|
|
74 |
continue;
|
75 |
}
|
76 |
|
4 |
** Akismet API: http://akismet.com/development/api/
|
5 |
**/
|
6 |
|
7 |
+
add_filter( 'wpcf7_spam', 'wpcf7_akismet', 10, 1 );
|
8 |
|
9 |
function wpcf7_akismet( $spam ) {
|
10 |
if ( $spam ) {
|
70 |
$has_akismet_option = false;
|
71 |
|
72 |
foreach ( (array) $_POST as $key => $val ) {
|
73 |
+
if ( '_wpcf7' == substr( $key, 0, 6 )
|
74 |
+
or '_wpnonce' == $key ) {
|
75 |
continue;
|
76 |
}
|
77 |
|
modules/checkbox.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
|
6 |
/* form_tag handler */
|
7 |
|
8 |
-
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_checkbox' );
|
9 |
|
10 |
function wpcf7_add_form_tag_checkbox() {
|
11 |
wpcf7_add_form_tag( array( 'checkbox', 'checkbox*', 'radio' ),
|
@@ -123,7 +123,8 @@ function wpcf7_checkbox_form_tag_handler( $tag ) {
|
|
123 |
$item = '<label>' . $item . '</label>';
|
124 |
}
|
125 |
|
126 |
-
if ( false !== $tabindex
|
|
|
127 |
$tabindex += 1;
|
128 |
}
|
129 |
|
@@ -147,7 +148,8 @@ function wpcf7_checkbox_form_tag_handler( $tag ) {
|
|
147 |
'tabindex' => false !== $tabindex ? $tabindex : '',
|
148 |
);
|
149 |
|
150 |
-
if ( wpcf7_is_posted()
|
|
|
151 |
$free_text_atts['value'] = wp_unslash(
|
152 |
$_POST[$free_text_name] );
|
153 |
}
|
@@ -176,16 +178,19 @@ function wpcf7_checkbox_form_tag_handler( $tag ) {
|
|
176 |
|
177 |
/* Validation filter */
|
178 |
|
179 |
-
add_filter( 'wpcf7_validate_checkbox',
|
180 |
-
|
181 |
-
add_filter( '
|
|
|
|
|
|
|
182 |
|
183 |
function wpcf7_checkbox_validation_filter( $result, $tag ) {
|
184 |
$name = $tag->name;
|
185 |
$is_required = $tag->is_required() || 'radio' == $tag->type;
|
186 |
$value = isset( $_POST[$name] ) ? (array) $_POST[$name] : array();
|
187 |
|
188 |
-
if ( $is_required
|
189 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
|
190 |
}
|
191 |
|
@@ -195,7 +200,7 @@ function wpcf7_checkbox_validation_filter( $result, $tag ) {
|
|
195 |
|
196 |
/* Adding free text field */
|
197 |
|
198 |
-
add_filter( 'wpcf7_posted_data', 'wpcf7_checkbox_posted_data' );
|
199 |
|
200 |
function wpcf7_checkbox_posted_data( $posted_data ) {
|
201 |
$tags = wpcf7_scan_form_tags(
|
@@ -248,7 +253,7 @@ function wpcf7_checkbox_posted_data( $posted_data ) {
|
|
248 |
/* Tag generator */
|
249 |
|
250 |
add_action( 'wpcf7_admin_init',
|
251 |
-
'wpcf7_add_tag_generator_checkbox_and_radio', 30 );
|
252 |
|
253 |
function wpcf7_add_tag_generator_checkbox_and_radio() {
|
254 |
$tag_generator = WPCF7_TagGenerator::get_instance();
|
5 |
|
6 |
/* form_tag handler */
|
7 |
|
8 |
+
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_checkbox', 10, 0 );
|
9 |
|
10 |
function wpcf7_add_form_tag_checkbox() {
|
11 |
wpcf7_add_form_tag( array( 'checkbox', 'checkbox*', 'radio' ),
|
123 |
$item = '<label>' . $item . '</label>';
|
124 |
}
|
125 |
|
126 |
+
if ( false !== $tabindex
|
127 |
+
and 0 < $tabindex ) {
|
128 |
$tabindex += 1;
|
129 |
}
|
130 |
|
148 |
'tabindex' => false !== $tabindex ? $tabindex : '',
|
149 |
);
|
150 |
|
151 |
+
if ( wpcf7_is_posted()
|
152 |
+
and isset( $_POST[$free_text_name] ) ) {
|
153 |
$free_text_atts['value'] = wp_unslash(
|
154 |
$_POST[$free_text_name] );
|
155 |
}
|
178 |
|
179 |
/* Validation filter */
|
180 |
|
181 |
+
add_filter( 'wpcf7_validate_checkbox',
|
182 |
+
'wpcf7_checkbox_validation_filter', 10, 2 );
|
183 |
+
add_filter( 'wpcf7_validate_checkbox*',
|
184 |
+
'wpcf7_checkbox_validation_filter', 10, 2 );
|
185 |
+
add_filter( 'wpcf7_validate_radio',
|
186 |
+
'wpcf7_checkbox_validation_filter', 10, 2 );
|
187 |
|
188 |
function wpcf7_checkbox_validation_filter( $result, $tag ) {
|
189 |
$name = $tag->name;
|
190 |
$is_required = $tag->is_required() || 'radio' == $tag->type;
|
191 |
$value = isset( $_POST[$name] ) ? (array) $_POST[$name] : array();
|
192 |
|
193 |
+
if ( $is_required and empty( $value ) ) {
|
194 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
|
195 |
}
|
196 |
|
200 |
|
201 |
/* Adding free text field */
|
202 |
|
203 |
+
add_filter( 'wpcf7_posted_data', 'wpcf7_checkbox_posted_data', 10, 1 );
|
204 |
|
205 |
function wpcf7_checkbox_posted_data( $posted_data ) {
|
206 |
$tags = wpcf7_scan_form_tags(
|
253 |
/* Tag generator */
|
254 |
|
255 |
add_action( 'wpcf7_admin_init',
|
256 |
+
'wpcf7_add_tag_generator_checkbox_and_radio', 30, 0 );
|
257 |
|
258 |
function wpcf7_add_tag_generator_checkbox_and_radio() {
|
259 |
$tag_generator = WPCF7_TagGenerator::get_instance();
|
modules/constant-contact.php
ADDED
@@ -0,0 +1,677 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
add_action( 'wpcf7_init', 'wpcf7_constant_contact_register_service', 10, 0 );
|
4 |
+
|
5 |
+
function wpcf7_constant_contact_register_service() {
|
6 |
+
$integration = WPCF7_Integration::get_instance();
|
7 |
+
|
8 |
+
$integration->add_category( 'email_marketing',
|
9 |
+
__( 'Email Marketing', 'contact-form-7' ) );
|
10 |
+
|
11 |
+
$service = WPCF7_ConstantContact::get_instance();
|
12 |
+
$integration->add_service( 'constant_contact', $service );
|
13 |
+
}
|
14 |
+
|
15 |
+
add_action( 'wpcf7_submit', 'wpcf7_constant_contact_submit', 10, 2 );
|
16 |
+
|
17 |
+
function wpcf7_constant_contact_submit( $contact_form, $result ) {
|
18 |
+
$service = WPCF7_ConstantContact::get_instance();
|
19 |
+
|
20 |
+
if ( ! $service->is_active() ) {
|
21 |
+
return;
|
22 |
+
}
|
23 |
+
|
24 |
+
if ( $contact_form->in_demo_mode() ) {
|
25 |
+
return;
|
26 |
+
}
|
27 |
+
|
28 |
+
$do_submit = true;
|
29 |
+
|
30 |
+
if ( empty( $result['status'] )
|
31 |
+
or ! in_array( $result['status'], array( 'mail_sent' ) ) ) {
|
32 |
+
$do_submit = false;
|
33 |
+
}
|
34 |
+
|
35 |
+
$do_submit = apply_filters( 'wpcf7_constant_contact_submit',
|
36 |
+
$do_submit, $contact_form, $result );
|
37 |
+
|
38 |
+
if ( ! $do_submit ) {
|
39 |
+
return;
|
40 |
+
}
|
41 |
+
|
42 |
+
$submission = WPCF7_Submission::get_instance();
|
43 |
+
|
44 |
+
$consented = true;
|
45 |
+
|
46 |
+
foreach ( $contact_form->scan_form_tags( 'feature=name-attr' ) as $tag ) {
|
47 |
+
if ( $tag->has_option( 'consent_for:constant_contact' )
|
48 |
+
and null == $submission->get_posted_data( $tag->name ) ) {
|
49 |
+
$consented = false;
|
50 |
+
break;
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
if ( ! $consented ) {
|
55 |
+
return;
|
56 |
+
}
|
57 |
+
|
58 |
+
$request_builder_class_name = apply_filters(
|
59 |
+
'wpcf7_constant_contact_contact_post_request_builder',
|
60 |
+
'WPCF7_ConstantContact_ContactPostRequest'
|
61 |
+
);
|
62 |
+
|
63 |
+
if ( ! class_exists( $request_builder_class_name ) ) {
|
64 |
+
return;
|
65 |
+
}
|
66 |
+
|
67 |
+
$request_builder = new $request_builder_class_name;
|
68 |
+
$request_builder->build( $submission );
|
69 |
+
|
70 |
+
if ( ! $request_builder->is_valid() ) {
|
71 |
+
return;
|
72 |
+
}
|
73 |
+
|
74 |
+
if ( $email = $request_builder->get_email_address()
|
75 |
+
and $service->email_exists( $email ) ) {
|
76 |
+
return;
|
77 |
+
}
|
78 |
+
|
79 |
+
$service->create_contact( $request_builder->to_array() );
|
80 |
+
}
|
81 |
+
|
82 |
+
if ( ! class_exists( 'WPCF7_Service_OAuth2' ) ) {
|
83 |
+
return;
|
84 |
+
}
|
85 |
+
|
86 |
+
class WPCF7_ConstantContact extends WPCF7_Service_OAuth2 {
|
87 |
+
|
88 |
+
const service_name = 'constant_contact';
|
89 |
+
const authorization_endpoint = 'https://api.cc.email/v3/idfed';
|
90 |
+
const token_endpoint = 'https://idfed.constantcontact.com/as/token.oauth2';
|
91 |
+
|
92 |
+
private static $instance;
|
93 |
+
|
94 |
+
public static function get_instance() {
|
95 |
+
if ( empty( self::$instance ) ) {
|
96 |
+
self::$instance = new self;
|
97 |
+
}
|
98 |
+
|
99 |
+
return self::$instance;
|
100 |
+
}
|
101 |
+
|
102 |
+
private function __construct() {
|
103 |
+
$this->authorization_endpoint = self::authorization_endpoint;
|
104 |
+
$this->token_endpoint = self::token_endpoint;
|
105 |
+
|
106 |
+
$option = (array) WPCF7::get_option( self::service_name );
|
107 |
+
|
108 |
+
if ( isset( $option['client_id'] ) ) {
|
109 |
+
$this->client_id = $option['client_id'];
|
110 |
+
}
|
111 |
+
|
112 |
+
if ( isset( $option['client_secret'] ) ) {
|
113 |
+
$this->client_secret = $option['client_secret'];
|
114 |
+
}
|
115 |
+
|
116 |
+
if ( isset( $option['access_token'] ) ) {
|
117 |
+
$this->access_token = $option['access_token'];
|
118 |
+
}
|
119 |
+
|
120 |
+
if ( isset( $option['refresh_token'] ) ) {
|
121 |
+
$this->refresh_token = $option['refresh_token'];
|
122 |
+
}
|
123 |
+
|
124 |
+
add_action( 'wpcf7_admin_init', array( $this, 'auth_redirect' ) );
|
125 |
+
}
|
126 |
+
|
127 |
+
public function auth_redirect() {
|
128 |
+
$auth = isset( $_GET['auth'] ) ? trim( $_GET['auth'] ) : '';
|
129 |
+
$code = isset( $_GET['code'] ) ? trim( $_GET['code'] ) : '';
|
130 |
+
|
131 |
+
if ( self::service_name === $auth and $code
|
132 |
+
and current_user_can( 'wpcf7_manage_integration' ) ) {
|
133 |
+
$redirect_to = add_query_arg(
|
134 |
+
array(
|
135 |
+
'service' => self::service_name,
|
136 |
+
'action' => 'auth_redirect',
|
137 |
+
'code' => $code,
|
138 |
+
),
|
139 |
+
menu_page_url( 'wpcf7-integration', false )
|
140 |
+
);
|
141 |
+
|
142 |
+
wp_safe_redirect( $redirect_to );
|
143 |
+
exit();
|
144 |
+
}
|
145 |
+
}
|
146 |
+
|
147 |
+
protected function save_data() {
|
148 |
+
$option = array_merge(
|
149 |
+
(array) WPCF7::get_option( self::service_name ),
|
150 |
+
array(
|
151 |
+
'client_id' => $this->client_id,
|
152 |
+
'client_secret' => $this->client_secret,
|
153 |
+
'access_token' => $this->access_token,
|
154 |
+
'refresh_token' => $this->refresh_token,
|
155 |
+
)
|
156 |
+
);
|
157 |
+
|
158 |
+
WPCF7::update_option( self::service_name, $option );
|
159 |
+
}
|
160 |
+
|
161 |
+
protected function reset_data() {
|
162 |
+
$this->client_id = '';
|
163 |
+
$this->client_secret = '';
|
164 |
+
$this->access_token = '';
|
165 |
+
$this->refresh_token = '';
|
166 |
+
|
167 |
+
$this->save_data();
|
168 |
+
}
|
169 |
+
|
170 |
+
public function get_title() {
|
171 |
+
return __( 'Constant Contact', 'contact-form-7' );
|
172 |
+
}
|
173 |
+
|
174 |
+
public function get_categories() {
|
175 |
+
return array( 'email_marketing' );
|
176 |
+
}
|
177 |
+
|
178 |
+
public function icon() {
|
179 |
+
}
|
180 |
+
|
181 |
+
public function link() {
|
182 |
+
echo sprintf( '<a href="%1$s">%2$s</a>',
|
183 |
+
'https://constant-contact.evyy.net/c/1293104/205991/3411',
|
184 |
+
'constantcontact.com'
|
185 |
+
);
|
186 |
+
}
|
187 |
+
|
188 |
+
protected function get_redirect_uri() {
|
189 |
+
return admin_url( '/?auth=' . self::service_name );
|
190 |
+
}
|
191 |
+
|
192 |
+
protected function menu_page_url( $args = '' ) {
|
193 |
+
$args = wp_parse_args( $args, array() );
|
194 |
+
|
195 |
+
$url = menu_page_url( 'wpcf7-integration', false );
|
196 |
+
$url = add_query_arg( array( 'service' => self::service_name ), $url );
|
197 |
+
|
198 |
+
if ( ! empty( $args) ) {
|
199 |
+
$url = add_query_arg( $args, $url );
|
200 |
+
}
|
201 |
+
|
202 |
+
return $url;
|
203 |
+
}
|
204 |
+
|
205 |
+
public function load( $action = '' ) {
|
206 |
+
parent::load( $action );
|
207 |
+
|
208 |
+
if ( 'setup' == $action and 'POST' == $_SERVER['REQUEST_METHOD'] ) {
|
209 |
+
check_admin_referer( 'wpcf7-constant-contact-setup' );
|
210 |
+
|
211 |
+
if ( ! empty( $_POST['reset'] ) ) {
|
212 |
+
$this->reset_data();
|
213 |
+
} else {
|
214 |
+
$this->client_id = isset( $_POST['client_id'] )
|
215 |
+
? trim( $_POST['client_id'] ) : '';
|
216 |
+
|
217 |
+
$this->client_secret = isset( $_POST['client_secret'] )
|
218 |
+
? trim( $_POST['client_secret'] ) : '';
|
219 |
+
|
220 |
+
$this->save_data();
|
221 |
+
$this->authorize( 'contact_data' );
|
222 |
+
}
|
223 |
+
|
224 |
+
wp_safe_redirect( $this->menu_page_url( 'action=setup' ) );
|
225 |
+
exit();
|
226 |
+
}
|
227 |
+
}
|
228 |
+
|
229 |
+
public function email_exists( $email ) {
|
230 |
+
$endpoint = add_query_arg(
|
231 |
+
array( 'email' => $email ),
|
232 |
+
'https://api.cc.email/v3/contacts'
|
233 |
+
);
|
234 |
+
|
235 |
+
$request = array(
|
236 |
+
'method' => 'GET',
|
237 |
+
'headers' => array(
|
238 |
+
'Accept' => 'application/json',
|
239 |
+
'Content-Type' => 'application/json; charset=utf-8',
|
240 |
+
'Authorization' => $this->get_http_authorization_header( 'bearer' ),
|
241 |
+
),
|
242 |
+
);
|
243 |
+
|
244 |
+
$response = $this->remote_request( esc_url_raw( $endpoint ), $request );
|
245 |
+
|
246 |
+
if ( WP_DEBUG
|
247 |
+
and 400 <= (int) wp_remote_retrieve_response_code( $response ) ) {
|
248 |
+
$this->log( $endpoint, $request, $response );
|
249 |
+
}
|
250 |
+
|
251 |
+
$response_body = wp_remote_retrieve_body( $response );
|
252 |
+
|
253 |
+
if ( empty( $response_body ) ) {
|
254 |
+
return false;
|
255 |
+
}
|
256 |
+
|
257 |
+
$response_body = json_decode( $response_body, true );
|
258 |
+
|
259 |
+
return ! empty( $response_body['contacts'] );
|
260 |
+
}
|
261 |
+
|
262 |
+
public function create_contact( $properties ) {
|
263 |
+
$endpoint = 'https://api.cc.email/v3/contacts';
|
264 |
+
|
265 |
+
$request = array(
|
266 |
+
'method' => 'POST',
|
267 |
+
'headers' => array(
|
268 |
+
'Accept' => 'application/json',
|
269 |
+
'Content-Type' => 'application/json; charset=utf-8',
|
270 |
+
'Authorization' => $this->get_http_authorization_header( 'bearer' ),
|
271 |
+
),
|
272 |
+
'body' => json_encode( $properties ),
|
273 |
+
);
|
274 |
+
|
275 |
+
$response = $this->remote_request( esc_url_raw( $endpoint ), $request );
|
276 |
+
|
277 |
+
if ( WP_DEBUG
|
278 |
+
and 400 <= (int) wp_remote_retrieve_response_code( $response ) ) {
|
279 |
+
$this->log( $endpoint, $request, $response );
|
280 |
+
}
|
281 |
+
}
|
282 |
+
|
283 |
+
public function display( $action = '' ) {
|
284 |
+
echo '<p>' . sprintf(
|
285 |
+
esc_html( __( 'The Constant Contact integration module allows you to send contact data collected through your contact forms to the Constant Contact API. You can create reliable email subscription services in a few easy steps. For details, see %s.', 'contact-form-7' ) ),
|
286 |
+
wpcf7_link(
|
287 |
+
__(
|
288 |
+
'https://contactform7.com/constant-contact-integration/',
|
289 |
+
'contact-form-7'
|
290 |
+
),
|
291 |
+
__( 'Constant Contact Integration', 'contact-form-7' )
|
292 |
+
)
|
293 |
+
) . '</p>';
|
294 |
+
|
295 |
+
if ( $this->is_active() or 'setup' == $action ) {
|
296 |
+
$this->display_setup();
|
297 |
+
} else {
|
298 |
+
echo sprintf(
|
299 |
+
'<p><a href="%1$s" class="button">%2$s</a></p>',
|
300 |
+
esc_url( $this->menu_page_url( 'action=setup' ) ),
|
301 |
+
esc_html( __( 'Setup Integration', 'contact-form-7' ) )
|
302 |
+
);
|
303 |
+
}
|
304 |
+
}
|
305 |
+
|
306 |
+
private function display_setup() {
|
307 |
+
?>
|
308 |
+
<form method="post" action="<?php echo esc_url( $this->menu_page_url( 'action=setup' ) ); ?>">
|
309 |
+
<?php wp_nonce_field( 'wpcf7-constant-contact-setup' ); ?>
|
310 |
+
<table class="form-table">
|
311 |
+
<tbody>
|
312 |
+
<tr>
|
313 |
+
<th scope="row"><label for="client_id"><?php echo esc_html( __( 'API Key', 'contact-form-7' ) ); ?></label></th>
|
314 |
+
<td><?php
|
315 |
+
if ( $this->is_active() ) {
|
316 |
+
echo esc_html( $this->client_id );
|
317 |
+
echo sprintf(
|
318 |
+
'<input type="hidden" value="%1$s" id="client_id" name="client_id" />',
|
319 |
+
esc_attr( $this->client_id )
|
320 |
+
);
|
321 |
+
} else {
|
322 |
+
echo sprintf(
|
323 |
+
'<input type="text" aria-required="true" value="%1$s" id="client_id" name="client_id" class="regular-text code" />',
|
324 |
+
esc_attr( $this->client_id )
|
325 |
+
);
|
326 |
+
}
|
327 |
+
?></td>
|
328 |
+
</tr>
|
329 |
+
<tr>
|
330 |
+
<th scope="row"><label for="client_secret"><?php echo esc_html( __( 'App Secret', 'contact-form-7' ) ); ?></label></th>
|
331 |
+
<td><?php
|
332 |
+
if ( $this->is_active() ) {
|
333 |
+
echo esc_html( wpcf7_mask_password( $this->client_secret ) );
|
334 |
+
echo sprintf(
|
335 |
+
'<input type="hidden" value="%1$s" id="client_secret" name="client_secret" />',
|
336 |
+
esc_attr( $this->client_secret )
|
337 |
+
);
|
338 |
+
} else {
|
339 |
+
echo sprintf(
|
340 |
+
'<input type="text" aria-required="true" value="%1$s" id="client_secret" name="client_secret" class="regular-text code" />',
|
341 |
+
esc_attr( $this->client_secret )
|
342 |
+
);
|
343 |
+
}
|
344 |
+
?></td>
|
345 |
+
</tr>
|
346 |
+
<tr>
|
347 |
+
<th scope="row"><label for="redirect_uri"><?php echo esc_html( __( 'Redirect URI', 'contact-form-7' ) ); ?></label></th>
|
348 |
+
<td><?php
|
349 |
+
echo sprintf(
|
350 |
+
'<input type="text" value="%1$s" id="redirect_uri" name="redirect_uri" class="large-text code" readonly="readonly" onfocus="this.select();" style="font-size: 11px;" />',
|
351 |
+
$this->get_redirect_uri()
|
352 |
+
);
|
353 |
+
?>
|
354 |
+
<p class="description"><?php echo esc_html( __( "Set this URL as the redirect URI.", 'contact-form-7' ) ); ?></p>
|
355 |
+
</td>
|
356 |
+
</tr>
|
357 |
+
</tbody>
|
358 |
+
</table>
|
359 |
+
<?php
|
360 |
+
if ( $this->is_active() ) {
|
361 |
+
submit_button(
|
362 |
+
_x( 'Remove Keys', 'API keys', 'contact-form-7' ),
|
363 |
+
'small', 'reset'
|
364 |
+
);
|
365 |
+
} else {
|
366 |
+
submit_button( __( 'Connect to the Constant Contact API', 'contact-form-7' ) );
|
367 |
+
}
|
368 |
+
?>
|
369 |
+
</form>
|
370 |
+
<?php
|
371 |
+
}
|
372 |
+
|
373 |
+
}
|
374 |
+
|
375 |
+
class WPCF7_ConstantContact_ContactPostRequest {
|
376 |
+
|
377 |
+
private $email_address;
|
378 |
+
private $first_name;
|
379 |
+
private $last_name;
|
380 |
+
private $job_title;
|
381 |
+
private $company_name;
|
382 |
+
private $create_source;
|
383 |
+
private $birthday_month;
|
384 |
+
private $birthday_day;
|
385 |
+
private $anniversary;
|
386 |
+
private $custom_fields = array();
|
387 |
+
private $phone_numbers = array();
|
388 |
+
private $street_addresses = array();
|
389 |
+
private $list_memberships = array();
|
390 |
+
|
391 |
+
public function __construct() {
|
392 |
+
}
|
393 |
+
|
394 |
+
public function build( WPCF7_Submission $submission ) {
|
395 |
+
$this->set_create_source( 'Contact' );
|
396 |
+
|
397 |
+
$posted_data = (array) $submission->get_posted_data();
|
398 |
+
|
399 |
+
if ( isset( $posted_data['your-first-name'] ) ) {
|
400 |
+
$this->set_first_name( $posted_data['your-first-name'] );
|
401 |
+
}
|
402 |
+
|
403 |
+
if ( isset( $posted_data['your-last-name'] ) ) {
|
404 |
+
$this->set_last_name( $posted_data['your-last-name'] );
|
405 |
+
}
|
406 |
+
|
407 |
+
if ( ! ( $this->first_name || $this->last_name )
|
408 |
+
and isset( $posted_data['your-name'] ) ) {
|
409 |
+
$your_name = preg_split( '/[\s]+/', $posted_data['your-name'], 2 );
|
410 |
+
$this->set_first_name( array_shift( $your_name ) );
|
411 |
+
$this->set_last_name( array_shift( $your_name ) );
|
412 |
+
}
|
413 |
+
|
414 |
+
if ( isset( $posted_data['your-email'] ) ) {
|
415 |
+
$this->set_email_address( $posted_data['your-email'], 'implicit' );
|
416 |
+
}
|
417 |
+
|
418 |
+
if ( isset( $posted_data['your-job-title'] ) ) {
|
419 |
+
$this->set_job_title( $posted_data['your-job-title'] );
|
420 |
+
}
|
421 |
+
|
422 |
+
if ( isset( $posted_data['your-company-name'] ) ) {
|
423 |
+
$this->set_company_name( $posted_data['your-company-name'] );
|
424 |
+
}
|
425 |
+
|
426 |
+
if ( isset( $posted_data['your-birthday-month'] )
|
427 |
+
and isset( $posted_data['your-birthday-day'] ) ) {
|
428 |
+
$this->set_birthday(
|
429 |
+
$posted_data['your-birthday-month'],
|
430 |
+
$posted_data['your-birthday-day']
|
431 |
+
);
|
432 |
+
} elseif ( isset( $posted_data['your-birthday'] ) ) {
|
433 |
+
$date = trim( $posted_data['your-birthday'] );
|
434 |
+
|
435 |
+
if ( preg_match( '/^(\d{4})-(\d{2})-(\d{2})$/', $date, $matches ) ) {
|
436 |
+
$this->set_birthday( $matches[2], $matches[3] );
|
437 |
+
}
|
438 |
+
}
|
439 |
+
|
440 |
+
if ( isset( $posted_data['your-anniversary'] ) ) {
|
441 |
+
$this->set_anniversary( $posted_data['your-anniversary'] );
|
442 |
+
}
|
443 |
+
|
444 |
+
if ( isset( $posted_data['your-phone-number'] ) ) {
|
445 |
+
$this->add_phone_number( $posted_data['your-phone-number'] );
|
446 |
+
}
|
447 |
+
|
448 |
+
$this->add_street_address(
|
449 |
+
isset( $posted_data['your-address-street'] )
|
450 |
+
? $posted_data['your-address-street'] : '',
|
451 |
+
isset( $posted_data['your-address-city'] )
|
452 |
+
? $posted_data['your-address-city'] : '',
|
453 |
+
isset( $posted_data['your-address-state'] )
|
454 |
+
? $posted_data['your-address-state'] : '',
|
455 |
+
isset( $posted_data['your-address-postal-code'] )
|
456 |
+
? $posted_data['your-address-postal-code'] : '',
|
457 |
+
isset( $posted_data['your-address-country'] )
|
458 |
+
? $posted_data['your-address-country'] : ''
|
459 |
+
);
|
460 |
+
}
|
461 |
+
|
462 |
+
public function is_valid() {
|
463 |
+
return $this->create_source
|
464 |
+
&& ( $this->email_address || $this->first_name || $this->last_name );
|
465 |
+
}
|
466 |
+
|
467 |
+
public function to_array() {
|
468 |
+
$output = array(
|
469 |
+
'email_address' => $this->email_address,
|
470 |
+
'first_name' => $this->first_name,
|
471 |
+
'last_name' => $this->last_name,
|
472 |
+
'job_title' => $this->job_title,
|
473 |
+
'company_name' => $this->company_name,
|
474 |
+
'create_source' => $this->create_source,
|
475 |
+
'birthday_month' => $this->birthday_month,
|
476 |
+
'birthday_day' => $this->birthday_day,
|
477 |
+
'anniversary' => $this->anniversary,
|
478 |
+
'custom_fields' => $this->custom_fields,
|
479 |
+
'phone_numbers' => $this->phone_numbers,
|
480 |
+
'street_addresses' => $this->street_addresses,
|
481 |
+
'list_memberships' => $this->list_memberships,
|
482 |
+
);
|
483 |
+
|
484 |
+
return array_filter( $output );
|
485 |
+
}
|
486 |
+
|
487 |
+
public function get_email_address() {
|
488 |
+
if ( isset( $this->email_address['address'] ) ) {
|
489 |
+
return $this->email_address['address'];
|
490 |
+
}
|
491 |
+
|
492 |
+
return '';
|
493 |
+
}
|
494 |
+
|
495 |
+
public function set_email_address( $address, $permission_to_send = '' ) {
|
496 |
+
if ( ! wpcf7_is_email( $address )
|
497 |
+
or 80 < $this->strlen( $address ) ) {
|
498 |
+
return false;
|
499 |
+
}
|
500 |
+
|
501 |
+
$types_of_permission = array(
|
502 |
+
'implicit', 'explicit', 'deprecate', 'pending',
|
503 |
+
'unsubscribe', 'temp_hold', 'not_set',
|
504 |
+
);
|
505 |
+
|
506 |
+
if ( ! in_array( $permission_to_send, $types_of_permission ) ) {
|
507 |
+
$permission_to_send = 'implicit';
|
508 |
+
}
|
509 |
+
|
510 |
+
return $this->email_address = array(
|
511 |
+
'address' => $address,
|
512 |
+
'permission_to_send' => $permission_to_send,
|
513 |
+
);
|
514 |
+
}
|
515 |
+
|
516 |
+
public function set_first_name( $first_name ) {
|
517 |
+
$first_name = trim( $first_name );
|
518 |
+
|
519 |
+
if ( empty( $first_name )
|
520 |
+
or 50 < $this->strlen( $first_name ) ) {
|
521 |
+
return false;
|
522 |
+
}
|
523 |
+
|
524 |
+
return $this->first_name = $first_name;
|
525 |
+
}
|
526 |
+
|
527 |
+
public function set_last_name( $last_name ) {
|
528 |
+
$last_name = trim( $last_name );
|
529 |
+
|
530 |
+
if ( empty( $last_name )
|
531 |
+
or 50 < $this->strlen( $last_name ) ) {
|
532 |
+
return false;
|
533 |
+
}
|
534 |
+
|
535 |
+
return $this->last_name = $last_name;
|
536 |
+
}
|
537 |
+
|
538 |
+
public function set_job_title( $job_title ) {
|
539 |
+
$job_title = trim( $job_title );
|
540 |
+
|
541 |
+
if ( empty( $job_title )
|
542 |
+
or 50 < $this->strlen( $job_title ) ) {
|
543 |
+
return false;
|
544 |
+
}
|
545 |
+
|
546 |
+
return $this->job_title = $job_title;
|
547 |
+
}
|
548 |
+
|
549 |
+
public function set_company_name( $company_name ) {
|
550 |
+
$company_name = trim( $company_name );
|
551 |
+
|
552 |
+
if ( empty( $company_name )
|
553 |
+
or 50 < $this->strlen( $company_name ) ) {
|
554 |
+
return false;
|
555 |
+
}
|
556 |
+
|
557 |
+
return $this->company_name = $company_name;
|
558 |
+
}
|
559 |
+
|
560 |
+
public function set_create_source( $create_source ) {
|
561 |
+
if ( ! in_array( $create_source, array( 'Contact', 'Account' ) ) ) {
|
562 |
+
return false;
|
563 |
+
}
|
564 |
+
|
565 |
+
return $this->create_source = $create_source;
|
566 |
+
}
|
567 |
+
|
568 |
+
public function set_birthday( $month, $day ) {
|
569 |
+
$month = (int) $month;
|
570 |
+
$day = (int) $day;
|
571 |
+
|
572 |
+
if ( $month < 1 || 12 < $month
|
573 |
+
or $day < 1 || 31 < $day ) {
|
574 |
+
return false;
|
575 |
+
}
|
576 |
+
|
577 |
+
$this->birthday_month = $month;
|
578 |
+
$this->birthday_day = $day;
|
579 |
+
|
580 |
+
return array( $this->birthday_month, $this->birthday_day );
|
581 |
+
}
|
582 |
+
|
583 |
+
public function set_anniversary( $anniversary ) {
|
584 |
+
$pattern = sprintf(
|
585 |
+
'#^(%s)$#',
|
586 |
+
implode( '|', array(
|
587 |
+
'\d{1,2}/\d{1,2}/\d{4}',
|
588 |
+
'\d{4}/\d{1,2}/\d{1,2}',
|
589 |
+
'\d{4}-\d{1,2}-\d{1,2}',
|
590 |
+
'\d{1,2}-\d{1,2}-\d{4}',
|
591 |
+
) )
|
592 |
+
);
|
593 |
+
|
594 |
+
if ( ! preg_match( $pattern, $anniversary ) ) {
|
595 |
+
return false;
|
596 |
+
}
|
597 |
+
|
598 |
+
return $this->anniversary = $anniversary;
|
599 |
+
}
|
600 |
+
|
601 |
+
public function add_custom_field( $custom_field_id, $value ) {
|
602 |
+
$uuid_pattern = '/^[0-9a-f-]+$/i';
|
603 |
+
|
604 |
+
$value = trim( $value );
|
605 |
+
|
606 |
+
if ( 25 <= count( $this->custom_fields )
|
607 |
+
or ! preg_match( $uuid_pattern, $custom_field_id )
|
608 |
+
or 255 < $this->strlen( $value ) ) {
|
609 |
+
return false;
|
610 |
+
}
|
611 |
+
|
612 |
+
return $this->custom_fields[] = array(
|
613 |
+
'custom_field_id' => $custom_field_id,
|
614 |
+
'value' => $value,
|
615 |
+
);
|
616 |
+
}
|
617 |
+
|
618 |
+
public function add_phone_number( $phone_number, $kind = 'home' ) {
|
619 |
+
$phone_number = trim( $phone_number );
|
620 |
+
|
621 |
+
if ( 2 <= count( $this->phone_numbers )
|
622 |
+
or ! wpcf7_is_tel( $phone_number )
|
623 |
+
or 25 < $this->strlen( $phone_number )
|
624 |
+
or ! in_array( $kind, array( 'home', 'work', 'other' ) ) ) {
|
625 |
+
return false;
|
626 |
+
}
|
627 |
+
|
628 |
+
return $this->phone_numbers[] = array(
|
629 |
+
'phone_number' => $phone_number,
|
630 |
+
'kind' => $kind,
|
631 |
+
);
|
632 |
+
}
|
633 |
+
|
634 |
+
public function add_street_address( $street, $city, $state, $postal_code, $country, $kind = 'home' ) {
|
635 |
+
$street = trim( $street );
|
636 |
+
$city = trim( $city );
|
637 |
+
$state = trim( $state );
|
638 |
+
$postal_code = trim( $postal_code );
|
639 |
+
$country = trim( $country );
|
640 |
+
|
641 |
+
if ( ! ( $street || $city || $state || $postal_code || $country )
|
642 |
+
or 1 <= count( $this->street_addresses )
|
643 |
+
or ! in_array( $kind, array( 'home', 'work', 'other' ) )
|
644 |
+
or 255 < $this->strlen( $street )
|
645 |
+
or 50 < $this->strlen( $city )
|
646 |
+
or 50 < $this->strlen( $state )
|
647 |
+
or 50 < $this->strlen( $postal_code )
|
648 |
+
or 50 < $this->strlen( $country ) ) {
|
649 |
+
return false;
|
650 |
+
}
|
651 |
+
|
652 |
+
return $this->street_addresses[] = array(
|
653 |
+
'kind' => $kind,
|
654 |
+
'street' => $street,
|
655 |
+
'city' => $city,
|
656 |
+
'state' => $state,
|
657 |
+
'postal_code' => $postal_code,
|
658 |
+
'country' => $country,
|
659 |
+
);
|
660 |
+
}
|
661 |
+
|
662 |
+
public function add_list_membership( $list_id ) {
|
663 |
+
$uuid_pattern = '/^[0-9a-f-]+$/i';
|
664 |
+
|
665 |
+
if ( 50 <= count( $this->list_memberships )
|
666 |
+
or ! preg_match( $uuid_pattern, $list_id ) ) {
|
667 |
+
return false;
|
668 |
+
}
|
669 |
+
|
670 |
+
return $this->list_memberships[] = $list_id;
|
671 |
+
}
|
672 |
+
|
673 |
+
protected function strlen( $string ) {
|
674 |
+
return wpcf7_count_code_units( stripslashes( $string ) );
|
675 |
+
}
|
676 |
+
|
677 |
+
}
|
modules/count.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
|
6 |
/* form_tag handler */
|
7 |
|
8 |
-
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_count' );
|
9 |
|
10 |
function wpcf7_add_form_tag_count() {
|
11 |
wpcf7_add_form_tag( 'count',
|
@@ -36,7 +36,8 @@ function wpcf7_count_form_tag_handler( $tag ) {
|
|
36 |
}
|
37 |
}
|
38 |
|
39 |
-
if ( $maxlength
|
|
|
40 |
$maxlength = $minlength = null;
|
41 |
}
|
42 |
|
5 |
|
6 |
/* form_tag handler */
|
7 |
|
8 |
+
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_count', 10, 0 );
|
9 |
|
10 |
function wpcf7_add_form_tag_count() {
|
11 |
wpcf7_add_form_tag( 'count',
|
36 |
}
|
37 |
}
|
38 |
|
39 |
+
if ( $maxlength and $minlength
|
40 |
+
and $maxlength < $minlength ) {
|
41 |
$maxlength = $minlength = null;
|
42 |
}
|
43 |
|
modules/date.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
|
7 |
/* form_tag handler */
|
8 |
|
9 |
-
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_date' );
|
10 |
|
11 |
function wpcf7_add_form_tag_date() {
|
12 |
wpcf7_add_form_tag( array( 'date', 'date*' ),
|
@@ -49,7 +49,8 @@ function wpcf7_date_form_tag_handler( $tag ) {
|
|
49 |
|
50 |
$value = (string) reset( $tag->values );
|
51 |
|
52 |
-
if ( $tag->has_option( 'placeholder' )
|
|
|
53 |
$atts['placeholder'] = $value;
|
54 |
$value = '';
|
55 |
}
|
@@ -93,13 +94,13 @@ function wpcf7_date_validation_filter( $result, $tag ) {
|
|
93 |
? trim( strtr( (string) $_POST[$name], "\n", " " ) )
|
94 |
: '';
|
95 |
|
96 |
-
if ( $tag->is_required()
|
97 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
|
98 |
-
} elseif ( '' != $value
|
99 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_date' ) );
|
100 |
-
} elseif ( '' != $value
|
101 |
$result->invalidate( $tag, wpcf7_get_message( 'date_too_early' ) );
|
102 |
-
} elseif ( '' != $value
|
103 |
$result->invalidate( $tag, wpcf7_get_message( 'date_too_late' ) );
|
104 |
}
|
105 |
|
@@ -109,7 +110,7 @@ function wpcf7_date_validation_filter( $result, $tag ) {
|
|
109 |
|
110 |
/* Messages */
|
111 |
|
112 |
-
add_filter( 'wpcf7_messages', 'wpcf7_date_messages' );
|
113 |
|
114 |
function wpcf7_date_messages( $messages ) {
|
115 |
return array_merge( $messages, array(
|
@@ -133,7 +134,7 @@ function wpcf7_date_messages( $messages ) {
|
|
133 |
|
134 |
/* Tag generator */
|
135 |
|
136 |
-
add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_date', 19 );
|
137 |
|
138 |
function wpcf7_add_tag_generator_date() {
|
139 |
$tag_generator = WPCF7_TagGenerator::get_instance();
|
6 |
|
7 |
/* form_tag handler */
|
8 |
|
9 |
+
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_date', 10, 0 );
|
10 |
|
11 |
function wpcf7_add_form_tag_date() {
|
12 |
wpcf7_add_form_tag( array( 'date', 'date*' ),
|
49 |
|
50 |
$value = (string) reset( $tag->values );
|
51 |
|
52 |
+
if ( $tag->has_option( 'placeholder' )
|
53 |
+
or $tag->has_option( 'watermark' ) ) {
|
54 |
$atts['placeholder'] = $value;
|
55 |
$value = '';
|
56 |
}
|
94 |
? trim( strtr( (string) $_POST[$name], "\n", " " ) )
|
95 |
: '';
|
96 |
|
97 |
+
if ( $tag->is_required() and '' == $value ) {
|
98 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
|
99 |
+
} elseif ( '' != $value and ! wpcf7_is_date( $value ) ) {
|
100 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_date' ) );
|
101 |
+
} elseif ( '' != $value and ! empty( $min ) and $value < $min ) {
|
102 |
$result->invalidate( $tag, wpcf7_get_message( 'date_too_early' ) );
|
103 |
+
} elseif ( '' != $value and ! empty( $max ) and $max < $value ) {
|
104 |
$result->invalidate( $tag, wpcf7_get_message( 'date_too_late' ) );
|
105 |
}
|
106 |
|
110 |
|
111 |
/* Messages */
|
112 |
|
113 |
+
add_filter( 'wpcf7_messages', 'wpcf7_date_messages', 10, 1 );
|
114 |
|
115 |
function wpcf7_date_messages( $messages ) {
|
116 |
return array_merge( $messages, array(
|
134 |
|
135 |
/* Tag generator */
|
136 |
|
137 |
+
add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_date', 19, 0 );
|
138 |
|
139 |
function wpcf7_add_tag_generator_date() {
|
140 |
$tag_generator = WPCF7_TagGenerator::get_instance();
|
modules/file.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
|
6 |
/* form_tag handler */
|
7 |
|
8 |
-
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_file' );
|
9 |
|
10 |
function wpcf7_add_form_tag_file() {
|
11 |
wpcf7_add_form_tag( array( 'file', 'file*' ),
|
@@ -56,7 +56,7 @@ function wpcf7_file_form_tag_handler( $tag ) {
|
|
56 |
|
57 |
/* Encode type filter */
|
58 |
|
59 |
-
add_filter( 'wpcf7_form_enctype', 'wpcf7_file_form_enctype_filter' );
|
60 |
|
61 |
function wpcf7_file_form_enctype_filter( $enctype ) {
|
62 |
$multipart = (bool) wpcf7_scan_form_tags(
|
@@ -81,12 +81,12 @@ function wpcf7_file_validation_filter( $result, $tag ) {
|
|
81 |
|
82 |
$file = isset( $_FILES[$name] ) ? $_FILES[$name] : null;
|
83 |
|
84 |
-
if ( $file['error']
|
85 |
$result->invalidate( $tag, wpcf7_get_message( 'upload_failed_php_error' ) );
|
86 |
return $result;
|
87 |
}
|
88 |
|
89 |
-
if ( empty( $file['tmp_name'] )
|
90 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
|
91 |
return $result;
|
92 |
}
|
@@ -153,7 +153,7 @@ function wpcf7_file_validation_filter( $result, $tag ) {
|
|
153 |
$filename = wp_unique_filename( $uploads_dir, $filename );
|
154 |
$new_file = path_join( $uploads_dir, $filename );
|
155 |
|
156 |
-
if ( false === move_uploaded_file( $file['tmp_name'], $new_file ) ) {
|
157 |
$result->invalidate( $tag, wpcf7_get_message( 'upload_failed' ) );
|
158 |
return $result;
|
159 |
}
|
@@ -171,7 +171,7 @@ function wpcf7_file_validation_filter( $result, $tag ) {
|
|
171 |
|
172 |
/* Messages */
|
173 |
|
174 |
-
add_filter( 'wpcf7_messages', 'wpcf7_file_messages' );
|
175 |
|
176 |
function wpcf7_file_messages( $messages ) {
|
177 |
return array_merge( $messages, array(
|
@@ -200,7 +200,7 @@ function wpcf7_file_messages( $messages ) {
|
|
200 |
|
201 |
/* Tag generator */
|
202 |
|
203 |
-
add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_file', 50 );
|
204 |
|
205 |
function wpcf7_add_tag_generator_file() {
|
206 |
$tag_generator = WPCF7_TagGenerator::get_instance();
|
@@ -280,10 +280,13 @@ function wpcf7_tag_generator_file( $contact_form, $args = '' ) {
|
|
280 |
|
281 |
/* Warning message */
|
282 |
|
283 |
-
add_action( 'wpcf7_admin_warnings',
|
|
|
284 |
|
285 |
-
function wpcf7_file_display_warning_message() {
|
286 |
-
if (
|
|
|
|
|
287 |
return;
|
288 |
}
|
289 |
|
@@ -297,7 +300,8 @@ function wpcf7_file_display_warning_message() {
|
|
297 |
$uploads_dir = wpcf7_upload_tmp_dir();
|
298 |
wpcf7_init_uploads();
|
299 |
|
300 |
-
if ( ! is_dir( $uploads_dir )
|
|
|
301 |
$message = sprintf( __( 'This contact form contains file uploading fields, but the temporary folder for the files (%s) does not exist or is not writable. You can create the folder or change its permission manually.', 'contact-form-7' ), $uploads_dir );
|
302 |
|
303 |
echo sprintf( '<div class="notice notice-warning"><p>%s</p></div>',
|
@@ -309,7 +313,8 @@ function wpcf7_file_display_warning_message() {
|
|
309 |
/* File uploading functions */
|
310 |
|
311 |
function wpcf7_acceptable_filetypes( $types = 'default', $format = 'regex' ) {
|
312 |
-
if ( 'default' === $types
|
|
|
313 |
$types = array(
|
314 |
'jpg',
|
315 |
'jpeg',
|
@@ -359,7 +364,8 @@ function wpcf7_acceptable_filetypes( $types = 'default', $format = 'regex' ) {
|
|
359 |
continue;
|
360 |
}
|
361 |
|
362 |
-
if ( 'attr' === $format
|
|
|
363 |
$output .= sprintf( '.%s', $type );
|
364 |
$output .= ',';
|
365 |
} else {
|
@@ -412,14 +418,19 @@ function wpcf7_upload_tmp_dir() {
|
|
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()
|
416 |
-
|
|
|
|
|
|
|
417 |
return;
|
418 |
}
|
419 |
|
420 |
$dir = trailingslashit( wpcf7_upload_tmp_dir() );
|
421 |
|
422 |
-
if ( ! is_dir( $dir )
|
|
|
|
|
423 |
return;
|
424 |
}
|
425 |
|
@@ -429,13 +440,15 @@ function wpcf7_cleanup_upload_files( $seconds = 60, $max = 100 ) {
|
|
429 |
|
430 |
if ( $handle = opendir( $dir ) ) {
|
431 |
while ( false !== ( $file = readdir( $handle ) ) ) {
|
432 |
-
if ( '.' == $file
|
|
|
|
|
433 |
continue;
|
434 |
}
|
435 |
|
436 |
$mtime = filemtime( path_join( $dir, $file ) );
|
437 |
|
438 |
-
if ( $mtime
|
439 |
continue;
|
440 |
}
|
441 |
|
5 |
|
6 |
/* form_tag handler */
|
7 |
|
8 |
+
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_file', 10, 0 );
|
9 |
|
10 |
function wpcf7_add_form_tag_file() {
|
11 |
wpcf7_add_form_tag( array( 'file', 'file*' ),
|
56 |
|
57 |
/* Encode type filter */
|
58 |
|
59 |
+
add_filter( 'wpcf7_form_enctype', 'wpcf7_file_form_enctype_filter', 10, 1 );
|
60 |
|
61 |
function wpcf7_file_form_enctype_filter( $enctype ) {
|
62 |
$multipart = (bool) wpcf7_scan_form_tags(
|
81 |
|
82 |
$file = isset( $_FILES[$name] ) ? $_FILES[$name] : null;
|
83 |
|
84 |
+
if ( $file['error'] and UPLOAD_ERR_NO_FILE != $file['error'] ) {
|
85 |
$result->invalidate( $tag, wpcf7_get_message( 'upload_failed_php_error' ) );
|
86 |
return $result;
|
87 |
}
|
88 |
|
89 |
+
if ( empty( $file['tmp_name'] ) and $tag->is_required() ) {
|
90 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
|
91 |
return $result;
|
92 |
}
|
153 |
$filename = wp_unique_filename( $uploads_dir, $filename );
|
154 |
$new_file = path_join( $uploads_dir, $filename );
|
155 |
|
156 |
+
if ( false === @move_uploaded_file( $file['tmp_name'], $new_file ) ) {
|
157 |
$result->invalidate( $tag, wpcf7_get_message( 'upload_failed' ) );
|
158 |
return $result;
|
159 |
}
|
171 |
|
172 |
/* Messages */
|
173 |
|
174 |
+
add_filter( 'wpcf7_messages', 'wpcf7_file_messages', 10, 1 );
|
175 |
|
176 |
function wpcf7_file_messages( $messages ) {
|
177 |
return array_merge( $messages, array(
|
200 |
|
201 |
/* Tag generator */
|
202 |
|
203 |
+
add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_file', 50, 0 );
|
204 |
|
205 |
function wpcf7_add_tag_generator_file() {
|
206 |
$tag_generator = WPCF7_TagGenerator::get_instance();
|
280 |
|
281 |
/* Warning message */
|
282 |
|
283 |
+
add_action( 'wpcf7_admin_warnings',
|
284 |
+
'wpcf7_file_display_warning_message', 10, 3 );
|
285 |
|
286 |
+
function wpcf7_file_display_warning_message( $page, $action, $object ) {
|
287 |
+
if ( $object instanceof WPCF7_ContactForm ) {
|
288 |
+
$contact_form = $object;
|
289 |
+
} else {
|
290 |
return;
|
291 |
}
|
292 |
|
300 |
$uploads_dir = wpcf7_upload_tmp_dir();
|
301 |
wpcf7_init_uploads();
|
302 |
|
303 |
+
if ( ! is_dir( $uploads_dir )
|
304 |
+
or ! wp_is_writable( $uploads_dir ) ) {
|
305 |
$message = sprintf( __( 'This contact form contains file uploading fields, but the temporary folder for the files (%s) does not exist or is not writable. You can create the folder or change its permission manually.', 'contact-form-7' ), $uploads_dir );
|
306 |
|
307 |
echo sprintf( '<div class="notice notice-warning"><p>%s</p></div>',
|
313 |
/* File uploading functions */
|
314 |
|
315 |
function wpcf7_acceptable_filetypes( $types = 'default', $format = 'regex' ) {
|
316 |
+
if ( 'default' === $types
|
317 |
+
or empty( $types ) ) {
|
318 |
$types = array(
|
319 |
'jpg',
|
320 |
'jpeg',
|
364 |
continue;
|
365 |
}
|
366 |
|
367 |
+
if ( 'attr' === $format
|
368 |
+
or 'attribute' === $format ) {
|
369 |
$output .= sprintf( '.%s', $type );
|
370 |
$output .= ',';
|
371 |
} else {
|
418 |
add_action( 'template_redirect', 'wpcf7_cleanup_upload_files', 20, 0 );
|
419 |
|
420 |
function wpcf7_cleanup_upload_files( $seconds = 60, $max = 100 ) {
|
421 |
+
if ( is_admin()
|
422 |
+
or 'GET' != $_SERVER['REQUEST_METHOD']
|
423 |
+
or is_robots()
|
424 |
+
or is_feed()
|
425 |
+
or is_trackback() ) {
|
426 |
return;
|
427 |
}
|
428 |
|
429 |
$dir = trailingslashit( wpcf7_upload_tmp_dir() );
|
430 |
|
431 |
+
if ( ! is_dir( $dir )
|
432 |
+
or ! is_readable( $dir )
|
433 |
+
or ! wp_is_writable( $dir ) ) {
|
434 |
return;
|
435 |
}
|
436 |
|
440 |
|
441 |
if ( $handle = opendir( $dir ) ) {
|
442 |
while ( false !== ( $file = readdir( $handle ) ) ) {
|
443 |
+
if ( '.' == $file
|
444 |
+
or '..' == $file
|
445 |
+
or '.htaccess' == $file ) {
|
446 |
continue;
|
447 |
}
|
448 |
|
449 |
$mtime = filemtime( path_join( $dir, $file ) );
|
450 |
|
451 |
+
if ( $mtime and time() < $mtime + $seconds ) { // less than $seconds old
|
452 |
continue;
|
453 |
}
|
454 |
|
modules/flamingo.php
CHANGED
@@ -8,7 +8,7 @@ add_action( 'wpcf7_submit', 'wpcf7_flamingo_submit', 10, 2 );
|
|
8 |
|
9 |
function wpcf7_flamingo_submit( $contact_form, $result ) {
|
10 |
if ( ! class_exists( 'Flamingo_Contact' )
|
11 |
-
|
12 |
return;
|
13 |
}
|
14 |
|
@@ -20,13 +20,14 @@ function wpcf7_flamingo_submit( $contact_form, $result ) {
|
|
20 |
array( 'spam', 'mail_sent', 'mail_failed' ) );
|
21 |
|
22 |
if ( empty( $result['status'] )
|
23 |
-
|
24 |
return;
|
25 |
}
|
26 |
|
27 |
$submission = WPCF7_Submission::get_instance();
|
28 |
|
29 |
-
if ( ! $submission
|
|
|
30 |
return;
|
31 |
}
|
32 |
|
@@ -46,7 +47,8 @@ function wpcf7_flamingo_submit( $contact_form, $result ) {
|
|
46 |
$exclude_names[] = 'g-recaptcha-response';
|
47 |
|
48 |
foreach ( $posted_data as $key => $value ) {
|
49 |
-
if ( '_' == substr( $key, 0, 1 )
|
|
|
50 |
unset( $posted_data[$key] );
|
51 |
}
|
52 |
}
|
@@ -87,7 +89,7 @@ function wpcf7_flamingo_submit( $contact_form, $result ) {
|
|
87 |
|
88 |
if ( $channel_id ) {
|
89 |
if ( ! isset( $post_meta['channel'] )
|
90 |
-
|
91 |
$post_meta = empty( $post_meta ) ? array() : (array) $post_meta;
|
92 |
$post_meta = array_merge( $post_meta, array(
|
93 |
'channel' => $channel_id,
|
@@ -99,7 +101,7 @@ function wpcf7_flamingo_submit( $contact_form, $result ) {
|
|
99 |
$channel = get_term( $channel_id,
|
100 |
Flamingo_Inbound_Message::channel_taxonomy );
|
101 |
|
102 |
-
if ( ! $channel
|
103 |
$channel = 'contact-form-7';
|
104 |
} else {
|
105 |
$channel = $channel->slug;
|
@@ -134,7 +136,8 @@ function wpcf7_flamingo_submit( $contact_form, $result ) {
|
|
134 |
}
|
135 |
|
136 |
function wpcf7_flamingo_get_value( $field, $contact_form ) {
|
137 |
-
if ( empty( $field )
|
|
|
138 |
return false;
|
139 |
}
|
140 |
|
@@ -204,7 +207,7 @@ function wpcf7_flamingo_add_channel( $slug, $name = '' ) {
|
|
204 |
return (int) $channel['term_id'];
|
205 |
}
|
206 |
|
207 |
-
add_action( 'wpcf7_after_update', 'wpcf7_flamingo_update_channel' );
|
208 |
|
209 |
function wpcf7_flamingo_update_channel( $contact_form ) {
|
210 |
if ( ! class_exists( 'Flamingo_Inbound_Message' ) ) {
|
@@ -219,7 +222,7 @@ function wpcf7_flamingo_update_channel( $contact_form ) {
|
|
219 |
: get_term_by( 'slug', $contact_form->name(),
|
220 |
Flamingo_Inbound_Message::channel_taxonomy );
|
221 |
|
222 |
-
if ( ! $channel
|
223 |
return;
|
224 |
}
|
225 |
|
@@ -243,7 +246,7 @@ function wpcf7_flamingo_serial_number( $output, $name, $html ) {
|
|
243 |
}
|
244 |
|
245 |
if ( ! class_exists( 'Flamingo_Inbound_Message' )
|
246 |
-
|
247 |
return $output;
|
248 |
}
|
249 |
|
8 |
|
9 |
function wpcf7_flamingo_submit( $contact_form, $result ) {
|
10 |
if ( ! class_exists( 'Flamingo_Contact' )
|
11 |
+
or ! class_exists( 'Flamingo_Inbound_Message' ) ) {
|
12 |
return;
|
13 |
}
|
14 |
|
20 |
array( 'spam', 'mail_sent', 'mail_failed' ) );
|
21 |
|
22 |
if ( empty( $result['status'] )
|
23 |
+
or ! in_array( $result['status'], $cases ) ) {
|
24 |
return;
|
25 |
}
|
26 |
|
27 |
$submission = WPCF7_Submission::get_instance();
|
28 |
|
29 |
+
if ( ! $submission
|
30 |
+
or ! $posted_data = $submission->get_posted_data() ) {
|
31 |
return;
|
32 |
}
|
33 |
|
47 |
$exclude_names[] = 'g-recaptcha-response';
|
48 |
|
49 |
foreach ( $posted_data as $key => $value ) {
|
50 |
+
if ( '_' == substr( $key, 0, 1 )
|
51 |
+
or in_array( $key, $exclude_names ) ) {
|
52 |
unset( $posted_data[$key] );
|
53 |
}
|
54 |
}
|
89 |
|
90 |
if ( $channel_id ) {
|
91 |
if ( ! isset( $post_meta['channel'] )
|
92 |
+
or $post_meta['channel'] !== $channel_id ) {
|
93 |
$post_meta = empty( $post_meta ) ? array() : (array) $post_meta;
|
94 |
$post_meta = array_merge( $post_meta, array(
|
95 |
'channel' => $channel_id,
|
101 |
$channel = get_term( $channel_id,
|
102 |
Flamingo_Inbound_Message::channel_taxonomy );
|
103 |
|
104 |
+
if ( ! $channel or is_wp_error( $channel ) ) {
|
105 |
$channel = 'contact-form-7';
|
106 |
} else {
|
107 |
$channel = $channel->slug;
|
136 |
}
|
137 |
|
138 |
function wpcf7_flamingo_get_value( $field, $contact_form ) {
|
139 |
+
if ( empty( $field )
|
140 |
+
or empty( $contact_form ) ) {
|
141 |
return false;
|
142 |
}
|
143 |
|
207 |
return (int) $channel['term_id'];
|
208 |
}
|
209 |
|
210 |
+
add_action( 'wpcf7_after_update', 'wpcf7_flamingo_update_channel', 10, 1 );
|
211 |
|
212 |
function wpcf7_flamingo_update_channel( $contact_form ) {
|
213 |
if ( ! class_exists( 'Flamingo_Inbound_Message' ) ) {
|
222 |
: get_term_by( 'slug', $contact_form->name(),
|
223 |
Flamingo_Inbound_Message::channel_taxonomy );
|
224 |
|
225 |
+
if ( ! $channel or is_wp_error( $channel ) ) {
|
226 |
return;
|
227 |
}
|
228 |
|
246 |
}
|
247 |
|
248 |
if ( ! class_exists( 'Flamingo_Inbound_Message' )
|
249 |
+
or ! method_exists( 'Flamingo_Inbound_Message', 'count' ) ) {
|
250 |
return $output;
|
251 |
}
|
252 |
|
modules/hidden.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_hidden' );
|
4 |
|
5 |
function wpcf7_add_form_tag_hidden() {
|
6 |
wpcf7_add_form_tag( 'hidden',
|
1 |
<?php
|
2 |
|
3 |
+
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_hidden', 10, 0 );
|
4 |
|
5 |
function wpcf7_add_form_tag_hidden() {
|
6 |
wpcf7_add_form_tag( 'hidden',
|
modules/number.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
|
8 |
/* form_tag handler */
|
9 |
|
10 |
-
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_number' );
|
11 |
|
12 |
function wpcf7_add_form_tag_number() {
|
13 |
wpcf7_add_form_tag( array( 'number', 'number*', 'range', 'range*' ),
|
@@ -50,7 +50,8 @@ function wpcf7_number_form_tag_handler( $tag ) {
|
|
50 |
|
51 |
$value = (string) reset( $tag->values );
|
52 |
|
53 |
-
if ( $tag->has_option( 'placeholder' )
|
|
|
54 |
$atts['placeholder'] = $value;
|
55 |
$value = '';
|
56 |
}
|
@@ -96,13 +97,13 @@ function wpcf7_number_validation_filter( $result, $tag ) {
|
|
96 |
$min = $tag->get_option( 'min', 'signed_int', true );
|
97 |
$max = $tag->get_option( 'max', 'signed_int', true );
|
98 |
|
99 |
-
if ( $tag->is_required()
|
100 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
|
101 |
-
} elseif ( '' != $value
|
102 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_number' ) );
|
103 |
-
} elseif ( '' != $value
|
104 |
$result->invalidate( $tag, wpcf7_get_message( 'number_too_small' ) );
|
105 |
-
} elseif ( '' != $value
|
106 |
$result->invalidate( $tag, wpcf7_get_message( 'number_too_large' ) );
|
107 |
}
|
108 |
|
@@ -112,7 +113,7 @@ function wpcf7_number_validation_filter( $result, $tag ) {
|
|
112 |
|
113 |
/* Messages */
|
114 |
|
115 |
-
add_filter( 'wpcf7_messages', 'wpcf7_number_messages' );
|
116 |
|
117 |
function wpcf7_number_messages( $messages ) {
|
118 |
return array_merge( $messages, array(
|
@@ -136,7 +137,7 @@ function wpcf7_number_messages( $messages ) {
|
|
136 |
|
137 |
/* Tag generator */
|
138 |
|
139 |
-
add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_number', 18 );
|
140 |
|
141 |
function wpcf7_add_tag_generator_number() {
|
142 |
$tag_generator = WPCF7_TagGenerator::get_instance();
|
7 |
|
8 |
/* form_tag handler */
|
9 |
|
10 |
+
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_number', 10, 0 );
|
11 |
|
12 |
function wpcf7_add_form_tag_number() {
|
13 |
wpcf7_add_form_tag( array( 'number', 'number*', 'range', 'range*' ),
|
50 |
|
51 |
$value = (string) reset( $tag->values );
|
52 |
|
53 |
+
if ( $tag->has_option( 'placeholder' )
|
54 |
+
or $tag->has_option( 'watermark' ) ) {
|
55 |
$atts['placeholder'] = $value;
|
56 |
$value = '';
|
57 |
}
|
97 |
$min = $tag->get_option( 'min', 'signed_int', true );
|
98 |
$max = $tag->get_option( 'max', 'signed_int', true );
|
99 |
|
100 |
+
if ( $tag->is_required() and '' == $value ) {
|
101 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
|
102 |
+
} elseif ( '' != $value and ! wpcf7_is_number( $value ) ) {
|
103 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_number' ) );
|
104 |
+
} elseif ( '' != $value and '' != $min and (float) $value < (float) $min ) {
|
105 |
$result->invalidate( $tag, wpcf7_get_message( 'number_too_small' ) );
|
106 |
+
} elseif ( '' != $value and '' != $max and (float) $max < (float) $value ) {
|
107 |
$result->invalidate( $tag, wpcf7_get_message( 'number_too_large' ) );
|
108 |
}
|
109 |
|
113 |
|
114 |
/* Messages */
|
115 |
|
116 |
+
add_filter( 'wpcf7_messages', 'wpcf7_number_messages', 10, 1 );
|
117 |
|
118 |
function wpcf7_number_messages( $messages ) {
|
119 |
return array_merge( $messages, array(
|
137 |
|
138 |
/* Tag generator */
|
139 |
|
140 |
+
add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_number', 18, 0 );
|
141 |
|
142 |
function wpcf7_add_tag_generator_number() {
|
143 |
$tag_generator = WPCF7_TagGenerator::get_instance();
|
modules/quiz.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
|
6 |
/* form_tag handler */
|
7 |
|
8 |
-
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_quiz' );
|
9 |
|
10 |
function wpcf7_add_form_tag_quiz() {
|
11 |
wpcf7_add_form_tag( 'quiz',
|
@@ -37,7 +37,8 @@ function wpcf7_quiz_form_tag_handler( $tag ) {
|
|
37 |
$atts['maxlength'] = $tag->get_maxlength_option();
|
38 |
$atts['minlength'] = $tag->get_minlength_option();
|
39 |
|
40 |
-
if ( $atts['maxlength']
|
|
|
41 |
unset( $atts['maxlength'], $atts['minlength'] );
|
42 |
}
|
43 |
|
@@ -50,7 +51,8 @@ function wpcf7_quiz_form_tag_handler( $tag ) {
|
|
50 |
|
51 |
$pipes = $tag->pipes;
|
52 |
|
53 |
-
if ( $pipes instanceof WPCF7_Pipes
|
|
|
54 |
$pipe = $pipes->random_pipe();
|
55 |
$question = $pipe->before;
|
56 |
$answer = $pipe->after;
|
@@ -103,8 +105,8 @@ function wpcf7_quiz_validation_filter( $result, $tag ) {
|
|
103 |
|
104 |
/* Ajax echo filter */
|
105 |
|
106 |
-
add_filter( 'wpcf7_ajax_onload', 'wpcf7_quiz_ajax_refill' );
|
107 |
-
add_filter( 'wpcf7_ajax_json_echo', 'wpcf7_quiz_ajax_refill' );
|
108 |
|
109 |
function wpcf7_quiz_ajax_refill( $items ) {
|
110 |
if ( ! is_array( $items ) ) {
|
@@ -127,7 +129,8 @@ function wpcf7_quiz_ajax_refill( $items ) {
|
|
127 |
continue;
|
128 |
}
|
129 |
|
130 |
-
if ( $pipes instanceof WPCF7_Pipes
|
|
|
131 |
$pipe = $pipes->random_pipe();
|
132 |
$question = $pipe->before;
|
133 |
$answer = $pipe->after;
|
@@ -152,7 +155,7 @@ function wpcf7_quiz_ajax_refill( $items ) {
|
|
152 |
|
153 |
/* Messages */
|
154 |
|
155 |
-
add_filter( 'wpcf7_messages', 'wpcf7_quiz_messages' );
|
156 |
|
157 |
function wpcf7_quiz_messages( $messages ) {
|
158 |
$messages = array_merge( $messages, array(
|
@@ -170,7 +173,7 @@ function wpcf7_quiz_messages( $messages ) {
|
|
170 |
|
171 |
/* Tag generator */
|
172 |
|
173 |
-
add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_quiz', 40 );
|
174 |
|
175 |
function wpcf7_add_tag_generator_quiz() {
|
176 |
$tag_generator = WPCF7_TagGenerator::get_instance();
|
5 |
|
6 |
/* form_tag handler */
|
7 |
|
8 |
+
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_quiz', 10, 0 );
|
9 |
|
10 |
function wpcf7_add_form_tag_quiz() {
|
11 |
wpcf7_add_form_tag( 'quiz',
|
37 |
$atts['maxlength'] = $tag->get_maxlength_option();
|
38 |
$atts['minlength'] = $tag->get_minlength_option();
|
39 |
|
40 |
+
if ( $atts['maxlength'] and $atts['minlength']
|
41 |
+
and $atts['maxlength'] < $atts['minlength'] ) {
|
42 |
unset( $atts['maxlength'], $atts['minlength'] );
|
43 |
}
|
44 |
|
51 |
|
52 |
$pipes = $tag->pipes;
|
53 |
|
54 |
+
if ( $pipes instanceof WPCF7_Pipes
|
55 |
+
and ! $pipes->zero() ) {
|
56 |
$pipe = $pipes->random_pipe();
|
57 |
$question = $pipe->before;
|
58 |
$answer = $pipe->after;
|
105 |
|
106 |
/* Ajax echo filter */
|
107 |
|
108 |
+
add_filter( 'wpcf7_ajax_onload', 'wpcf7_quiz_ajax_refill', 10, 1 );
|
109 |
+
add_filter( 'wpcf7_ajax_json_echo', 'wpcf7_quiz_ajax_refill', 10, 1 );
|
110 |
|
111 |
function wpcf7_quiz_ajax_refill( $items ) {
|
112 |
if ( ! is_array( $items ) ) {
|
129 |
continue;
|
130 |
}
|
131 |
|
132 |
+
if ( $pipes instanceof WPCF7_Pipes
|
133 |
+
and ! $pipes->zero() ) {
|
134 |
$pipe = $pipes->random_pipe();
|
135 |
$question = $pipe->before;
|
136 |
$answer = $pipe->after;
|
155 |
|
156 |
/* Messages */
|
157 |
|
158 |
+
add_filter( 'wpcf7_messages', 'wpcf7_quiz_messages', 10, 1 );
|
159 |
|
160 |
function wpcf7_quiz_messages( $messages ) {
|
161 |
$messages = array_merge( $messages, array(
|
173 |
|
174 |
/* Tag generator */
|
175 |
|
176 |
+
add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_quiz', 40, 0 );
|
177 |
|
178 |
function wpcf7_add_tag_generator_quiz() {
|
179 |
$tag_generator = WPCF7_TagGenerator::get_instance();
|
modules/really-simple-captcha.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
|
6 |
/* form_tag handler */
|
7 |
|
8 |
-
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_captcha' );
|
9 |
|
10 |
function wpcf7_add_form_tag_captcha() {
|
11 |
// CAPTCHA-Challenge (image)
|
@@ -106,8 +106,8 @@ function wpcf7_captchar_form_tag_handler( $tag ) {
|
|
106 |
$atts['maxlength'] = $tag->get_maxlength_option();
|
107 |
$atts['minlength'] = $tag->get_minlength_option();
|
108 |
|
109 |
-
if ( $atts['maxlength']
|
110 |
-
|
111 |
unset( $atts['maxlength'], $atts['minlength'] );
|
112 |
}
|
113 |
|
@@ -124,7 +124,7 @@ function wpcf7_captchar_form_tag_handler( $tag ) {
|
|
124 |
}
|
125 |
|
126 |
if ( $tag->has_option( 'placeholder' )
|
127 |
-
|
128 |
$atts['placeholder'] = $value;
|
129 |
$value = '';
|
130 |
}
|
@@ -145,7 +145,8 @@ function wpcf7_captchar_form_tag_handler( $tag ) {
|
|
145 |
|
146 |
/* Validation filter */
|
147 |
|
148 |
-
add_filter( 'wpcf7_validate_captchar',
|
|
|
149 |
|
150 |
function wpcf7_captcha_validation_filter( $result, $tag ) {
|
151 |
$type = $tag->type;
|
@@ -157,7 +158,8 @@ function wpcf7_captcha_validation_filter( $result, $tag ) {
|
|
157 |
$response = isset( $_POST[$name] ) ? (string) $_POST[$name] : '';
|
158 |
$response = wpcf7_canonicalize( $response );
|
159 |
|
160 |
-
if ( 0 == strlen( $prefix )
|
|
|
161 |
$result->invalidate( $tag, wpcf7_get_message( 'captcha_not_match' ) );
|
162 |
}
|
163 |
|
@@ -171,8 +173,8 @@ function wpcf7_captcha_validation_filter( $result, $tag ) {
|
|
171 |
|
172 |
/* Ajax echo filter */
|
173 |
|
174 |
-
add_filter( 'wpcf7_ajax_onload', 'wpcf7_captcha_ajax_refill' );
|
175 |
-
add_filter( 'wpcf7_ajax_json_echo', 'wpcf7_captcha_ajax_refill' );
|
176 |
|
177 |
function wpcf7_captcha_ajax_refill( $items ) {
|
178 |
if ( ! is_array( $items ) ) {
|
@@ -213,7 +215,7 @@ function wpcf7_captcha_ajax_refill( $items ) {
|
|
213 |
|
214 |
/* Messages */
|
215 |
|
216 |
-
add_filter( 'wpcf7_messages', 'wpcf7_captcha_messages' );
|
217 |
|
218 |
function wpcf7_captcha_messages( $messages ) {
|
219 |
$messages = array_merge( $messages, array(
|
@@ -231,7 +233,7 @@ function wpcf7_captcha_messages( $messages ) {
|
|
231 |
|
232 |
/* Tag generator */
|
233 |
|
234 |
-
add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_captcha', 46 );
|
235 |
|
236 |
function wpcf7_add_tag_generator_captcha() {
|
237 |
if ( ! wpcf7_use_really_simple_captcha() ) {
|
@@ -328,10 +330,13 @@ function wpcf7_tag_generator_captcha( $contact_form, $args = '' ) {
|
|
328 |
|
329 |
/* Warning message */
|
330 |
|
331 |
-
add_action( 'wpcf7_admin_warnings',
|
|
|
332 |
|
333 |
-
function wpcf7_captcha_display_warning_message() {
|
334 |
-
if (
|
|
|
|
|
335 |
return;
|
336 |
}
|
337 |
|
@@ -349,14 +354,15 @@ function wpcf7_captcha_display_warning_message() {
|
|
349 |
$uploads_dir = wpcf7_captcha_tmp_dir();
|
350 |
wpcf7_init_captcha();
|
351 |
|
352 |
-
if ( ! is_dir( $uploads_dir )
|
|
|
353 |
$message = sprintf( __( 'This contact form contains CAPTCHA fields, but the temporary folder for the files (%s) does not exist or is not writable. You can create the folder or change its permission manually.', 'contact-form-7' ), $uploads_dir );
|
354 |
|
355 |
echo '<div class="notice notice-warning"><p>' . esc_html( $message ) . '</p></div>';
|
356 |
}
|
357 |
|
358 |
if ( ! function_exists( 'imagecreatetruecolor' )
|
359 |
-
|
360 |
$message = __( "This contact form contains CAPTCHA fields, but the necessary libraries (GD and FreeType) are not available on your server.", 'contact-form-7' );
|
361 |
|
362 |
echo '<div class="notice notice-warning"><p>' . esc_html( $message ) . '</p></div>';
|
@@ -434,7 +440,8 @@ function wpcf7_captcha_tmp_url() {
|
|
434 |
function wpcf7_captcha_url( $filename ) {
|
435 |
$url = path_join( wpcf7_captcha_tmp_url(), $filename );
|
436 |
|
437 |
-
if ( is_ssl()
|
|
|
438 |
$url = 'https:' . substr( $url, 5 );
|
439 |
}
|
440 |
|
@@ -447,7 +454,7 @@ function wpcf7_generate_captcha( $options = null ) {
|
|
447 |
}
|
448 |
|
449 |
if ( ! is_dir( $captcha->tmp_dir )
|
450 |
-
|
451 |
return false;
|
452 |
}
|
453 |
|
@@ -515,7 +522,7 @@ function wpcf7_remove_captcha( $prefix ) {
|
|
515 |
$captcha->remove( $prefix );
|
516 |
}
|
517 |
|
518 |
-
add_action( 'template_redirect', 'wpcf7_cleanup_captcha_files', 20 );
|
519 |
|
520 |
function wpcf7_cleanup_captcha_files() {
|
521 |
if ( ! $captcha = wpcf7_init_captcha() ) {
|
@@ -528,7 +535,9 @@ function wpcf7_cleanup_captcha_files() {
|
|
528 |
|
529 |
$dir = trailingslashit( wpcf7_captcha_tmp_dir() );
|
530 |
|
531 |
-
if ( ! is_dir( $dir )
|
|
|
|
|
532 |
return false;
|
533 |
}
|
534 |
|
5 |
|
6 |
/* form_tag handler */
|
7 |
|
8 |
+
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_captcha', 10, 0 );
|
9 |
|
10 |
function wpcf7_add_form_tag_captcha() {
|
11 |
// CAPTCHA-Challenge (image)
|
106 |
$atts['maxlength'] = $tag->get_maxlength_option();
|
107 |
$atts['minlength'] = $tag->get_minlength_option();
|
108 |
|
109 |
+
if ( $atts['maxlength'] and $atts['minlength']
|
110 |
+
and $atts['maxlength'] < $atts['minlength'] ) {
|
111 |
unset( $atts['maxlength'], $atts['minlength'] );
|
112 |
}
|
113 |
|
124 |
}
|
125 |
|
126 |
if ( $tag->has_option( 'placeholder' )
|
127 |
+
or $tag->has_option( 'watermark' ) ) {
|
128 |
$atts['placeholder'] = $value;
|
129 |
$value = '';
|
130 |
}
|
145 |
|
146 |
/* Validation filter */
|
147 |
|
148 |
+
add_filter( 'wpcf7_validate_captchar',
|
149 |
+
'wpcf7_captcha_validation_filter', 10, 2 );
|
150 |
|
151 |
function wpcf7_captcha_validation_filter( $result, $tag ) {
|
152 |
$type = $tag->type;
|
158 |
$response = isset( $_POST[$name] ) ? (string) $_POST[$name] : '';
|
159 |
$response = wpcf7_canonicalize( $response );
|
160 |
|
161 |
+
if ( 0 == strlen( $prefix )
|
162 |
+
or ! wpcf7_check_captcha( $prefix, $response ) ) {
|
163 |
$result->invalidate( $tag, wpcf7_get_message( 'captcha_not_match' ) );
|
164 |
}
|
165 |
|
173 |
|
174 |
/* Ajax echo filter */
|
175 |
|
176 |
+
add_filter( 'wpcf7_ajax_onload', 'wpcf7_captcha_ajax_refill', 10, 1 );
|
177 |
+
add_filter( 'wpcf7_ajax_json_echo', 'wpcf7_captcha_ajax_refill', 10, 1 );
|
178 |
|
179 |
function wpcf7_captcha_ajax_refill( $items ) {
|
180 |
if ( ! is_array( $items ) ) {
|
215 |
|
216 |
/* Messages */
|
217 |
|
218 |
+
add_filter( 'wpcf7_messages', 'wpcf7_captcha_messages', 10, 1 );
|
219 |
|
220 |
function wpcf7_captcha_messages( $messages ) {
|
221 |
$messages = array_merge( $messages, array(
|
233 |
|
234 |
/* Tag generator */
|
235 |
|
236 |
+
add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_captcha', 46, 0 );
|
237 |
|
238 |
function wpcf7_add_tag_generator_captcha() {
|
239 |
if ( ! wpcf7_use_really_simple_captcha() ) {
|
330 |
|
331 |
/* Warning message */
|
332 |
|
333 |
+
add_action( 'wpcf7_admin_warnings',
|
334 |
+
'wpcf7_captcha_display_warning_message', 10, 3 );
|
335 |
|
336 |
+
function wpcf7_captcha_display_warning_message( $page, $action, $object ) {
|
337 |
+
if ( $object instanceof WPCF7_ContactForm ) {
|
338 |
+
$contact_form = $object;
|
339 |
+
} else {
|
340 |
return;
|
341 |
}
|
342 |
|
354 |
$uploads_dir = wpcf7_captcha_tmp_dir();
|
355 |
wpcf7_init_captcha();
|
356 |
|
357 |
+
if ( ! is_dir( $uploads_dir )
|
358 |
+
or ! wp_is_writable( $uploads_dir ) ) {
|
359 |
$message = sprintf( __( 'This contact form contains CAPTCHA fields, but the temporary folder for the files (%s) does not exist or is not writable. You can create the folder or change its permission manually.', 'contact-form-7' ), $uploads_dir );
|
360 |
|
361 |
echo '<div class="notice notice-warning"><p>' . esc_html( $message ) . '</p></div>';
|
362 |
}
|
363 |
|
364 |
if ( ! function_exists( 'imagecreatetruecolor' )
|
365 |
+
or ! function_exists( 'imagettftext' ) ) {
|
366 |
$message = __( "This contact form contains CAPTCHA fields, but the necessary libraries (GD and FreeType) are not available on your server.", 'contact-form-7' );
|
367 |
|
368 |
echo '<div class="notice notice-warning"><p>' . esc_html( $message ) . '</p></div>';
|
440 |
function wpcf7_captcha_url( $filename ) {
|
441 |
$url = path_join( wpcf7_captcha_tmp_url(), $filename );
|
442 |
|
443 |
+
if ( is_ssl()
|
444 |
+
and 'http:' == substr( $url, 0, 5 ) ) {
|
445 |
$url = 'https:' . substr( $url, 5 );
|
446 |
}
|
447 |
|
454 |
}
|
455 |
|
456 |
if ( ! is_dir( $captcha->tmp_dir )
|
457 |
+
or ! wp_is_writable( $captcha->tmp_dir ) ) {
|
458 |
return false;
|
459 |
}
|
460 |
|
522 |
$captcha->remove( $prefix );
|
523 |
}
|
524 |
|
525 |
+
add_action( 'template_redirect', 'wpcf7_cleanup_captcha_files', 20, 0 );
|
526 |
|
527 |
function wpcf7_cleanup_captcha_files() {
|
528 |
if ( ! $captcha = wpcf7_init_captcha() ) {
|
535 |
|
536 |
$dir = trailingslashit( wpcf7_captcha_tmp_dir() );
|
537 |
|
538 |
+
if ( ! is_dir( $dir )
|
539 |
+
or ! is_readable( $dir )
|
540 |
+
or ! wp_is_writable( $dir ) ) {
|
541 |
return false;
|
542 |
}
|
543 |
|
modules/recaptcha.php
CHANGED
@@ -1,8 +1,196 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
private static $instance;
|
8 |
private $sitekeys;
|
@@ -37,13 +225,15 @@ class WPCF7_RECAPTCHA extends WPCF7_Service {
|
|
37 |
}
|
38 |
|
39 |
public function link() {
|
40 |
-
echo
|
41 |
'https://www.google.com/recaptcha/intro/index.html',
|
42 |
-
'google.com/recaptcha'
|
|
|
43 |
}
|
44 |
|
45 |
public function get_sitekey() {
|
46 |
-
if ( empty( $this->sitekeys )
|
|
|
47 |
return false;
|
48 |
}
|
49 |
|
@@ -62,37 +252,53 @@ class WPCF7_RECAPTCHA extends WPCF7_Service {
|
|
62 |
}
|
63 |
}
|
64 |
|
65 |
-
|
|
|
|
|
|
|
|
|
66 |
$is_human = false;
|
67 |
|
68 |
-
if ( empty( $
|
69 |
return $is_human;
|
70 |
}
|
71 |
|
72 |
-
$
|
|
|
73 |
$sitekey = $this->get_sitekey();
|
74 |
$secret = $this->get_secret( $sitekey );
|
75 |
|
76 |
-
$
|
77 |
'body' => array(
|
78 |
'secret' => $secret,
|
79 |
-
'response' => $
|
80 |
-
'remoteip' => $_SERVER['REMOTE_ADDR'],
|
81 |
),
|
82 |
-
)
|
|
|
|
|
83 |
|
84 |
if ( 200 != wp_remote_retrieve_response_code( $response ) ) {
|
|
|
|
|
|
|
|
|
85 |
return $is_human;
|
86 |
}
|
87 |
|
88 |
-
$
|
89 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
|
91 |
-
$is_human = isset( $response['success'] ) && true == $response['success'];
|
92 |
return $is_human;
|
93 |
}
|
94 |
|
95 |
-
|
96 |
$args = wp_parse_args( $args, array() );
|
97 |
|
98 |
$url = menu_page_url( 'wpcf7-integration', false );
|
@@ -105,21 +311,30 @@ class WPCF7_RECAPTCHA extends WPCF7_Service {
|
|
105 |
return $url;
|
106 |
}
|
107 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
public function load( $action = '' ) {
|
109 |
-
if ( 'setup' == $action ) {
|
110 |
-
|
111 |
-
check_admin_referer( 'wpcf7-recaptcha-setup' );
|
112 |
|
|
|
|
|
|
|
|
|
113 |
$sitekey = isset( $_POST['sitekey'] ) ? trim( $_POST['sitekey'] ) : '';
|
114 |
$secret = isset( $_POST['secret'] ) ? trim( $_POST['secret'] ) : '';
|
115 |
|
116 |
-
if ( $sitekey
|
117 |
-
|
118 |
-
$
|
119 |
-
|
120 |
-
) );
|
121 |
-
} elseif ( '' === $sitekey && '' === $secret ) {
|
122 |
-
WPCF7::update_option( 'recaptcha', null );
|
123 |
$redirect_to = $this->menu_page_url( array(
|
124 |
'message' => 'success',
|
125 |
) );
|
@@ -129,10 +344,14 @@ class WPCF7_RECAPTCHA extends WPCF7_Service {
|
|
129 |
'message' => 'invalid',
|
130 |
) );
|
131 |
}
|
|
|
132 |
|
133 |
-
|
134 |
-
|
135 |
}
|
|
|
|
|
|
|
136 |
}
|
137 |
}
|
138 |
|
@@ -151,47 +370,29 @@ class WPCF7_RECAPTCHA extends WPCF7_Service {
|
|
151 |
}
|
152 |
|
153 |
public function display( $action = '' ) {
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
|
|
|
|
|
|
|
|
159 |
$this->display_setup();
|
160 |
-
return;
|
161 |
-
}
|
162 |
-
|
163 |
-
if ( $this->is_active() ) {
|
164 |
-
$sitekey = $this->get_sitekey();
|
165 |
-
$secret = $this->get_secret( $sitekey );
|
166 |
-
?>
|
167 |
-
<table class="form-table">
|
168 |
-
<tbody>
|
169 |
-
<tr>
|
170 |
-
<th scope="row"><?php echo esc_html( __( 'Site Key', 'contact-form-7' ) ); ?></th>
|
171 |
-
<td class="code"><?php echo esc_html( $sitekey ); ?></td>
|
172 |
-
</tr>
|
173 |
-
<tr>
|
174 |
-
<th scope="row"><?php echo esc_html( __( 'Secret Key', 'contact-form-7' ) ); ?></th>
|
175 |
-
<td class="code"><?php echo esc_html( wpcf7_mask_password( $secret ) ); ?></td>
|
176 |
-
</tr>
|
177 |
-
</tbody>
|
178 |
-
</table>
|
179 |
-
|
180 |
-
<p><a href="<?php echo esc_url( $this->menu_page_url( 'action=setup' ) ); ?>" class="button"><?php echo esc_html( __( "Reset Keys", 'contact-form-7' ) ); ?></a></p>
|
181 |
-
|
182 |
-
<?php
|
183 |
} else {
|
184 |
-
|
185 |
-
<p
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
<p><?php echo sprintf( esc_html( __( "For more details, see %s.", 'contact-form-7' ) ), wpcf7_link( __( 'https://contactform7.com/recaptcha/', 'contact-form-7' ), __( 'reCAPTCHA', 'contact-form-7' ) ) ); ?></p>
|
190 |
-
<?php
|
191 |
}
|
192 |
}
|
193 |
|
194 |
-
|
|
|
|
|
|
|
195 |
?>
|
196 |
<form method="post" action="<?php echo esc_url( $this->menu_page_url( 'action=setup' ) ); ?>">
|
197 |
<?php wp_nonce_field( 'wpcf7-recaptcha-setup' ); ?>
|
@@ -199,317 +400,51 @@ class WPCF7_RECAPTCHA extends WPCF7_Service {
|
|
199 |
<tbody>
|
200 |
<tr>
|
201 |
<th scope="row"><label for="sitekey"><?php echo esc_html( __( 'Site Key', 'contact-form-7' ) ); ?></label></th>
|
202 |
-
<td
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
</tr>
|
204 |
<tr>
|
205 |
<th scope="row"><label for="secret"><?php echo esc_html( __( 'Secret Key', 'contact-form-7' ) ); ?></label></th>
|
206 |
-
<td
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
207 |
</tr>
|
208 |
</tbody>
|
209 |
</table>
|
210 |
-
|
211 |
-
<p class="submit"><input type="submit" class="button button-primary" value="<?php echo esc_attr( __( 'Save', 'contact-form-7' ) ); ?>" name="submit" /></p>
|
212 |
-
</form>
|
213 |
<?php
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
$categories = array(
|
223 |
-
'captcha' => __( 'CAPTCHA', 'contact-form-7' ),
|
224 |
-
);
|
225 |
-
|
226 |
-
foreach ( $categories as $name => $category ) {
|
227 |
-
$integration->add_category( $name, $category );
|
228 |
-
}
|
229 |
-
|
230 |
-
$services = array(
|
231 |
-
'recaptcha' => WPCF7_RECAPTCHA::get_instance(),
|
232 |
-
);
|
233 |
-
|
234 |
-
foreach ( $services as $name => $service ) {
|
235 |
-
$integration->add_service( $name, $service );
|
236 |
-
}
|
237 |
-
}
|
238 |
-
|
239 |
-
add_action( 'wpcf7_enqueue_scripts', 'wpcf7_recaptcha_enqueue_scripts' );
|
240 |
-
|
241 |
-
function wpcf7_recaptcha_enqueue_scripts() {
|
242 |
-
$url = 'https://www.google.com/recaptcha/api.js';
|
243 |
-
$url = add_query_arg( array(
|
244 |
-
'onload' => 'recaptchaCallback',
|
245 |
-
'render' => 'explicit',
|
246 |
-
), $url );
|
247 |
-
|
248 |
-
wp_register_script( 'google-recaptcha', $url, array(), '2.0', true );
|
249 |
-
}
|
250 |
-
|
251 |
-
add_action( 'wp_footer', 'wpcf7_recaptcha_callback_script' );
|
252 |
-
|
253 |
-
function wpcf7_recaptcha_callback_script() {
|
254 |
-
if ( ! wp_script_is( 'google-recaptcha', 'enqueued' ) ) {
|
255 |
-
return;
|
256 |
-
}
|
257 |
-
|
258 |
-
?>
|
259 |
-
<script type="text/javascript">
|
260 |
-
var recaptchaWidgets = [];
|
261 |
-
var recaptchaCallback = function() {
|
262 |
-
var forms = document.getElementsByTagName( 'form' );
|
263 |
-
var pattern = /(^|\s)g-recaptcha(\s|$)/;
|
264 |
-
|
265 |
-
for ( var i = 0; i < forms.length; i++ ) {
|
266 |
-
var divs = forms[ i ].getElementsByTagName( 'div' );
|
267 |
-
|
268 |
-
for ( var j = 0; j < divs.length; j++ ) {
|
269 |
-
var sitekey = divs[ j ].getAttribute( 'data-sitekey' );
|
270 |
-
|
271 |
-
if ( divs[ j ].className && divs[ j ].className.match( pattern ) && sitekey ) {
|
272 |
-
var params = {
|
273 |
-
'sitekey': sitekey,
|
274 |
-
'type': divs[ j ].getAttribute( 'data-type' ),
|
275 |
-
'size': divs[ j ].getAttribute( 'data-size' ),
|
276 |
-
'theme': divs[ j ].getAttribute( 'data-theme' ),
|
277 |
-
'badge': divs[ j ].getAttribute( 'data-badge' ),
|
278 |
-
'tabindex': divs[ j ].getAttribute( 'data-tabindex' )
|
279 |
-
};
|
280 |
-
|
281 |
-
var callback = divs[ j ].getAttribute( 'data-callback' );
|
282 |
-
|
283 |
-
if ( callback && 'function' == typeof window[ callback ] ) {
|
284 |
-
params[ 'callback' ] = window[ callback ];
|
285 |
-
}
|
286 |
-
|
287 |
-
var expired_callback = divs[ j ].getAttribute( 'data-expired-callback' );
|
288 |
-
|
289 |
-
if ( expired_callback && 'function' == typeof window[ expired_callback ] ) {
|
290 |
-
params[ 'expired-callback' ] = window[ expired_callback ];
|
291 |
-
}
|
292 |
-
|
293 |
-
var widget_id = grecaptcha.render( divs[ j ], params );
|
294 |
-
recaptchaWidgets.push( widget_id );
|
295 |
-
break;
|
296 |
-
}
|
297 |
}
|
298 |
-
}
|
299 |
-
};
|
300 |
-
|
301 |
-
document.addEventListener( 'wpcf7submit', function( event ) {
|
302 |
-
switch ( event.detail.status ) {
|
303 |
-
case 'spam':
|
304 |
-
case 'mail_sent':
|
305 |
-
case 'mail_failed':
|
306 |
-
for ( var i = 0; i < recaptchaWidgets.length; i++ ) {
|
307 |
-
grecaptcha.reset( recaptchaWidgets[ i ] );
|
308 |
-
}
|
309 |
-
}
|
310 |
-
}, false );
|
311 |
-
</script>
|
312 |
-
<?php
|
313 |
-
}
|
314 |
-
|
315 |
-
add_action( 'wpcf7_init', 'wpcf7_recaptcha_add_form_tag_recaptcha' );
|
316 |
-
|
317 |
-
function wpcf7_recaptcha_add_form_tag_recaptcha() {
|
318 |
-
$recaptcha = WPCF7_RECAPTCHA::get_instance();
|
319 |
-
|
320 |
-
if ( $recaptcha->is_active() ) {
|
321 |
-
wpcf7_add_form_tag( 'recaptcha', 'wpcf7_recaptcha_form_tag_handler',
|
322 |
-
array( 'display-block' => true ) );
|
323 |
-
}
|
324 |
-
}
|
325 |
-
|
326 |
-
function wpcf7_recaptcha_form_tag_handler( $tag ) {
|
327 |
-
if ( ! wp_script_is( 'google-recaptcha', 'registered' ) ) {
|
328 |
-
wpcf7_recaptcha_enqueue_scripts();
|
329 |
-
}
|
330 |
-
|
331 |
-
wp_enqueue_script( 'google-recaptcha' );
|
332 |
-
|
333 |
-
$atts = array();
|
334 |
-
|
335 |
-
$recaptcha = WPCF7_RECAPTCHA::get_instance();
|
336 |
-
$atts['data-sitekey'] = $recaptcha->get_sitekey();
|
337 |
-
$atts['data-type'] = $tag->get_option( 'type', '(audio|image)', true );
|
338 |
-
$atts['data-size'] = $tag->get_option(
|
339 |
-
'size', '(compact|normal|invisible)', true );
|
340 |
-
$atts['data-theme'] = $tag->get_option( 'theme', '(dark|light)', true );
|
341 |
-
$atts['data-badge'] = $tag->get_option(
|
342 |
-
'badge', '(bottomright|bottomleft|inline)', true );
|
343 |
-
$atts['data-tabindex'] = $tag->get_option( 'tabindex', 'signed_int', true );
|
344 |
-
$atts['data-callback'] = $tag->get_option( 'callback', '', true );
|
345 |
-
$atts['data-expired-callback'] =
|
346 |
-
$tag->get_option( 'expired_callback', '', true );
|
347 |
-
|
348 |
-
$atts['class'] = $tag->get_class_option(
|
349 |
-
wpcf7_form_controls_class( $tag->type, 'g-recaptcha' ) );
|
350 |
-
$atts['id'] = $tag->get_id_option();
|
351 |
-
|
352 |
-
$html = sprintf( '<div %1$s></div>', wpcf7_format_atts( $atts ) );
|
353 |
-
$html .= wpcf7_recaptcha_noscript(
|
354 |
-
array( 'sitekey' => $atts['data-sitekey'] ) );
|
355 |
-
$html = sprintf( '<div class="wpcf7-form-control-wrap">%s</div>', $html );
|
356 |
-
|
357 |
-
return $html;
|
358 |
-
}
|
359 |
-
|
360 |
-
function wpcf7_recaptcha_noscript( $args = '' ) {
|
361 |
-
$args = wp_parse_args( $args, array(
|
362 |
-
'sitekey' => '',
|
363 |
-
) );
|
364 |
-
|
365 |
-
if ( empty( $args['sitekey'] ) ) {
|
366 |
-
return;
|
367 |
-
}
|
368 |
-
|
369 |
-
$url = add_query_arg( 'k', $args['sitekey'],
|
370 |
-
'https://www.google.com/recaptcha/api/fallback' );
|
371 |
-
|
372 |
-
ob_start();
|
373 |
-
?>
|
374 |
-
|
375 |
-
<noscript>
|
376 |
-
<div style="width: 302px; height: 422px;">
|
377 |
-
<div style="width: 302px; height: 422px; position: relative;">
|
378 |
-
<div style="width: 302px; height: 422px; position: absolute;">
|
379 |
-
<iframe src="<?php echo esc_url( $url ); ?>" frameborder="0" scrolling="no" style="width: 302px; height:422px; border-style: none;">
|
380 |
-
</iframe>
|
381 |
-
</div>
|
382 |
-
<div style="width: 300px; height: 60px; border-style: none; bottom: 12px; left: 25px; margin: 0px; padding: 0px; right: 25px; background: #f9f9f9; border: 1px solid #c1c1c1; border-radius: 3px;">
|
383 |
-
<textarea id="g-recaptcha-response" name="g-recaptcha-response" class="g-recaptcha-response" style="width: 250px; height: 40px; border: 1px solid #c1c1c1; margin: 10px 25px; padding: 0px; resize: none;">
|
384 |
-
</textarea>
|
385 |
-
</div>
|
386 |
-
</div>
|
387 |
-
</div>
|
388 |
-
</noscript>
|
389 |
-
<?php
|
390 |
-
return ob_get_clean();
|
391 |
-
}
|
392 |
-
|
393 |
-
add_filter( 'wpcf7_spam', 'wpcf7_recaptcha_check_with_google', 9 );
|
394 |
-
|
395 |
-
function wpcf7_recaptcha_check_with_google( $spam ) {
|
396 |
-
if ( $spam ) {
|
397 |
-
return $spam;
|
398 |
-
}
|
399 |
-
|
400 |
-
$contact_form = wpcf7_get_current_contact_form();
|
401 |
-
|
402 |
-
if ( ! $contact_form ) {
|
403 |
-
return $spam;
|
404 |
-
}
|
405 |
-
|
406 |
-
$tags = $contact_form->scan_form_tags( array( 'type' => 'recaptcha' ) );
|
407 |
-
|
408 |
-
if ( empty( $tags ) ) {
|
409 |
-
return $spam;
|
410 |
-
}
|
411 |
-
|
412 |
-
$recaptcha = WPCF7_RECAPTCHA::get_instance();
|
413 |
-
|
414 |
-
if ( ! $recaptcha->is_active() ) {
|
415 |
-
return $spam;
|
416 |
-
}
|
417 |
-
|
418 |
-
$response_token = wpcf7_recaptcha_response();
|
419 |
-
$spam = ! $recaptcha->verify( $response_token );
|
420 |
-
|
421 |
-
return $spam;
|
422 |
-
}
|
423 |
-
|
424 |
-
add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_recaptcha', 45 );
|
425 |
-
|
426 |
-
function wpcf7_add_tag_generator_recaptcha() {
|
427 |
-
$tag_generator = WPCF7_TagGenerator::get_instance();
|
428 |
-
$tag_generator->add( 'recaptcha', __( 'reCAPTCHA', 'contact-form-7' ),
|
429 |
-
'wpcf7_tag_generator_recaptcha', array( 'nameless' => 1 ) );
|
430 |
-
}
|
431 |
-
|
432 |
-
function wpcf7_tag_generator_recaptcha( $contact_form, $args = '' ) {
|
433 |
-
$args = wp_parse_args( $args, array() );
|
434 |
-
|
435 |
-
$recaptcha = WPCF7_RECAPTCHA::get_instance();
|
436 |
-
|
437 |
-
if ( ! $recaptcha->is_active() ) {
|
438 |
-
?>
|
439 |
-
<div class="control-box">
|
440 |
-
<fieldset>
|
441 |
-
<legend><?php echo sprintf( esc_html( __( "To use reCAPTCHA, first you need to install an API key pair. For more details, see %s.", 'contact-form-7' ) ), wpcf7_link( __( 'https://contactform7.com/recaptcha/', 'contact-form-7' ), __( 'reCAPTCHA', 'contact-form-7' ) ) ); ?></legend>
|
442 |
-
</fieldset>
|
443 |
-
</div>
|
444 |
-
<?php
|
445 |
-
|
446 |
-
return;
|
447 |
-
}
|
448 |
-
|
449 |
-
$description = __( "Generate a form-tag for a reCAPTCHA widget. For more details, see %s.", 'contact-form-7' );
|
450 |
-
|
451 |
-
$desc_link = wpcf7_link( __( 'https://contactform7.com/recaptcha/', 'contact-form-7' ), __( 'reCAPTCHA', 'contact-form-7' ) );
|
452 |
-
|
453 |
?>
|
454 |
-
|
455 |
-
<fieldset>
|
456 |
-
<legend><?php echo sprintf( esc_html( $description ), $desc_link ); ?></legend>
|
457 |
-
|
458 |
-
<table class="form-table">
|
459 |
-
<tbody>
|
460 |
-
<tr>
|
461 |
-
<th scope="row"><?php echo esc_html( __( 'Size', 'contact-form-7' ) ); ?></th>
|
462 |
-
<td>
|
463 |
-
<fieldset>
|
464 |
-
<legend class="screen-reader-text"><?php echo esc_html( __( 'Size', 'contact-form-7' ) ); ?></legend>
|
465 |
-
<label for="<?php echo esc_attr( $args['content'] . '-size-normal' ); ?>"><input type="radio" name="size" class="option default" id="<?php echo esc_attr( $args['content'] . '-size-normal' ); ?>" value="normal" checked="checked" /> <?php echo esc_html( __( 'Normal', 'contact-form-7' ) ); ?></label>
|
466 |
-
<br />
|
467 |
-
<label for="<?php echo esc_attr( $args['content'] . '-size-compact' ); ?>"><input type="radio" name="size" class="option" id="<?php echo esc_attr( $args['content'] . '-size-compact' ); ?>" value="compact" /> <?php echo esc_html( __( 'Compact', 'contact-form-7' ) ); ?></label>
|
468 |
-
</fieldset>
|
469 |
-
</td>
|
470 |
-
</tr>
|
471 |
-
|
472 |
-
<tr>
|
473 |
-
<th scope="row"><?php echo esc_html( __( 'Theme', 'contact-form-7' ) ); ?></th>
|
474 |
-
<td>
|
475 |
-
<fieldset>
|
476 |
-
<legend class="screen-reader-text"><?php echo esc_html( __( 'Theme', 'contact-form-7' ) ); ?></legend>
|
477 |
-
<label for="<?php echo esc_attr( $args['content'] . '-theme-light' ); ?>"><input type="radio" name="theme" class="option default" id="<?php echo esc_attr( $args['content'] . '-theme-light' ); ?>" value="light" checked="checked" /> <?php echo esc_html( __( 'Light', 'contact-form-7' ) ); ?></label>
|
478 |
-
<br />
|
479 |
-
<label for="<?php echo esc_attr( $args['content'] . '-theme-dark' ); ?>"><input type="radio" name="theme" class="option" id="<?php echo esc_attr( $args['content'] . '-theme-dark' ); ?>" value="dark" /> <?php echo esc_html( __( 'Dark', 'contact-form-7' ) ); ?></label>
|
480 |
-
</fieldset>
|
481 |
-
</td>
|
482 |
-
</tr>
|
483 |
-
|
484 |
-
<tr>
|
485 |
-
<th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-id' ); ?>"><?php echo esc_html( __( 'Id attribute', 'contact-form-7' ) ); ?></label></th>
|
486 |
-
<td><input type="text" name="id" class="idvalue oneline option" id="<?php echo esc_attr( $args['content'] . '-id' ); ?>" /></td>
|
487 |
-
</tr>
|
488 |
-
|
489 |
-
<tr>
|
490 |
-
<th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-class' ); ?>"><?php echo esc_html( __( 'Class attribute', 'contact-form-7' ) ); ?></label></th>
|
491 |
-
<td><input type="text" name="class" class="classvalue oneline option" id="<?php echo esc_attr( $args['content'] . '-class' ); ?>" /></td>
|
492 |
-
</tr>
|
493 |
-
|
494 |
-
</tbody>
|
495 |
-
</table>
|
496 |
-
</fieldset>
|
497 |
-
</div>
|
498 |
-
|
499 |
-
<div class="insert-box">
|
500 |
-
<input type="text" name="recaptcha" class="tag code" readonly="readonly" onfocus="this.select()" />
|
501 |
-
|
502 |
-
<div class="submitbox">
|
503 |
-
<input type="button" class="button button-primary insert-tag" value="<?php echo esc_attr( __( 'Insert Tag', 'contact-form-7' ) ); ?>" />
|
504 |
-
</div>
|
505 |
-
</div>
|
506 |
<?php
|
507 |
-
}
|
508 |
-
|
509 |
-
function wpcf7_recaptcha_response() {
|
510 |
-
if ( isset( $_POST['g-recaptcha-response'] ) ) {
|
511 |
-
return $_POST['g-recaptcha-response'];
|
512 |
}
|
513 |
-
|
514 |
-
return false;
|
515 |
}
|
1 |
<?php
|
2 |
|
3 |
+
add_action( 'wpcf7_init', 'wpcf7_recaptcha_register_service', 10, 0 );
|
4 |
+
|
5 |
+
function wpcf7_recaptcha_register_service() {
|
6 |
+
$integration = WPCF7_Integration::get_instance();
|
7 |
+
|
8 |
+
$integration->add_category( 'captcha',
|
9 |
+
__( 'CAPTCHA', 'contact-form-7' )
|
10 |
+
);
|
11 |
+
|
12 |
+
$integration->add_service( 'recaptcha',
|
13 |
+
WPCF7_RECAPTCHA::get_instance()
|
14 |
+
);
|
15 |
+
}
|
16 |
+
|
17 |
+
add_action( 'wp_enqueue_scripts', 'wpcf7_recaptcha_enqueue_scripts', 10, 0 );
|
18 |
+
|
19 |
+
function wpcf7_recaptcha_enqueue_scripts() {
|
20 |
+
$service = WPCF7_RECAPTCHA::get_instance();
|
21 |
+
|
22 |
+
if ( ! $service->is_active() ) {
|
23 |
+
return;
|
24 |
+
}
|
25 |
+
|
26 |
+
$url = add_query_arg(
|
27 |
+
array(
|
28 |
+
'render' => $service->get_sitekey(),
|
29 |
+
),
|
30 |
+
'https://www.google.com/recaptcha/api.js'
|
31 |
+
);
|
32 |
|
33 |
+
wp_enqueue_script( 'google-recaptcha', $url, array(), '3.0', true );
|
34 |
+
}
|
35 |
+
|
36 |
+
add_filter( 'wpcf7_form_hidden_fields',
|
37 |
+
'wpcf7_recaptcha_add_hidden_fields', 100, 1 );
|
38 |
+
|
39 |
+
function wpcf7_recaptcha_add_hidden_fields( $fields ) {
|
40 |
+
return array_merge( $fields, array(
|
41 |
+
'g-recaptcha-response' => '',
|
42 |
+
) );
|
43 |
+
}
|
44 |
+
|
45 |
+
add_action( 'wp_footer', 'wpcf7_recaptcha_onload_script', 40, 0 );
|
46 |
+
|
47 |
+
function wpcf7_recaptcha_onload_script() {
|
48 |
+
$service = WPCF7_RECAPTCHA::get_instance();
|
49 |
+
|
50 |
+
if ( ! $service->is_active() ) {
|
51 |
+
return;
|
52 |
+
}
|
53 |
+
|
54 |
+
if ( ! wp_script_is( 'google-recaptcha', 'done' ) ) {
|
55 |
+
return;
|
56 |
+
}
|
57 |
+
|
58 |
+
?>
|
59 |
+
<script type="text/javascript">
|
60 |
+
( function( grecaptcha, sitekey ) {
|
61 |
+
|
62 |
+
var wpcf7recaptcha = {
|
63 |
+
execute: function() {
|
64 |
+
grecaptcha.execute(
|
65 |
+
sitekey,
|
66 |
+
{ action: 'homepage' }
|
67 |
+
).then( function( token ) {
|
68 |
+
var forms = document.getElementsByTagName( 'form' );
|
69 |
+
|
70 |
+
for ( var i = 0; i < forms.length; i++ ) {
|
71 |
+
var fields = forms[ i ].getElementsByTagName( 'input' );
|
72 |
+
|
73 |
+
for ( var j = 0; j < fields.length; j++ ) {
|
74 |
+
var field = fields[ j ];
|
75 |
+
|
76 |
+
if ( 'g-recaptcha-response' === field.getAttribute( 'name' ) ) {
|
77 |
+
field.setAttribute( 'value', token );
|
78 |
+
break;
|
79 |
+
}
|
80 |
+
}
|
81 |
+
}
|
82 |
+
} );
|
83 |
+
}
|
84 |
+
};
|
85 |
+
|
86 |
+
grecaptcha.ready( wpcf7recaptcha.execute );
|
87 |
+
|
88 |
+
document.addEventListener( 'wpcf7submit', wpcf7recaptcha.execute, false );
|
89 |
+
|
90 |
+
} )( grecaptcha, '<?php echo esc_js( $service->get_sitekey() ); ?>' );
|
91 |
+
</script>
|
92 |
+
<?php
|
93 |
+
}
|
94 |
+
|
95 |
+
add_filter( 'wpcf7_spam', 'wpcf7_recaptcha_verify_response', 9, 1 );
|
96 |
+
|
97 |
+
function wpcf7_recaptcha_verify_response( $spam ) {
|
98 |
+
if ( $spam ) {
|
99 |
+
return $spam;
|
100 |
+
}
|
101 |
+
|
102 |
+
$service = WPCF7_RECAPTCHA::get_instance();
|
103 |
+
|
104 |
+
if ( ! $service->is_active() ) {
|
105 |
+
return $spam;
|
106 |
+
}
|
107 |
+
|
108 |
+
$token = isset( $_POST['g-recaptcha-response'] )
|
109 |
+
? trim( $_POST['g-recaptcha-response'] ) : '';
|
110 |
+
|
111 |
+
if ( ! $token ) {
|
112 |
+
return $spam;
|
113 |
+
}
|
114 |
+
|
115 |
+
return ! $service->verify( $token );
|
116 |
+
}
|
117 |
+
|
118 |
+
add_action( 'wpcf7_init', 'wpcf7_recaptcha_add_form_tag_recaptcha', 10, 0 );
|
119 |
+
|
120 |
+
function wpcf7_recaptcha_add_form_tag_recaptcha() {
|
121 |
+
$service = WPCF7_RECAPTCHA::get_instance();
|
122 |
+
|
123 |
+
if ( ! $service->is_active() ) {
|
124 |
+
return;
|
125 |
+
}
|
126 |
+
|
127 |
+
wpcf7_add_form_tag( 'recaptcha',
|
128 |
+
'__return_empty_string', // no output
|
129 |
+
array( 'display-block' => true )
|
130 |
+
);
|
131 |
+
}
|
132 |
+
|
133 |
+
add_action( 'wpcf7_upgrade', 'wpcf7_upgrade_recaptcha_v2_v3', 10, 2 );
|
134 |
+
|
135 |
+
function wpcf7_upgrade_recaptcha_v2_v3( $new_ver, $old_ver ) {
|
136 |
+
if ( version_compare( '5.1-dev', $old_ver, '<=' ) ) {
|
137 |
+
return;
|
138 |
+
}
|
139 |
+
|
140 |
+
$service = WPCF7_RECAPTCHA::get_instance();
|
141 |
+
|
142 |
+
if ( ! $service->is_active() ) {
|
143 |
+
return;
|
144 |
+
}
|
145 |
+
|
146 |
+
// Maybe v2 keys are used now. Warning necessary.
|
147 |
+
WPCF7::update_option( 'recaptcha_v2_v3_warning', true );
|
148 |
+
WPCF7::update_option( 'recaptcha', null );
|
149 |
+
}
|
150 |
+
|
151 |
+
add_action( 'wpcf7_admin_menu', 'wpcf7_admin_init_recaptcha_v2_v3', 10, 0 );
|
152 |
+
|
153 |
+
function wpcf7_admin_init_recaptcha_v2_v3() {
|
154 |
+
if ( ! WPCF7::get_option( 'recaptcha_v2_v3_warning' ) ) {
|
155 |
+
return;
|
156 |
+
}
|
157 |
+
|
158 |
+
add_filter( 'wpcf7_admin_menu_change_notice',
|
159 |
+
'wpcf7_admin_menu_change_notice_recaptcha_v2_v3', 10, 1 );
|
160 |
+
|
161 |
+
add_action( 'wpcf7_admin_warnings',
|
162 |
+
'wpcf7_admin_warnings_recaptcha_v2_v3', 5, 3 );
|
163 |
+
}
|
164 |
+
|
165 |
+
function wpcf7_admin_menu_change_notice_recaptcha_v2_v3( $counts ) {
|
166 |
+
$counts['wpcf7-integration'] += 1;
|
167 |
+
return $counts;
|
168 |
+
}
|
169 |
+
|
170 |
+
function wpcf7_admin_warnings_recaptcha_v2_v3( $page, $action, $object ) {
|
171 |
+
if ( 'wpcf7-integration' !== $page ) {
|
172 |
+
return;
|
173 |
+
}
|
174 |
+
|
175 |
+
$message = sprintf(
|
176 |
+
esc_html( __( "API keys for reCAPTCHA v3 are different from those for v2; keys for v2 don’t work with the v3 API. You need to register your sites again to get new keys for v3. For details, see %s.", 'contact-form-7' ) ),
|
177 |
+
wpcf7_link(
|
178 |
+
__( 'https://contactform7.com/recaptcha/', 'contact-form-7' ),
|
179 |
+
__( 'reCAPTCHA (v3)', 'contact-form-7' )
|
180 |
+
)
|
181 |
+
);
|
182 |
+
|
183 |
+
echo sprintf(
|
184 |
+
'<div class="notice notice-warning"><p>%s</p></div>',
|
185 |
+
$message
|
186 |
+
);
|
187 |
+
}
|
188 |
+
|
189 |
+
if ( ! class_exists( 'WPCF7_Service' ) ) {
|
190 |
+
return;
|
191 |
+
}
|
192 |
+
|
193 |
+
class WPCF7_RECAPTCHA extends WPCF7_Service {
|
194 |
|
195 |
private static $instance;
|
196 |
private $sitekeys;
|
225 |
}
|
226 |
|
227 |
public function link() {
|
228 |
+
echo wpcf7_link(
|
229 |
'https://www.google.com/recaptcha/intro/index.html',
|
230 |
+
'google.com/recaptcha'
|
231 |
+
);
|
232 |
}
|
233 |
|
234 |
public function get_sitekey() {
|
235 |
+
if ( empty( $this->sitekeys )
|
236 |
+
or ! is_array( $this->sitekeys ) ) {
|
237 |
return false;
|
238 |
}
|
239 |
|
252 |
}
|
253 |
}
|
254 |
|
255 |
+
protected function log( $url, $request, $response ) {
|
256 |
+
wpcf7_log_remote_request( $url, $request, $response );
|
257 |
+
}
|
258 |
+
|
259 |
+
public function verify( $token ) {
|
260 |
$is_human = false;
|
261 |
|
262 |
+
if ( empty( $token ) or ! $this->is_active() ) {
|
263 |
return $is_human;
|
264 |
}
|
265 |
|
266 |
+
$endpoint = 'https://www.google.com/recaptcha/api/siteverify';
|
267 |
+
|
268 |
$sitekey = $this->get_sitekey();
|
269 |
$secret = $this->get_secret( $sitekey );
|
270 |
|
271 |
+
$request = array(
|
272 |
'body' => array(
|
273 |
'secret' => $secret,
|
274 |
+
'response' => $token,
|
|
|
275 |
),
|
276 |
+
);
|
277 |
+
|
278 |
+
$response = wp_remote_post( esc_url_raw( $endpoint ), $request );
|
279 |
|
280 |
if ( 200 != wp_remote_retrieve_response_code( $response ) ) {
|
281 |
+
if ( WP_DEBUG ) {
|
282 |
+
$this->log( $endpoint, $request, $response );
|
283 |
+
}
|
284 |
+
|
285 |
return $is_human;
|
286 |
}
|
287 |
|
288 |
+
$response_body = wp_remote_retrieve_body( $response );
|
289 |
+
$response_body = json_decode( $response_body, true );
|
290 |
+
|
291 |
+
$score = isset( $response_body['score'] ) ? $response_body['score'] : 0;
|
292 |
+
$threshold = 0.5;
|
293 |
+
$is_human = $threshold < $score;
|
294 |
+
|
295 |
+
$is_human = apply_filters( 'wpcf7_recaptcha_verify_response',
|
296 |
+
$is_human, $response_body );
|
297 |
|
|
|
298 |
return $is_human;
|
299 |
}
|
300 |
|
301 |
+
protected function menu_page_url( $args = '' ) {
|
302 |
$args = wp_parse_args( $args, array() );
|
303 |
|
304 |
$url = menu_page_url( 'wpcf7-integration', false );
|
311 |
return $url;
|
312 |
}
|
313 |
|
314 |
+
protected function save_data() {
|
315 |
+
WPCF7::update_option( 'recaptcha', $this->sitekeys );
|
316 |
+
}
|
317 |
+
|
318 |
+
protected function reset_data() {
|
319 |
+
$this->sitekeys = null;
|
320 |
+
$this->save_data();
|
321 |
+
}
|
322 |
+
|
323 |
public function load( $action = '' ) {
|
324 |
+
if ( 'setup' == $action and 'POST' == $_SERVER['REQUEST_METHOD'] ) {
|
325 |
+
check_admin_referer( 'wpcf7-recaptcha-setup' );
|
|
|
326 |
|
327 |
+
if ( ! empty( $_POST['reset'] ) ) {
|
328 |
+
$this->reset_data();
|
329 |
+
$redirect_to = $this->menu_page_url( 'action=setup' );
|
330 |
+
} else {
|
331 |
$sitekey = isset( $_POST['sitekey'] ) ? trim( $_POST['sitekey'] ) : '';
|
332 |
$secret = isset( $_POST['secret'] ) ? trim( $_POST['secret'] ) : '';
|
333 |
|
334 |
+
if ( $sitekey and $secret ) {
|
335 |
+
$this->sitekeys = array( $sitekey => $secret );
|
336 |
+
$this->save_data();
|
337 |
+
|
|
|
|
|
|
|
338 |
$redirect_to = $this->menu_page_url( array(
|
339 |
'message' => 'success',
|
340 |
) );
|
344 |
'message' => 'invalid',
|
345 |
) );
|
346 |
}
|
347 |
+
}
|
348 |
|
349 |
+
if ( WPCF7::get_option( 'recaptcha_v2_v3_warning' ) ) {
|
350 |
+
WPCF7::update_option( 'recaptcha_v2_v3_warning', false );
|
351 |
}
|
352 |
+
|
353 |
+
wp_safe_redirect( $redirect_to );
|
354 |
+
exit();
|
355 |
}
|
356 |
}
|
357 |
|
370 |
}
|
371 |
|
372 |
public function display( $action = '' ) {
|
373 |
+
echo '<p>' . sprintf(
|
374 |
+
esc_html( __( 'reCAPTCHA protects you against spam and other types of automated abuse. With Contact Form 7’s reCAPTCHA integration module, you can block abusive form submissions by spam bots. For details, see %s.', 'contact-form-7' ) ),
|
375 |
+
wpcf7_link(
|
376 |
+
__( 'https://contactform7.com/recaptcha/', 'contact-form-7' ),
|
377 |
+
__( 'reCAPTCHA (v3)', 'contact-form-7' )
|
378 |
+
)
|
379 |
+
) . '</p>';
|
380 |
+
|
381 |
+
if ( $this->is_active() or 'setup' == $action ) {
|
382 |
$this->display_setup();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
383 |
} else {
|
384 |
+
echo sprintf(
|
385 |
+
'<p><a href="%1$s" class="button">%2$s</a></p>',
|
386 |
+
esc_url( $this->menu_page_url( 'action=setup' ) ),
|
387 |
+
esc_html( __( 'Setup Integration', 'contact-form-7' ) )
|
388 |
+
);
|
|
|
|
|
389 |
}
|
390 |
}
|
391 |
|
392 |
+
private function display_setup() {
|
393 |
+
$sitekey = $this->is_active() ? $this->get_sitekey() : '';
|
394 |
+
$secret = $this->is_active() ? $this->get_secret( $sitekey ) : '';
|
395 |
+
|
396 |
?>
|
397 |
<form method="post" action="<?php echo esc_url( $this->menu_page_url( 'action=setup' ) ); ?>">
|
398 |
<?php wp_nonce_field( 'wpcf7-recaptcha-setup' ); ?>
|
400 |
<tbody>
|
401 |
<tr>
|
402 |
<th scope="row"><label for="sitekey"><?php echo esc_html( __( 'Site Key', 'contact-form-7' ) ); ?></label></th>
|
403 |
+
<td><?php
|
404 |
+
if ( $this->is_active() ) {
|
405 |
+
echo esc_html( $sitekey );
|
406 |
+
echo sprintf(
|
407 |
+
'<input type="hidden" value="%1$s" id="sitekey" name="sitekey" />',
|
408 |
+
esc_attr( $sitekey )
|
409 |
+
);
|
410 |
+
} else {
|
411 |
+
echo sprintf(
|
412 |
+
'<input type="text" aria-required="true" value="%1$s" id="sitekey" name="sitekey" class="regular-text code" />',
|
413 |
+
esc_attr( $sitekey )
|
414 |
+
);
|
415 |
+
}
|
416 |
+
?></td>
|
417 |
</tr>
|
418 |
<tr>
|
419 |
<th scope="row"><label for="secret"><?php echo esc_html( __( 'Secret Key', 'contact-form-7' ) ); ?></label></th>
|
420 |
+
<td><?php
|
421 |
+
if ( $this->is_active() ) {
|
422 |
+
echo esc_html( wpcf7_mask_password( $secret ) );
|
423 |
+
echo sprintf(
|
424 |
+
'<input type="hidden" value="%1$s" id="secret" name="secret" />',
|
425 |
+
esc_attr( $secret )
|
426 |
+
);
|
427 |
+
} else {
|
428 |
+
echo sprintf(
|
429 |
+
'<input type="text" aria-required="true" value="%1$s" id="secret" name="secret" class="regular-text code" />',
|
430 |
+
esc_attr( $secret )
|
431 |
+
);
|
432 |
+
}
|
433 |
+
?></td>
|
434 |
</tr>
|
435 |
</tbody>
|
436 |
</table>
|
|
|
|
|
|
|
437 |
<?php
|
438 |
+
if ( $this->is_active() ) {
|
439 |
+
submit_button(
|
440 |
+
_x( 'Remove Keys', 'API keys', 'contact-form-7' ),
|
441 |
+
'small', 'reset'
|
442 |
+
);
|
443 |
+
} else {
|
444 |
+
submit_button( __( 'Save Changes', 'contact-form-7' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
445 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
446 |
?>
|
447 |
+
</form>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
448 |
<?php
|
|
|
|
|
|
|
|
|
|
|
449 |
}
|
|
|
|
|
450 |
}
|
modules/response.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
|
6 |
/* form_tag handler */
|
7 |
|
8 |
-
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_response' );
|
9 |
|
10 |
function wpcf7_add_form_tag_response() {
|
11 |
wpcf7_add_form_tag( 'response', 'wpcf7_response_form_tag_handler',
|
5 |
|
6 |
/* form_tag handler */
|
7 |
|
8 |
+
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_response', 10, 0 );
|
9 |
|
10 |
function wpcf7_add_form_tag_response() {
|
11 |
wpcf7_add_form_tag( 'response', 'wpcf7_response_form_tag_handler',
|
modules/select.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
|
6 |
/* form_tag handler */
|
7 |
|
8 |
-
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_select' );
|
9 |
|
10 |
function wpcf7_add_form_tag_select() {
|
11 |
wpcf7_add_form_tag( array( 'select', 'select*' ),
|
@@ -71,7 +71,8 @@ function wpcf7_select_form_tag_handler( $tag ) {
|
|
71 |
'shifted' => $include_blank,
|
72 |
) );
|
73 |
|
74 |
-
if ( $include_blank
|
|
|
75 |
array_unshift( $labels, '---' );
|
76 |
array_unshift( $values, '' );
|
77 |
} elseif ( $first_as_label ) {
|
@@ -125,7 +126,8 @@ add_filter( 'wpcf7_validate_select*', 'wpcf7_select_validation_filter', 10, 2 );
|
|
125 |
function wpcf7_select_validation_filter( $result, $tag ) {
|
126 |
$name = $tag->name;
|
127 |
|
128 |
-
if ( isset( $_POST[$name] )
|
|
|
129 |
foreach ( $_POST[$name] as $key => $value ) {
|
130 |
if ( '' === $value ) {
|
131 |
unset( $_POST[$name][$key] );
|
@@ -135,7 +137,7 @@ function wpcf7_select_validation_filter( $result, $tag ) {
|
|
135 |
|
136 |
$empty = ! isset( $_POST[$name] ) || empty( $_POST[$name] ) && '0' !== $_POST[$name];
|
137 |
|
138 |
-
if ( $tag->is_required()
|
139 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
|
140 |
}
|
141 |
|
@@ -145,7 +147,7 @@ function wpcf7_select_validation_filter( $result, $tag ) {
|
|
145 |
|
146 |
/* Tag generator */
|
147 |
|
148 |
-
add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_menu', 25 );
|
149 |
|
150 |
function wpcf7_add_tag_generator_menu() {
|
151 |
$tag_generator = WPCF7_TagGenerator::get_instance();
|
5 |
|
6 |
/* form_tag handler */
|
7 |
|
8 |
+
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_select', 10, 0 );
|
9 |
|
10 |
function wpcf7_add_form_tag_select() {
|
11 |
wpcf7_add_form_tag( array( 'select', 'select*' ),
|
71 |
'shifted' => $include_blank,
|
72 |
) );
|
73 |
|
74 |
+
if ( $include_blank
|
75 |
+
or empty( $values ) ) {
|
76 |
array_unshift( $labels, '---' );
|
77 |
array_unshift( $values, '' );
|
78 |
} elseif ( $first_as_label ) {
|
126 |
function wpcf7_select_validation_filter( $result, $tag ) {
|
127 |
$name = $tag->name;
|
128 |
|
129 |
+
if ( isset( $_POST[$name] )
|
130 |
+
and is_array( $_POST[$name] ) ) {
|
131 |
foreach ( $_POST[$name] as $key => $value ) {
|
132 |
if ( '' === $value ) {
|
133 |
unset( $_POST[$name][$key] );
|
137 |
|
138 |
$empty = ! isset( $_POST[$name] ) || empty( $_POST[$name] ) && '0' !== $_POST[$name];
|
139 |
|
140 |
+
if ( $tag->is_required() and $empty ) {
|
141 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
|
142 |
}
|
143 |
|
147 |
|
148 |
/* Tag generator */
|
149 |
|
150 |
+
add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_menu', 25, 0 );
|
151 |
|
152 |
function wpcf7_add_tag_generator_menu() {
|
153 |
$tag_generator = WPCF7_TagGenerator::get_instance();
|
modules/submit.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
|
6 |
/* form_tag handler */
|
7 |
|
8 |
-
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_submit' );
|
9 |
|
10 |
function wpcf7_add_form_tag_submit() {
|
11 |
wpcf7_add_form_tag( 'submit', 'wpcf7_submit_form_tag_handler' );
|
@@ -39,7 +39,7 @@ function wpcf7_submit_form_tag_handler( $tag ) {
|
|
39 |
|
40 |
/* Tag generator */
|
41 |
|
42 |
-
add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_submit', 55 );
|
43 |
|
44 |
function wpcf7_add_tag_generator_submit() {
|
45 |
$tag_generator = WPCF7_TagGenerator::get_instance();
|
5 |
|
6 |
/* form_tag handler */
|
7 |
|
8 |
+
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_submit', 10, 0 );
|
9 |
|
10 |
function wpcf7_add_form_tag_submit() {
|
11 |
wpcf7_add_form_tag( 'submit', 'wpcf7_submit_form_tag_handler' );
|
39 |
|
40 |
/* Tag generator */
|
41 |
|
42 |
+
add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_submit', 55, 0 );
|
43 |
|
44 |
function wpcf7_add_tag_generator_submit() {
|
45 |
$tag_generator = WPCF7_TagGenerator::get_instance();
|
modules/text.php
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
|
10 |
/* form_tag handler */
|
11 |
|
12 |
-
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_text' );
|
13 |
|
14 |
function wpcf7_add_form_tag_text() {
|
15 |
wpcf7_add_form_tag(
|
@@ -40,8 +40,8 @@ function wpcf7_text_form_tag_handler( $tag ) {
|
|
40 |
$atts['maxlength'] = $tag->get_maxlength_option();
|
41 |
$atts['minlength'] = $tag->get_minlength_option();
|
42 |
|
43 |
-
if ( $atts['maxlength']
|
44 |
-
|
45 |
unset( $atts['maxlength'], $atts['minlength'] );
|
46 |
}
|
47 |
|
@@ -64,7 +64,8 @@ function wpcf7_text_form_tag_handler( $tag ) {
|
|
64 |
|
65 |
$value = (string) reset( $tag->values );
|
66 |
|
67 |
-
if ( $tag->has_option( 'placeholder' )
|
|
|
68 |
$atts['placeholder'] = $value;
|
69 |
$value = '';
|
70 |
}
|
@@ -112,31 +113,31 @@ function wpcf7_text_validation_filter( $result, $tag ) {
|
|
112 |
: '';
|
113 |
|
114 |
if ( 'text' == $tag->basetype ) {
|
115 |
-
if ( $tag->is_required()
|
116 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
|
117 |
}
|
118 |
}
|
119 |
|
120 |
if ( 'email' == $tag->basetype ) {
|
121 |
-
if ( $tag->is_required()
|
122 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
|
123 |
-
} elseif ( '' != $value
|
124 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_email' ) );
|
125 |
}
|
126 |
}
|
127 |
|
128 |
if ( 'url' == $tag->basetype ) {
|
129 |
-
if ( $tag->is_required()
|
130 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
|
131 |
-
} elseif ( '' != $value
|
132 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_url' ) );
|
133 |
}
|
134 |
}
|
135 |
|
136 |
if ( 'tel' == $tag->basetype ) {
|
137 |
-
if ( $tag->is_required()
|
138 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
|
139 |
-
} elseif ( '' != $value
|
140 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_tel' ) );
|
141 |
}
|
142 |
}
|
@@ -145,16 +146,16 @@ function wpcf7_text_validation_filter( $result, $tag ) {
|
|
145 |
$maxlength = $tag->get_maxlength_option();
|
146 |
$minlength = $tag->get_minlength_option();
|
147 |
|
148 |
-
if ( $maxlength
|
149 |
$maxlength = $minlength = null;
|
150 |
}
|
151 |
|
152 |
$code_units = wpcf7_count_code_units( stripslashes( $value ) );
|
153 |
|
154 |
if ( false !== $code_units ) {
|
155 |
-
if ( $maxlength
|
156 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_too_long' ) );
|
157 |
-
} elseif ( $minlength
|
158 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_too_short' ) );
|
159 |
}
|
160 |
}
|
@@ -166,7 +167,7 @@ function wpcf7_text_validation_filter( $result, $tag ) {
|
|
166 |
|
167 |
/* Messages */
|
168 |
|
169 |
-
add_filter( 'wpcf7_messages', 'wpcf7_text_messages' );
|
170 |
|
171 |
function wpcf7_text_messages( $messages ) {
|
172 |
$messages = array_merge( $messages, array(
|
@@ -198,7 +199,7 @@ function wpcf7_text_messages( $messages ) {
|
|
198 |
|
199 |
/* Tag generator */
|
200 |
|
201 |
-
add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_text', 15 );
|
202 |
|
203 |
function wpcf7_add_tag_generator_text() {
|
204 |
$tag_generator = WPCF7_TagGenerator::get_instance();
|
9 |
|
10 |
/* form_tag handler */
|
11 |
|
12 |
+
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_text', 10, 0 );
|
13 |
|
14 |
function wpcf7_add_form_tag_text() {
|
15 |
wpcf7_add_form_tag(
|
40 |
$atts['maxlength'] = $tag->get_maxlength_option();
|
41 |
$atts['minlength'] = $tag->get_minlength_option();
|
42 |
|
43 |
+
if ( $atts['maxlength'] and $atts['minlength']
|
44 |
+
and $atts['maxlength'] < $atts['minlength'] ) {
|
45 |
unset( $atts['maxlength'], $atts['minlength'] );
|
46 |
}
|
47 |
|
64 |
|
65 |
$value = (string) reset( $tag->values );
|
66 |
|
67 |
+
if ( $tag->has_option( 'placeholder' )
|
68 |
+
or $tag->has_option( 'watermark' ) ) {
|
69 |
$atts['placeholder'] = $value;
|
70 |
$value = '';
|
71 |
}
|
113 |
: '';
|
114 |
|
115 |
if ( 'text' == $tag->basetype ) {
|
116 |
+
if ( $tag->is_required() and '' == $value ) {
|
117 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
|
118 |
}
|
119 |
}
|
120 |
|
121 |
if ( 'email' == $tag->basetype ) {
|
122 |
+
if ( $tag->is_required() and '' == $value ) {
|
123 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
|
124 |
+
} elseif ( '' != $value and ! wpcf7_is_email( $value ) ) {
|
125 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_email' ) );
|
126 |
}
|
127 |
}
|
128 |
|
129 |
if ( 'url' == $tag->basetype ) {
|
130 |
+
if ( $tag->is_required() and '' == $value ) {
|
131 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
|
132 |
+
} elseif ( '' != $value and ! wpcf7_is_url( $value ) ) {
|
133 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_url' ) );
|
134 |
}
|
135 |
}
|
136 |
|
137 |
if ( 'tel' == $tag->basetype ) {
|
138 |
+
if ( $tag->is_required() and '' == $value ) {
|
139 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
|
140 |
+
} elseif ( '' != $value and ! wpcf7_is_tel( $value ) ) {
|
141 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_tel' ) );
|
142 |
}
|
143 |
}
|
146 |
$maxlength = $tag->get_maxlength_option();
|
147 |
$minlength = $tag->get_minlength_option();
|
148 |
|
149 |
+
if ( $maxlength and $minlength and $maxlength < $minlength ) {
|
150 |
$maxlength = $minlength = null;
|
151 |
}
|
152 |
|
153 |
$code_units = wpcf7_count_code_units( stripslashes( $value ) );
|
154 |
|
155 |
if ( false !== $code_units ) {
|
156 |
+
if ( $maxlength and $maxlength < $code_units ) {
|
157 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_too_long' ) );
|
158 |
+
} elseif ( $minlength and $code_units < $minlength ) {
|
159 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_too_short' ) );
|
160 |
}
|
161 |
}
|
167 |
|
168 |
/* Messages */
|
169 |
|
170 |
+
add_filter( 'wpcf7_messages', 'wpcf7_text_messages', 10, 1 );
|
171 |
|
172 |
function wpcf7_text_messages( $messages ) {
|
173 |
$messages = array_merge( $messages, array(
|
199 |
|
200 |
/* Tag generator */
|
201 |
|
202 |
+
add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_text', 15, 0 );
|
203 |
|
204 |
function wpcf7_add_tag_generator_text() {
|
205 |
$tag_generator = WPCF7_TagGenerator::get_instance();
|
modules/textarea.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
|
6 |
/* form_tag handler */
|
7 |
|
8 |
-
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_textarea' );
|
9 |
|
10 |
function wpcf7_add_form_tag_textarea() {
|
11 |
wpcf7_add_form_tag( array( 'textarea', 'textarea*' ),
|
@@ -32,7 +32,8 @@ function wpcf7_textarea_form_tag_handler( $tag ) {
|
|
32 |
$atts['maxlength'] = $tag->get_maxlength_option();
|
33 |
$atts['minlength'] = $tag->get_minlength_option();
|
34 |
|
35 |
-
if ( $atts['maxlength']
|
|
|
36 |
unset( $atts['maxlength'], $atts['minlength'] );
|
37 |
}
|
38 |
|
@@ -57,7 +58,8 @@ function wpcf7_textarea_form_tag_handler( $tag ) {
|
|
57 |
? (string) reset( $tag->values )
|
58 |
: $tag->content;
|
59 |
|
60 |
-
if ( $tag->has_option( 'placeholder' )
|
|
|
61 |
$atts['placeholder'] = $value;
|
62 |
$value = '';
|
63 |
}
|
@@ -81,8 +83,10 @@ function wpcf7_textarea_form_tag_handler( $tag ) {
|
|
81 |
|
82 |
/* Validation filter */
|
83 |
|
84 |
-
add_filter( 'wpcf7_validate_textarea',
|
85 |
-
|
|
|
|
|
86 |
|
87 |
function wpcf7_textarea_validation_filter( $result, $tag ) {
|
88 |
$type = $tag->type;
|
@@ -90,7 +94,7 @@ function wpcf7_textarea_validation_filter( $result, $tag ) {
|
|
90 |
|
91 |
$value = isset( $_POST[$name] ) ? (string) $_POST[$name] : '';
|
92 |
|
93 |
-
if ( $tag->is_required()
|
94 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
|
95 |
}
|
96 |
|
@@ -98,16 +102,17 @@ function wpcf7_textarea_validation_filter( $result, $tag ) {
|
|
98 |
$maxlength = $tag->get_maxlength_option();
|
99 |
$minlength = $tag->get_minlength_option();
|
100 |
|
101 |
-
if ( $maxlength
|
|
|
102 |
$maxlength = $minlength = null;
|
103 |
}
|
104 |
|
105 |
$code_units = wpcf7_count_code_units( stripslashes( $value ) );
|
106 |
|
107 |
if ( false !== $code_units ) {
|
108 |
-
if ( $maxlength
|
109 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_too_long' ) );
|
110 |
-
} elseif ( $minlength
|
111 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_too_short' ) );
|
112 |
}
|
113 |
}
|
@@ -119,7 +124,7 @@ function wpcf7_textarea_validation_filter( $result, $tag ) {
|
|
119 |
|
120 |
/* Tag generator */
|
121 |
|
122 |
-
add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_textarea', 20 );
|
123 |
|
124 |
function wpcf7_add_tag_generator_textarea() {
|
125 |
$tag_generator = WPCF7_TagGenerator::get_instance();
|
5 |
|
6 |
/* form_tag handler */
|
7 |
|
8 |
+
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_textarea', 10, 0 );
|
9 |
|
10 |
function wpcf7_add_form_tag_textarea() {
|
11 |
wpcf7_add_form_tag( array( 'textarea', 'textarea*' ),
|
32 |
$atts['maxlength'] = $tag->get_maxlength_option();
|
33 |
$atts['minlength'] = $tag->get_minlength_option();
|
34 |
|
35 |
+
if ( $atts['maxlength'] and $atts['minlength']
|
36 |
+
and $atts['maxlength'] < $atts['minlength'] ) {
|
37 |
unset( $atts['maxlength'], $atts['minlength'] );
|
38 |
}
|
39 |
|
58 |
? (string) reset( $tag->values )
|
59 |
: $tag->content;
|
60 |
|
61 |
+
if ( $tag->has_option( 'placeholder' )
|
62 |
+
or $tag->has_option( 'watermark' ) ) {
|
63 |
$atts['placeholder'] = $value;
|
64 |
$value = '';
|
65 |
}
|
83 |
|
84 |
/* Validation filter */
|
85 |
|
86 |
+
add_filter( 'wpcf7_validate_textarea',
|
87 |
+
'wpcf7_textarea_validation_filter', 10, 2 );
|
88 |
+
add_filter( 'wpcf7_validate_textarea*',
|
89 |
+
'wpcf7_textarea_validation_filter', 10, 2 );
|
90 |
|
91 |
function wpcf7_textarea_validation_filter( $result, $tag ) {
|
92 |
$type = $tag->type;
|
94 |
|
95 |
$value = isset( $_POST[$name] ) ? (string) $_POST[$name] : '';
|
96 |
|
97 |
+
if ( $tag->is_required() and '' == $value ) {
|
98 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
|
99 |
}
|
100 |
|
102 |
$maxlength = $tag->get_maxlength_option();
|
103 |
$minlength = $tag->get_minlength_option();
|
104 |
|
105 |
+
if ( $maxlength and $minlength
|
106 |
+
and $maxlength < $minlength ) {
|
107 |
$maxlength = $minlength = null;
|
108 |
}
|
109 |
|
110 |
$code_units = wpcf7_count_code_units( stripslashes( $value ) );
|
111 |
|
112 |
if ( false !== $code_units ) {
|
113 |
+
if ( $maxlength and $maxlength < $code_units ) {
|
114 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_too_long' ) );
|
115 |
+
} elseif ( $minlength and $code_units < $minlength ) {
|
116 |
$result->invalidate( $tag, wpcf7_get_message( 'invalid_too_short' ) );
|
117 |
}
|
118 |
}
|
124 |
|
125 |
/* Tag generator */
|
126 |
|
127 |
+
add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_textarea', 20, 0 );
|
128 |
|
129 |
function wpcf7_add_tag_generator_textarea() {
|
130 |
$tag_generator = WPCF7_TagGenerator::get_instance();
|
readme.txt
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
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.
|
6 |
-
Tested up to:
|
7 |
-
Stable tag: 5.
|
8 |
License: GPLv2 or later
|
9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -35,6 +35,7 @@ If you activate certain features in this plugin, the contact form submitter's pe
|
|
35 |
|
36 |
* reCAPTCHA ([Google](https://policies.google.com/?hl=en))
|
37 |
* Akismet ([Automattic](https://automattic.com/privacy/))
|
|
|
38 |
|
39 |
= Recommended Plugins =
|
40 |
|
@@ -74,6 +75,12 @@ Do you have questions or issues with Contact Form 7? Use these support channels
|
|
74 |
|
75 |
For more information, see [Releases](https://contactform7.com/category/releases/).
|
76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
= 5.0.5 =
|
78 |
|
79 |
* Fixes the inconsistency problem between get_data_option() and get_default_option() in the WPCF7_FormTag class.
|
2 |
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.9
|
6 |
+
Tested up to: 5.0
|
7 |
+
Stable tag: 5.1
|
8 |
License: GPLv2 or later
|
9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
35 |
|
36 |
* reCAPTCHA ([Google](https://policies.google.com/?hl=en))
|
37 |
* Akismet ([Automattic](https://automattic.com/privacy/))
|
38 |
+
* Constant Contact ([Endurance International Group](https://www.endurance.com/privacy))
|
39 |
|
40 |
= Recommended Plugins =
|
41 |
|
75 |
|
76 |
For more information, see [Releases](https://contactform7.com/category/releases/).
|
77 |
|
78 |
+
= 5.1 =
|
79 |
+
|
80 |
+
* Introduces the Constant Contact integration module.
|
81 |
+
* Updates the reCAPTCHA module to support reCAPTCHA v3.
|
82 |
+
* Adds Dark Mode style rules.
|
83 |
+
|
84 |
= 5.0.5 =
|
85 |
|
86 |
* Fixes the inconsistency problem between get_data_option() and get_default_option() in the WPCF7_FormTag class.
|
settings.php
CHANGED
@@ -31,10 +31,12 @@ class WPCF7 {
|
|
31 |
self::load_module( 'acceptance' );
|
32 |
self::load_module( 'akismet' );
|
33 |
self::load_module( 'checkbox' );
|
|
|
34 |
self::load_module( 'count' );
|
35 |
self::load_module( 'date' );
|
36 |
self::load_module( 'file' );
|
37 |
self::load_module( 'flamingo' );
|
|
|
38 |
self::load_module( 'listo' );
|
39 |
self::load_module( 'number' );
|
40 |
self::load_module( 'quiz' );
|
@@ -45,13 +47,12 @@ class WPCF7 {
|
|
45 |
self::load_module( 'submit' );
|
46 |
self::load_module( 'text' );
|
47 |
self::load_module( 'textarea' );
|
48 |
-
self::load_module( 'hidden' );
|
49 |
}
|
50 |
|
51 |
protected static function load_module( $mod ) {
|
52 |
$dir = WPCF7_PLUGIN_MODULES_DIR;
|
53 |
|
54 |
-
if ( empty( $dir )
|
55 |
return false;
|
56 |
}
|
57 |
|
@@ -84,7 +85,7 @@ class WPCF7 {
|
|
84 |
}
|
85 |
}
|
86 |
|
87 |
-
add_action( 'plugins_loaded', 'wpcf7' );
|
88 |
|
89 |
function wpcf7() {
|
90 |
wpcf7_load_textdomain();
|
@@ -95,7 +96,7 @@ function wpcf7() {
|
|
95 |
add_shortcode( 'contact-form', 'wpcf7_contact_form_tag_func' );
|
96 |
}
|
97 |
|
98 |
-
add_action( 'init', 'wpcf7_init' );
|
99 |
|
100 |
function wpcf7_init() {
|
101 |
wpcf7_get_request_uri();
|
@@ -104,7 +105,7 @@ function wpcf7_init() {
|
|
104 |
do_action( 'wpcf7_init' );
|
105 |
}
|
106 |
|
107 |
-
add_action( 'admin_init', 'wpcf7_upgrade' );
|
108 |
|
109 |
function wpcf7_upgrade() {
|
110 |
$old_ver = WPCF7::get_option( 'version', '0' );
|
@@ -121,7 +122,7 @@ function wpcf7_upgrade() {
|
|
121 |
|
122 |
/* Install and default settings */
|
123 |
|
124 |
-
add_action( 'activate_' . WPCF7_PLUGIN_BASENAME, 'wpcf7_install' );
|
125 |
|
126 |
function wpcf7_install() {
|
127 |
if ( $opt = get_option( 'wpcf7' ) ) {
|
31 |
self::load_module( 'acceptance' );
|
32 |
self::load_module( 'akismet' );
|
33 |
self::load_module( 'checkbox' );
|
34 |
+
self::load_module( 'constant-contact' );
|
35 |
self::load_module( 'count' );
|
36 |
self::load_module( 'date' );
|
37 |
self::load_module( 'file' );
|
38 |
self::load_module( 'flamingo' );
|
39 |
+
self::load_module( 'hidden' );
|
40 |
self::load_module( 'listo' );
|
41 |
self::load_module( 'number' );
|
42 |
self::load_module( 'quiz' );
|
47 |
self::load_module( 'submit' );
|
48 |
self::load_module( 'text' );
|
49 |
self::load_module( 'textarea' );
|
|
|
50 |
}
|
51 |
|
52 |
protected static function load_module( $mod ) {
|
53 |
$dir = WPCF7_PLUGIN_MODULES_DIR;
|
54 |
|
55 |
+
if ( empty( $dir ) or ! is_dir( $dir ) ) {
|
56 |
return false;
|
57 |
}
|
58 |
|
85 |
}
|
86 |
}
|
87 |
|
88 |
+
add_action( 'plugins_loaded', 'wpcf7', 10, 0 );
|
89 |
|
90 |
function wpcf7() {
|
91 |
wpcf7_load_textdomain();
|
96 |
add_shortcode( 'contact-form', 'wpcf7_contact_form_tag_func' );
|
97 |
}
|
98 |
|
99 |
+
add_action( 'init', 'wpcf7_init', 10, 0 );
|
100 |
|
101 |
function wpcf7_init() {
|
102 |
wpcf7_get_request_uri();
|
105 |
do_action( 'wpcf7_init' );
|
106 |
}
|
107 |
|
108 |
+
add_action( 'admin_init', 'wpcf7_upgrade', 10, 0 );
|
109 |
|
110 |
function wpcf7_upgrade() {
|
111 |
$old_ver = WPCF7::get_option( 'version', '0' );
|
122 |
|
123 |
/* Install and default settings */
|
124 |
|
125 |
+
add_action( 'activate_' . WPCF7_PLUGIN_BASENAME, 'wpcf7_install', 10, 0 );
|
126 |
|
127 |
function wpcf7_install() {
|
128 |
if ( $opt = get_option( 'wpcf7' ) ) {
|
wp-contact-form-7.php
CHANGED
@@ -7,12 +7,12 @@ Author: Takayuki Miyoshi
|
|
7 |
Author URI: https://ideasilo.wordpress.com/
|
8 |
Text Domain: contact-form-7
|
9 |
Domain Path: /languages/
|
10 |
-
Version: 5.
|
11 |
*/
|
12 |
|
13 |
-
define( 'WPCF7_VERSION', '5.
|
14 |
|
15 |
-
define( 'WPCF7_REQUIRED_WP_VERSION', '4.
|
16 |
|
17 |
define( 'WPCF7_PLUGIN', __FILE__ );
|
18 |
|
@@ -61,6 +61,7 @@ if ( ! defined( 'WPCF7_VALIDATE_CONFIGURATION' ) ) {
|
|
61 |
}
|
62 |
|
63 |
// Deprecated, not used in the plugin core. Use wpcf7_plugin_url() instead.
|
64 |
-
define( 'WPCF7_PLUGIN_URL',
|
|
|
65 |
|
66 |
require_once WPCF7_PLUGIN_DIR . '/settings.php';
|
7 |
Author URI: https://ideasilo.wordpress.com/
|
8 |
Text Domain: contact-form-7
|
9 |
Domain Path: /languages/
|
10 |
+
Version: 5.1
|
11 |
*/
|
12 |
|
13 |
+
define( 'WPCF7_VERSION', '5.1' );
|
14 |
|
15 |
+
define( 'WPCF7_REQUIRED_WP_VERSION', '4.9' );
|
16 |
|
17 |
define( 'WPCF7_PLUGIN', __FILE__ );
|
18 |
|
61 |
}
|
62 |
|
63 |
// Deprecated, not used in the plugin core. Use wpcf7_plugin_url() instead.
|
64 |
+
define( 'WPCF7_PLUGIN_URL',
|
65 |
+
untrailingslashit( plugins_url( '', WPCF7_PLUGIN ) ) );
|
66 |
|
67 |
require_once WPCF7_PLUGIN_DIR . '/settings.php';
|