'validate' ), menu_page_url( 'wpcf7', false ) ), __( 'Validate Contact Form 7 Configuration', 'contact-form-7' ) ); $message = __( "Misconfiguration leads to mail delivery failure or other troubles. Validate your contact forms now.", 'contact-form-7' ); echo sprintf( '

%1$s » %2$s

', esc_html( $message ), $link ); } add_action( 'wpcf7_admin_load', 'wpcf7_load_bulk_validate_page', 10, 2 ); function wpcf7_load_bulk_validate_page( $page, $action ) { if ( 'wpcf7' != $page or 'validate' != $action or ! wpcf7_validate_configuration() or 'POST' != $_SERVER['REQUEST_METHOD'] ) { return; } check_admin_referer( 'wpcf7-bulk-validate' ); if ( ! current_user_can( 'wpcf7_edit_contact_forms' ) ) { wp_die( __( "You are not allowed to validate configuration.", 'contact-form-7' ) ); } $contact_forms = WPCF7_ContactForm::find(); $result = array( 'timestamp' => time(), 'version' => WPCF7_VERSION, 'count_valid' => 0, 'count_invalid' => 0, ); foreach ( $contact_forms as $contact_form ) { $config_validator = new WPCF7_ConfigValidator( $contact_form ); $config_validator->validate(); $config_validator->save(); if ( $config_validator->is_valid() ) { $result['count_valid'] += 1; } else { $result['count_invalid'] += 1; } } WPCF7::update_option( 'bulk_validate', $result ); $redirect_to = add_query_arg( array( 'message' => 'validated', ), menu_page_url( 'wpcf7', false ) ); wp_safe_redirect( $redirect_to ); exit(); } function wpcf7_admin_bulk_validate_page() { $contact_forms = WPCF7_ContactForm::find(); $count = WPCF7_ContactForm::count(); $submit_text = sprintf( _n( /* translators: %s: number of contact forms */ "Validate %s contact form now", "Validate %s contact forms now", $count, 'contact-form-7' ), number_format_i18n( $count ) ); ?>