PluginProbe ʕ •ᴥ•ʔ
Contact Form 7 / 5.1.8
Contact Form 7 v5.1.8
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
css 7 years ago includes 6 years ago js 7 years ago admin.php 6 years ago edit-contact-form.php 6 years ago
admin.php
612 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 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;
177 }
178
179 return $result;
180 }
181
182 function wpcf7_load_contact_form_admin() {
183 global $plugin_page;
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 );
195
196 if ( ! current_user_can( 'wpcf7_edit_contact_form', $id ) ) {
197 wp_die( __( 'You are not allowed to edit this item.', 'contact-form-7' ) );
198 }
199
200 $args = $_REQUEST;
201 $args['id'] = $id;
202
203 $args['title'] = isset( $_POST['post_title'] )
204 ? $_POST['post_title'] : null;
205
206 $args['locale'] = isset( $_POST['wpcf7-locale'] )
207 ? $_POST['wpcf7-locale'] : null;
208
209 $args['form'] = isset( $_POST['wpcf7-form'] )
210 ? $_POST['wpcf7-form'] : '';
211
212 $args['mail'] = isset( $_POST['wpcf7-mail'] )
213 ? $_POST['wpcf7-mail'] : array();
214
215 $args['mail_2'] = isset( $_POST['wpcf7-mail-2'] )
216 ? $_POST['wpcf7-mail-2'] : array();
217
218 $args['messages'] = isset( $_POST['wpcf7-messages'] )
219 ? $_POST['wpcf7-messages'] : array();
220
221 $args['additional_settings'] = isset( $_POST['wpcf7-additional-settings'] )
222 ? $_POST['wpcf7-additional-settings'] : '';
223
224 $contact_form = wpcf7_save_contact_form( $args );
225
226 if ( $contact_form and wpcf7_validate_configuration() ) {
227 $config_validator = new WPCF7_ConfigValidator( $contact_form );
228 $config_validator->validate();
229 $config_validator->save();
230 }
231
232 $query = array(
233 'post' => $contact_form ? $contact_form->id() : 0,
234 'active-tab' => isset( $_POST['active-tab'] )
235 ? (int) $_POST['active-tab'] : 0,
236 );
237
238 if ( ! $contact_form ) {
239 $query['message'] = 'failed';
240 } elseif ( -1 == $id ) {
241 $query['message'] = 'created';
242 } else {
243 $query['message'] = 'saved';
244 }
245
246 $redirect_to = add_query_arg( $query, menu_page_url( 'wpcf7', false ) );
247 wp_safe_redirect( $redirect_to );
248 exit();
249 }
250
251 if ( 'copy' == $action ) {
252 $id = empty( $_POST['post_ID'] )
253 ? absint( $_REQUEST['post'] )
254 : absint( $_POST['post_ID'] );
255
256 check_admin_referer( 'wpcf7-copy-contact-form_' . $id );
257
258 if ( ! current_user_can( 'wpcf7_edit_contact_form', $id ) ) {
259 wp_die( __( 'You are not allowed to edit this item.', 'contact-form-7' ) );
260 }
261
262 $query = array();
263
264 if ( $contact_form = wpcf7_contact_form( $id ) ) {
265 $new_contact_form = $contact_form->copy();
266 $new_contact_form->save();
267
268 $query['post'] = $new_contact_form->id();
269 $query['message'] = 'created';
270 }
271
272 $redirect_to = add_query_arg( $query, menu_page_url( 'wpcf7', false ) );
273
274 wp_safe_redirect( $redirect_to );
275 exit();
276 }
277
278 if ( 'delete' == $action ) {
279 if ( ! empty( $_POST['post_ID'] ) ) {
280 check_admin_referer( 'wpcf7-delete-contact-form_' . $_POST['post_ID'] );
281 } elseif ( ! is_array( $_REQUEST['post'] ) ) {
282 check_admin_referer( 'wpcf7-delete-contact-form_' . $_REQUEST['post'] );
283 } else {
284 check_admin_referer( 'bulk-posts' );
285 }
286
287 $posts = empty( $_POST['post_ID'] )
288 ? (array) $_REQUEST['post']
289 : (array) $_POST['post_ID'];
290
291 $deleted = 0;
292
293 foreach ( $posts as $post ) {
294 $post = WPCF7_ContactForm::get_instance( $post );
295
296 if ( empty( $post ) ) {
297 continue;
298 }
299
300 if ( ! current_user_can( 'wpcf7_delete_contact_form', $post->id() ) ) {
301 wp_die( __( 'You are not allowed to delete this item.', 'contact-form-7' ) );
302 }
303
304 if ( ! $post->delete() ) {
305 wp_die( __( 'Error in deleting.', 'contact-form-7' ) );
306 }
307
308 $deleted += 1;
309 }
310
311 $query = array();
312
313 if ( ! empty( $deleted ) ) {
314 $query['message'] = 'deleted';
315 }
316
317 $redirect_to = add_query_arg( $query, menu_page_url( 'wpcf7', false ) );
318
319 wp_safe_redirect( $redirect_to );
320 exit();
321 }
322
323 $post = null;
324
325 if ( 'wpcf7-new' == $plugin_page ) {
326 $post = WPCF7_ContactForm::get_template( array(
327 'locale' => isset( $_GET['locale'] ) ? $_GET['locale'] : null,
328 ) );
329 } elseif ( ! empty( $_GET['post'] ) ) {
330 $post = WPCF7_ContactForm::get_instance( $_GET['post'] );
331 }
332
333 $current_screen = get_current_screen();
334
335 $help_tabs = new WPCF7_Help_Tabs( $current_screen );
336
337 if ( $post
338 and current_user_can( 'wpcf7_edit_contact_form', $post->id() ) ) {
339 $help_tabs->set_help_tabs( 'edit' );
340 } else {
341 $help_tabs->set_help_tabs( 'list' );
342
343 if ( ! class_exists( 'WPCF7_Contact_Form_List_Table' ) ) {
344 require_once WPCF7_PLUGIN_DIR . '/admin/includes/class-contact-forms-list-table.php';
345 }
346
347 add_filter( 'manage_' . $current_screen->id . '_columns',
348 array( 'WPCF7_Contact_Form_List_Table', 'define_columns' ), 10, 0 );
349
350 add_screen_option( 'per_page', array(
351 'default' => 20,
352 'option' => 'cfseven_contact_forms_per_page',
353 ) );
354 }
355 }
356
357 function wpcf7_admin_management_page() {
358 if ( $post = wpcf7_get_current_contact_form() ) {
359 $post_id = $post->initial() ? -1 : $post->id();
360
361 require_once WPCF7_PLUGIN_DIR . '/admin/includes/editor.php';
362 require_once WPCF7_PLUGIN_DIR . '/admin/edit-contact-form.php';
363 return;
364 }
365
366 if ( 'validate' == wpcf7_current_action()
367 and wpcf7_validate_configuration()
368 and current_user_can( 'wpcf7_edit_contact_forms' ) ) {
369 wpcf7_admin_bulk_validate_page();
370 return;
371 }
372
373 $list_table = new WPCF7_Contact_Form_List_Table();
374 $list_table->prepare_items();
375
376 ?>
377 <div class="wrap" id="wpcf7-contact-form-list-table">
378
379 <h1 class="wp-heading-inline"><?php
380 echo esc_html( __( 'Contact Forms', 'contact-form-7' ) );
381 ?></h1>
382
383 <?php
384 if ( current_user_can( 'wpcf7_edit_contact_forms' ) ) {
385 echo wpcf7_link(
386 menu_page_url( 'wpcf7-new', false ),
387 __( 'Add New', 'contact-form-7' ),
388 array( 'class' => 'page-title-action' )
389 );
390 }
391
392 if ( ! empty( $_REQUEST['s'] ) ) {
393 echo sprintf( '<span class="subtitle">'
394 /* translators: %s: search keywords */
395 . __( 'Search results for &#8220;%s&#8221;', 'contact-form-7' )
396 . '</span>', esc_html( $_REQUEST['s'] )
397 );
398 }
399 ?>
400
401 <hr class="wp-header-end">
402
403 <?php
404 do_action( 'wpcf7_admin_warnings',
405 'wpcf7', wpcf7_current_action(), null );
406
407 wpcf7_welcome_panel();
408
409 do_action( 'wpcf7_admin_notices',
410 'wpcf7', wpcf7_current_action(), null );
411 ?>
412
413 <form method="get" action="">
414 <input type="hidden" name="page" value="<?php echo esc_attr( $_REQUEST['page'] ); ?>" />
415 <?php $list_table->search_box( __( 'Search Contact Forms', 'contact-form-7' ), 'wpcf7-contact' ); ?>
416 <?php $list_table->display(); ?>
417 </form>
418
419 </div>
420 <?php
421 }
422
423 function wpcf7_admin_add_new_page() {
424 $post = wpcf7_get_current_contact_form();
425
426 if ( ! $post ) {
427 $post = WPCF7_ContactForm::get_template();
428 }
429
430 $post_id = -1;
431
432 require_once WPCF7_PLUGIN_DIR . '/admin/includes/editor.php';
433 require_once WPCF7_PLUGIN_DIR . '/admin/edit-contact-form.php';
434 }
435
436 function wpcf7_load_integration_page() {
437 do_action( 'wpcf7_admin_load',
438 isset( $_GET['page'] ) ? trim( $_GET['page'] ) : '',
439 wpcf7_current_action()
440 );
441
442 $integration = WPCF7_Integration::get_instance();
443
444 if ( isset( $_REQUEST['service'] )
445 and $integration->service_exists( $_REQUEST['service'] ) ) {
446 $service = $integration->get_service( $_REQUEST['service'] );
447 $service->load( wpcf7_current_action() );
448 }
449
450 $help_tabs = new WPCF7_Help_Tabs( get_current_screen() );
451 $help_tabs->set_help_tabs( 'integration' );
452 }
453
454 function wpcf7_admin_integration_page() {
455 $integration = WPCF7_Integration::get_instance();
456
457 $service = isset( $_REQUEST['service'] )
458 ? $integration->get_service( $_REQUEST['service'] )
459 : null;
460
461 ?>
462 <div class="wrap" id="wpcf7-integration">
463
464 <h1><?php echo esc_html( __( 'Integration with Other Services', 'contact-form-7' ) ); ?></h1>
465
466 <?php
467 do_action( 'wpcf7_admin_warnings',
468 'wpcf7-integration', wpcf7_current_action(), $service );
469
470 do_action( 'wpcf7_admin_notices',
471 'wpcf7-integration', wpcf7_current_action(), $service );
472
473 if ( $service ) {
474 $message = isset( $_REQUEST['message'] ) ? $_REQUEST['message'] : '';
475 $service->admin_notice( $message );
476 $integration->list_services( array( 'include' => $_REQUEST['service'] ) );
477 } else {
478 $integration->list_services();
479 }
480 ?>
481
482 </div>
483 <?php
484 }
485
486 /* Misc */
487
488 add_action( 'wpcf7_admin_notices', 'wpcf7_admin_updated_message', 10, 3 );
489
490 function wpcf7_admin_updated_message( $page, $action, $object ) {
491 if ( ! in_array( $page, array( 'wpcf7', 'wpcf7-new' ) ) ) {
492 return;
493 }
494
495 if ( empty( $_REQUEST['message'] ) ) {
496 return;
497 }
498
499 if ( 'created' == $_REQUEST['message'] ) {
500 $updated_message = __( "Contact form created.", 'contact-form-7' );
501 } elseif ( 'saved' == $_REQUEST['message'] ) {
502 $updated_message = __( "Contact form saved.", 'contact-form-7' );
503 } elseif ( 'deleted' == $_REQUEST['message'] ) {
504 $updated_message = __( "Contact form deleted.", 'contact-form-7' );
505 }
506
507 if ( ! empty( $updated_message ) ) {
508 echo sprintf( '<div id="message" class="notice notice-success is-dismissible"><p>%s</p></div>', esc_html( $updated_message ) );
509 return;
510 }
511
512 if ( 'failed' == $_REQUEST['message'] ) {
513 $updated_message = __( "There was an error saving the contact form.",
514 'contact-form-7' );
515
516 echo sprintf( '<div id="message" class="notice notice-error is-dismissible"><p>%s</p></div>', esc_html( $updated_message ) );
517 return;
518 }
519
520 if ( 'validated' == $_REQUEST['message'] ) {
521 $bulk_validate = WPCF7::get_option( 'bulk_validate', array() );
522 $count_invalid = isset( $bulk_validate['count_invalid'] )
523 ? absint( $bulk_validate['count_invalid'] ) : 0;
524
525 if ( $count_invalid ) {
526 $updated_message = sprintf(
527 _n(
528 /* translators: %s: number of contact forms */
529 "Configuration validation completed. %s invalid contact form was found.",
530 "Configuration validation completed. %s invalid contact forms were found.",
531 $count_invalid, 'contact-form-7'
532 ),
533 number_format_i18n( $count_invalid )
534 );
535
536 echo sprintf( '<div id="message" class="notice notice-warning is-dismissible"><p>%s</p></div>', esc_html( $updated_message ) );
537 } else {
538 $updated_message = __( "Configuration validation completed. No invalid contact form was found.", 'contact-form-7' );
539
540 echo sprintf( '<div id="message" class="notice notice-success is-dismissible"><p>%s</p></div>', esc_html( $updated_message ) );
541 }
542
543 return;
544 }
545 }
546
547 add_filter( 'plugin_action_links', 'wpcf7_plugin_action_links', 10, 2 );
548
549 function wpcf7_plugin_action_links( $links, $file ) {
550 if ( $file != WPCF7_PLUGIN_BASENAME ) {
551 return $links;
552 }
553
554 if ( ! current_user_can( 'wpcf7_read_contact_forms' ) ) {
555 return $links;
556 }
557
558 $settings_link = wpcf7_link(
559 menu_page_url( 'wpcf7', false ),
560 __( 'Settings', 'contact-form-7' )
561 );
562
563 array_unshift( $links, $settings_link );
564
565 return $links;
566 }
567
568 add_action( 'wpcf7_admin_warnings', 'wpcf7_old_wp_version_error', 10, 3 );
569
570 function wpcf7_old_wp_version_error( $page, $action, $object ) {
571 $wp_version = get_bloginfo( 'version' );
572
573 if ( ! version_compare( $wp_version, WPCF7_REQUIRED_WP_VERSION, '<' ) ) {
574 return;
575 }
576
577 ?>
578 <div class="notice notice-warning">
579 <p><?php
580 echo sprintf(
581 /* translators: 1: version of Contact Form 7, 2: version of WordPress, 3: URL */
582 __( '<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' ),
583 WPCF7_VERSION,
584 WPCF7_REQUIRED_WP_VERSION,
585 admin_url( 'update-core.php' )
586 );
587 ?></p>
588 </div>
589 <?php
590 }
591
592 add_action( 'wpcf7_admin_warnings', 'wpcf7_not_allowed_to_edit', 10, 3 );
593
594 function wpcf7_not_allowed_to_edit( $page, $action, $object ) {
595 if ( $object instanceof WPCF7_ContactForm ) {
596 $contact_form = $object;
597 } else {
598 return;
599 }
600
601 if ( current_user_can( 'wpcf7_edit_contact_form', $contact_form->id() ) ) {
602 return;
603 }
604
605 $message = __( "You are not allowed to edit this contact form.",
606 'contact-form-7' );
607
608 echo sprintf(
609 '<div class="notice notice-warning"><p>%s</p></div>',
610 esc_html( $message ) );
611 }
612