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 | ![]() |
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#x2F;, '' );
|
196 |
|
197 |
$.each( errors, function( key, val ) {
|
198 |
key = key.replace( /^mail_\d+\./, 'mail.' );
|
199 |
|
200 |
if ( key.replace( /\..*#x2F;, '' ) == 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#x2F;, '' );
|
196 |
|
197 |
$.each( errors, function( key, val ) {
|
198 |
key = key.replace( /^mail_\d+\./, 'mail.' );
|
199 |
|
200 |
if ( key.replace( /\..*#x2F;, '' ) == 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( '/\..*#x2F;', '', $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 |
|