PluginProbe ʕ •ᴥ•ʔ
Contact Form 7 / 6.1.6
Contact Form 7 v6.1.6
6.1.6 5.0.2 5.0.3 5.0.4 5.0.5 5.1 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.1.8 5.1.9 5.2 5.2.1 5.2.2 5.3 5.3.1 5.3.2 5.4 5.4.1 5.4.2 5.5 5.5.1 5.5.2 5.5.3 5.5.4 5.5.5 5.5.6 5.5.6.1 5.6 5.6.1 5.6.2 5.6.3 5.6.4 5.7 5.7.1 5.7.2 5.7.3 5.7.4 5.7.5 5.7.5.1 5.7.6 5.7.7 5.8 5.8.1 5.8.2 5.8.3 5.8.4 5.8.5 5.8.6 5.8.7 5.9 5.9.2 5.9.3 5.9.4 5.9.5 5.9.6 5.9.7 5.9.8 6.0 6.0.1 6.0.2 6.0.3 6.0.4 6.0.5 6.0.6 6.1 6.1.1 6.1.2 6.1.3 6.1.4 6.1.5 trunk 1.1 1.10 1.10.0.1 1.10.1 1.2 1.3 1.3.1 1.3.2 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.5 1.6 1.6.1 1.7 1.7.1 1.7.2 1.7.4 1.7.5 1.7.6 1.7.6.1 1.7.7 1.7.7.1 1.7.8 1.8 1.8.0.1 1.8.0.2 1.8.0.3 1.8.0.4 1.8.1 1.8.1.1 1.9 1.9.1 1.9.2 1.9.2.1 1.9.2.2 1.9.3 1.9.4 1.9.5 1.9.5.1 2.0 2.0-beta 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1 2.1.1 2.1.2 2.2 2.2.1 2.3 2.3.1 2.4 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 3.0 3.0-beta 3.0.1 3.0.2 3.0.2.1 3.1 3.1.1 3.1.2 3.2 3.2.1 3.3 3.3.1 3.3.2 3.3.3 3.4 3.4.1 3.4.2 3.5 3.5.1 3.5.2 3.5.3 3.5.4 3.6 3.7 3.7.1 3.7.2 3.8 3.8.1 3.9 3.9-beta 3.9.1 3.9.2 3.9.3 4.0 4.0.1 4.0.2 4.0.3 4.1 4.1-beta 4.1.1 4.1.2 4.2 4.2-beta 4.2.1 4.2.2 4.3 4.3.1 4.4 4.4.1 4.4.2 4.5 4.5.1 4.6 4.6.1 4.7 4.8 4.8.1 4.9 4.9.1 4.9.2 5.0 5.0.1
contact-form-7 / admin / admin.php
contact-form-7 / admin Last commit date
includes 7 months ago admin.php 6 months ago edit-contact-form.php 7 months ago
admin.php
760 lines
1 <?php
2
3 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 require_once WPCF7_PLUGIN_DIR . '/admin/includes/config-validator.php';
8
9
10 add_action(
11 'admin_init',
12 static function () {
13 do_action( 'wpcf7_admin_init' );
14 },
15 10, 0
16 );
17
18
19 add_action(
20 'admin_menu',
21 'wpcf7_admin_menu',
22 9, 0
23 );
24
25 function wpcf7_admin_menu() {
26 do_action( 'wpcf7_admin_menu' );
27
28 add_menu_page(
29 __( 'Contact Form 7', 'contact-form-7' ),
30 __( 'Contact', 'contact-form-7' )
31 . wpcf7_admin_menu_change_notice(),
32 'wpcf7_read_contact_forms',
33 'wpcf7',
34 'wpcf7_admin_management_page',
35 'dashicons-email',
36 30
37 );
38
39 $edit = add_submenu_page( 'wpcf7',
40 __( 'Edit Contact Form', 'contact-form-7' ),
41 __( 'Contact Forms', 'contact-form-7' )
42 . wpcf7_admin_menu_change_notice( 'wpcf7' ),
43 'wpcf7_read_contact_forms',
44 'wpcf7',
45 'wpcf7_admin_management_page'
46 );
47
48 add_action( 'load-' . $edit, 'wpcf7_load_contact_form_admin', 10, 0 );
49
50 $addnew = add_submenu_page( 'wpcf7',
51 __( 'Add Contact Form', 'contact-form-7' ),
52 __( 'Add Contact Form', 'contact-form-7' )
53 . wpcf7_admin_menu_change_notice( 'wpcf7-new' ),
54 'wpcf7_edit_contact_forms',
55 'wpcf7-new',
56 'wpcf7_admin_add_new_page'
57 );
58
59 add_action( 'load-' . $addnew, 'wpcf7_load_contact_form_admin', 10, 0 );
60
61 $integration = WPCF7_Integration::get_instance();
62
63 if ( $integration->service_exists() ) {
64 $integration = add_submenu_page( 'wpcf7',
65 __( 'Integration with External API', 'contact-form-7' ),
66 __( 'Integration', 'contact-form-7' )
67 . wpcf7_admin_menu_change_notice( 'wpcf7-integration' ),
68 'wpcf7_manage_integration',
69 'wpcf7-integration',
70 'wpcf7_admin_integration_page'
71 );
72
73 add_action( 'load-' . $integration, 'wpcf7_load_integration_page', 10, 0 );
74 }
75 }
76
77
78 function wpcf7_admin_menu_change_notice( $menu_slug = '' ) {
79 $counts = apply_filters( 'wpcf7_admin_menu_change_notice',
80 array(
81 'wpcf7' => 0,
82 'wpcf7-new' => 0,
83 'wpcf7-integration' => 0,
84 )
85 );
86
87 if ( empty( $menu_slug ) ) {
88 $count = absint( array_sum( $counts ) );
89 } elseif ( isset( $counts[$menu_slug] ) ) {
90 $count = absint( $counts[$menu_slug] );
91 } else {
92 $count = 0;
93 }
94
95 if ( $count ) {
96 return sprintf(
97 ' <span class="update-plugins %1$d"><span class="plugin-count">%2$s</span></span>',
98 $count,
99 esc_html( number_format_i18n( $count ) )
100 );
101 }
102
103 return '';
104 }
105
106
107 add_action(
108 'admin_enqueue_scripts',
109 'wpcf7_admin_enqueue_scripts',
110 10, 1
111 );
112
113 function wpcf7_admin_enqueue_scripts( $hook_suffix ) {
114 if ( false === strpos( $hook_suffix, 'wpcf7' ) ) {
115 return;
116 }
117
118 wp_enqueue_style( 'contact-form-7-admin',
119 wpcf7_plugin_url( 'admin/includes/css/styles.css' ),
120 array(), WPCF7_VERSION, 'all'
121 );
122
123 if ( wpcf7_is_rtl() ) {
124 wp_enqueue_style( 'contact-form-7-admin-rtl',
125 wpcf7_plugin_url( 'admin/includes/css/styles-rtl.css' ),
126 array(), WPCF7_VERSION, 'all'
127 );
128 }
129
130 $assets = include wpcf7_plugin_path( 'admin/includes/js/index.asset.php' );
131
132 $assets = wp_parse_args( $assets, array(
133 'dependencies' => array(),
134 'version' => WPCF7_VERSION,
135 ) );
136
137 wp_enqueue_script( 'wpcf7-admin',
138 wpcf7_plugin_url( 'admin/includes/js/index.js' ),
139 $assets['dependencies'],
140 $assets['version'],
141 array( 'in_footer' => true )
142 );
143
144 wp_set_script_translations( 'wpcf7-admin', 'contact-form-7' );
145
146 $wpcf7_obj = array(
147 'apiSettings' => array(
148 'root' => sanitize_url( rest_url( 'contact-form-7/v1' ) ),
149 'namespace' => 'contact-form-7/v1',
150 ),
151 );
152
153 $post = wpcf7_get_current_contact_form();
154
155 if ( $post ) {
156 $wpcf7_obj = array_merge( $wpcf7_obj, array(
157 'nonce' => array(
158 'save' => wp_create_nonce(
159 sprintf(
160 'wpcf7-save-contact-form_%s',
161 $post->initial() ? -1 : $post->id()
162 )
163 ),
164 'copy' => wp_create_nonce(
165 sprintf(
166 'wpcf7-copy-contact-form_%s',
167 $post->initial() ? -1 : $post->id()
168 )
169 ),
170 'delete' => wp_create_nonce(
171 sprintf(
172 'wpcf7-delete-contact-form_%s',
173 $post->initial() ? -1 : $post->id()
174 )
175 ),
176 ),
177 'configValidator' => array(
178 'errors' => array(),
179 'docUrl' => WPCF7_ConfigValidator::get_doc_link(),
180 ),
181 ) );
182
183 if (
184 current_user_can( 'wpcf7_edit_contact_form', $post->id() ) and
185 wpcf7_validate_configuration()
186 ) {
187 $config_validator = new WPCF7_ConfigValidator( $post );
188 $config_validator->restore();
189
190 $wpcf7_obj['configValidator'] = array_merge(
191 $wpcf7_obj['configValidator'],
192 array(
193 'errors' => $config_validator->collect_error_messages(
194 array( 'decodes_html_entities' => true )
195 ),
196 )
197 );
198 }
199 }
200
201 wp_add_inline_script( 'wpcf7-admin',
202 sprintf(
203 'var wpcf7 = %s;',
204 wp_json_encode( $wpcf7_obj, JSON_PRETTY_PRINT )
205 ),
206 'before'
207 );
208 }
209
210
211 add_filter(
212 'set_screen_option_wpcf7_contact_forms_per_page',
213 static function ( $result, $option, $value ) {
214 $wpcf7_screens = array(
215 'wpcf7_contact_forms_per_page',
216 );
217
218 if ( in_array( $option, $wpcf7_screens, true ) ) {
219 $result = $value;
220 }
221
222 return $result;
223 },
224 10, 3
225 );
226
227
228 function wpcf7_load_contact_form_admin() {
229 global $plugin_page;
230
231 $action = wpcf7_current_action();
232
233 do_action( 'wpcf7_admin_load',
234 wpcf7_superglobal_get( 'page' ),
235 $action
236 );
237
238 if ( 'save' === $action ) {
239 $id = wpcf7_superglobal_post( 'post_ID', '-1' );
240
241 check_admin_referer( 'wpcf7-save-contact-form_' . $id );
242
243 if ( ! current_user_can( 'wpcf7_edit_contact_form', $id ) ) {
244 wp_die(
245 esc_html( __( 'You are not allowed to edit this item.', 'contact-form-7' ) )
246 );
247 }
248
249 $contact_form = wpcf7_save_contact_form(
250 array_merge(
251 wp_unslash( $_REQUEST ),
252 array(
253 'id' => $id,
254 'title' => wpcf7_superglobal_post( 'post_title', null ),
255 'locale' => wpcf7_superglobal_post( 'wpcf7-locale', null ),
256 'form' => wpcf7_superglobal_post( 'wpcf7-form', '' ),
257 'mail' => wpcf7_superglobal_post( 'wpcf7-mail', array() ),
258 'mail_2' => wpcf7_superglobal_post( 'wpcf7-mail-2', array() ),
259 'messages' => wpcf7_superglobal_post( 'wpcf7-messages', array() ),
260 'additional_settings' => wpcf7_superglobal_post( 'wpcf7-additional-settings', '' ),
261 )
262 )
263 );
264
265 if ( $contact_form and wpcf7_validate_configuration() ) {
266 $config_validator = new WPCF7_ConfigValidator( $contact_form );
267 $config_validator->validate();
268 $config_validator->save();
269 }
270
271 $query = array(
272 'post' => $contact_form ? $contact_form->id() : 0,
273 'active-tab' => wpcf7_canonicalize_name(
274 wpcf7_superglobal_post( 'active-tab' )
275 ),
276 );
277
278 if ( ! $contact_form ) {
279 $query['message'] = 'failed';
280 } elseif ( -1 === (int) $id ) {
281 $query['message'] = 'created';
282 } else {
283 $query['message'] = 'saved';
284 }
285
286 $redirect_to = add_query_arg( $query, menu_page_url( 'wpcf7', false ) );
287 wp_safe_redirect( $redirect_to );
288 exit();
289 }
290
291 if ( 'copy' === $action ) {
292 $id = absint( $_POST['post_ID'] ?? $_REQUEST['post'] ?? '' );
293
294 check_admin_referer( 'wpcf7-copy-contact-form_' . $id );
295
296 if ( ! current_user_can( 'wpcf7_edit_contact_form', $id ) ) {
297 wp_die(
298 esc_html( __( 'You are not allowed to edit this item.', 'contact-form-7' ) )
299 );
300 }
301
302 $query = array();
303
304 if ( $contact_form = wpcf7_contact_form( $id ) ) {
305 $new_contact_form = $contact_form->copy();
306 $new_contact_form->save();
307
308 $query['post'] = $new_contact_form->id();
309 $query['message'] = 'created';
310 }
311
312 $redirect_to = add_query_arg( $query, menu_page_url( 'wpcf7', false ) );
313
314 wp_safe_redirect( $redirect_to );
315 exit();
316 }
317
318 if ( 'delete' === $action ) {
319 $nonce_action = 'bulk-posts';
320
321 if (
322 $post_id = wpcf7_superglobal_post( 'post_ID' ) or
323 ! is_array( $post_id = wpcf7_superglobal_request( 'post', array() ) )
324 ) {
325 $nonce_action = sprintf( 'wpcf7-delete-contact-form_%s', $post_id );
326 }
327
328 check_admin_referer( $nonce_action );
329
330 $posts = array_filter( (array) $post_id );
331
332 $deleted = 0;
333
334 foreach ( $posts as $post ) {
335 $post = WPCF7_ContactForm::get_instance( $post );
336
337 if ( empty( $post ) ) {
338 continue;
339 }
340
341 if ( ! current_user_can( 'wpcf7_delete_contact_form', $post->id() ) ) {
342 wp_die(
343 esc_html( __( 'You are not allowed to delete this item.', 'contact-form-7' ) )
344 );
345 }
346
347 if ( ! $post->delete() ) {
348 wp_die(
349 esc_html( __( 'Error in deleting.', 'contact-form-7' ) )
350 );
351 }
352
353 $deleted += 1;
354 }
355
356 $query = array();
357
358 if ( ! empty( $deleted ) ) {
359 $query['message'] = 'deleted';
360 }
361
362 $redirect_to = add_query_arg( $query, menu_page_url( 'wpcf7', false ) );
363
364 wp_safe_redirect( $redirect_to );
365 exit();
366 }
367
368 $post = null;
369
370 if ( 'wpcf7-new' === $plugin_page ) {
371 $post = WPCF7_ContactForm::get_template( array(
372 'locale' => wpcf7_superglobal_get( 'locale', null ),
373 ) );
374 } elseif ( $post_id = wpcf7_superglobal_get( 'post' ) ) {
375 $post = WPCF7_ContactForm::get_instance( $post_id );
376 }
377
378 $current_screen = get_current_screen();
379
380 $help_tabs = new WPCF7_Help_Tabs( $current_screen );
381
382 if ( $post and current_user_can( 'wpcf7_edit_contact_form', $post->id() ) ) {
383 $help_tabs->set_help_tabs( 'edit' );
384 } else {
385 $help_tabs->set_help_tabs( 'list' );
386
387 if ( ! class_exists( 'WPCF7_Contact_Form_List_Table' ) ) {
388 require_once WPCF7_PLUGIN_DIR . '/admin/includes/class-contact-forms-list-table.php';
389 }
390
391 add_filter(
392 'manage_' . $current_screen->id . '_columns',
393 array( 'WPCF7_Contact_Form_List_Table', 'define_columns' ),
394 10, 0
395 );
396
397 add_screen_option( 'per_page', array(
398 'default' => 20,
399 'option' => 'wpcf7_contact_forms_per_page',
400 ) );
401 }
402 }
403
404
405 function wpcf7_admin_management_page() {
406 if ( $post = wpcf7_get_current_contact_form() ) {
407 $post_id = $post->initial() ? -1 : $post->id();
408
409 require_once WPCF7_PLUGIN_DIR . '/admin/includes/editor.php';
410 require_once WPCF7_PLUGIN_DIR . '/admin/edit-contact-form.php';
411 return;
412 }
413
414 if (
415 'validate' === wpcf7_current_action() and
416 wpcf7_validate_configuration() and
417 current_user_can( 'wpcf7_edit_contact_forms' )
418 ) {
419 wpcf7_admin_bulk_validate_page();
420 return;
421 }
422
423 $list_table = new WPCF7_Contact_Form_List_Table();
424 $list_table->prepare_items();
425
426 $formatter = new WPCF7_HTMLFormatter( array(
427 'allowed_html' => array_merge( wpcf7_kses_allowed_html(), array(
428 'form' => array(
429 'method' => true,
430 ),
431 ) ),
432 ) );
433
434 $formatter->append_start_tag( 'div', array(
435 'class' => 'wrap',
436 'id' => 'wpcf7-contact-form-list-table',
437 ) );
438
439 $formatter->append_start_tag( 'h1', array(
440 'class' => 'wp-heading-inline',
441 ) );
442
443 $formatter->append_preformatted(
444 esc_html( __( 'Contact Forms', 'contact-form-7' ) )
445 );
446
447 $formatter->end_tag( 'h1' );
448
449 if ( current_user_can( 'wpcf7_edit_contact_forms' ) ) {
450 $formatter->append_preformatted(
451 wpcf7_link(
452 menu_page_url( 'wpcf7-new', false ),
453 __( 'Add Contact Form', 'contact-form-7' ),
454 array( 'class' => 'page-title-action' )
455 )
456 );
457 }
458
459 if ( $search_keyword = wpcf7_superglobal_request( 's' ) ) {
460 $formatter->append_start_tag( 'span', array(
461 'class' => 'subtitle',
462 ) );
463
464 $formatter->append_preformatted(
465 sprintf(
466 /* translators: %s: Search query. */
467 __( 'Search results for: <strong>%s</strong>', 'contact-form-7' ),
468 esc_html( $search_keyword )
469 )
470 );
471
472 $formatter->end_tag( 'span' );
473 }
474
475 $formatter->append_start_tag( 'hr', array(
476 'class' => 'wp-header-end',
477 ) );
478
479 $formatter->call_user_func( static function () {
480 do_action( 'wpcf7_admin_warnings',
481 'wpcf7', wpcf7_current_action(), null
482 );
483
484 wpcf7_welcome_panel();
485
486 do_action( 'wpcf7_admin_notices',
487 'wpcf7', wpcf7_current_action(), null
488 );
489 } );
490
491 $formatter->append_start_tag( 'form', array(
492 'method' => 'get',
493 ) );
494
495 $formatter->append_start_tag( 'input', array(
496 'type' => 'hidden',
497 'name' => 'page',
498 'value' => wpcf7_superglobal_request( 'page' ),
499 ) );
500
501 $formatter->call_user_func( static function () use ( $list_table ) {
502 $list_table->search_box(
503 __( 'Search Contact Forms', 'contact-form-7' ),
504 'wpcf7-contact'
505 );
506
507 $list_table->display();
508 } );
509
510 $formatter->print();
511 }
512
513
514 function wpcf7_admin_add_new_page() {
515 $post = wpcf7_get_current_contact_form();
516
517 if ( ! $post ) {
518 $post = WPCF7_ContactForm::get_template();
519 }
520
521 $post_id = -1;
522
523 require_once WPCF7_PLUGIN_DIR . '/admin/includes/editor.php';
524 require_once WPCF7_PLUGIN_DIR . '/admin/edit-contact-form.php';
525 }
526
527
528 function wpcf7_load_integration_page() {
529 do_action( 'wpcf7_admin_load',
530 wpcf7_superglobal_get( 'page' ),
531 wpcf7_current_action()
532 );
533
534 $integration = WPCF7_Integration::get_instance();
535
536 if (
537 $service_name = wpcf7_superglobal_request( 'service' ) and
538 $integration->service_exists( $service_name )
539 ) {
540 $service = $integration->get_service( $service_name );
541 $service->load( wpcf7_current_action() );
542 }
543
544 $help_tabs = new WPCF7_Help_Tabs( get_current_screen() );
545 $help_tabs->set_help_tabs( 'integration' );
546 }
547
548
549 function wpcf7_admin_integration_page() {
550 $integration = WPCF7_Integration::get_instance();
551
552 $service_name = wpcf7_superglobal_request( 'service' );
553 $service = null;
554
555 if ( $service_name and $integration->service_exists( $service_name ) ) {
556 $service = $integration->get_service( $service_name );
557 }
558
559 $formatter = new WPCF7_HTMLFormatter( array(
560 'allowed_html' => array_merge( wpcf7_kses_allowed_html(), array(
561 'form' => array(
562 'action' => true,
563 'method' => true,
564 ),
565 ) ),
566 ) );
567
568 $formatter->append_start_tag( 'div', array(
569 'class' => 'wrap',
570 'id' => 'wpcf7-integration',
571 ) );
572
573 $formatter->append_start_tag( 'h1' );
574
575 $formatter->append_preformatted(
576 esc_html( __( 'Integration with External API', 'contact-form-7' ) )
577 );
578
579 $formatter->end_tag( 'h1' );
580
581 $formatter->append_start_tag( 'p' );
582
583 $formatter->append_preformatted(
584 sprintf(
585 /* translators: %s: URL to support page about integration with external APIs */
586 __( 'You can expand the possibilities of your contact forms by integrating them with external services. For details, see <a href="%s">Integration with external APIs</a>.', 'contact-form-7' ),
587 __( 'https://contactform7.com/integration-with-external-apis/', 'contact-form-7' )
588 )
589 );
590
591 $formatter->end_tag( 'p' );
592
593 $formatter->call_user_func(
594 static function () use ( $integration, $service, $service_name ) {
595 do_action( 'wpcf7_admin_warnings',
596 'wpcf7-integration', wpcf7_current_action(), $service
597 );
598
599 do_action( 'wpcf7_admin_notices',
600 'wpcf7-integration', wpcf7_current_action(), $service
601 );
602
603 if ( $service ) {
604 $message = wpcf7_superglobal_request( 'message' );
605 $service->admin_notice( $message );
606
607 $integration->list_services( array(
608 'include' => $service_name,
609 ) );
610 } else {
611 $integration->list_services();
612 }
613 }
614 );
615
616 $formatter->print();
617 }
618
619
620 add_action( 'wpcf7_admin_notices', 'wpcf7_admin_updated_message', 10, 3 );
621
622 function wpcf7_admin_updated_message( $page, $action, $object ) {
623 if ( ! in_array( $page, array( 'wpcf7', 'wpcf7-new' ), true ) ) {
624 return;
625 }
626
627 $message_type = wpcf7_superglobal_request( 'message' );
628
629 if ( ! $message_type ) {
630 return;
631 }
632
633 $notice_type = 'success';
634
635 if ( 'created' === $message_type ) {
636 $message = __( 'Contact form created.', 'contact-form-7' );
637 } elseif ( 'saved' === $message_type ) {
638 $message = __( 'Contact form saved.', 'contact-form-7' );
639 } elseif ( 'deleted' === $message_type ) {
640 $message = __( 'Contact form deleted.', 'contact-form-7' );
641 } elseif ( 'failed' === $message_type ) {
642 $notice_type = 'error';
643 $message = __( 'There was an error saving the contact form.', 'contact-form-7' );
644 } elseif ( 'validated' === $message_type ) {
645 $bulk_validate = WPCF7::get_option( 'bulk_validate', array() );
646 $count_invalid = absint( $bulk_validate['count_invalid'] ?? 0 );
647
648 if ( $count_invalid ) {
649 $notice_type = 'warning';
650
651 $message = sprintf(
652 /* translators: %s: number of contact forms */
653 _n(
654 'Configuration validation completed. %s invalid contact form was found.',
655 'Configuration validation completed. %s invalid contact forms were found.',
656 $count_invalid, 'contact-form-7'
657 ),
658 number_format_i18n( $count_invalid )
659 );
660 } else {
661 $message = __( 'Configuration validation completed. No invalid contact form was found.', 'contact-form-7' );
662 }
663 }
664
665 if ( ! empty( $message ) ) {
666 wp_admin_notice(
667 $message,
668 array( 'type' => $notice_type )
669 );
670 }
671 }
672
673
674 add_filter( 'plugin_action_links', 'wpcf7_plugin_action_links', 10, 2 );
675
676 function wpcf7_plugin_action_links( $links, $file ) {
677 if ( WPCF7_PLUGIN_BASENAME !== $file ) {
678 return $links;
679 }
680
681 if ( ! current_user_can( 'wpcf7_read_contact_forms' ) ) {
682 return $links;
683 }
684
685 $settings_link = wpcf7_link(
686 menu_page_url( 'wpcf7', false ),
687 __( 'Settings', 'contact-form-7' )
688 );
689
690 array_unshift( $links, $settings_link );
691
692 return $links;
693 }
694
695
696 add_action( 'wpcf7_admin_warnings', 'wpcf7_old_wp_version_error', 10, 3 );
697
698 function wpcf7_old_wp_version_error( $page, $action, $object ) {
699 $wp_version = get_bloginfo( 'version' );
700
701 if ( version_compare( $wp_version, WPCF7_REQUIRED_WP_VERSION, '<' ) ) {
702 wp_admin_notice(
703 sprintf(
704 /* translators: 1: version of Contact Form 7, 2: version of WordPress, 3: URL */
705 __( '<strong>Contact Form 7 %1$s requires WordPress %2$s or higher.</strong> Please <a href="%3$s">update WordPress</a> first.', 'contact-form-7' ),
706 WPCF7_VERSION,
707 WPCF7_REQUIRED_WP_VERSION,
708 admin_url( 'update-core.php' )
709 ),
710 array( 'type' => 'warning' )
711 );
712 }
713 }
714
715
716 add_action( 'wpcf7_admin_warnings', 'wpcf7_not_allowed_to_edit', 10, 3 );
717
718 function wpcf7_not_allowed_to_edit( $page, $action, $object ) {
719 if ( $object instanceof WPCF7_ContactForm ) {
720 $contact_form = $object;
721 } else {
722 return;
723 }
724
725 if ( ! current_user_can( 'wpcf7_edit_contact_form', $contact_form->id() ) ) {
726 wp_admin_notice(
727 __( 'You are not allowed to edit this contact form.', 'contact-form-7' ),
728 array( 'type' => 'warning' )
729 );
730 }
731 }
732
733
734 add_action( 'wpcf7_admin_warnings', 'wpcf7_ctct_deprecated_warning', 10, 3 );
735
736 function wpcf7_ctct_deprecated_warning( $page, $action, $object ) {
737 $service = WPCF7_ConstantContact::get_instance();
738
739 if ( $service->is_active() ) {
740 wp_admin_notice(
741 __( 'Contact Form 7 has completed the <a href="https://contactform7.com/2025/01/08/complete-removal-of-constant-contact-integration/">removal of the Constant Contact integration</a>. We recommend <a href="https://contactform7.com/sendinblue-integration/">Brevo</a> as an alternative.', 'contact-form-7' ),
742 array( 'type' => 'warning' )
743 );
744 }
745 }
746
747
748 add_action( 'wpcf7_admin_warnings', 'wpcf7_captcha_future_warning', 10, 3 );
749
750 function wpcf7_captcha_future_warning( $page, $action, $object ) {
751 $service = WPCF7_RECAPTCHA::get_instance();
752
753 if ( $service->is_active() ) {
754 wp_admin_notice(
755 __( '<strong>Attention reCAPTCHA users:</strong> Google attempts to make all reCAPTCHA users migrate to reCAPTCHA Enterprise, meaning Google charges you for API calls exceeding the free tier. Contact Form 7 supports <a href="https://contactform7.com/turnstile-integration/">Cloudflare Turnstile</a>, and we recommend it unless you have reasons to use reCAPTCHA.', 'contact-form-7' ),
756 array( 'type' => 'warning' )
757 );
758 }
759 }
760