8889841creadme.txt000064400000011362150515101440006541 0ustar00=== Contact Form 7 === Contributors: takayukister Donate link: https://contactform7.com/donate/ Tags: contact, form, contact form, feedback, email, ajax, captcha, akismet, multilingual Requires at least: 6.2 Requires PHP: 7.4 Tested up to: 6.3 Stable tag: 5.8 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html Just another contact form plugin. Simple but flexible. == Description == Contact Form 7 can manage multiple contact forms, plus you can customize the form and the mail contents flexibly with simple markup. The form supports Ajax-powered submitting, CAPTCHA, Akismet spam filtering and so on. = Docs and support = You can find [docs](https://contactform7.com/docs/), [FAQ](https://contactform7.com/faq/) and more detailed information about Contact Form 7 on [contactform7.com](https://contactform7.com/). When you cannot find the answer to your question on the FAQ or in any of the documentation, check the [support forum](https://wordpress.org/support/plugin/contact-form-7/) on WordPress.org. If you cannot locate any topics that pertain to your particular issue, post a new topic for it. = Contact Form 7 needs your support = It is hard to continue development and support for this free plugin without contributions from users like you. If you enjoy using Contact Form 7 and find it useful, please consider [making a donation](https://contactform7.com/donate/). Your donation will help encourage and support the plugin's continued development and better user support. = Privacy notices = With the default configuration, this plugin, in itself, does not: * track users by stealth; * write any user personal data to the database; * send any data to external servers; * use cookies. If you activate certain features in this plugin, the contact form submitter's personal data, including their IP address, may be sent to the service provider. Thus, confirming the provider's privacy policy is recommended. These features include: * reCAPTCHA ([Google](https://policies.google.com/?hl=en)) * Akismet ([Automattic](https://automattic.com/privacy/)) * Constant Contact ([Endurance International Group](https://www.endurance.com/privacy)) * [Brevo (formerly Sendinblue)](https://www.brevo.com/legal/privacypolicy/) * [Stripe](https://stripe.com/privacy) = Recommended plugins = The following plugins are recommended for Contact Form 7 users: * [Flamingo](https://wordpress.org/plugins/flamingo/) by Takayuki Miyoshi - With Flamingo, you can save submitted messages via contact forms in the database. * [Bogo](https://wordpress.org/plugins/bogo/) by Takayuki Miyoshi - Bogo is a straight-forward multilingual plugin that does not cause headaches. = Translations = You can [translate Contact Form 7](https://contactform7.com/translating-contact-form-7/) on [translate.wordpress.org](https://translate.wordpress.org/projects/wp-plugins/contact-form-7). == Installation == 1. Upload the entire `contact-form-7` folder to the `/wp-content/plugins/` directory. 1. Activate the plugin through the **Plugins** screen (**Plugins > Installed Plugins**). You will find **Contact** menu in your WordPress admin screen. For basic usage, have a look at the [plugin's website](https://contactform7.com/). == Frequently Asked Questions == Do you have questions or issues with Contact Form 7? Use these support channels appropriately. 1. [Docs](https://contactform7.com/docs/) 1. [FAQ](https://contactform7.com/faq/) 1. [Support forum](https://wordpress.org/support/plugin/contact-form-7/) [Support](https://contactform7.com/support/) == Screenshots == 1. screenshot-1.png == Changelog == For more information, see [Releases](https://contactform7.com/category/releases/). = 5.8 = [https://contactform7.com/contact-form-7-58/](https://contactform7.com/contact-form-7-58/) = 5.7.7 = [https://contactform7.com/contact-form-7-577/](https://contactform7.com/contact-form-7-577/) = 5.7.6 = [https://contactform7.com/contact-form-7-576/](https://contactform7.com/contact-form-7-576/) = 5.7.5.1 = * Fixes an old PHP compatibility issue. = 5.7.5 = [https://contactform7.com/contact-form-7-575/](https://contactform7.com/contact-form-7-575/) = 5.7.4 = [https://contactform7.com/contact-form-7-574/](https://contactform7.com/contact-form-7-574/) = 5.7.3 = [https://contactform7.com/contact-form-7-573/](https://contactform7.com/contact-form-7-573/) = 5.7.2 = [https://contactform7.com/contact-form-7-572/](https://contactform7.com/contact-form-7-572/) = 5.7.1 = [https://contactform7.com/contact-form-7-571/](https://contactform7.com/contact-form-7-571/) = 5.7 = [https://contactform7.com/contact-form-7-57/](https://contactform7.com/contact-form-7-57/) == Upgrade Notice == admin/admin.php000064400000042664150515101440007445 0ustar00service_exists() ) { $integration = add_submenu_page( 'wpcf7', __( 'Integration with External API', 'contact-form-7' ), __( 'Integration', 'contact-form-7' ) . wpcf7_admin_menu_change_notice( 'wpcf7-integration' ), 'wpcf7_manage_integration', 'wpcf7-integration', 'wpcf7_admin_integration_page' ); add_action( 'load-' . $integration, 'wpcf7_load_integration_page', 10, 0 ); } } function wpcf7_admin_menu_change_notice( $menu_slug = '' ) { $counts = apply_filters( 'wpcf7_admin_menu_change_notice', array( 'wpcf7' => 0, 'wpcf7-new' => 0, 'wpcf7-integration' => 0, ) ); if ( empty( $menu_slug ) ) { $count = absint( array_sum( $counts ) ); } elseif ( isset( $counts[$menu_slug] ) ) { $count = absint( $counts[$menu_slug] ); } else { $count = 0; } if ( $count ) { return sprintf( ' %2$s', $count, esc_html( number_format_i18n( $count ) ) ); } return ''; } add_action( 'admin_enqueue_scripts', 'wpcf7_admin_enqueue_scripts', 10, 1 ); function wpcf7_admin_enqueue_scripts( $hook_suffix ) { if ( false === strpos( $hook_suffix, 'wpcf7' ) ) { return; } wp_enqueue_style( 'contact-form-7-admin', wpcf7_plugin_url( 'admin/css/styles.css' ), array(), WPCF7_VERSION, 'all' ); if ( wpcf7_is_rtl() ) { wp_enqueue_style( 'contact-form-7-admin-rtl', wpcf7_plugin_url( 'admin/css/styles-rtl.css' ), array(), WPCF7_VERSION, 'all' ); } wp_enqueue_script( 'wpcf7-admin', wpcf7_plugin_url( 'admin/js/scripts.js' ), array( 'jquery', 'jquery-ui-tabs' ), WPCF7_VERSION, true ); $args = array( 'apiSettings' => array( 'root' => sanitize_url( rest_url( 'contact-form-7/v1' ) ), 'namespace' => 'contact-form-7/v1', 'nonce' => ( wp_installing() && ! is_multisite() ) ? '' : wp_create_nonce( 'wp_rest' ), ), 'pluginUrl' => wpcf7_plugin_url(), 'saveAlert' => __( "The changes you made will be lost if you navigate away from this page.", 'contact-form-7' ), 'activeTab' => isset( $_GET['active-tab'] ) ? (int) $_GET['active-tab'] : 0, 'configValidator' => array( 'errors' => array(), 'howToCorrect' => __( "How to resolve?", 'contact-form-7' ), 'oneError' => __( '1 configuration error detected', 'contact-form-7' ), 'manyErrors' => __( '%d configuration errors detected', 'contact-form-7' ), 'oneErrorInTab' => __( '1 configuration error detected in this tab panel', 'contact-form-7' ), 'manyErrorsInTab' => __( '%d configuration errors detected in this tab panel', 'contact-form-7' ), 'docUrl' => WPCF7_ConfigValidator::get_doc_link(), /* translators: screen reader text */ 'iconAlt' => __( '(configuration error)', 'contact-form-7' ), ), ); if ( $post = wpcf7_get_current_contact_form() and current_user_can( 'wpcf7_edit_contact_form', $post->id() ) and wpcf7_validate_configuration() ) { $config_validator = new WPCF7_ConfigValidator( $post ); $config_validator->restore(); $args['configValidator']['errors'] = $config_validator->collect_error_messages(); } wp_localize_script( 'wpcf7-admin', 'wpcf7', $args ); add_thickbox(); wp_enqueue_script( 'wpcf7-admin-taggenerator', wpcf7_plugin_url( 'admin/js/tag-generator.js' ), array( 'jquery', 'thickbox', 'wpcf7-admin' ), WPCF7_VERSION, true ); } add_filter( 'set_screen_option_wpcf7_contact_forms_per_page', static function ( $result, $option, $value ) { $wpcf7_screens = array( 'wpcf7_contact_forms_per_page', ); if ( in_array( $option, $wpcf7_screens ) ) { $result = $value; } return $result; }, 10, 3 ); function wpcf7_load_contact_form_admin() { global $plugin_page; $action = wpcf7_current_action(); do_action( 'wpcf7_admin_load', isset( $_GET['page'] ) ? trim( $_GET['page'] ) : '', $action ); if ( 'save' == $action ) { $id = isset( $_POST['post_ID'] ) ? $_POST['post_ID'] : '-1'; check_admin_referer( 'wpcf7-save-contact-form_' . $id ); if ( ! current_user_can( 'wpcf7_edit_contact_form', $id ) ) { wp_die( __( "You are not allowed to edit this item.", 'contact-form-7' ) ); } $args = $_REQUEST; $args['id'] = $id; $args['title'] = isset( $_POST['post_title'] ) ? $_POST['post_title'] : null; $args['locale'] = isset( $_POST['wpcf7-locale'] ) ? $_POST['wpcf7-locale'] : null; $args['form'] = isset( $_POST['wpcf7-form'] ) ? $_POST['wpcf7-form'] : ''; $args['mail'] = isset( $_POST['wpcf7-mail'] ) ? $_POST['wpcf7-mail'] : array(); $args['mail_2'] = isset( $_POST['wpcf7-mail-2'] ) ? $_POST['wpcf7-mail-2'] : array(); $args['messages'] = isset( $_POST['wpcf7-messages'] ) ? $_POST['wpcf7-messages'] : array(); $args['additional_settings'] = isset( $_POST['wpcf7-additional-settings'] ) ? $_POST['wpcf7-additional-settings'] : ''; $contact_form = wpcf7_save_contact_form( $args ); if ( $contact_form and wpcf7_validate_configuration() ) { $config_validator = new WPCF7_ConfigValidator( $contact_form ); $config_validator->validate(); $config_validator->save(); } $query = array( 'post' => $contact_form ? $contact_form->id() : 0, 'active-tab' => isset( $_POST['active-tab'] ) ? (int) $_POST['active-tab'] : 0, ); if ( ! $contact_form ) { $query['message'] = 'failed'; } elseif ( -1 == $id ) { $query['message'] = 'created'; } else { $query['message'] = 'saved'; } $redirect_to = add_query_arg( $query, menu_page_url( 'wpcf7', false ) ); wp_safe_redirect( $redirect_to ); exit(); } if ( 'copy' == $action ) { $id = empty( $_POST['post_ID'] ) ? absint( $_REQUEST['post'] ) : absint( $_POST['post_ID'] ); check_admin_referer( 'wpcf7-copy-contact-form_' . $id ); if ( ! current_user_can( 'wpcf7_edit_contact_form', $id ) ) { wp_die( __( "You are not allowed to edit this item.", 'contact-form-7' ) ); } $query = array(); if ( $contact_form = wpcf7_contact_form( $id ) ) { $new_contact_form = $contact_form->copy(); $new_contact_form->save(); $query['post'] = $new_contact_form->id(); $query['message'] = 'created'; } $redirect_to = add_query_arg( $query, menu_page_url( 'wpcf7', false ) ); wp_safe_redirect( $redirect_to ); exit(); } if ( 'delete' == $action ) { if ( ! empty( $_POST['post_ID'] ) ) { check_admin_referer( 'wpcf7-delete-contact-form_' . $_POST['post_ID'] ); } elseif ( ! is_array( $_REQUEST['post'] ) ) { check_admin_referer( 'wpcf7-delete-contact-form_' . $_REQUEST['post'] ); } else { check_admin_referer( 'bulk-posts' ); } $posts = empty( $_POST['post_ID'] ) ? (array) $_REQUEST['post'] : (array) $_POST['post_ID']; $deleted = 0; foreach ( $posts as $post ) { $post = WPCF7_ContactForm::get_instance( $post ); if ( empty( $post ) ) { continue; } if ( ! current_user_can( 'wpcf7_delete_contact_form', $post->id() ) ) { wp_die( __( "You are not allowed to delete this item.", 'contact-form-7' ) ); } if ( ! $post->delete() ) { wp_die( __( "Error in deleting.", 'contact-form-7' ) ); } $deleted += 1; } $query = array(); if ( ! empty( $deleted ) ) { $query['message'] = 'deleted'; } $redirect_to = add_query_arg( $query, menu_page_url( 'wpcf7', false ) ); wp_safe_redirect( $redirect_to ); exit(); } $post = null; if ( 'wpcf7-new' == $plugin_page ) { $post = WPCF7_ContactForm::get_template( array( 'locale' => isset( $_GET['locale'] ) ? $_GET['locale'] : null, ) ); } elseif ( ! empty( $_GET['post'] ) ) { $post = WPCF7_ContactForm::get_instance( $_GET['post'] ); } $current_screen = get_current_screen(); $help_tabs = new WPCF7_Help_Tabs( $current_screen ); if ( $post and current_user_can( 'wpcf7_edit_contact_form', $post->id() ) ) { $help_tabs->set_help_tabs( 'edit' ); } else { $help_tabs->set_help_tabs( 'list' ); if ( ! class_exists( 'WPCF7_Contact_Form_List_Table' ) ) { require_once WPCF7_PLUGIN_DIR . '/admin/includes/class-contact-forms-list-table.php'; } add_filter( 'manage_' . $current_screen->id . '_columns', array( 'WPCF7_Contact_Form_List_Table', 'define_columns' ), 10, 0 ); add_screen_option( 'per_page', array( 'default' => 20, 'option' => 'wpcf7_contact_forms_per_page', ) ); } } function wpcf7_admin_management_page() { if ( $post = wpcf7_get_current_contact_form() ) { $post_id = $post->initial() ? -1 : $post->id(); require_once WPCF7_PLUGIN_DIR . '/admin/includes/editor.php'; require_once WPCF7_PLUGIN_DIR . '/admin/edit-contact-form.php'; return; } if ( 'validate' == wpcf7_current_action() and wpcf7_validate_configuration() and current_user_can( 'wpcf7_edit_contact_forms' ) ) { wpcf7_admin_bulk_validate_page(); return; } $list_table = new WPCF7_Contact_Form_List_Table(); $list_table->prepare_items(); ?>

'page-title-action' ) ); } if ( ! empty( $_REQUEST['s'] ) ) { echo sprintf( '' /* translators: %s: search keywords */ . __( 'Search results for “%s”', 'contact-form-7' ) . '', esc_html( $_REQUEST['s'] ) ); } ?>
search_box( __( 'Search Contact Forms', 'contact-form-7' ), 'wpcf7-contact' ); ?> display(); ?>
service_exists( $_REQUEST['service'] ) ) { $service = $integration->get_service( $_REQUEST['service'] ); $service->load( wpcf7_current_action() ); } $help_tabs = new WPCF7_Help_Tabs( get_current_screen() ); $help_tabs->set_help_tabs( 'integration' ); } function wpcf7_admin_integration_page() { $integration = WPCF7_Integration::get_instance(); $service = isset( $_REQUEST['service'] ) ? $integration->get_service( $_REQUEST['service'] ) : null; ?>

admin_notice( $message ); $integration->list_services( array( 'include' => $_REQUEST['service'], ) ); } else { $integration->list_services(); } ?>

%s

', esc_html( $updated_message ) ); return; } if ( 'failed' == $_REQUEST['message'] ) { $updated_message = __( "There was an error saving the contact form.", 'contact-form-7' ); echo sprintf( '

%s

', esc_html( $updated_message ) ); return; } if ( 'validated' == $_REQUEST['message'] ) { $bulk_validate = WPCF7::get_option( 'bulk_validate', array() ); $count_invalid = isset( $bulk_validate['count_invalid'] ) ? absint( $bulk_validate['count_invalid'] ) : 0; if ( $count_invalid ) { $updated_message = sprintf( _n( /* translators: %s: number of contact forms */ "Configuration validation completed. %s invalid contact form was found.", "Configuration validation completed. %s invalid contact forms were found.", $count_invalid, 'contact-form-7' ), number_format_i18n( $count_invalid ) ); echo sprintf( '

%s

', esc_html( $updated_message ) ); } else { $updated_message = __( "Configuration validation completed. No invalid contact form was found.", 'contact-form-7' ); echo sprintf( '

%s

', esc_html( $updated_message ) ); } return; } } add_filter( 'plugin_action_links', 'wpcf7_plugin_action_links', 10, 2 ); function wpcf7_plugin_action_links( $links, $file ) { if ( $file != WPCF7_PLUGIN_BASENAME ) { return $links; } if ( ! current_user_can( 'wpcf7_read_contact_forms' ) ) { return $links; } $settings_link = wpcf7_link( menu_page_url( 'wpcf7', false ), __( 'Settings', 'contact-form-7' ) ); array_unshift( $links, $settings_link ); return $links; } add_action( 'wpcf7_admin_warnings', 'wpcf7_old_wp_version_error', 10, 3 ); function wpcf7_old_wp_version_error( $page, $action, $object ) { $wp_version = get_bloginfo( 'version' ); if ( ! version_compare( $wp_version, WPCF7_REQUIRED_WP_VERSION, '<' ) ) { return; } ?>

Contact Form 7 %1$s requires WordPress %2$s or higher. Please update WordPress first.', 'contact-form-7' ), WPCF7_VERSION, WPCF7_REQUIRED_WP_VERSION, admin_url( 'update-core.php' ) ); ?>

id() ) ) { return; } $message = __( "You are not allowed to edit this contact form.", 'contact-form-7' ); echo sprintf( '

%s

', esc_html( $message ) ); } add_action( 'wpcf7_admin_warnings', 'wpcf7_outdated_php_warning', 10, 3 ); function wpcf7_outdated_php_warning( $page, $action, $object ) { if ( ! version_compare( PHP_VERSION, '7.4', '<' ) ) { return; } $message = __( "The next major release of Contact Form 7 will discontinue support for outdated PHP versions. If you don't upgrade PHP, you will not be able to upgrade the plugin.", 'contact-form-7' ); echo sprintf( '

%s

', esc_html( $message ) ); } admin/css/styles.css000064400000021020150515101440010450 0ustar00#titlediv .inside p.description { margin: 8px 2px 0; } #titlediv .inside p.description label { cursor: pointer; } span.shortcode { display: block; margin: 2px 0; } span.shortcode.old { background: #777; color: #fff; } span.shortcode input { font-size: 12px; border: none; box-shadow: none; padding: 4px 8px; margin: 0; } #wpcf7-contact-form-list-table span.shortcode input, #wpcf7-contact-form-editor span.shortcode input { background: transparent; } #wpcf7-contact-form-list-table span.shortcode input { color: #444; } #wpcf7-contact-form-editor span.shortcode input { color: #fff; } #submitpost input.copy { margin-bottom: 10px; } #submitpost input.delete { padding: 0; margin: 0; border: none; cursor: pointer; background: inherit; color: #a00; } #submitpost input.delete:hover { color: #dc3232; /* Red */ } #submitpost input.delete:focus { outline: thin dotted; } .postbox-container .postbox h3 { border-bottom: 1px solid transparent; } .keyboard-interaction { visibility: hidden; color: #23282d; /* Dark Gray 800 */ } div.config-error, span.config-error, ul.config-error { color: #444; font-style: normal; font-size: 13px; } ul.config-error { margin: 2px 0; } ul.config-error li { list-style: none; padding: 2px 2px; margin: 0; } [data-config-field][aria-invalid="true"] { border-color: #dc3232; } #contact-form-editor-tabs li a .icon-in-circle, #contact-form-editor .config-error .icon-in-circle, .wp-list-table .config-error .icon-in-circle, .icon-in-circle { display: inline-block; vertical-align: text-top; margin: 1px 6px 0; padding: 0 5px; min-width: 7px; height: 17px; border-radius: 11px; background-color: #ca4a1f; color: #fff; font-size: 12px; font-weight: bold; line-height: 17px; text-align: center; z-index: 26; } /* * Tabs */ #contact-form-editor-tabs { border-bottom: 1px solid #aaa; padding: 9px 15px 0 10px; margin: 0; } #contact-form-editor-tabs li { display: inline-block; list-style: none; border: 1px solid #ccc; border-bottom: 1px solid #aaa; padding: 0; margin: 0 4px -1px; background-color: #e4e4e4; } #contact-form-editor-tabs li:hover { background-color: #fff; } #contact-form-editor-tabs li.ui-tabs-active, #contact-form-editor-tabs li.ui-tabs-active:hover { border-top: 1px solid #aaa; border-right: 1px solid #aaa; border-left: 1px solid #aaa; border-bottom: 1px solid #f5f5f5; background-color: #f5f5f5; } #contact-form-editor-tabs li a { padding: 6px 10px; font-size: 14px; font-weight: normal; line-height: 30px; color: #333; text-decoration: none; } #contact-form-editor-tabs li.ui-tabs-active a { color: #000; font-size: 14px; font-weight: bold; } #contact-form-editor-tabs li a:hover { color: #000; } #contact-form-editor .contact-form-editor-panel > div.config-error { margin-bottom: 1.4em; } #contact-form-editor-tabs li.ui-tabs-active a .icon-in-circle { display: none; } #contact-form-editor .contact-form-editor-panel h2 { font-size: 18px; font-weight: 400; line-height: 24px; margin: 8px 0; padding: 0; } #contact-form-editor .contact-form-editor-panel { background-color: #f5f5f5; border: 1px solid #aaa; border-top: none; padding: 16px; } #contact-form-editor .form-table th { width: 100px; } #contact-form-editor .contact-form-editor-panel fieldset legend { line-height: 1.5; margin: .6em 0 .4em; } /* * Form Tab */ #tag-generator-list a.button { font-size: 12px; height: 26px; line-height: 24px; margin: 2px; padding: 0 8px 1px; } .tag-generator-panel { height: 495px; display: flex; flex-direction: column; } .tag-generator-panel .control-box { padding: 0; margin: 0; overflow: auto; flex-grow: 1; } .tag-generator-panel .control-box > fieldset > legend { border: 1px solid #dfdfdf; border-left: 4px solid #00a0d2; background: #f7fcfe; padding: 4px 12px; margin: 4px 0; line-height: 1.4em; width: 100%; box-sizing: border-box; } .tag-generator-panel table { width: 100%; } .tag-generator-panel table.form-table th { width: 120px; padding: 4px 10px 4px 0; font-size: 13px; } .tag-generator-panel table.form-table td { padding: 4px 10px; font-size: 13px; } .tag-generator-panel .control-box input.oneline { width: 200px; } .tag-generator-panel .control-box input.large-text { width: 400px; } .tag-generator-panel .control-box textarea.values { width: 200px; height: 6em; } .tag-generator-panel .control-box input[type="number"], .tag-generator-panel .control-box input[type="date"] { width: 88px; } .tag-generator-panel .control-box table caption { text-align: left; font-size: 110%; font-weight: bold; color: #777; margin: 10px 0 5px; } .tag-generator-panel .control-box table.form-table td label { line-height: 1.1em; } .tag-generator-panel .control-box table.form-table td label .description { line-height: 1.4em; } .tag-generator-panel .insert-box { margin: 0 -15px -15px; padding: 8px 16px; background-color: #fcfcfc; border-top: 1px solid #dfdfdf; overflow: auto; } .tag-generator-panel .insert-box input.tag { width: 510px; float: left; background-color: transparent; box-shadow: none; } .tag-generator-panel .insert-box .submitbox { padding: 0; } .tag-generator-panel .insert-box .submitbox input[type="button"] { float: right; } .tag-generator-panel .insert-box .description label { cursor: text; } /* * Mail Tab */ .contact-form-editor-box-mail span.mailtag { display: inline-block; margin: 0 0 0 4px; padding: 1px 2px; cursor: pointer; color: #000; } .contact-form-editor-box-mail span.mailtag.used { color: #666; } .contact-form-editor-box-mail span.mailtag.unused { font-weight: bold; } /* * Messages Tab */ #messages-panel p.description { margin: 5px 0 10px; } /* * Tabs for integration modules */ #ctct-panel table tr.inactive ~ tr, #sendinblue-panel table tr.inactive ~ tr { display: none; } #ctct-panel .dashicons, #sendinblue-panel .dashicons { text-decoration: none; } #ctct-panel td p, #sendinblue-panel td p { margin-top: 12px; } /* * List Table */ .fixed .column-title { width: 38%; } .fixed .column-shortcode { width: 38%; } /* * Welcome Panel */ .wpcf7-welcome-panel { position: relative; overflow: auto; margin: 16px 0; padding: 23px 10px 0; border: 1px solid #c3c4c7; box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04); background: #fff; font-size: 13px; line-height: 1.7; } .wpcf7-welcome-panel h3 { font-size: 16px; font-weight: 600; line-height: 2.1em; margin: 1em 0 1.2em; } .wpcf7-welcome-panel h3 .dashicons { position: relative; top: -2px; display: inline-block; width: 60px; color: #575757; font-size: 40px; } .wpcf7-welcome-panel p { color: #646970; } .wpcf7-welcome-panel p a { font-weight: bold; } .wpcf7-welcome-panel .welcome-panel-close { position: absolute; z-index: 2; top: 10px; right: 10px; padding: 10px 15px 10px 21px; font-size: 13px; line-height: 1.23076923; /* Chrome rounding, needs to be 16px equivalent */ text-decoration: none; } .wpcf7-welcome-panel .welcome-panel-close::before { background: 0 0; color: #787c82; content: "\f153"; display: block; font: normal 16px/20px dashicons; speak: never; height: 20px; text-align: center; width: 20px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; position: absolute; top: 8px; left: 0; transition: all .1s ease-in-out; } .wpcf7-welcome-panel .welcome-panel-content { display: block; margin-left: 13px; max-width: 1500px; min-height: auto; } .wpcf7-welcome-panel .welcome-panel-column-container { clear: both; position: relative; } .wpcf7-welcome-panel .welcome-panel-column { display: block; width: 48%; min-width: 200px; float: left; padding: 0 2% 0 0; margin: 0 0 1em 0; } @media screen and (max-width: 870px) { .wpcf7-welcome-panel .welcome-panel-column { display: block; float: none; width: 100%; } } .wpcf7-welcome-panel .welcome-panel-column p { margin-top: 7px; color: #3c434a; } /* * Integration */ .card { background: #fff none repeat scroll 0 0; border: 1px solid #e5e5e5; border-left: 4px solid #e5e5e5; box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04); margin-top: 20px; max-width: 520px; min-width: 255px; padding: 0.7em 2em 1em; position: relative; } .card.active { border-color: #00a0d2; } .card img.icon { float: left; margin: 8px 8px 8px -8px; } .card h2.title { float: left; max-width: 240px; font-size: 1.3em; font-weight: 600; } .card .infobox { float: right; font-size: 13px; color: #666; margin: 1em; line-height: 1.5; max-width: 240px; } .card .inside .form-table th { padding: 15px 10px 15px 0; width: 160px; } .card .inside .form-table td { padding: 10px 10px; } .card .checkboxes li { margin: 0; } admin/css/styles-rtl.css000064400000002075150515101440011260 0ustar00/* * Tabs */ #contact-form-editor-tabs { padding: 9px 10px 0 15px; } /* * Form Tab */ .tag-generator-panel { text-align: right; } .tag-generator-panel .control-box > fieldset > legend { border: 1px solid #dfdfdf; border-right: 4px solid #00a0d2; } .tag-generator-panel .insert-box input.tag { float: right; } .tag-generator-panel .insert-box .submitbox input[type="button"] { float: left; } /* * Mail Tab */ .contact-form-editor-box-mail span.mailtag { margin: 0 4px 0 0; } /* * Welcome Panel */ .wpcf7-welcome-panel .welcome-panel-close { left: 10px; right: auto; padding: 10px 21px 10px 15px; } .wpcf7-welcome-panel .welcome-panel-close::before { right: 0; left: auto; } .wpcf7-welcome-panel .welcome-panel-content { margin-right: 13px; } .wpcf7-welcome-panel .welcome-panel-column { float: right; padding: 0 0 0 2%; } /* * Integration */ .card { border-left: 1px solid #e5e5e5; border-right: 4px solid #e5e5e5; } .card img.icon { float: right; margin: 8px -8px 8px 8px; } .card h2.title { float: right; } .card .infobox { float: left; } admin/includes/tag-generator.php000064400000003447150515101440012716 0ustar00panels[$id] = array( 'title' => $title, 'content' => 'tag-generator-panel-' . $id, 'options' => $options, 'callback' => $callback, ); return true; } public function print_buttons() { echo ''; foreach ( (array) $this->panels as $panel ) { echo sprintf( '%3$s', esc_attr( $panel['content'] ), esc_attr( sprintf( /* translators: %s: title of form-tag like 'email' or 'checkboxes' */ __( 'Form-tag Generator: %s', 'contact-form-7' ), $panel['title'] ) ), esc_html( $panel['title'] ) ); } echo ''; } public function print_panels( WPCF7_ContactForm $contact_form ) { foreach ( (array) $this->panels as $id => $panel ) { $callback = $panel['callback']; $options = wp_parse_args( $panel['options'], array() ); $options = array_merge( $options, array( 'id' => $id, 'title' => $panel['title'], 'content' => $panel['content'], ) ); if ( is_callable( $callback ) ) { echo sprintf( ''; } } } } admin/includes/admin-functions.php000064400000001104150515101440013241 0ustar00add( $name, $title, $callback, $options ); } admin/includes/config-validator.php000064400000006516150515101440013407 0ustar00 '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 ) ); ?>

contact_form = $contact_form; } public function add_panel( $panel_id, $title, $callback ) { if ( wpcf7_is_name( $panel_id ) ) { $this->panels[$panel_id] = array( 'title' => $title, 'callback' => $callback, ); } } public function display() { if ( empty( $this->panels ) ) { return; } echo ''; foreach ( $this->panels as $panel_id => $panel ) { echo sprintf( '
', esc_attr( $panel_id ) ); if ( is_callable( $panel['callback'] ) ) { $this->notice( $panel_id, $panel ); call_user_func( $panel['callback'], $this->contact_form ); } echo '
'; } } public function notice( $panel_id, $panel ) { echo '
'; } } function wpcf7_editor_panel_form( $post ) { $desc_link = wpcf7_link( __( 'https://contactform7.com/editing-form-template/', 'contact-form-7' ), __( 'Editing form template', 'contact-form-7' ) ); $description = __( "You can edit the form template here. For details, see %s.", 'contact-form-7' ); $description = sprintf( esc_html( $description ), $desc_link ); ?>

print_buttons(); ?>
'; wpcf7_editor_box_mail( $post, array( 'id' => 'wpcf7-mail-2', 'name' => 'mail_2', 'title' => __( 'Mail (2)', 'contact-form-7' ), 'use' => __( 'Use Mail (2)', 'contact-form-7' ), ) ); } function wpcf7_editor_box_mail( $post, $args = '' ) { $args = wp_parse_args( $args, array( 'id' => 'wpcf7-mail', 'name' => 'mail', 'title' => __( 'Mail', 'contact-form-7' ), 'use' => null, ) ); $id = esc_attr( $args['id'] ); $mail = wp_parse_args( $post->prop( $args['name'] ), array( 'active' => false, 'recipient' => '', 'sender' => '', 'subject' => '', 'body' => '', 'additional_headers' => '', 'attachments' => '', 'use_html' => false, 'exclude_blank' => false, ) ); ?>

'; echo esc_html( __( "In the following fields, you can use these mail-tags:", 'contact-form-7' ) ); echo '
'; $post->suggest_mail_tags( $args['name'] ); ?>

$arr ) { $field_id = sprintf( 'wpcf7-message-%s', strtr( $key, '_', '-' ) ); $field_name = sprintf( 'wpcf7-messages[%s]', $key ); ?>

screen = $screen; } public function set_help_tabs( $screen_type ) { switch ( $screen_type ) { case 'list': $this->screen->add_help_tab( array( 'id' => 'list_overview', 'title' => __( 'Overview', 'contact-form-7' ), 'content' => $this->content( 'list_overview' ), ) ); $this->screen->add_help_tab( array( 'id' => 'list_available_actions', 'title' => __( 'Available Actions', 'contact-form-7' ), 'content' => $this->content( 'list_available_actions' ), ) ); $this->sidebar(); return; case 'edit': $this->screen->add_help_tab( array( 'id' => 'edit_overview', 'title' => __( 'Overview', 'contact-form-7' ), 'content' => $this->content( 'edit_overview' ), ) ); $this->screen->add_help_tab( array( 'id' => 'edit_form_tags', 'title' => __( 'Form-tags', 'contact-form-7' ), 'content' => $this->content( 'edit_form_tags' ), ) ); $this->screen->add_help_tab( array( 'id' => 'edit_mail_tags', 'title' => __( 'Mail-tags', 'contact-form-7' ), 'content' => $this->content( 'edit_mail_tags' ), ) ); $this->sidebar(); return; case 'integration': $this->screen->add_help_tab( array( 'id' => 'integration_overview', 'title' => __( 'Overview', 'contact-form-7' ), 'content' => $this->content( 'integration_overview' ), ) ); $this->sidebar(); return; } } private function content( $name ) { $content = array(); $content['list_overview'] = '

' . __( "On this screen, you can manage contact forms provided by Contact Form 7. You can manage an unlimited number of contact forms. Each contact form has a unique ID and Contact Form 7 shortcode ([contact-form-7 ...]). To insert a contact form into a post or a text widget, insert the shortcode into the target.", 'contact-form-7' ) . '

'; $content['list_available_actions'] = '

' . __( "Hovering over a row in the contact forms list will display action links that allow you to manage your contact form. You can perform the following actions:", 'contact-form-7' ) . '

'; $content['list_available_actions'] .= '

' . __( "Edit - Navigates to the editing screen for that contact form. You can also reach that screen by clicking on the contact form title.", 'contact-form-7' ) . '

'; $content['list_available_actions'] .= '

' . __( "Duplicate - Clones that contact form. A cloned contact form inherits all content from the original, but has a different ID.", 'contact-form-7' ) . '

'; $content['edit_overview'] = '

' . __( "On this screen, you can edit a contact form. A contact form is comprised of the following components:", 'contact-form-7' ) . '

'; $content['edit_overview'] .= '

' . __( "Title is the title of a contact form. This title is only used for labeling a contact form, and can be edited.", 'contact-form-7' ) . '

'; $content['edit_overview'] .= '

' . __( "Form is a content of HTML form. You can use arbitrary HTML, which is allowed inside a form element. You can also use Contact Form 7’s form-tags here.", 'contact-form-7' ) . '

'; $content['edit_overview'] .= '

' . __( "Mail manages a mail template (headers and message body) that this contact form will send when users submit it. You can use Contact Form 7’s mail-tags here.", 'contact-form-7' ) . '

'; $content['edit_overview'] .= '

' . __( "Mail (2) is an additional mail template that works similar to Mail. Mail (2) is different in that it is sent only when Mail has been sent successfully.", 'contact-form-7' ) . '

'; $content['edit_overview'] .= '

' . __( "In Messages, you can edit various types of messages used for this contact form. These messages are relatively short messages, like a validation error message you see when you leave a required field blank.", 'contact-form-7' ) . '

'; $content['edit_overview'] .= '

' . __( "Additional Settings provides a place where you can customize the behavior of this contact form by adding code snippets.", 'contact-form-7' ) . '

'; $content['edit_form_tags'] = '

' . __( "A form-tag is a short code enclosed in square brackets used in a form content. A form-tag generally represents an input field, and its components can be separated into four parts: type, name, options, and values. Contact Form 7 supports several types of form-tags including text fields, number fields, date fields, checkboxes, radio buttons, menus, file-uploading fields, CAPTCHAs, and quiz fields.", 'contact-form-7' ) . '

'; $content['edit_form_tags'] .= '

' . __( "While form-tags have a comparatively complex syntax, you do not need to know the syntax to add form-tags because you can use the straightforward tag generator (Generate Tag button on this screen).", 'contact-form-7' ) . '

'; $content['edit_mail_tags'] = '

' . __( "A mail-tag is also a short code enclosed in square brackets that you can use in every Mail and Mail (2) field. A mail-tag represents a user input value through an input field of a corresponding form-tag.", 'contact-form-7' ) . '

'; $content['edit_mail_tags'] .= '

' . __( "There are also special mail-tags that have specific names, but do not have corresponding form-tags. They are used to represent meta information of form submissions like the submitter’s IP address or the URL of the page.", 'contact-form-7' ) . '

'; $content['integration_overview'] = '

' . __( "On this screen, you can manage services that are available through Contact Form 7. Using API will allow you to collaborate with any services that are available.", 'contact-form-7' ) . '

'; $content['integration_overview'] .= '

' . __( "You may need to first sign up for an account with the service that you plan to use. When you do so, you would need to authorize Contact Form 7 to access the service with your account.", 'contact-form-7' ) . '

'; $content['integration_overview'] .= '

' . __( "Any information you provide will not be shared with service providers without your authorization.", 'contact-form-7' ) . '

'; if ( ! empty( $content[$name] ) ) { return $content[$name]; } } public function sidebar() { $content = '

' . __( 'For more information:', 'contact-form-7' ) . '

'; $content .= '

' . wpcf7_link( __( 'https://contactform7.com/docs/', 'contact-form-7' ), __( 'Docs', 'contact-form-7' ) ) . '

'; $content .= '

' . wpcf7_link( __( 'https://contactform7.com/faq/', 'contact-form-7' ), __( 'FAQ', 'contact-form-7' ) ) . '

'; $content .= '

' . wpcf7_link( __( 'https://contactform7.com/support/', 'contact-form-7' ), __( 'Support', 'contact-form-7' ) ) . '

'; $this->screen->set_help_sidebar( $content ); } } admin/includes/class-contact-forms-list-table.php000064400000013323150515101440016071 0ustar00 '', 'title' => __( 'Title', 'contact-form-7' ), 'shortcode' => __( 'Shortcode', 'contact-form-7' ), 'author' => __( 'Author', 'contact-form-7' ), 'date' => __( 'Date', 'contact-form-7' ), ); return $columns; } public function __construct() { parent::__construct( array( 'singular' => 'post', 'plural' => 'posts', 'ajax' => false, ) ); } public function prepare_items() { $current_screen = get_current_screen(); $per_page = $this->get_items_per_page( 'wpcf7_contact_forms_per_page' ); $args = array( 'posts_per_page' => $per_page, 'orderby' => 'title', 'order' => 'ASC', 'offset' => ( $this->get_pagenum() - 1 ) * $per_page, ); if ( ! empty( $_REQUEST['s'] ) ) { $args['s'] = $_REQUEST['s']; } if ( ! empty( $_REQUEST['orderby'] ) ) { if ( 'title' == $_REQUEST['orderby'] ) { $args['orderby'] = 'title'; } elseif ( 'author' == $_REQUEST['orderby'] ) { $args['orderby'] = 'author'; } elseif ( 'date' == $_REQUEST['orderby'] ) { $args['orderby'] = 'date'; } } if ( ! empty( $_REQUEST['order'] ) ) { if ( 'asc' == strtolower( $_REQUEST['order'] ) ) { $args['order'] = 'ASC'; } elseif ( 'desc' == strtolower( $_REQUEST['order'] ) ) { $args['order'] = 'DESC'; } } $this->items = WPCF7_ContactForm::find( $args ); $total_items = WPCF7_ContactForm::count(); $total_pages = ceil( $total_items / $per_page ); $this->set_pagination_args( array( 'total_items' => $total_items, 'total_pages' => $total_pages, 'per_page' => $per_page, ) ); } public function get_columns() { return get_column_headers( get_current_screen() ); } protected function get_sortable_columns() { $columns = array( 'title' => array( 'title', true ), 'author' => array( 'author', false ), 'date' => array( 'date', false ), ); return $columns; } protected function get_bulk_actions() { $actions = array( 'delete' => __( 'Delete', 'contact-form-7' ), ); return $actions; } protected function column_default( $item, $column_name ) { return ''; } public function column_cb( $item ) { return sprintf( '', $this->_args['singular'], $item->id() ); } public function column_title( $item ) { $edit_link = add_query_arg( array( 'post' => absint( $item->id() ), 'action' => 'edit', ), menu_page_url( 'wpcf7', false ) ); $output = sprintf( '%3$s', esc_url( $edit_link ), esc_attr( sprintf( /* translators: %s: title of contact form */ __( 'Edit “%s”', 'contact-form-7' ), $item->title() ) ), esc_html( $item->title() ) ); $output = sprintf( '%s', $output ); if ( wpcf7_validate_configuration() and current_user_can( 'wpcf7_edit_contact_form', $item->id() ) ) { $config_validator = new WPCF7_ConfigValidator( $item ); $config_validator->restore(); if ( $count_errors = $config_validator->count_errors() ) { $error_notice = sprintf( _n( /* translators: %s: number of errors detected */ '%s configuration error detected', '%s configuration errors detected', $count_errors, 'contact-form-7' ), number_format_i18n( $count_errors ) ); $output .= sprintf( '
%s
', $error_notice ); } } return $output; } protected function handle_row_actions( $item, $column_name, $primary ) { if ( $column_name !== $primary ) { return ''; } $edit_link = add_query_arg( array( 'post' => absint( $item->id() ), 'action' => 'edit', ), menu_page_url( 'wpcf7', false ) ); $actions = array( 'edit' => wpcf7_link( $edit_link, __( 'Edit', 'contact-form-7' ) ), ); if ( current_user_can( 'wpcf7_edit_contact_form', $item->id() ) ) { $copy_link = add_query_arg( array( 'post' => absint( $item->id() ), 'action' => 'copy', ), menu_page_url( 'wpcf7', false ) ); $copy_link = wp_nonce_url( $copy_link, 'wpcf7-copy-contact-form_' . absint( $item->id() ) ); $actions = array_merge( $actions, array( 'copy' => wpcf7_link( $copy_link, __( 'Duplicate', 'contact-form-7' ) ), ) ); } return $this->row_actions( $actions ); } public function column_author( $item ) { $post = get_post( $item->id() ); if ( ! $post ) { return; } $author = get_userdata( $post->post_author ); if ( false === $author ) { return; } return esc_html( $author->display_name ); } public function column_shortcode( $item ) { $shortcodes = array( $item->shortcode() ); $output = ''; foreach ( $shortcodes as $shortcode ) { $output .= "\n" . ''; } return trim( $output ); } public function column_date( $item ) { $datetime = get_post_datetime( $item->id() ); if ( false === $datetime ) { return ''; } $t_time = sprintf( /* translators: 1: date, 2: time */ __( '%1$s at %2$s', 'contact-form-7' ), /* translators: date format, see https://www.php.net/date */ $datetime->format( __( 'Y/m/d', 'contact-form-7' ) ), /* translators: time format, see https://www.php.net/date */ $datetime->format( __( 'g:i a', 'contact-form-7' ) ) ); return $t_time; } } admin/includes/welcome-panel.php000064400000021230150515101440012675 0ustar00', esc_attr( $this->icon() ) ); $title = sprintf( '

%1$s %2$s

', $icon, $this->title() ); $content = $this->content(); if ( is_array( $content ) ) { $content = implode( "\n\n", $content ); } $content = wp_kses_post( $content ); $content = wptexturize( $content ); $content = convert_chars( $content ); $content = wpautop( $content ); echo "\n"; echo '
'; echo $title; echo $content; echo '
'; } } class WPCF7_WelcomePanelColumn_AntiSpam extends WPCF7_WelcomePanelColumn { protected function icon() { return 'shield'; } protected function title() { return esc_html( __( "Getting spammed? You have protection.", 'contact-form-7' ) ); } protected function content() { return array( esc_html( __( "Spammers target everything; your contact forms are not an exception. Before you get spammed, protect your contact forms with the powerful anti-spam features Contact Form 7 provides.", 'contact-form-7' ) ), sprintf( /* translators: links labeled 1: 'Akismet', 2: 'reCAPTCHA', 3: 'disallowed list' */ esc_html( __( 'Contact Form 7 supports spam-filtering with %1$s. Intelligent %2$s blocks annoying spambots. Plus, using %3$s, you can block messages containing specified keywords or those sent from specified IP addresses.', 'contact-form-7' ) ), wpcf7_link( __( 'https://contactform7.com/spam-filtering-with-akismet/', 'contact-form-7' ), __( 'Akismet', 'contact-form-7' ) ), wpcf7_link( __( 'https://contactform7.com/recaptcha/', 'contact-form-7' ), __( 'reCAPTCHA', 'contact-form-7' ) ), wpcf7_link( __( 'https://contactform7.com/comment-blacklist/', 'contact-form-7' ), __( 'disallowed list', 'contact-form-7' ) ) ), ); } } class WPCF7_WelcomePanelColumn_Donation extends WPCF7_WelcomePanelColumn { protected function icon() { return 'megaphone'; } protected function title() { return esc_html( __( "Contact Form 7 needs your support.", 'contact-form-7' ) ); } protected function content() { return array( esc_html( __( "It is hard to continue development and support for this plugin without contributions from users like you.", 'contact-form-7' ) ), sprintf( /* translators: %s: link labeled 'making a donation' */ esc_html( __( 'If you enjoy using Contact Form 7 and find it useful, please consider %s.', 'contact-form-7' ) ), wpcf7_link( __( 'https://contactform7.com/donate/', 'contact-form-7' ), __( 'making a donation', 'contact-form-7' ) ) ), esc_html( __( "Your donation will help encourage and support the plugin’s continued development and better user support.", 'contact-form-7' ) ), ); } } class WPCF7_WelcomePanelColumn_Flamingo extends WPCF7_WelcomePanelColumn { protected function icon() { return 'editor-help'; } protected function title() { return esc_html( __( "Before you cry over spilt mail…", 'contact-form-7' ) ); } protected function content() { return array( esc_html( __( "Contact Form 7 does not store submitted messages anywhere. Therefore, you may lose important messages forever if your mail server has issues or you make a mistake in mail configuration.", 'contact-form-7' ) ), sprintf( /* translators: %s: link labeled 'Flamingo' */ esc_html( __( 'Install a message storage plugin before this happens to you. %s saves all messages through contact forms into the database. Flamingo is a free WordPress plugin created by the same author as Contact Form 7.', 'contact-form-7' ) ), wpcf7_link( __( 'https://contactform7.com/save-submitted-messages-with-flamingo/', 'contact-form-7' ), __( 'Flamingo', 'contact-form-7' ) ) ), ); } } class WPCF7_WelcomePanelColumn_Integration extends WPCF7_WelcomePanelColumn { protected function icon() { return 'superhero-alt'; } protected function title() { return esc_html( __( "You have strong allies to back you up.", 'contact-form-7' ) ); } protected function content() { return array( sprintf( /* translators: 1: link labeled 'Brevo', 2: link labeled 'Constant Contact' */ esc_html( __( 'Your contact forms will become more powerful and versatile by integrating them with external APIs. With CRM and email marketing services, you can build your own contact lists (%1$s and %2$s).', 'contact-form-7' ) ), wpcf7_link( __( 'https://contactform7.com/sendinblue-integration/', 'contact-form-7' ), __( 'Brevo', 'contact-form-7' ) ), wpcf7_link( __( 'https://contactform7.com/constant-contact-integration/', 'contact-form-7' ), __( 'Constant Contact', 'contact-form-7' ) ) ), sprintf( /* translators: 1: link labeled 'reCAPTCHA', 2: link labeled 'Stripe' */ esc_html( __( 'With help from cloud-based machine learning, anti-spam services will protect your forms (%1$s). Even payment services are natively supported (%2$s).', 'contact-form-7' ) ), wpcf7_link( __( 'https://contactform7.com/recaptcha/', 'contact-form-7' ), __( 'reCAPTCHA', 'contact-form-7' ) ), wpcf7_link( __( 'https://contactform7.com/stripe-integration/', 'contact-form-7' ), __( 'Stripe', 'contact-form-7' ) ) ), ); } } function wpcf7_welcome_panel() { $columns = array(); $flamingo_is_active = defined( 'FLAMINGO_VERSION' ); $sendinblue_is_active = false; if ( class_exists( 'WPCF7_Sendinblue' ) and $sendinblue = WPCF7_Sendinblue::get_instance() ) { $sendinblue_is_active = $sendinblue->is_active(); } if ( $flamingo_is_active and $sendinblue_is_active ) { $columns[] = new WPCF7_WelcomePanelColumn_AntiSpam(); $columns[] = new WPCF7_WelcomePanelColumn_Donation(); } elseif ( $flamingo_is_active ) { $columns[] = new WPCF7_WelcomePanelColumn_Integration(); $columns[] = new WPCF7_WelcomePanelColumn_AntiSpam(); } elseif ( $sendinblue_is_active ) { $columns[] = new WPCF7_WelcomePanelColumn_Flamingo(); $columns[] = new WPCF7_WelcomePanelColumn_AntiSpam(); } else { $columns[] = new WPCF7_WelcomePanelColumn_Flamingo(); $columns[] = new WPCF7_WelcomePanelColumn_Integration(); } $classes = 'wpcf7-welcome-panel'; $vers = (array) get_user_meta( get_current_user_id(), 'wpcf7_hide_welcome_panel_on', true ); if ( wpcf7_version_grep( wpcf7_version( 'only_major=1' ), $vers ) ) { $classes .= ' hidden'; } ?>
print_content(); } ?>
id ) { return $screen_settings; } $vers = (array) get_user_meta( get_current_user_id(), 'wpcf7_hide_welcome_panel_on', true ); $checkbox_id = 'wpcf7-welcome-panel-show'; $checked = ! in_array( wpcf7_version( 'only_major=1' ), $vers ); $checkbox = sprintf( '', wpcf7_format_atts( array( 'id' => $checkbox_id, 'type' => 'checkbox', 'checked' => $checked, ) ) ); $screen_settings .= sprintf( '
%1$s
', esc_html( __( 'Welcome panel', 'contact-form-7' ) ), esc_attr( $checkbox_id ), $checkbox, esc_html( __( 'Show welcome panel', 'contact-form-7' ) ) ); return $screen_settings; } admin/edit-contact-form.php000064400000022570150515101440011666 0ustar00', esc_attr( __( 'Save', 'contact-form-7' ) ), $onclick ); echo $button; } ?>

initial() ) { echo esc_html( __( 'Add New Contact Form', 'contact-form-7' ) ); } else { echo esc_html( __( 'Edit Contact Form', 'contact-form-7' ) ); } ?>

initial() and current_user_can( 'wpcf7_edit_contact_forms' ) ) { echo wpcf7_link( menu_page_url( 'wpcf7-new', false ), __( 'Add New', 'contact-form-7' ), array( 'class' => 'page-title-action' ) ); } ?>
initial() ? 'wpcf7-new' : 'wpcf7', wpcf7_current_action(), $post ); do_action( 'wpcf7_admin_notices', $post->initial() ? 'wpcf7-new' : 'wpcf7', wpcf7_current_action(), $post ); ?>
>
'text', 'name' => 'post_title', 'size' => 30, 'value' => $post->initial() ? '' : $post->title(), 'id' => 'title', 'spellcheck' => 'true', 'autocomplete' => 'off', 'disabled' => ! current_user_can( 'wpcf7_edit_contact_form', $post_id ), ); echo sprintf( '', wpcf7_format_atts( $posttitle_atts ) ); ?>
initial() ) : ?>

shortcode( array( 'use_old_format' => true ) ) ) : ?>

initial() ) : $copy_nonce = wp_create_nonce( 'wpcf7-copy-contact-form_' . $post_id ); ?> />
initial() ) : $delete_nonce = wp_create_nonce( 'wpcf7-delete-contact-form_' . $post_id ); ?>
/>

', sprintf( '%s', /* translators: screen reader text */ esc_html( __( '(left and right arrow)', 'contact-form-7' ) ) ) ); ?>
array( 'title' => __( 'Form', 'contact-form-7' ), 'callback' => 'wpcf7_editor_panel_form', ), 'mail-panel' => array( 'title' => __( 'Mail', 'contact-form-7' ), 'callback' => 'wpcf7_editor_panel_mail', ), 'messages-panel' => array( 'title' => __( 'Messages', 'contact-form-7' ), 'callback' => 'wpcf7_editor_panel_messages', ), ); $additional_settings = $post->prop( 'additional_settings' ); if ( ! is_scalar( $additional_settings ) ) { $additional_settings = ''; } $additional_settings = trim( $additional_settings ); $additional_settings = explode( "\n", $additional_settings ); $additional_settings = array_filter( $additional_settings ); $additional_settings = count( $additional_settings ); $panels['additional-settings-panel'] = array( 'title' => $additional_settings ? sprintf( /* translators: %d: number of additional settings */ __( 'Additional Settings (%d)', 'contact-form-7' ), $additional_settings ) : __( 'Additional Settings', 'contact-form-7' ), 'callback' => 'wpcf7_editor_panel_additional_settings', ); } $panels = apply_filters( 'wpcf7_editor_panels', $panels ); foreach ( $panels as $id => $panel ) { $editor->add_panel( $id, $panel['title'], $panel['callback'] ); } $editor->display(); ?>


print_panels( $post ); do_action( 'wpcf7_admin_footer', $post ); admin/js/scripts.js000064400000020212150515101440010266 0ustar00( function( $ ) { 'use strict'; if ( typeof wpcf7 === 'undefined' || wpcf7 === null ) { return; } $( function() { var welcomePanel = $( '#wpcf7-welcome-panel' ); var updateWelcomePanel; updateWelcomePanel = function( visible ) { $.post( ajaxurl, { action: 'wpcf7-update-welcome-panel', visible: visible, welcomepanelnonce: $( '#welcomepanelnonce' ).val() } ); }; $( 'a.welcome-panel-close', welcomePanel ).click( function( event ) { event.preventDefault(); welcomePanel.addClass( 'hidden' ); updateWelcomePanel( 0 ); $( '#wpcf7-welcome-panel-show' ).prop( 'checked', false ); } ); $( '#wpcf7-welcome-panel-show' ).click( function( event ) { if ( this.checked ) { welcomePanel.removeClass( 'hidden' ); updateWelcomePanel( 1 ); } else { welcomePanel.addClass( 'hidden' ); updateWelcomePanel( 0 ); } } ); $( '#contact-form-editor' ).tabs( { active: wpcf7.activeTab, activate: function( event, ui ) { $( '#active-tab' ).val( ui.newTab.index() ); } } ); $( '#contact-form-editor-tabs' ).focusin( function( event ) { $( '#contact-form-editor .keyboard-interaction' ).css( 'visibility', 'visible' ); } ).focusout( function( event ) { $( '#contact-form-editor .keyboard-interaction' ).css( 'visibility', 'hidden' ); } ); wpcf7.toggleMail2( 'input:checkbox.toggle-form-table' ); $( 'input:checkbox.toggle-form-table' ).click( function( event ) { wpcf7.toggleMail2( this ); } ); if ( '' === $( '#title' ).val() ) { $( '#title' ).focus(); } wpcf7.titleHint(); $( '.contact-form-editor-box-mail span.mailtag' ).click( function( event ) { var range = document.createRange(); range.selectNodeContents( this ); window.getSelection().addRange( range ); } ); wpcf7.updateConfigErrors(); $( '[data-config-field]' ).change( function() { var postId = $( '#post_ID' ).val(); if ( ! postId || -1 == postId ) { return; } var data = []; $( this ).closest( 'form' ).find( '[data-config-field]' ).each( function() { data.push( { 'name': $( this ).attr( 'name' ).replace( /^wpcf7-/, '' ).replace( /-/g, '_' ), 'value': $( this ).val() } ); } ); data.push( { 'name': 'context', 'value': 'dry-run' } ); $.ajax( { method: 'POST', url: wpcf7.apiSettings.getRoute( '/contact-forms/' + postId ), beforeSend: function( xhr ) { xhr.setRequestHeader( 'X-WP-Nonce', wpcf7.apiSettings.nonce ); }, data: data } ).done( function( response ) { wpcf7.configValidator.errors = response.config_errors; wpcf7.updateConfigErrors(); } ); } ); $( window ).on( 'beforeunload', function( event ) { var changed = false; $( '#wpcf7-admin-form-element :input[type!="hidden"]' ).each( function() { if ( $( this ).is( ':checkbox, :radio' ) ) { if ( this.defaultChecked != $( this ).is( ':checked' ) ) { changed = true; } } else if ( $( this ).is( 'select' ) ) { $( this ).find( 'option' ).each( function() { if ( this.defaultSelected != $( this ).is( ':selected' ) ) { changed = true; } } ); } else { if ( this.defaultValue != $( this ).val() ) { changed = true; } } } ); if ( changed ) { event.returnValue = wpcf7.saveAlert; return wpcf7.saveAlert; } } ); $( '#wpcf7-admin-form-element' ).submit( function() { if ( 'copy' != this.action.value ) { $( window ).off( 'beforeunload' ); } if ( 'save' == this.action.value ) { $( '#publishing-action .spinner' ).addClass( 'is-active' ); } } ); $( '#wpcf7-ctct-enable-contact-list, #wpcf7-sendinblue-enable-contact-list, #wpcf7-sendinblue-enable-transactional-email' ).on( 'change', function() { if ( $( this ).is( ':checked' ) ) { $( this ).closest( 'tr' ).removeClass( 'inactive' ); } else { $( this ).closest( 'tr' ).addClass( 'inactive' ); } } ); } ); wpcf7.toggleMail2 = function( checkbox ) { var $checkbox = $( checkbox ); var $fieldset = $( 'fieldset', $checkbox.closest( '.contact-form-editor-box-mail' ) ); if ( $checkbox.is( ':checked' ) ) { $fieldset.removeClass( 'hidden' ); } else { $fieldset.addClass( 'hidden' ); } }; wpcf7.updateConfigErrors = function() { var errors = wpcf7.configValidator.errors; var errorCount = { total: 0 }; $( '[data-config-field]' ).each( function() { $( this ).removeAttr( 'aria-invalid' ); $( this ).next( 'ul.config-error' ).remove(); var section = $( this ).attr( 'data-config-field' ); $( this ).attr( 'aria-describedby', 'wpcf7-config-error-for-' + section ); if ( errors[ section ] ) { var $list = $( '' ).attr( { 'id': 'wpcf7-config-error-for-' + section, 'class': 'config-error' } ); $.each( errors[ section ], function( i, val ) { var $li = $( '
  • ' ).append( wpcf7.iconInCircle( '!' ) ).append( $( '' ).text( wpcf7.configValidator.iconAlt ) ).append( ' ' ); if ( val.link ) { $li.append( $( '' ).attr( 'href', val.link ).text( val.message ) ); } else { $li.text( val.message ); } $li.appendTo( $list ); var tab = section .replace( /^mail_\d+\./, 'mail.' ).replace( /\..*$/, '' ); if ( ! errorCount[ tab ] ) { errorCount[ tab ] = 0; } errorCount[ tab ] += 1; errorCount.total += 1; } ); $( this ).after( $list ).attr( { 'aria-invalid': 'true' } ); } } ); $( '#contact-form-editor-tabs > li' ).each( function() { var $item = $( this ); $item.find( '.icon-in-circle' ).remove(); var tab = $item.attr( 'id' ).replace( /-panel-tab$/, '' ); $.each( errors, function( key, val ) { key = key.replace( /^mail_\d+\./, 'mail.' ); if ( key.replace( /\..*$/, '' ) == tab.replace( '-', '_' ) ) { var $mark = wpcf7.iconInCircle( '!' ); $item.find( 'a.ui-tabs-anchor' ).first().append( $mark ); return false; } } ); var $tabPanelError = $( '#' + tab + '-panel > div.config-error:first' ); $tabPanelError.empty(); if ( errorCount[ tab.replace( '-', '_' ) ] ) { $tabPanelError.append( wpcf7.iconInCircle( '!' ) ); if ( 1 < errorCount[ tab.replace( '-', '_' ) ] ) { var manyErrorsInTab = wpcf7.configValidator.manyErrorsInTab .replace( '%d', errorCount[ tab.replace( '-', '_' ) ] ); $tabPanelError.append( manyErrorsInTab ); } else { $tabPanelError.append( wpcf7.configValidator.oneErrorInTab ); } } } ); $( '#misc-publishing-actions .misc-pub-section.config-error' ).remove(); if ( errorCount.total ) { var $warning = $( '
    ' ) .addClass( 'misc-pub-section config-error' ) .append( wpcf7.iconInCircle( '!' ) ); if ( 1 < errorCount.total ) { $warning.append( wpcf7.configValidator.manyErrors.replace( '%d', errorCount.total ) ); } else { $warning.append( wpcf7.configValidator.oneError ); } $warning.append( '
    ' ).append( $( '' ) .attr( 'href', wpcf7.configValidator.docUrl ) .text( wpcf7.configValidator.howToCorrect ) ); $( '#misc-publishing-actions' ).append( $warning ); } }; /** * Copied from wptitlehint() in wp-admin/js/post.js */ wpcf7.titleHint = function() { var $title = $( '#title' ); var $titleprompt = $( '#title-prompt-text' ); if ( '' === $title.val() ) { $titleprompt.removeClass( 'screen-reader-text' ); } $titleprompt.click( function() { $( this ).addClass( 'screen-reader-text' ); $title.focus(); } ); $title.blur( function() { if ( '' === $(this).val() ) { $titleprompt.removeClass( 'screen-reader-text' ); } } ).focus( function() { $titleprompt.addClass( 'screen-reader-text' ); } ).keydown( function( e ) { $titleprompt.addClass( 'screen-reader-text' ); $( this ).unbind( e ); } ); }; wpcf7.iconInCircle = function( icon ) { var $span = $( '' ); return $span.text( icon ); }; wpcf7.apiSettings.getRoute = function( path ) { var url = wpcf7.apiSettings.root; url = url.replace( wpcf7.apiSettings.namespace, wpcf7.apiSettings.namespace + path ); return url; }; } )( jQuery ); admin/js/tag-generator.js000064400000013577150515101440011356 0ustar00( function( $ ) { 'use strict'; if ( typeof wpcf7 === 'undefined' || wpcf7 === null ) { return; } wpcf7.taggen = {}; $( function() { $( 'form.tag-generator-panel' ).each( function() { wpcf7.taggen.update( $( this ) ); } ); } ); $( 'form.tag-generator-panel' ).submit( function() { return false; } ); $( 'form.tag-generator-panel .control-box :input' ).change( function() { var $form = $( this ).closest( 'form.tag-generator-panel' ); wpcf7.taggen.normalize( $( this ) ); wpcf7.taggen.update( $form ); } ); $( 'input.insert-tag' ).click( function() { var $form = $( this ).closest( 'form.tag-generator-panel' ); var tag = $form.find( 'input.tag' ).val(); wpcf7.taggen.insert( tag ); tb_remove(); // close thickbox return false; } ); wpcf7.taggen.update = function( $form ) { var id = $form.attr( 'data-id' ); var name = ''; var name_fields = $form.find( 'input[name="name"]' ); if ( name_fields.length ) { name = name_fields.val(); if ( '' === name ) { name = id + '-' + Math.floor( Math.random() * 1000 ); name_fields.val( name ); } } if ( $.isFunction( wpcf7.taggen.update[ id ] ) ) { return wpcf7.taggen.update[ id ].call( this, $form ); } $form.find( 'input.tag' ).each( function() { var tag_type = $( this ).attr( 'name' ); if ( $form.find( ':input[name="tagtype"]' ).length ) { tag_type = $form.find( ':input[name="tagtype"]' ).val(); } if ( $form.find( ':input[name="required"]' ).is( ':checked' ) ) { tag_type += '*'; } var components = wpcf7.taggen.compose( tag_type, $form ); $( this ).val( components ); } ); $form.find( 'span.mail-tag' ).text( '[' + name + ']' ); $form.find( 'input.mail-tag' ).each( function() { $( this ).val( '[' + name + ']' ); } ); }; wpcf7.taggen.update.captcha = function( $form ) { var captchac = wpcf7.taggen.compose( 'captchac', $form ); var captchar = wpcf7.taggen.compose( 'captchar', $form ); $form.find( 'input.tag' ).val( captchac + ' ' + captchar ); }; wpcf7.taggen.compose = function( tagType, $form ) { var name = $form.find( 'input[name="name"]' ).val(); var scope = $form.find( '.scope.' + tagType ); if ( ! scope.length ) { scope = $form; } var options = []; scope.find( 'input.option' ).not( ':checkbox,:radio' ).each( function( i ) { var val = $( this ).val(); if ( ! val ) { return; } if ( $( this ).hasClass( 'filetype' ) ) { val = val.split( /[,|\s]+/ ).join( '|' ); } if ( $( this ).hasClass( 'color' ) ) { val = '#' + val; } if ( 'class' == $( this ).attr( 'name' ) ) { $.each( val.split( ' ' ), function( i, n ) { options.push( 'class:' + n ); } ); } else { options.push( $( this ).attr( 'name' ) + ':' + val ); } } ); scope.find( 'input:checkbox.option' ).each( function( i ) { if ( $( this ).is( ':checked' ) ) { options.push( $( this ).attr( 'name' ) ); } } ); scope.find( 'input:radio.option' ).each( function( i ) { if ( $( this ).is( ':checked' ) && ! $( this ).hasClass( 'default' ) ) { options.push( $( this ).attr( 'name' ) + ':' + $( this ).val() ); } } ); if ( 'radio' == tagType ) { options.push( 'default:1' ); } options = ( options.length > 0 ) ? options.join( ' ' ) : ''; var value = ''; if ( scope.find( ':input[name="values"]' ).val() ) { $.each( scope.find( ':input[name="values"]' ).val().split( "\n" ), function( i, n ) { value += ' "' + n.replace( /["]/g, '"' ) + '"'; } ); } var components = []; $.each( [ tagType, name, options, value ], function( i, v ) { v = $.trim( v ); if ( '' != v ) { components.push( v ); } } ); components = $.trim( components.join( ' ' ) ); components = '[' + components + ']'; var content = scope.find( ':input[name="content"]' ).val(); content = $.trim( content ); if ( content ) { components += ' ' + content + ' [/' + tagType + ']'; } return components; }; wpcf7.taggen.normalize = function( $input ) { var val = $input.val(); if ( $input.is( 'input[name="name"]' ) ) { val = val.replace( /[^0-9a-zA-Z:._-]/g, '' ).replace( /^[^a-zA-Z]+/, '' ); } if ( $input.is( '.numeric' ) ) { val = val.replace( /[^0-9.-]/g, '' ); } if ( $input.is( '.idvalue' ) ) { val = val.replace( /[^-0-9a-zA-Z_]/g, '' ); } if ( $input.is( '.classvalue' ) ) { val = $.map( val.split( ' ' ), function( n ) { return n.replace( /[^-0-9a-zA-Z_]/g, '' ); } ).join( ' ' ); val = $.trim( val.replace( /\s+/g, ' ' ) ); } if ( $input.is( '.color' ) ) { val = val.replace( /[^0-9a-fA-F]/g, '' ); } if ( $input.is( '.filesize' ) ) { val = val.replace( /[^0-9kKmMbB]/g, '' ); } if ( $input.is( '.filetype' ) ) { val = val.replace( /[^0-9a-zA-Z.,|\s]/g, '' ); } if ( $input.is( '.date' ) ) { // 'yyyy-mm-dd' ISO 8601 format if ( ! val.match( /^\d{4}-\d{2}-\d{2}$/ ) ) { val = ''; } } if ( $input.is( ':input[name="values"]' ) ) { val = $.trim( val ); } $input.val( val ); if ( $input.is( ':checkbox.exclusive' ) ) { wpcf7.taggen.exclusiveCheckbox( $input ); } }; wpcf7.taggen.exclusiveCheckbox = function( $cb ) { if ( $cb.is( ':checked' ) ) { $cb.siblings( ':checkbox.exclusive' ).prop( 'checked', false ); } }; wpcf7.taggen.insert = function( content ) { $( 'textarea#wpcf7-form' ).each( function() { this.focus(); if ( document.selection ) { // IE var selection = document.selection.createRange(); selection.text = content; } else if ( this.selectionEnd || 0 === this.selectionEnd ) { var val = $( this ).val(); var end = this.selectionEnd; $( this ).val( val.substring( 0, end ) + content + val.substring( end, val.length ) ); this.selectionStart = end + content.length; this.selectionEnd = end + content.length; } else { $( this ).val( $( this ).val() + content ); } this.focus(); } ); }; } )( jQuery ); uninstall.php000064400000000767150515101440007274 0ustar00 -1, 'post_type' => 'wpcf7_contact_form', 'post_status' => 'any', ) ); foreach ( $posts as $post ) { wp_delete_post( $post->ID, true ); } $wpdb->query( sprintf( "DROP TABLE IF EXISTS %s", $wpdb->prefix . 'contact_form_7' ) ); } if ( ! defined( 'WPCF7_VERSION' ) ) { wpcf7_delete_plugin(); } load.php000064400000013142150515101440006171 0ustar00 $value ) ); update_option( 'wpcf7', $option ); } } add_action( 'plugins_loaded', 'wpcf7', 10, 0 ); /** * Loads modules and registers WordPress shortcodes. */ function wpcf7() { WPCF7::load_modules(); add_shortcode( 'contact-form-7', 'wpcf7_contact_form_tag_func' ); add_shortcode( 'contact-form', 'wpcf7_contact_form_tag_func' ); } add_action( 'init', 'wpcf7_init', 10, 0 ); /** * Registers post types for contact forms. */ function wpcf7_init() { wpcf7_get_request_uri(); wpcf7_register_post_types(); do_action( 'wpcf7_init' ); } add_action( 'admin_init', 'wpcf7_upgrade', 10, 0 ); /** * Upgrades option data when necessary. */ function wpcf7_upgrade() { $old_ver = WPCF7::get_option( 'version', '0' ); $new_ver = WPCF7_VERSION; if ( $old_ver == $new_ver ) { return; } do_action( 'wpcf7_upgrade', $new_ver, $old_ver ); WPCF7::update_option( 'version', $new_ver ); } add_action( 'activate_' . WPCF7_PLUGIN_BASENAME, 'wpcf7_install', 10, 0 ); /** * Callback tied to plugin activation action hook. Attempts to create * initial user dataset. */ function wpcf7_install() { if ( $opt = get_option( 'wpcf7' ) ) { return; } wpcf7_register_post_types(); wpcf7_upgrade(); if ( get_posts( array( 'post_type' => 'wpcf7_contact_form' ) ) ) { return; } $contact_form = WPCF7_ContactForm::get_template( array( 'title' => /* translators: title of your first contact form. %d: number fixed to '1' */ sprintf( __( 'Contact form %d', 'contact-form-7' ), 1 ), ) ); $contact_form->save(); WPCF7::update_option( 'bulk_validate', array( 'timestamp' => time(), 'version' => WPCF7_VERSION, 'count_valid' => 1, 'count_invalid' => 0, ) ); } license.txt000064400000045313150515101440006731 0ustar00Contact Form 7 WordPress Plugin, 2007-2023 Takayuki Miyoshi Contact Form 7 is distributed under the terms of the GNU GPL This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Contact Form 7 WordPress Plugin bundles the following third-party resources: The official icon designed by Cheung Vong https://contactform7.com/2020/04/08/new-official-logo/ =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. languages/readme.txt000064400000000200150515101440010474 0ustar00Translations have moved to https://translate.wordpress.org/projects/wp-plugins/contact-form-7 Thank you for your contribution. assets/icon.png000064400000072155150515101440007512 0ustar00PNG  IHDR\rfgAMA a cHRMz&u0`:pQ<eXIfMM*JR(iZHHwJ pHYs  hiTXtXML:com.adobe.xmp 1 2 1 240 241 #P@IDATx}|\WN.rc4{$!@BHh%j:aދ,[{=Iwt{Tmgtw훷;;;;3;bK։JĆ^pm֛Fih%mL?DE!Ze@]K0S/"!:9$JU4CC|s=㈱2ÉD: JF`nRCSw4 yDaG{ Kw1(3Tbѵ.{7+c16DrA:a ֎trZnλȀGD%/ 0b)1(`W0 N3tpz >HA"b.# dY z'fERLOu#EȌn"'eGu@Dp(KaV0@R.o~#!N&ʠ_SEE*eBHD !EQ7(;O| ڪ-p< G'g8xx-ͨ1 7.QwM(χGg8654!7RUZ5vvTE(a"#G%?3P2O"%C}>ր amy&GDy{ F78x nxxBЂZ <3Rxs;: h57LM-ȪDQEpnME߹d'k9;!V@0cD@h"'eMK pxDS@HO&zVL A I;H:w et[B R `#9+i4R(9J ,C#5h*-_IZJrP{|?J z,g5+_Sz=zH(}4Qf"" )`A8#8qq썖e+hGsE~7 (%X0''SDR00C]8!~)QGDHyh/$^AL$DY4 !h Apd,B#n nٻύ )KKO#B+ wuǑL83!;~¼M׉H =[HqQމhěDn^nNMkv(Lϸq߬H9efUJ?!"z ~:ADp?;4,eQ ǽF FU8/Y; -_ , bv)bik&t :Q&]u5|g_1 Po4q}YL4LS@^3{} bA7ooKZdA_&ш^waDk,É={.!W۰N෩?5nF9 0erN&3,DV/?;A*X0QY8}U"#uƻZM4QCۧ==b@p1Gabjz.K#*?d ;XO_ ^?`$1ֻx1(}OwE<,x/yf^hjd# vzsvwQWEr[7 "A|he%:|a8]y6딼 N'>4Z71WދYp@%ӏ0x( FGVxTQ }i7.cE*ؗREA,x҉Sr/М0΁a(7)#gJ: ^ 4swe.CF7`F5"w2aX~ 8,y~x1ѝ gE땏sƠ |}koPf#p_S#?_jG%w~b8݋kQSI`7ұf) 2(\޳&`U{=|O@RQڳo~u 1,8a&ܝQvОQ>B"uhQ;cpaa>Q ;~߅ؑ-L{6| /G(}+nG}-vdlju@11KX7#?/'(.1I'yMp`տ"* e|'d1Hf-Ja8Ɂ gvڮ (:+*D/ t@~79(0z␅bH_!DG ӌSZ oDq0i >}kn[A=KclLZ|`Qݾ,#drQ C*vũ֞Pq\Q߄W#nZ}=X/3d)0.r4s,Ue%0Ӻ>x61(LЂ $dDk |˾aјr툾؝4Su]L " njq5#d/AcwCJ/0(b.!N-L1x5݄\w-F^\hɈdLw bZ.K}lbϴ ,xa(1ݗeDON cRbo:Q@: Q70n&bq^ꐻ],z* ŧ bOO_2OzS@mX H ơMm'ƅ̑XXI?G C-VdI|ӌ_lY:P/I)J_2eiqP{V`2L(r*9xEsaJ7VzSe-=$צ#5TJ)AR<Da+F 0DӜ`\}?"* |aR4X!CkglOPxr--ڢ2Ygb9XF& `Qf HsfUngȤS.S"3,UNڡN.=P@@ǘE$ϛ Bs *3wV<&ŭdudCYx f=T 3NQhL$Gc%J3؛e{ Qψ$pލI _QL?>ZSt\Ke_62x1r$LH1|gc=XMo&ba:: *;:j,h'Ѝl !'Vg< WR h0\r_uS`(Q@@B"=z^H z8h2;` Np!9C؀Jhc{9 iK.jWChSS`pQ@,$iHLrƁ?vO>&bxSW8Cʁ!ZKߠ$ Rö^vS`(P@Lcp HȦf 2(D͂7J@[)}hDQ]T2F;=ĥWÁ2,&#lȲ`+)*Eؿ^-#X"DM[xȩ"6S`8Q@t vmD"<^Xۃ˸x*'S[9 >AjG_C儳"Ɓ:Pdy|1j4RWjAe|J<%p*l?OMW@kQeciRI.Bk@({Ge?q/^  m!x)QsKq] ? 𧀢cq{00,Gu,ރ2S%T1_?' Iq3 򆻑7I﷊ 6Ì־^s"QQTL**e(©`BlZھI?_~}߆NzˆDjdl0yXUM?+{D1 #!`ϰy u'0]tJHAqt j 9ca(D07kJ2ϏhWsۇhp p,/Ɲ{.’m :Fd,t5! J=!aLjC`@`  eDٺPѓ#p`RRAO)0( na h%?e%WN!O4 bzk:EDv}!3χ^S`RkEݑ POJgg / 颿*đL,X3L͵>)uּM/Jx Q]Kip`L6/E^ikƝ JTN4Il?_z1YH8N=fANm 41Z;u uBƚɖ{6=D[f=BXx8ZDÙTVڄ8i,3^=lmk]_e=bH$&Cetw)C AyVD* $Ўjkl|!kuDٛ%+o@Kȣ[:Ds5"ڡ%HK "7!mKUpcUW6`a\ν 呣ʠm'G.cƢiZLU@9_C dL*Ѓ/ё4vwey(ߕLov) j npvBGuluP@"Q.y OV]Sx_@[m?5:4 =M9obeloe9*cJƖIHއ ?<\yg_JMX upqqA Y_*LB$5y_Nm]"HyEXÙо .09P^T i_U47 lL6 ?:4p6D%|dEʋa.CSU1rX]F0#F-$~( wM9,7J;Rps3ިgV't,Fk cr1c`o@$+hXwU3]t`CL: 0_ob-S4iY8fJ}hI=ƭ}6Oe#zO_Cu8Mrۯ ʎRn1-c/ת<oGC(v}"VF=w-6ʌOQi4b1D/^hr!0 c=ٯL3d#;Eo2q̀X]/ )KSCھ?9]]Os(ʼn;R7w;#,, \>w{PዼZWpW Hݻ]E+RIoòƐU`jK`HU4k+{ة" ~8).ZLt8p$ݝ9\^ם_$ z*ȾuZ^xu_xAg-7]gc-¶e2n#Pw0.2%R@Xn+j38Ri ˘AOڅ2.{Pɿ{uAQhRDD"zb?( Bѹ0n7ۏ{\*OQV*K1%>adžP6A@|D F̲WHz3/ܱ857X/5 @ѻW#dի(z]E"s UMM5qժuUh ڔ/wbԄv+Sګ7ϫӘv{3矃E͖ve`;/i9舀{^k\멤XgI)6w+)x^$VLJ ;'dEhO36|~M-APu)$d@ ֬Y\Ï୷œ3 pqvs;!))IM@75Qsܜ<t8=)a)GT2iU2E} 1Fb-&aF)jeS/: Nw`oEFU2smC9///qwÓO>K/lp |}GE6nؠ\έҊ%wfL= (\nߨUviDMe`w J^|=ѦՀgC%F]$8h{cA6gxܶz]gΜxw0FH11$Yv- 4DQ*Ѵ{$'&&:KA2@SgW <|!hJGju8 ` ӦQGQ̪4\r)n&FQר\]ln!.$kWpk>_oaxPLեĮNB?^I<[^baRtFɩ &L}Jb0% Yny޼qͷ >6/5xgԬ'bV\ÿ dӮS@$GC(fɖ ha6;a &s&b4s>x{WN _ j+X%ظx7nt`=}"?-~شY]7!vrEֶ2y?2u\p|s@,fi-.{!I&I-4&t K:]+ˏ1>y_vq/ VI /W\qFދ{~;E!hM)) Q;.o*G_(@=~,\k5_,`!o(Cuco_D٩+Q6U&ę. ekP.6F%˃3!6n$8z,99ہM뚯bЮwBDc35!Mp/>ATr ?[^A?X"mIB! nO6I3!*4Ι2zg5=,*KLع!?4eEC( ]ҷ==v˟[oRZE)Sh>CWv!¡GB=GĚBT 'K֒pot*OK(y>;O@&87ޭZ~{9v}]Ą8_ܻAyZ ׾&Jt r1J1cXB"i3.O9S4q7cw"V2xo`GL8Qzk+@"4TQ[6л/ %}RukA5&MƦkp8\8V5@$>a4ؑÀ8uZ(049tֵӓ2}y g(z&J׎׻r744৷{.Ex9Fww[o6!Hg+~y_Z6X'Бa 5\3QC h/$F/@gh5靗kAFc ϟbTR*x`.e]_yEi4TU>{>B{xHg}{rxk!\QkkUDL tTp & )y.*U=xys{AWoch#OqG>wV+/ӧO]lx`.C"""իW)LOtQ)Ǜ?nd1a6yLtIHpH_rUEs"#U%y0# ܽ}ek,㺏P*1z}OoM 1}8} SrmcB(/_,WSp݁9 )0eT X@ 4r {V[HڞWm\VV1k~~~&ϡR r෿-.=Bc5X_Q{(ᡨ$Ԝl3DXiFEG$Xbe"2q^P$:tO٥ ɞ185bb1B39JbG~>>'\"ҫ+ .wމ0x'xUKAz图7(HP%MgʹHƸI)ZeGIz@awZv@fzXv<>ՕK=~`yvjYG'3>YfVnhGTp(c Ҩk *0h 4bEuױAq:,Ư~u'Y]Foab݃1cOJ`p x2zP%ӉDѯ8^gW"ʆ-41THo_D% ZY ]|<Oh۷Ҫ+uRpZt&Е@~ p4zK+^D+ **i`^waG!}vB2}oj( ƤSZYFgo㳗t&F44m % _(=x3ѕh)hȦ36:TaW#{tdY^ކ#+AD Bzz&rJLQQ\֊"lèIhd?eG QXgmj@8w3O{oEg~npQ%jɺF7 ;3!b׽]teM; /ۂtjqoZ3#/EwbM#͍%ɞ\jџ"Q܊j٢欧Cc;~ 2݅$U"(ErVM1J=Juz5w) Ga0QhEDz챿 E#P?FW׮UJ >+WT(R#?Lk?1fZ@+G~&̛W H5S[ EK@=@ʌ`?%<P⍍hN0O3la0eGJAs?E`ư aC>ctfRB]֊/>KÖ9 qCp/\U}zDF 񈎎_| jYj0ӚO5j,@8 X|Ksrh+e[y zۅ3{5ݮ.kplmNwb[uOO?5 K1vԶPL̲܄6kc|xrQX'VcUQ\B;>'vq?=VR{O°[xT(X#Q-(ѻN!6~bX+CbdC+Wˎ5󇇆".,'Ww~5\B_9Pߨ8}Pw◷}w?ހҲ~ӓASnSOU@ l!]wGnj,`ol ~(F|ۍ??O#?z QARGݏ58Qrw$g`nZ F[ ND%][ߕ'ENts6QwRa->$E%?凱OU[j8(v_ (ۤ/Xt(~1; n]Źjۉg_Z:u=j'?܃OP+҉qo|1/'m^;G<5ıg|~.]gq[`p T6cPxЂr8(RjF x;ix=n9/<4yK;^}`a-:Q`DSBăߏaiqq=ll>}(Eפ?BSݝpˇNJ .|2G0al׶lS\\42~ՅhRvJw^1k wnԜ'$&MC؋>"7˹ !7^ MWbΙ}%Z ciu){>y_+dlẎG88M_e±5Jh ^Aj,xmAx`hv^Ȭx9"JWAEU"%HzHd1g ;@q rQ3/V|.0szRkxDuϚ&| ?ŭ&TX~UQc3(x:XJ9r8+_ 柍 ck /ՠ"֗XHN s^3>eP_ K ޔS6@}q8+/CJ?~;q(`Ț6&)wե'7u:Un1(m1PI=31)p&Tn0H/W3lhMXҌ'^^ ##L˵Ŷ211>A]BۚNޭ ɃY8deTʺGS.258m>9^W Ӭ Q@eyIo L . :Č&u9cjd(KĐN3fq(sze;@I~6# DL x@+PFvdյHJVk$yoiG 𓿬'&J@̘JY8eSg}y.i_O& EXj5]T&њ@Βw%7(W {? %-3f: *؉z:IfHΛCT>=AfO7JQb>ꎷLE|/nn#{doG-!Cjۢm` : n!F,8EFv>[Y0@$<ĔN|OUT~V7X*@Qu '>l7o7 ~o'[cv8Dcg'&BXtliJZ0!!=422HhXqfE O4X_#lг3JI@|+OQSbxBt0g"5GCN{u;~q|{WUscH,*)J%& fٺbKb[Ja)!]هP]X>Z~(HhExrqy>la! 3wZz0~/Wc= ڽ "5>AФ”M(yp nɈI^x[:1ֿT탉L2C^%>F<jx628(`10R܋ڳiߊ4U@]A¢8 )`G˫&Da8d32vAliە}-B|"~r |UwxYclB4VX%TfU|:Bâg lڏB[#*m+ })= _ź1e2k:yL&;e%%4|\xKd,M'H'oQc;upfP:zB=7xŜ] g tvB:&lzcMmcS1RI8߇Hr6hd6DbEQ:8zN"nld8&!A,Nt1#gVϝ#`qz"pck|C n}|>PwddLC)- ywGb̥ Iм,%w<}pRsK OCHup,w7P֞͒k1Pk&d#/@K؜h evxO>1S3ll3G3\kypųll Nq~1 p*!˪J3jo{\4.=><&QҬKɃa XRPt_\k3ʲ_ߑnr*m8[$Dgmm+}7aPfnn2n|şupwPsp2:‚yd&FAMv+ٸpJ8k d52$̐[P lGك҉H1DCQgnbv󎠾z@촵Zӓt9˧ +_9iڵh)3YH7ȪOο nqySS%a)1h>~y{p'ìv|N <$V<0IDAT7.TZu$2r*ʐK>L8}a`! %ZҚS 7LMdi/FܥpN'vM.܄=|Oj~'v}%e3vdsˬiw' i8"LH`Pyp-|&2|/%g͙-)<&½;nq1f\|(Ǝ3 {e\T2#}16%4=H >}l@پ\<0s-X0or hqSEDJ.-Q6`?@iO΄TSwoS]‹ zOP1klGwߒP,b+}^%)IW3+ b ;q^Ex#E`92OMU(K_*f_fZLMxMQ\ی`ZXbҟ9盰eOv)ƞ~L SSR­% 'wkF۟'8|1e}ޟz,9ÈB--ki *2P7Ruû;#ԋ' u*CagPF'ٳ),bH@Cڃ./Cס2vJh>,;V$KY!\V<'YJ S8&T pKݎگ<SlǎFH"z$ C el|~tf4.]:CyR.>CIi5OY;Yσ9ʐG4NIy,xZCd_SbB7; pAv.-+qSnKA) aӉa upbUʎNt~/&+-HWrPĻ Vӊ0 %ݏޫ[(eЌz3o=vLZ"M2ɴ2.S =U)p@p3 }7y[rK#=gL? .&WC⊸t\slN.*Ǹ3L@4b#^d -ȈĬhbCN(f8K3kzgBZbAT3\L~t{՘R?? ] O JhZ\Rwl(P5XkҒ gmڝ KJS`p@,ndAp>yѤFj2\!ʾfz~qzD_GKsu^^^5qkxxmQ8s[ɂFzkxkWҞЄ ?W<׺H1rd5H @SS3֮QLj Z:œMk8Hü1c6כ>9E ^YrwwxJN؞vðv%|BA&jJڱZ{V.t{De?#P DY= =OTK H/>cŋXC(cm S`G狨s1{4yjR_!gEqϚ(Ͽv>G'O?zVߟ7݁b̚ќQxoέfA}¹E̕ @,n"n&х2!bd$TY W^XčXzbk ؄ <|'`O3-S_֌__;nW`x/؋9F1vM_u3qnY^Y53[4\S !c0&9kV%C$uS+dP0i0:7 >n?Oy1.C }uRY 0rBC:+ uç{m۰J7Ѽ~]40ɜ{ڄB&OD?2s,faZyt J s@eFbջw=ݽ4f."a]k+Y /rIK53gďes'I١P:{43G6qyWX!5wӣr$h[\$TX2i)N@ r+"vb"ՠ8$ĽmjXڷwvJiDBT\†*g92FLrc*upٌX|۶yp~ִD*; b'bt<6`{YGitߥ'oo<pMr]XéL|B Oe0p)F`@l%qK:HHG>\@$;_1X:&fW~K"M5`AWҶc"Bמ'rb5iˣsګUɍsx:rZo|3 I/F)jЩޒb⺹308;0́/HG8Ruo6[]#k@x,! nh{s4hcp{t ǛVu#,D5ZooB7\4 5+! 4r Xlb$te{iC*kc z ;~I}ߣ7W1yg_ tᶧ%p[Yoٖ~}sZr{J^4N㲓#^n?euPY՚" j}~VۅCt.je/cǔcj/$.CGoDB`>9&[2Re|2u,6mc%ݝ&cfAA icXVsh{߈(3Ӛ4|3iK+ܸ?QUǛ7O7#{Eל;Qmqz_Mu e\p`q %X8g|శ xS˾)xhv}¢bZ s<7j%CoǛuT)7Y`:ѷcA^Fk4EœZ[~nħWoȵp6mLx{¥(tAeK[]H9sK?#{2 q \ ]cPd2$W/( my%|F3iϤ9WtVn=tמH?V_DE!Ü|T#JyXj!/džC"5(cg)j`@:p'F\r߄1 =N(@}݇=qi"@Bx~`jykmIWl>Ulx=pu/n]֔Ni4Zz__bwq\:?l) Fo6c4&.AsFwLGm1*:[ʎ#0BUd:~FG+@h kv(&HvqFa>%yN_8840vz"}?~oÁi>T?3Q8o8]o :àg}NPVVVlij?d q@O({Sѣbx@xU() |>ϾԫI_n"lG$p,D zkаg+˳9¼O}6$$eq2&OoHi$]60_p)PqQ(l_m ֞~C;*ܟP r/]Bz.)Syy]g/ن7icSg7vD(cx6pֱet7 UN8WXRZ `כqp^ԷT?_zLl4!nv4!Qt(*A ,Y~i~3ԭՃ۔;WL(lb'bYJ”N7:~8ViEܾaDW`vw#pv$u)q* qqvNNjǷb`N^;ݽ?]w{ TB%ڍ܉XF/L ~6_^R@qyOq4-u$|O:߽ĵj/xxڅ=I D|916? N9oOx(LFՇx7 tq>ňr*CM1ۆ6:p&yb_V B^gi-7dO>EDrmX 3ȴgy:BMThstJ~ 5w1~pt;ըuw[ndSMbR F#c$P٨3`{-pzKF5!20Fw8 Tow4551^<8hC?H$8flzN DW# /%()Jy)xwĎ!xх S!)fF&=G9u tC%]G^?kBvvJR׈{:|ҦxbPf=rқ|"KN'iEf=MȤ2yr(!FAgn@t=,#=abIe*1@bK"x8j =QNP@ 8BKwG`rR4+]u/xvbVewdȵ*xqO[!uS@@w%uq3,Q4ؿB ElnYJ':t R@u6[5CUkkٞ2Y`HsP_6y2zN}H2Bju*{CU=}ZZ[$ E&=]@( cJƖo:c亮^p].L-)c)(" U i pIH'ppNVYQ(%Y")QH/ۖ:H$͛3;ߔk{sml+,`SpAW+vRŀb PSԭW_.vo#Xr |7&3+I1hCU,.~@ PS- ShKnzr _=8,)H* %J%*Jg?u:E䶮yO'Y1E'CGfŕ)MI%(%3S\)\lco08z<j8rq X  I)Ja'eaꢶKNt;M&UbwdNZpTˣÐ(;JS 4,ƿN/uYXl~)` n@>Q*E1P̑IO jWu랝Ew+K "GaGZ(j:p 8 ph^,Vl-4^(4,􌏸VYd` XJ5ɪq ]sp$vY[b˳1)d4@d= /EJ3q;{ďUP%u3Dd^~ǼNd cjșǁ9q{P~{RiIex# #XVČ]vh̓sRXWPݶV|rK߰[uiqI{q9%ѕСJ%<|{YG/}wlT#ixG teDm#Mm&vD1P/ $ Y$qcy ?Lg֍6+aA1n$zJ)KJ1{&1|2qdn= M Z]ns`LEĹ|MbTIR)*x5jb8|G6dj2;PX 0hk6n[!O)~ ((Iiq[+!s ҥ6l"|K2<̹;'5! 2QCGo@WR`uy/^2Ě`n ʿ4%K2:tA|y TG gM[6“'a,1@W0 FIb .]*qaX/;P[g$bϗM iO6 \%8QJ8$-"ҔcJ6\/4 Q)?]}va}k#<X<'07fۊحNia#oo.ЃM}fD':$9oaasK}cMZ1$-4Mna¼"C҆DܮV a.Up(Yo Es&ż<*c@jBjP 8$%SZZwKۃV2`Nɺ1@gqkôv>]~^2*7恚yMk3B\¡"zH4k 5.Hɖa1}FѷXN|Ql)a=񪺹 o3 03\Cb5YFUrgi yt!'O9<ׁ/5Z4x=@-3ߔC=^,<╔ @)Q T!h5ô$E9yUmT_=lG W竘%YR =DX.1{u(nJ o@M4ϕJ)j+ݒ$NgAQGP |Kي9 /{0<Z2k^@ܨԍfM'Ćo|[P;fp=>,`=-u%Nɍ#.+]m2kn\*]1p/q. wT;Լԋ t8-ࣀ0Aiwd&Ici`ڤz26sO'BM4?vppۓuz2^z''Tea~FBJo[ %@4WU yk,Y|ț%{MGs41Xq*u#fH,U]ad2F#kSLvaX1)11D1<^Evȴu팄BK*?R~>z4n%2ὤS YNI",tD꒑ F@y!~z4kGٱKI,ξ;E w1hPzkE V.:8U Sa\ H`i%Nʑ1e^55&ݘ>۴L.K*]R!>C|xXVxk_C0;*.kJRXpG2N'jWYwﲘgH&HdܼJ}%wOJrJ:&e \MK:Џ6-.6 !o%>"7>|paǤ縌'an,\ o7%1gằx3,ɢ]ᲄׁ`UrK#Tx'(Y`l. W<@#Y2qUH'n(>qSr3>~@H#SC@kOtNɚ,0f/h#Z.3j4Ϧe%*)9rT|"e?^N]e ZP6'?ēbGmZRD:)_X%kg+&pc£Trp>F__'e[vOT$ǎ=G$j3#`B,1i/J{Qp%Y`\= |eV?y>< xČfD.dL~ò-tRf&ly^6uYgez\xbdRP6+">Y`)7-CX,GȞz*K1,ڭ\0& Mli`ηޒkפmJPx| `6M1q7c  |ђE)\Jo{C!}o,WᇒPr ق 4&V@I \ķ*1 @,p;? 8@`꾒`cɧŸ@Ncr9wQ(JQ^TG хo$ l'ӟwwnW+d@ nn~;hZ.20.[3 np:>  C.=4-@C>7@e9==9 aV_Vj 67 O8H0Be=BE'9l[oUR (PKAh1a: 0`4r M;BThog.=_I1.x[IENDB`assets/icon.svg000064400000002777150515101440007530 0ustar00 wp-contact-form-7.php000064400000003544150515101440010443 0ustar00 true, 'zero-controls-container' => true, 'not-for-mail' => true, ) ); // CAPTCHA-Response (input) wpcf7_add_form_tag( 'captchar', 'wpcf7_captchar_form_tag_handler', array( 'name-attr' => true, 'do-not-store' => true, 'not-for-mail' => true, ) ); } function wpcf7_captchac_form_tag_handler( $tag ) { if ( ! class_exists( 'ReallySimpleCaptcha' ) ) { $error = sprintf( /* translators: %s: link labeled 'Really Simple CAPTCHA' */ esc_html( __( "To use CAPTCHA, you need %s plugin installed.", 'contact-form-7' ) ), wpcf7_link( 'https://wordpress.org/plugins/really-simple-captcha/', 'Really Simple CAPTCHA' ) ); return sprintf( '%s', $error ); } if ( empty( $tag->name ) ) { return ''; } $class = wpcf7_form_controls_class( $tag->type ); $class .= ' wpcf7-captcha-' . str_replace( ':', '', $tag->name ); $atts = array(); $atts['class'] = $tag->get_class_option( $class ); $atts['id'] = $tag->get_id_option(); $op = array( // Default 'img_size' => array( 72, 24 ), 'base' => array( 6, 18 ), 'font_size' => 14, 'font_char_width' => 15, ); $op = array_merge( $op, wpcf7_captchac_options( $tag->options ) ); if ( ! $filename = wpcf7_generate_captcha( $op ) ) { return ''; } if ( ! empty( $op['img_size'] ) ) { if ( isset( $op['img_size'][0] ) ) { $atts['width'] = $op['img_size'][0]; } if ( isset( $op['img_size'][1] ) ) { $atts['height'] = $op['img_size'][1]; } } $atts['alt'] = 'captcha'; $atts['src'] = wpcf7_captcha_url( $filename ); $atts = wpcf7_format_atts( $atts ); $prefix = substr( $filename, 0, strrpos( $filename, '.' ) ); $html = sprintf( '', esc_attr( sprintf( '_wpcf7_captcha_challenge_%s', $tag->name ) ), esc_attr( $prefix ), $atts ); return $html; } function wpcf7_captchar_form_tag_handler( $tag ) { if ( empty( $tag->name ) ) { return ''; } $validation_error = wpcf7_get_validation_error( $tag->name ); $class = wpcf7_form_controls_class( $tag->type ); if ( $validation_error ) { $class .= ' wpcf7-not-valid'; } $atts = array(); $atts['size'] = $tag->get_size_option( '40' ); $atts['maxlength'] = $tag->get_maxlength_option(); $atts['minlength'] = $tag->get_minlength_option(); if ( $atts['maxlength'] and $atts['minlength'] and $atts['maxlength'] < $atts['minlength'] ) { unset( $atts['maxlength'], $atts['minlength'] ); } $atts['class'] = $tag->get_class_option( $class ); $atts['id'] = $tag->get_id_option(); $atts['tabindex'] = $tag->get_option( 'tabindex', 'signed_int', true ); $atts['autocomplete'] = 'off'; if ( $validation_error ) { $atts['aria-invalid'] = 'true'; $atts['aria-describedby'] = wpcf7_get_validation_error_reference( $tag->name ); } else { $atts['aria-invalid'] = 'false'; } $value = (string) reset( $tag->values ); if ( wpcf7_is_posted() ) { $value = ''; } if ( $tag->has_option( 'placeholder' ) or $tag->has_option( 'watermark' ) ) { $atts['placeholder'] = $value; $value = ''; } $atts['value'] = $value; $atts['type'] = 'text'; $atts['name'] = $tag->name; $html = sprintf( '%3$s', esc_attr( $tag->name ), wpcf7_format_atts( $atts ), $validation_error ); return $html; } /* Validation filter */ add_filter( 'wpcf7_validate_captchar', 'wpcf7_captcha_validation_filter', 10, 2 ); function wpcf7_captcha_validation_filter( $result, $tag ) { $type = $tag->type; $name = $tag->name; $captchac = '_wpcf7_captcha_challenge_' . $name; $prefix = isset( $_POST[$captchac] ) ? (string) $_POST[$captchac] : ''; $response = isset( $_POST[$name] ) ? (string) $_POST[$name] : ''; $response = wpcf7_canonicalize( $response ); if ( 0 === strlen( $prefix ) or ! wpcf7_check_captcha( $prefix, $response ) ) { $result->invalidate( $tag, wpcf7_get_message( 'captcha_not_match' ) ); } if ( 0 !== strlen( $prefix ) ) { wpcf7_remove_captcha( $prefix ); } return $result; } /* Ajax echo filter */ add_filter( 'wpcf7_refill_response', 'wpcf7_captcha_ajax_refill', 10, 1 ); add_filter( 'wpcf7_feedback_response', 'wpcf7_captcha_ajax_refill', 10, 1 ); function wpcf7_captcha_ajax_refill( $items ) { if ( ! is_array( $items ) ) { return $items; } $tags = wpcf7_scan_form_tags( array( 'type' => 'captchac' ) ); if ( empty( $tags ) ) { return $items; } $refill = array(); foreach ( $tags as $tag ) { $name = $tag->name; $options = $tag->options; if ( empty( $name ) ) { continue; } $op = wpcf7_captchac_options( $options ); if ( $filename = wpcf7_generate_captcha( $op ) ) { $captcha_url = wpcf7_captcha_url( $filename ); $refill[$name] = $captcha_url; } } if ( ! empty( $refill ) ) { $items['captcha'] = $refill; } return $items; } /* Messages */ add_filter( 'wpcf7_messages', 'wpcf7_captcha_messages', 10, 1 ); function wpcf7_captcha_messages( $messages ) { $messages = array_merge( $messages, array( 'captcha_not_match' => array( 'description' => __( "The code that sender entered does not match the CAPTCHA", 'contact-form-7' ), 'default' => __( 'Your entered code is incorrect.', 'contact-form-7' ), ), ) ); return $messages; } /* Tag generator */ add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_captcha', 46, 0 ); function wpcf7_add_tag_generator_captcha() { if ( ! wpcf7_use_really_simple_captcha() ) { return; } $tag_generator = WPCF7_TagGenerator::get_instance(); $tag_generator->add( 'captcha', __( 'CAPTCHA (Really Simple CAPTCHA)', 'contact-form-7' ), 'wpcf7_tag_generator_captcha' ); } function wpcf7_tag_generator_captcha( $contact_form, $args = '' ) { $args = wp_parse_args( $args, array() ); if ( ! class_exists( 'ReallySimpleCaptcha' ) ) { ?>
    scan_form_tags( array( 'type' => array( 'captchac' ) ) ); if ( ! $has_tags ) { return; } if ( ! class_exists( 'ReallySimpleCaptcha' ) ) { return; } $uploads_dir = wpcf7_captcha_tmp_dir(); wpcf7_init_captcha(); if ( ! is_dir( $uploads_dir ) or ! wp_is_writable( $uploads_dir ) ) { $message = sprintf( __( 'This contact form contains CAPTCHA fields, but the temporary folder for the files (%s) does not exist or is not writable. You can create the folder or change its permission manually.', 'contact-form-7' ), $uploads_dir ); echo '

    ' . esc_html( $message ) . '

    '; } if ( ! function_exists( 'imagecreatetruecolor' ) or ! function_exists( 'imagettftext' ) ) { $message = __( "This contact form contains CAPTCHA fields, but the necessary libraries (GD and FreeType) are not available on your server.", 'contact-form-7' ); echo '

    ' . esc_html( $message ) . '

    '; } } /* CAPTCHA functions */ function wpcf7_init_captcha() { static $captcha = null; if ( $captcha ) { return $captcha; } if ( class_exists( 'ReallySimpleCaptcha' ) ) { $captcha = new ReallySimpleCaptcha(); } else { return false; } $dir = trailingslashit( wpcf7_captcha_tmp_dir() ); $captcha->tmp_dir = $dir; if ( is_callable( array( $captcha, 'make_tmp_dir' ) ) ) { $result = $captcha->make_tmp_dir(); if ( ! $result ) { return false; } return $captcha; } $result = wp_mkdir_p( $dir ); if ( ! $result ) { return false; } $htaccess_file = path_join( $dir, '.htaccess' ); if ( file_exists( $htaccess_file ) ) { list( $first_line_comment ) = (array) file( $htaccess_file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES ); if ( '# Apache 2.4+' === $first_line_comment ) { return $captcha; } } if ( $handle = @fopen( $htaccess_file, 'w' ) ) { fwrite( $handle, "# Apache 2.4+\n" ); fwrite( $handle, "\n" ); fwrite( $handle, " Require all denied\n" ); fwrite( $handle, ' ' . "\n" ); fwrite( $handle, " Require all granted\n" ); fwrite( $handle, " \n" ); fwrite( $handle, "\n" ); fwrite( $handle, "\n" ); fwrite( $handle, "# Apache 2.2\n" ); fwrite( $handle, "\n" ); fwrite( $handle, " Order deny,allow\n" ); fwrite( $handle, " Deny from all\n" ); fwrite( $handle, ' ' . "\n" ); fwrite( $handle, " Allow from all\n" ); fwrite( $handle, " \n" ); fwrite( $handle, "\n" ); fclose( $handle ); } return $captcha; } /** * Returns the directory path for Really Simple CAPTCHA files. * * @return string Directory path. */ function wpcf7_captcha_tmp_dir() { if ( defined( 'WPCF7_CAPTCHA_TMP_DIR' ) ) { $dir = path_join( WP_CONTENT_DIR, WPCF7_CAPTCHA_TMP_DIR ); wp_mkdir_p( $dir ); if ( wpcf7_is_file_path_in_content_dir( $dir ) ) { return $dir; } } $dir = path_join( wpcf7_upload_dir( 'dir' ), 'wpcf7_captcha' ); wp_mkdir_p( $dir ); return $dir; } function wpcf7_captcha_tmp_url() { if ( defined( 'WPCF7_CAPTCHA_TMP_URL' ) ) { return WPCF7_CAPTCHA_TMP_URL; } else { return path_join( wpcf7_upload_dir( 'url' ), 'wpcf7_captcha' ); } } function wpcf7_captcha_url( $filename ) { $url = path_join( wpcf7_captcha_tmp_url(), $filename ); if ( is_ssl() and 'http:' == substr( $url, 0, 5 ) ) { $url = 'https:' . substr( $url, 5 ); } return apply_filters( 'wpcf7_captcha_url', sanitize_url( $url ) ); } function wpcf7_generate_captcha( $options = null ) { if ( ! $captcha = wpcf7_init_captcha() ) { return false; } if ( ! is_dir( $captcha->tmp_dir ) or ! wp_is_writable( $captcha->tmp_dir ) ) { return false; } $img_type = imagetypes(); if ( $img_type & IMG_PNG ) { $captcha->img_type = 'png'; } elseif ( $img_type & IMG_GIF ) { $captcha->img_type = 'gif'; } elseif ( $img_type & IMG_JPG ) { $captcha->img_type = 'jpeg'; } else { return false; } if ( is_array( $options ) ) { if ( isset( $options['img_size'] ) ) { $captcha->img_size = $options['img_size']; } if ( isset( $options['base'] ) ) { $captcha->base = $options['base']; } if ( isset( $options['font_size'] ) ) { $captcha->font_size = $options['font_size']; } if ( isset( $options['font_char_width'] ) ) { $captcha->font_char_width = $options['font_char_width']; } if ( isset( $options['fg'] ) ) { $captcha->fg = $options['fg']; } if ( isset( $options['bg'] ) ) { $captcha->bg = $options['bg']; } } $prefix = wp_rand(); $captcha_word = $captcha->generate_random_word(); return $captcha->generate_image( $prefix, $captcha_word ); } function wpcf7_check_captcha( $prefix, $response ) { if ( ! $captcha = wpcf7_init_captcha() ) { return false; } return $captcha->check( $prefix, $response ); } function wpcf7_remove_captcha( $prefix ) { if ( ! $captcha = wpcf7_init_captcha() ) { return false; } // Contact Form 7 generates $prefix with wp_rand() if ( preg_match( '/[^0-9]/', $prefix ) ) { return false; } $captcha->remove( $prefix ); } add_action( 'shutdown', 'wpcf7_cleanup_captcha_files', 20, 0 ); function wpcf7_cleanup_captcha_files() { if ( ! $captcha = wpcf7_init_captcha() ) { return false; } if ( is_callable( array( $captcha, 'cleanup' ) ) ) { return $captcha->cleanup(); } $dir = trailingslashit( wpcf7_captcha_tmp_dir() ); if ( ! is_dir( $dir ) or ! is_readable( $dir ) or ! wp_is_writable( $dir ) ) { return false; } if ( $handle = opendir( $dir ) ) { while ( false !== ( $file = readdir( $handle ) ) ) { if ( ! preg_match( '/^[0-9]+\.(php|txt|png|gif|jpeg)$/', $file ) ) { continue; } $stat = stat( path_join( $dir, $file ) ); if ( $stat['mtime'] + HOUR_IN_SECONDS < time() ) { @unlink( path_join( $dir, $file ) ); } } closedir( $handle ); } } function wpcf7_captchac_options( $options ) { if ( ! is_array( $options ) ) { return array(); } $op = array(); $image_size_array = preg_grep( '%^size:[smlSML]$%', $options ); if ( $image_size = array_shift( $image_size_array ) ) { preg_match( '%^size:([smlSML])$%', $image_size, $is_matches ); switch ( strtolower( $is_matches[1] ) ) { case 's': $op['img_size'] = array( 60, 20 ); $op['base'] = array( 6, 15 ); $op['font_size'] = 11; $op['font_char_width'] = 13; break; case 'l': $op['img_size'] = array( 84, 28 ); $op['base'] = array( 6, 20 ); $op['font_size'] = 17; $op['font_char_width'] = 19; break; case 'm': default: $op['img_size'] = array( 72, 24 ); $op['base'] = array( 6, 18 ); $op['font_size'] = 14; $op['font_char_width'] = 15; } } $fg_color_array = preg_grep( '%^fg:#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$%', $options ); if ( $fg_color = array_shift( $fg_color_array ) ) { preg_match( '%^fg:#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$%', $fg_color, $fc_matches ); if ( 3 == strlen( $fc_matches[1] ) ) { $r = substr( $fc_matches[1], 0, 1 ); $g = substr( $fc_matches[1], 1, 1 ); $b = substr( $fc_matches[1], 2, 1 ); $op['fg'] = array( hexdec( $r . $r ), hexdec( $g . $g ), hexdec( $b . $b ), ); } elseif ( 6 == strlen( $fc_matches[1] ) ) { $r = substr( $fc_matches[1], 0, 2 ); $g = substr( $fc_matches[1], 2, 2 ); $b = substr( $fc_matches[1], 4, 2 ); $op['fg'] = array( hexdec( $r ), hexdec( $g ), hexdec( $b ), ); } } $bg_color_array = preg_grep( '%^bg:#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$%', $options ); if ( $bg_color = array_shift( $bg_color_array ) ) { preg_match( '%^bg:#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$%', $bg_color, $bc_matches ); if ( 3 == strlen( $bc_matches[1] ) ) { $r = substr( $bc_matches[1], 0, 1 ); $g = substr( $bc_matches[1], 1, 1 ); $b = substr( $bc_matches[1], 2, 1 ); $op['bg'] = array( hexdec( $r . $r ), hexdec( $g . $g ), hexdec( $b . $b ), ); } elseif ( 6 == strlen( $bc_matches[1] ) ) { $r = substr( $bc_matches[1], 0, 2 ); $g = substr( $bc_matches[1], 2, 2 ); $b = substr( $bc_matches[1], 4, 2 ); $op['bg'] = array( hexdec( $r ), hexdec( $g ), hexdec( $b ), ); } } return $op; } modules/text.php000064400000023776150515101440007724 0ustar00 true, ) ); } function wpcf7_text_form_tag_handler( $tag ) { if ( empty( $tag->name ) ) { return ''; } $validation_error = wpcf7_get_validation_error( $tag->name ); $class = wpcf7_form_controls_class( $tag->type, 'wpcf7-text' ); if ( in_array( $tag->basetype, array( 'email', 'url', 'tel' ) ) ) { $class .= ' wpcf7-validates-as-' . $tag->basetype; } if ( $validation_error ) { $class .= ' wpcf7-not-valid'; } $atts = array(); $atts['size'] = $tag->get_size_option( '40' ); $atts['maxlength'] = $tag->get_maxlength_option(); $atts['minlength'] = $tag->get_minlength_option(); if ( $atts['maxlength'] and $atts['minlength'] and $atts['maxlength'] < $atts['minlength'] ) { unset( $atts['maxlength'], $atts['minlength'] ); } $atts['class'] = $tag->get_class_option( $class ); $atts['id'] = $tag->get_id_option(); $atts['tabindex'] = $tag->get_option( 'tabindex', 'signed_int', true ); $atts['readonly'] = $tag->has_option( 'readonly' ); $atts['autocomplete'] = $tag->get_option( 'autocomplete', '[-0-9a-zA-Z]+', true ); if ( $tag->is_required() ) { $atts['aria-required'] = 'true'; } if ( $validation_error ) { $atts['aria-invalid'] = 'true'; $atts['aria-describedby'] = wpcf7_get_validation_error_reference( $tag->name ); } else { $atts['aria-invalid'] = 'false'; } $value = (string) reset( $tag->values ); if ( $tag->has_option( 'placeholder' ) or $tag->has_option( 'watermark' ) ) { $atts['placeholder'] = $value; $value = ''; } $value = $tag->get_default_option( $value ); $value = wpcf7_get_hangover( $tag->name, $value ); $atts['value'] = $value; $atts['type'] = $tag->basetype; $atts['name'] = $tag->name; $html = sprintf( '%3$s', esc_attr( $tag->name ), wpcf7_format_atts( $atts ), $validation_error ); return $html; } add_action( 'wpcf7_swv_create_schema', 'wpcf7_swv_add_text_rules', 10, 2 ); function wpcf7_swv_add_text_rules( $schema, $contact_form ) { $tags = $contact_form->scan_form_tags( array( 'basetype' => array( 'text', 'email', 'url', 'tel' ), ) ); foreach ( $tags as $tag ) { if ( $tag->is_required() ) { $schema->add_rule( wpcf7_swv_create_rule( 'required', array( 'field' => $tag->name, 'error' => wpcf7_get_message( 'invalid_required' ), ) ) ); } if ( 'email' === $tag->basetype ) { $schema->add_rule( wpcf7_swv_create_rule( 'email', array( 'field' => $tag->name, 'error' => wpcf7_get_message( 'invalid_email' ), ) ) ); } if ( 'url' === $tag->basetype ) { $schema->add_rule( wpcf7_swv_create_rule( 'url', array( 'field' => $tag->name, 'error' => wpcf7_get_message( 'invalid_url' ), ) ) ); } if ( 'tel' === $tag->basetype ) { $schema->add_rule( wpcf7_swv_create_rule( 'tel', array( 'field' => $tag->name, 'error' => wpcf7_get_message( 'invalid_tel' ), ) ) ); } if ( $minlength = $tag->get_minlength_option() ) { $schema->add_rule( wpcf7_swv_create_rule( 'minlength', array( 'field' => $tag->name, 'threshold' => absint( $minlength ), 'error' => wpcf7_get_message( 'invalid_too_short' ), ) ) ); } if ( $maxlength = $tag->get_maxlength_option() ) { $schema->add_rule( wpcf7_swv_create_rule( 'maxlength', array( 'field' => $tag->name, 'threshold' => absint( $maxlength ), 'error' => wpcf7_get_message( 'invalid_too_long' ), ) ) ); } } } /* Messages */ add_filter( 'wpcf7_messages', 'wpcf7_text_messages', 10, 1 ); function wpcf7_text_messages( $messages ) { $messages = array_merge( $messages, array( 'invalid_email' => array( 'description' => __( "Email address that the sender entered is invalid", 'contact-form-7' ), 'default' => __( "Please enter an email address.", 'contact-form-7' ), ), 'invalid_url' => array( 'description' => __( "URL that the sender entered is invalid", 'contact-form-7' ), 'default' => __( "Please enter a URL.", 'contact-form-7' ), ), 'invalid_tel' => array( 'description' => __( "Telephone number that the sender entered is invalid", 'contact-form-7' ), 'default' => __( "Please enter a telephone number.", 'contact-form-7' ), ), ) ); return $messages; } /* Tag generator */ add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_text', 15, 0 ); function wpcf7_add_tag_generator_text() { $tag_generator = WPCF7_TagGenerator::get_instance(); $tag_generator->add( 'text', __( 'text', 'contact-form-7' ), 'wpcf7_tag_generator_text' ); $tag_generator->add( 'email', __( 'email', 'contact-form-7' ), 'wpcf7_tag_generator_text' ); $tag_generator->add( 'url', __( 'URL', 'contact-form-7' ), 'wpcf7_tag_generator_text' ); $tag_generator->add( 'tel', __( 'tel', 'contact-form-7' ), 'wpcf7_tag_generator_text' ); } function wpcf7_tag_generator_text( $contact_form, $args = '' ) { $args = wp_parse_args( $args, array() ); $type = $args['id']; if ( ! in_array( $type, array( 'email', 'url', 'tel' ) ) ) { $type = 'text'; } if ( 'text' == $type ) { $description = __( "Generate a form-tag for a single-line plain text input field. For more details, see %s.", 'contact-form-7' ); } elseif ( 'email' == $type ) { $description = __( "Generate a form-tag for a single-line email address input field. For more details, see %s.", 'contact-form-7' ); } elseif ( 'url' == $type ) { $description = __( "Generate a form-tag for a single-line URL input field. For more details, see %s.", 'contact-form-7' ); } elseif ( 'tel' == $type ) { $description = __( "Generate a form-tag for a single-line telephone number input field. For more details, see %s.", 'contact-form-7' ); } $desc_link = wpcf7_link( __( 'https://contactform7.com/text-fields/', 'contact-form-7' ), __( 'Text fields', 'contact-form-7' ) ); ?>


    array(), 'version' => WPCF7_VERSION, ); modules/recaptcha/index.js000064400000001737150515101440011617 0ustar00document.addEventListener("DOMContentLoaded",(t=>{var e;wpcf7_recaptcha={...null!==(e=wpcf7_recaptcha)&&void 0!==e?e:{}};const c=wpcf7_recaptcha.sitekey,{homepage:n,contactform:a}=wpcf7_recaptcha.actions,o=t=>{const{action:e,func:n,params:a}=t;grecaptcha.execute(c,{action:e}).then((t=>{const c=new CustomEvent("wpcf7grecaptchaexecuted",{detail:{action:e,token:t}});document.dispatchEvent(c)})).then((()=>{"function"==typeof n&&n(...a)})).catch((t=>console.error(t)))};if(grecaptcha.ready((()=>{o({action:n})})),document.addEventListener("change",(t=>{o({action:a})})),"undefined"!=typeof wpcf7&&"function"==typeof wpcf7.submit){const t=wpcf7.submit;wpcf7.submit=function(e){o({action:a,func:t,params:[e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}]})}}document.addEventListener("wpcf7grecaptchaexecuted",(t=>{const e=document.querySelectorAll('form.wpcf7-form input[name="_wpcf7_recaptcha_response"]');for(let c=0;csitekeys = WPCF7::get_option( 'recaptcha' ); } public function get_title() { return __( 'reCAPTCHA', 'contact-form-7' ); } public function is_active() { $sitekey = $this->get_sitekey(); $secret = $this->get_secret( $sitekey ); return $sitekey && $secret; } public function get_categories() { return array( 'spam_protection' ); } public function icon() { } public function link() { echo wpcf7_link( 'https://www.google.com/recaptcha/intro/index.html', 'google.com/recaptcha' ); } public function get_global_sitekey() { static $sitekey = ''; if ( $sitekey ) { return $sitekey; } if ( defined( 'WPCF7_RECAPTCHA_SITEKEY' ) ) { $sitekey = WPCF7_RECAPTCHA_SITEKEY; } $sitekey = apply_filters( 'wpcf7_recaptcha_sitekey', $sitekey ); return $sitekey; } public function get_global_secret() { static $secret = ''; if ( $secret ) { return $secret; } if ( defined( 'WPCF7_RECAPTCHA_SECRET' ) ) { $secret = WPCF7_RECAPTCHA_SECRET; } $secret = apply_filters( 'wpcf7_recaptcha_secret', $secret ); return $secret; } public function get_sitekey() { if ( $this->get_global_sitekey() and $this->get_global_secret() ) { return $this->get_global_sitekey(); } if ( empty( $this->sitekeys ) or ! is_array( $this->sitekeys ) ) { return false; } $sitekeys = array_keys( $this->sitekeys ); return $sitekeys[0]; } public function get_secret( $sitekey ) { if ( $this->get_global_sitekey() and $this->get_global_secret() ) { return $this->get_global_secret(); } $sitekeys = (array) $this->sitekeys; if ( isset( $sitekeys[$sitekey] ) ) { return $sitekeys[$sitekey]; } else { return false; } } protected function log( $url, $request, $response ) { wpcf7_log_remote_request( $url, $request, $response ); } public function verify( $token ) { $is_human = false; if ( empty( $token ) or ! $this->is_active() ) { return $is_human; } $endpoint = 'https://www.google.com/recaptcha/api/siteverify'; $sitekey = $this->get_sitekey(); $secret = $this->get_secret( $sitekey ); $request = array( 'body' => array( 'secret' => $secret, 'response' => $token, ), ); $response = wp_remote_post( sanitize_url( $endpoint ), $request ); if ( 200 != wp_remote_retrieve_response_code( $response ) ) { if ( WP_DEBUG ) { $this->log( $endpoint, $request, $response ); } return $is_human; } $response_body = wp_remote_retrieve_body( $response ); $response_body = json_decode( $response_body, true ); $this->last_score = $score = isset( $response_body['score'] ) ? $response_body['score'] : 0; $threshold = $this->get_threshold(); $is_human = $threshold < $score; $is_human = apply_filters( 'wpcf7_recaptcha_verify_response', $is_human, $response_body ); if ( $submission = WPCF7_Submission::get_instance() ) { $submission->push( 'recaptcha', array( 'version' => '3.0', 'threshold' => $threshold, 'response' => $response_body, ) ); } return $is_human; } public function get_threshold() { return apply_filters( 'wpcf7_recaptcha_threshold', 0.50 ); } public function get_last_score() { return $this->last_score; } protected function menu_page_url( $args = '' ) { $args = wp_parse_args( $args, array() ); $url = menu_page_url( 'wpcf7-integration', false ); $url = add_query_arg( array( 'service' => 'recaptcha' ), $url ); if ( ! empty( $args ) ) { $url = add_query_arg( $args, $url ); } return $url; } protected function save_data() { WPCF7::update_option( 'recaptcha', $this->sitekeys ); } protected function reset_data() { $this->sitekeys = null; $this->save_data(); } public function load( $action = '' ) { if ( 'setup' == $action and 'POST' == $_SERVER['REQUEST_METHOD'] ) { check_admin_referer( 'wpcf7-recaptcha-setup' ); if ( ! empty( $_POST['reset'] ) ) { $this->reset_data(); $redirect_to = $this->menu_page_url( 'action=setup' ); } else { $sitekey = isset( $_POST['sitekey'] ) ? trim( $_POST['sitekey'] ) : ''; $secret = isset( $_POST['secret'] ) ? trim( $_POST['secret'] ) : ''; if ( $sitekey and $secret ) { $this->sitekeys = array( $sitekey => $secret ); $this->save_data(); $redirect_to = $this->menu_page_url( array( 'message' => 'success', ) ); } else { $redirect_to = $this->menu_page_url( array( 'action' => 'setup', 'message' => 'invalid', ) ); } } if ( WPCF7::get_option( 'recaptcha_v2_v3_warning' ) ) { WPCF7::update_option( 'recaptcha_v2_v3_warning', false ); } wp_safe_redirect( $redirect_to ); exit(); } } public function admin_notice( $message = '' ) { if ( 'invalid' == $message ) { echo sprintf( '

    %1$s: %2$s

    ', esc_html( __( "Error", 'contact-form-7' ) ), esc_html( __( "Invalid key values.", 'contact-form-7' ) ) ); } if ( 'success' == $message ) { echo sprintf( '

    %s

    ', esc_html( __( 'Settings saved.', 'contact-form-7' ) ) ); } } public function display( $action = '' ) { echo sprintf( '

    %s

    ', esc_html( __( "reCAPTCHA protects you against spam and other types of automated abuse. With Contact Form 7’s reCAPTCHA integration module, you can block abusive form submissions by spam bots.", 'contact-form-7' ) ) ); echo sprintf( '

    %s

    ', wpcf7_link( __( 'https://contactform7.com/recaptcha/', 'contact-form-7' ), __( 'reCAPTCHA (v3)', 'contact-form-7' ) ) ); if ( $this->is_active() ) { echo sprintf( '

    %s

    ', esc_html( __( "reCAPTCHA is active on this site.", 'contact-form-7' ) ) ); } if ( 'setup' == $action ) { $this->display_setup(); } else { echo sprintf( '

    %2$s

    ', esc_url( $this->menu_page_url( 'action=setup' ) ), esc_html( __( 'Setup Integration', 'contact-form-7' ) ) ); } } private function display_setup() { $sitekey = $this->is_active() ? $this->get_sitekey() : ''; $secret = $this->is_active() ? $this->get_secret( $sitekey ) : ''; ?>
    is_active() ) { echo esc_html( $sitekey ); echo sprintf( '', esc_attr( $sitekey ) ); } else { echo sprintf( '', esc_attr( $sitekey ) ); } ?>
    is_active() ) { echo esc_html( wpcf7_mask_password( $secret, 4, 4 ) ); echo sprintf( '', esc_attr( $secret ) ); } else { echo sprintf( '', esc_attr( $secret ) ); } ?>
    is_active() ) { if ( $this->get_global_sitekey() and $this->get_global_secret() ) { // nothing } else { submit_button( _x( 'Remove Keys', 'API keys', 'contact-form-7' ), 'small', 'reset' ); } } else { submit_button( __( 'Save Changes', 'contact-form-7' ) ); } ?>
    add_service( 'recaptcha', WPCF7_RECAPTCHA::get_instance() ); } add_action( 'wp_enqueue_scripts', 'wpcf7_recaptcha_enqueue_scripts', 20, 0 ); /** * Enqueues frontend scripts for reCAPTCHA. */ function wpcf7_recaptcha_enqueue_scripts() { $service = WPCF7_RECAPTCHA::get_instance(); if ( ! $service->is_active() ) { return; } $url = 'https://www.google.com/recaptcha/api.js'; if ( apply_filters( 'wpcf7_use_recaptcha_net', false ) ) { $url = 'https://www.recaptcha.net/recaptcha/api.js'; } wp_register_script( 'google-recaptcha', add_query_arg( array( 'render' => $service->get_sitekey(), ), $url ), array(), '3.0', true ); $assets = array(); $asset_file = wpcf7_plugin_path( 'modules/recaptcha/index.asset.php' ); if ( file_exists( $asset_file ) ) { $assets = include( $asset_file ); } $assets = wp_parse_args( $assets, array( 'dependencies' => array(), 'version' => WPCF7_VERSION, ) ); wp_register_script( 'wpcf7-recaptcha', wpcf7_plugin_url( 'modules/recaptcha/index.js' ), array_merge( $assets['dependencies'], array( 'google-recaptcha', 'wp-polyfill', ) ), $assets['version'], true ); wp_enqueue_script( 'wpcf7-recaptcha' ); wp_localize_script( 'wpcf7-recaptcha', 'wpcf7_recaptcha', array( 'sitekey' => $service->get_sitekey(), 'actions' => apply_filters( 'wpcf7_recaptcha_actions', array( 'homepage' => 'homepage', 'contactform' => 'contactform', ) ), ) ); } add_filter( 'wpcf7_form_hidden_fields', 'wpcf7_recaptcha_add_hidden_fields', 100, 1 ); /** * Adds hidden form field for reCAPTCHA. */ function wpcf7_recaptcha_add_hidden_fields( $fields ) { $service = WPCF7_RECAPTCHA::get_instance(); if ( ! $service->is_active() ) { return $fields; } return array_merge( $fields, array( '_wpcf7_recaptcha_response' => '', ) ); } add_filter( 'wpcf7_spam', 'wpcf7_recaptcha_verify_response', 9, 2 ); /** * Verifies reCAPTCHA token on the server side. */ function wpcf7_recaptcha_verify_response( $spam, $submission ) { if ( $spam ) { return $spam; } $service = WPCF7_RECAPTCHA::get_instance(); if ( ! $service->is_active() ) { return $spam; } $token = isset( $_POST['_wpcf7_recaptcha_response'] ) ? trim( $_POST['_wpcf7_recaptcha_response'] ) : ''; if ( $service->verify( $token ) ) { // Human $spam = false; } else { // Bot $spam = true; if ( '' === $token ) { $submission->add_spam_log( array( 'agent' => 'recaptcha', 'reason' => __( 'reCAPTCHA response token is empty.', 'contact-form-7' ), ) ); } else { $submission->add_spam_log( array( 'agent' => 'recaptcha', 'reason' => sprintf( __( 'reCAPTCHA score (%1$.2f) is lower than the threshold (%2$.2f).', 'contact-form-7' ), $service->get_last_score(), $service->get_threshold() ), ) ); } } return $spam; } add_action( 'wpcf7_init', 'wpcf7_recaptcha_add_form_tag_recaptcha', 10, 0 ); /** * Registers form-tag types for reCAPTCHA. */ function wpcf7_recaptcha_add_form_tag_recaptcha() { $service = WPCF7_RECAPTCHA::get_instance(); if ( ! $service->is_active() ) { return; } wpcf7_add_form_tag( 'recaptcha', '__return_empty_string', // no output array( 'display-block' => true ) ); } add_action( 'wpcf7_upgrade', 'wpcf7_upgrade_recaptcha_v2_v3', 10, 2 ); /** * Adds warnings for users upgrading from reCAPTCHA v2 to v3. */ function wpcf7_upgrade_recaptcha_v2_v3( $new_ver, $old_ver ) { if ( version_compare( '5.1-dev', $old_ver, '<=' ) ) { return; } $service = WPCF7_RECAPTCHA::get_instance(); if ( ! $service->is_active() or $service->get_global_sitekey() ) { return; } // Maybe v2 keys are used now. Warning necessary. WPCF7::update_option( 'recaptcha_v2_v3_warning', true ); WPCF7::update_option( 'recaptcha', null ); } add_action( 'wpcf7_admin_menu', 'wpcf7_admin_init_recaptcha_v2_v3', 10, 0 ); /** * Adds filters and actions for warnings. */ function wpcf7_admin_init_recaptcha_v2_v3() { if ( ! WPCF7::get_option( 'recaptcha_v2_v3_warning' ) ) { return; } add_filter( 'wpcf7_admin_menu_change_notice', 'wpcf7_admin_menu_change_notice_recaptcha_v2_v3', 10, 1 ); add_action( 'wpcf7_admin_warnings', 'wpcf7_admin_warnings_recaptcha_v2_v3', 5, 3 ); } /** * Increments the admin menu counter for the Integration page. */ function wpcf7_admin_menu_change_notice_recaptcha_v2_v3( $counts ) { $counts['wpcf7-integration'] += 1; return $counts; } /** * Prints warnings on the admin screen. */ function wpcf7_admin_warnings_recaptcha_v2_v3( $page, $action, $object ) { if ( 'wpcf7-integration' !== $page ) { return; } $message = sprintf( esc_html( __( "API keys for reCAPTCHA v3 are different from those for v2; keys for v2 do not work with the v3 API. You need to register your sites again to get new keys for v3. For details, see %s.", 'contact-form-7' ) ), wpcf7_link( __( 'https://contactform7.com/recaptcha/', 'contact-form-7' ), __( 'reCAPTCHA (v3)', 'contact-form-7' ) ) ); echo sprintf( '

    %s

    ', $message ); } modules/file.php000064400000015275150515101440007652 0ustar00 true, 'file-uploading' => true, ) ); } function wpcf7_file_form_tag_handler( $tag ) { if ( empty( $tag->name ) ) { return ''; } $validation_error = wpcf7_get_validation_error( $tag->name ); $class = wpcf7_form_controls_class( $tag->type ); if ( $validation_error ) { $class .= ' wpcf7-not-valid'; } $atts = array(); $atts['size'] = $tag->get_size_option( '40' ); $atts['class'] = $tag->get_class_option( $class ); $atts['id'] = $tag->get_id_option(); $atts['capture'] = $tag->get_option( 'capture', '(user|environment)', true ); $atts['tabindex'] = $tag->get_option( 'tabindex', 'signed_int', true ); $atts['accept'] = wpcf7_acceptable_filetypes( $tag->get_option( 'filetypes' ), 'attr' ); if ( $tag->is_required() ) { $atts['aria-required'] = 'true'; } if ( $validation_error ) { $atts['aria-invalid'] = 'true'; $atts['aria-describedby'] = wpcf7_get_validation_error_reference( $tag->name ); } else { $atts['aria-invalid'] = 'false'; } $atts['type'] = 'file'; $atts['name'] = $tag->name; $html = sprintf( '%3$s', esc_attr( $tag->name ), wpcf7_format_atts( $atts ), $validation_error ); return $html; } add_action( 'wpcf7_swv_create_schema', 'wpcf7_swv_add_file_rules', 10, 2 ); function wpcf7_swv_add_file_rules( $schema, $contact_form ) { $tags = $contact_form->scan_form_tags( array( 'basetype' => array( 'file' ), ) ); foreach ( $tags as $tag ) { if ( $tag->is_required() ) { $schema->add_rule( wpcf7_swv_create_rule( 'requiredfile', array( 'field' => $tag->name, 'error' => wpcf7_get_message( 'invalid_required' ), ) ) ); } $schema->add_rule( wpcf7_swv_create_rule( 'file', array( 'field' => $tag->name, 'accept' => explode( ',', wpcf7_acceptable_filetypes( $tag->get_option( 'filetypes' ), 'attr' ) ), 'error' => wpcf7_get_message( 'upload_file_type_invalid' ), ) ) ); $schema->add_rule( wpcf7_swv_create_rule( 'maxfilesize', array( 'field' => $tag->name, 'threshold' => $tag->get_limit_option(), 'error' => wpcf7_get_message( 'upload_file_too_large' ), ) ) ); } } add_filter( 'wpcf7_mail_tag_replaced_file', 'wpcf7_file_mail_tag', 10, 4 ); add_filter( 'wpcf7_mail_tag_replaced_file*', 'wpcf7_file_mail_tag', 10, 4 ); function wpcf7_file_mail_tag( $replaced, $submitted, $html, $mail_tag ) { $submission = WPCF7_Submission::get_instance(); $uploaded_files = $submission->uploaded_files(); $name = $mail_tag->field_name(); if ( ! empty( $uploaded_files[$name] ) ) { $paths = (array) $uploaded_files[$name]; $paths = array_map( 'wp_basename', $paths ); $replaced = wpcf7_flat_join( $paths, array( 'separator' => wp_get_list_item_separator(), ) ); } return $replaced; } /* Tag generator */ add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_file', 50, 0 ); function wpcf7_add_tag_generator_file() { $tag_generator = WPCF7_TagGenerator::get_instance(); $tag_generator->add( 'file', __( 'file', 'contact-form-7' ), 'wpcf7_tag_generator_file' ); } function wpcf7_tag_generator_file( $contact_form, $args = '' ) { $args = wp_parse_args( $args, array() ); $type = 'file'; $description = __( "Generate a form-tag for a file uploading field. For more details, see %s.", 'contact-form-7' ); $desc_link = wpcf7_link( __( 'https://contactform7.com/file-uploading-and-attachment/', 'contact-form-7' ), __( 'File uploading and attachment', 'contact-form-7' ) ); ?>

    true ) ); } function wpcf7_textarea_form_tag_handler( $tag ) { if ( empty( $tag->name ) ) { return ''; } $validation_error = wpcf7_get_validation_error( $tag->name ); $class = wpcf7_form_controls_class( $tag->type ); if ( $validation_error ) { $class .= ' wpcf7-not-valid'; } $atts = array(); $atts['cols'] = $tag->get_cols_option( '40' ); $atts['rows'] = $tag->get_rows_option( '10' ); $atts['maxlength'] = $tag->get_maxlength_option(); $atts['minlength'] = $tag->get_minlength_option(); if ( $atts['maxlength'] and $atts['minlength'] and $atts['maxlength'] < $atts['minlength'] ) { unset( $atts['maxlength'], $atts['minlength'] ); } $atts['class'] = $tag->get_class_option( $class ); $atts['id'] = $tag->get_id_option(); $atts['tabindex'] = $tag->get_option( 'tabindex', 'signed_int', true ); $atts['readonly'] = $tag->has_option( 'readonly' ); $atts['autocomplete'] = $tag->get_option( 'autocomplete', '[-0-9a-zA-Z]+', true ); if ( $tag->is_required() ) { $atts['aria-required'] = 'true'; } if ( $validation_error ) { $atts['aria-invalid'] = 'true'; $atts['aria-describedby'] = wpcf7_get_validation_error_reference( $tag->name ); } else { $atts['aria-invalid'] = 'false'; } $value = empty( $tag->content ) ? (string) reset( $tag->values ) : $tag->content; if ( $tag->has_option( 'placeholder' ) or $tag->has_option( 'watermark' ) ) { $atts['placeholder'] = $value; $value = ''; } $value = $tag->get_default_option( $value ); $value = wpcf7_get_hangover( $tag->name, $value ); $atts['name'] = $tag->name; $html = sprintf( '%4$s', esc_attr( $tag->name ), wpcf7_format_atts( $atts ), esc_textarea( $value ), $validation_error ); return $html; } add_action( 'wpcf7_swv_create_schema', 'wpcf7_swv_add_textarea_rules', 10, 2 ); function wpcf7_swv_add_textarea_rules( $schema, $contact_form ) { $tags = $contact_form->scan_form_tags( array( 'basetype' => array( 'textarea' ), ) ); foreach ( $tags as $tag ) { if ( $tag->is_required() ) { $schema->add_rule( wpcf7_swv_create_rule( 'required', array( 'field' => $tag->name, 'error' => wpcf7_get_message( 'invalid_required' ), ) ) ); } if ( $minlength = $tag->get_minlength_option() ) { $schema->add_rule( wpcf7_swv_create_rule( 'minlength', array( 'field' => $tag->name, 'threshold' => absint( $minlength ), 'error' => wpcf7_get_message( 'invalid_too_short' ), ) ) ); } if ( $maxlength = $tag->get_maxlength_option() ) { $schema->add_rule( wpcf7_swv_create_rule( 'maxlength', array( 'field' => $tag->name, 'threshold' => absint( $maxlength ), 'error' => wpcf7_get_message( 'invalid_too_long' ), ) ) ); } } } /* Tag generator */ add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_textarea', 20, 0 ); function wpcf7_add_tag_generator_textarea() { $tag_generator = WPCF7_TagGenerator::get_instance(); $tag_generator->add( 'textarea', __( 'text area', 'contact-form-7' ), 'wpcf7_tag_generator_textarea' ); } function wpcf7_tag_generator_textarea( $contact_form, $args = '' ) { $args = wp_parse_args( $args, array() ); $type = 'textarea'; $description = __( "Generate a form-tag for a multi-line text input field. For more details, see %s.", 'contact-form-7' ); $desc_link = wpcf7_link( __( 'https://contactform7.com/text-fields/', 'contact-form-7' ), __( 'Text fields', 'contact-form-7' ) ); ?>


    true, ) ); } function wpcf7_response_form_tag_handler( $tag ) { if ( $contact_form = wpcf7_get_current_contact_form() ) { return $contact_form->form_response_output(); } } modules/listo.php000064400000001347150515101440010060 0ustar00locale(); foreach ( (array) $options as $option ) { $option = explode( '.', $option ); $type = $option[0]; if ( isset( $option[1] ) ) { $args['group'] = $option[1]; } else { unset( $args['group'] ); } if ( $list = listo( $type, $args ) ) { $data = array_merge( (array) $data, $list ); } } return $data; } modules/submit.php000064400000005571150515101440010234 0ustar00type, 'has-spinner' ); $atts = array(); $atts['class'] = $tag->get_class_option( $class ); $atts['id'] = $tag->get_id_option(); $atts['tabindex'] = $tag->get_option( 'tabindex', 'signed_int', true ); $value = isset( $tag->values[0] ) ? $tag->values[0] : ''; if ( empty( $value ) ) { $value = __( 'Send', 'contact-form-7' ); } $atts['type'] = 'submit'; $atts['value'] = $value; $atts = wpcf7_format_atts( $atts ); $html = sprintf( '', $atts ); return $html; } /* Tag generator */ add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_submit', 55, 0 ); function wpcf7_add_tag_generator_submit() { $tag_generator = WPCF7_TagGenerator::get_instance(); $tag_generator->add( 'submit', __( 'submit', 'contact-form-7' ), 'wpcf7_tag_generator_submit', array( 'nameless' => 1 ) ); } function wpcf7_tag_generator_submit( $contact_form, $args = '' ) { $args = wp_parse_args( $args, array() ); $description = __( "Generate a form-tag for a submit button. For more details, see %s.", 'contact-form-7' ); $desc_link = wpcf7_link( __( 'https://contactform7.com/submit-button/', 'contact-form-7' ), __( 'Submit button', 'contact-form-7' ) ); ?>
    true, 'selectable-values' => true, 'multiple-controls-container' => true, ) ); } function wpcf7_checkbox_form_tag_handler( $tag ) { if ( empty( $tag->name ) ) { return ''; } $validation_error = wpcf7_get_validation_error( $tag->name ); $class = wpcf7_form_controls_class( $tag->type ); if ( $validation_error ) { $class .= ' wpcf7-not-valid'; } $label_first = $tag->has_option( 'label_first' ); $use_label_element = $tag->has_option( 'use_label_element' ); $exclusive = $tag->has_option( 'exclusive' ); $free_text = $tag->has_option( 'free_text' ); $multiple = false; if ( 'checkbox' == $tag->basetype ) { $multiple = ! $exclusive; } else { // radio $exclusive = false; } if ( $exclusive ) { $class .= ' wpcf7-exclusive-checkbox'; } $atts = array(); $atts['class'] = $tag->get_class_option( $class ); $atts['id'] = $tag->get_id_option(); if ( $validation_error ) { $atts['aria-describedby'] = wpcf7_get_validation_error_reference( $tag->name ); } $tabindex = $tag->get_option( 'tabindex', 'signed_int', true ); if ( false !== $tabindex ) { $tabindex = (int) $tabindex; } $html = ''; $count = 0; if ( $data = (array) $tag->get_data_option() ) { if ( $free_text ) { $tag->values = array_merge( array_slice( $tag->values, 0, -1 ), array_values( $data ), array_slice( $tag->values, -1 ) ); $tag->labels = array_merge( array_slice( $tag->labels, 0, -1 ), array_values( $data ), array_slice( $tag->labels, -1 ) ); } else { $tag->values = array_merge( $tag->values, array_values( $data ) ); $tag->labels = array_merge( $tag->labels, array_values( $data ) ); } } $values = $tag->values; $labels = $tag->labels; $default_choice = $tag->get_default_option( null, array( 'multiple' => $multiple, ) ); $hangover = wpcf7_get_hangover( $tag->name, $multiple ? array() : '' ); foreach ( $values as $key => $value ) { if ( $hangover ) { $checked = in_array( $value, (array) $hangover, true ); } else { $checked = in_array( $value, (array) $default_choice, true ); } if ( isset( $labels[$key] ) ) { $label = $labels[$key]; } else { $label = $value; } $item_atts = array( 'type' => $tag->basetype, 'name' => $tag->name . ( $multiple ? '[]' : '' ), 'value' => $value, 'checked' => $checked, 'tabindex' => $tabindex, ); $item_atts = wpcf7_format_atts( $item_atts ); if ( $label_first ) { // put label first, input last $item = sprintf( '%1$s', esc_html( $label ), $item_atts ); } else { $item = sprintf( '%1$s', esc_html( $label ), $item_atts ); } if ( $use_label_element ) { $item = ''; } if ( false !== $tabindex and 0 < $tabindex ) { $tabindex += 1; } $class = 'wpcf7-list-item'; $count += 1; if ( 1 == $count ) { $class .= ' first'; } if ( count( $values ) == $count ) { // last round $class .= ' last'; if ( $free_text ) { $free_text_name = $tag->name . '_free_text'; $free_text_atts = array( 'name' => $free_text_name, 'class' => 'wpcf7-free-text', 'tabindex' => $tabindex, ); if ( wpcf7_is_posted() and isset( $_POST[$free_text_name] ) ) { $free_text_atts['value'] = wp_unslash( $_POST[$free_text_name] ); } $free_text_atts = wpcf7_format_atts( $free_text_atts ); $item .= sprintf( ' ', $free_text_atts ); $class .= ' has-free-text'; } } $item = '' . $item . ''; $html .= $item; } $html = sprintf( '%3$s%4$s', esc_attr( $tag->name ), wpcf7_format_atts( $atts ), $html, $validation_error ); return $html; } add_action( 'wpcf7_swv_create_schema', 'wpcf7_swv_add_checkbox_rules', 10, 2 ); function wpcf7_swv_add_checkbox_rules( $schema, $contact_form ) { $tags = $contact_form->scan_form_tags( array( 'type' => array( 'checkbox*', 'radio' ), ) ); foreach ( $tags as $tag ) { $schema->add_rule( wpcf7_swv_create_rule( 'required', array( 'field' => $tag->name, 'error' => wpcf7_get_message( 'invalid_required' ), ) ) ); } } /* Tag generator */ add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_checkbox_and_radio', 30, 0 ); function wpcf7_add_tag_generator_checkbox_and_radio() { $tag_generator = WPCF7_TagGenerator::get_instance(); $tag_generator->add( 'checkbox', __( 'checkboxes', 'contact-form-7' ), 'wpcf7_tag_generator_checkbox' ); $tag_generator->add( 'radio', __( 'radio buttons', 'contact-form-7' ), 'wpcf7_tag_generator_checkbox' ); } function wpcf7_tag_generator_checkbox( $contact_form, $args = '' ) { $args = wp_parse_args( $args, array() ); $type = $args['id']; if ( 'radio' != $type ) { $type = 'checkbox'; } if ( 'checkbox' == $type ) { $description = __( "Generate a form-tag for a group of checkboxes. For more details, see %s.", 'contact-form-7' ); } elseif ( 'radio' == $type ) { $description = __( "Generate a form-tag for a group of radio buttons. For more details, see %s.", 'contact-form-7' ); } $desc_link = wpcf7_link( __( 'https://contactform7.com/checkboxes-radio-buttons-and-menus/', 'contact-form-7' ), __( 'Checkboxes, radio buttons and menus', 'contact-form-7' ) ); ?>




    true, 'zero-controls-container' => true, 'not-for-mail' => true, ) ); } function wpcf7_count_form_tag_handler( $tag ) { if ( empty( $tag->name ) ) { return ''; } $targets = wpcf7_scan_form_tags( array( 'name' => $tag->name ) ); $maxlength = $minlength = null; while ( $targets ) { $target = array_shift( $targets ); if ( 'count' != $target->type ) { $maxlength = $target->get_maxlength_option(); $minlength = $target->get_minlength_option(); break; } } if ( $maxlength and $minlength and $maxlength < $minlength ) { $maxlength = $minlength = null; } if ( $tag->has_option( 'down' ) ) { $value = (int) $maxlength; $class = 'wpcf7-character-count down'; } else { $value = '0'; $class = 'wpcf7-character-count up'; } $atts = array(); $atts['id'] = $tag->get_id_option(); $atts['class'] = $tag->get_class_option( $class ); $atts['data-target-name'] = $tag->name; $atts['data-starting-value'] = $value; $atts['data-current-value'] = $value; $atts['data-maximum-value'] = $maxlength; $atts['data-minimum-value'] = $minlength; $html = sprintf( '%2$s', wpcf7_format_atts( $atts ), $value ); return $html; } modules/quiz.php000064400000016346150515101440007723 0ustar00 true, 'do-not-store' => true, 'not-for-mail' => true, ) ); } function wpcf7_quiz_form_tag_handler( $tag ) { if ( empty( $tag->name ) ) { return ''; } $validation_error = wpcf7_get_validation_error( $tag->name ); $class = wpcf7_form_controls_class( $tag->type ); if ( $validation_error ) { $class .= ' wpcf7-not-valid'; } $atts = array(); $atts['size'] = $tag->get_size_option( '40' ); $atts['maxlength'] = $tag->get_maxlength_option(); $atts['minlength'] = $tag->get_minlength_option(); if ( $atts['maxlength'] and $atts['minlength'] and $atts['maxlength'] < $atts['minlength'] ) { unset( $atts['maxlength'], $atts['minlength'] ); } $atts['class'] = $tag->get_class_option( $class ); $atts['id'] = $tag->get_id_option(); $atts['tabindex'] = $tag->get_option( 'tabindex', 'signed_int', true ); $atts['autocomplete'] = 'off'; $atts['aria-required'] = 'true'; if ( $validation_error ) { $atts['aria-invalid'] = 'true'; $atts['aria-describedby'] = wpcf7_get_validation_error_reference( $tag->name ); } else { $atts['aria-invalid'] = 'false'; } $pipes = $tag->pipes; if ( $pipes instanceof WPCF7_Pipes and ! $pipes->zero() ) { $pipe = $pipes->random_pipe(); $question = $pipe->before; $answer = $pipe->after; } else { // default quiz $question = '1+1=?'; $answer = '2'; } $answer = wpcf7_canonicalize( $answer, array( 'strip_separators' => true, ) ); $atts['type'] = 'text'; $atts['name'] = $tag->name; $html = sprintf( '%6$s', esc_attr( $tag->name ), esc_html( $question ), wpcf7_format_atts( $atts ), $tag->name, wp_hash( $answer, 'wpcf7_quiz' ), $validation_error ); return $html; } /* Validation filter */ add_filter( 'wpcf7_validate_quiz', 'wpcf7_quiz_validation_filter', 10, 2 ); function wpcf7_quiz_validation_filter( $result, $tag ) { $name = $tag->name; $answer = isset( $_POST[$name] ) ? wp_unslash( $_POST[$name] ) : ''; $answer = wpcf7_canonicalize( $answer, array( 'strip_separators' => true, ) ); $answer_hash = wp_hash( $answer, 'wpcf7_quiz' ); $expected_hash = isset( $_POST['_wpcf7_quiz_answer_' . $name] ) ? (string) $_POST['_wpcf7_quiz_answer_' . $name] : ''; if ( ! hash_equals( $expected_hash, $answer_hash ) ) { $result->invalidate( $tag, wpcf7_get_message( 'quiz_answer_not_correct' ) ); } return $result; } /* Ajax echo filter */ add_filter( 'wpcf7_refill_response', 'wpcf7_quiz_ajax_refill', 10, 1 ); add_filter( 'wpcf7_feedback_response', 'wpcf7_quiz_ajax_refill', 10, 1 ); function wpcf7_quiz_ajax_refill( $items ) { if ( ! is_array( $items ) ) { return $items; } $fes = wpcf7_scan_form_tags( array( 'type' => 'quiz' ) ); if ( empty( $fes ) ) { return $items; } $refill = array(); foreach ( $fes as $fe ) { $name = $fe['name']; $pipes = $fe['pipes']; if ( empty( $name ) ) { continue; } if ( $pipes instanceof WPCF7_Pipes and ! $pipes->zero() ) { $pipe = $pipes->random_pipe(); $question = $pipe->before; $answer = $pipe->after; } else { // default quiz $question = '1+1=?'; $answer = '2'; } $answer = wpcf7_canonicalize( $answer, array( 'strip_separators' => true, ) ); $refill[$name] = array( $question, wp_hash( $answer, 'wpcf7_quiz' ) ); } if ( ! empty( $refill ) ) { $items['quiz'] = $refill; } return $items; } /* Mail-tag replacement */ add_filter( 'wpcf7_mail_tag_replaced_quiz', 'wpcf7_quiz_mail_tag', 10, 4 ); function wpcf7_quiz_mail_tag( $replaced, $submitted, $html, $mail_tag ) { $field_name = $mail_tag->field_name(); $submitted = isset( $_POST[$field_name] ) ? $_POST[$field_name] : ''; $replaced = $submitted; if ( $html ) { $replaced = esc_html( $replaced ); $replaced = wptexturize( $replaced ); } return $replaced; } /* Messages */ add_filter( 'wpcf7_messages', 'wpcf7_quiz_messages', 10, 1 ); function wpcf7_quiz_messages( $messages ) { $messages = array_merge( $messages, array( 'quiz_answer_not_correct' => array( 'description' => __( "Sender does not enter the correct answer to the quiz", 'contact-form-7' ), 'default' => __( "The answer to the quiz is incorrect.", 'contact-form-7' ), ), ) ); return $messages; } /* Tag generator */ add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_quiz', 40, 0 ); function wpcf7_add_tag_generator_quiz() { $tag_generator = WPCF7_TagGenerator::get_instance(); $tag_generator->add( 'quiz', __( 'quiz', 'contact-form-7' ), 'wpcf7_tag_generator_quiz' ); } function wpcf7_tag_generator_quiz( $contact_form, $args = '' ) { $args = wp_parse_args( $args, array() ); $type = 'quiz'; $description = __( "Generate a form-tag for a question-answer pair. For more details, see %s.", 'contact-form-7' ); $desc_link = wpcf7_link( __( 'https://contactform7.com/quiz/', 'contact-form-7' ), __( 'Quiz', 'contact-form-7' ) ); ?>

    get_contact_form(); $do_doi = apply_filters( 'wpcf7_do_doi', ! $contact_form->is_false( 'doi' ), $agent_name, $args ); if ( ! $do_doi ) { return; } $token = doihelper_start_session( $agent_name, $args ); } modules/disallowed-list.php000064400000003423150515101440012023 0ustar00get_posted_data() ); $target[] = $submission->get_meta( 'remote_ip' ); $target[] = $submission->get_meta( 'user_agent' ); $target = implode( "\n", $target ); $word = wpcf7_check_disallowed_list( $target ); $word = wpcf7_apply_filters_deprecated( 'wpcf7_submission_is_blacklisted', array( $word, $submission ), '5.3', 'wpcf7_submission_has_disallowed_words' ); $word = apply_filters( 'wpcf7_submission_has_disallowed_words', $word, $submission ); if ( $word ) { if ( is_bool( $word ) ) { $reason = __( "Disallowed words are used.", 'contact-form-7' ); } else { $reason = sprintf( __( "Disallowed words (%s) are used.", 'contact-form-7' ), implode( ', ', (array) $word ) ); } $submission->add_spam_log( array( 'agent' => 'disallowed_list', 'reason' => $reason, ) ); } $spam = (bool) $word; return $spam; } function wpcf7_check_disallowed_list( $target ) { $mod_keys = get_option( 'disallowed_keys' ); if ( is_scalar( $mod_keys ) ) { $mod_keys = trim( $mod_keys ); } else { $mod_keys = ''; } if ( '' === $mod_keys ) { return false; } foreach ( explode( "\n", $mod_keys ) as $word ) { $word = trim( $word ); $length = strlen( $word ); if ( $length < 2 or 256 < $length ) { continue; } $pattern = sprintf( '#%s#i', preg_quote( $word, '#' ) ); if ( preg_match( $pattern, $target ) ) { return $word; } } return false; } function wpcf7_blacklist_check( $target ) { wpcf7_deprecated_function( __FUNCTION__, '5.3', 'wpcf7_check_disallowed_list' ); return wpcf7_check_disallowed_list( $target ); } modules/select.php000064400000016200150515101440010177 0ustar00 true, 'selectable-values' => true, ) ); } function wpcf7_select_form_tag_handler( $tag ) { if ( empty( $tag->name ) ) { return ''; } $validation_error = wpcf7_get_validation_error( $tag->name ); $class = wpcf7_form_controls_class( $tag->type ); if ( $validation_error ) { $class .= ' wpcf7-not-valid'; } $atts = array(); $atts['class'] = $tag->get_class_option( $class ); $atts['id'] = $tag->get_id_option(); $atts['tabindex'] = $tag->get_option( 'tabindex', 'signed_int', true ); $atts['autocomplete'] = $tag->get_option( 'autocomplete', '[-0-9a-zA-Z]+', true ); if ( $tag->is_required() ) { $atts['aria-required'] = 'true'; } if ( $validation_error ) { $atts['aria-invalid'] = 'true'; $atts['aria-describedby'] = wpcf7_get_validation_error_reference( $tag->name ); } else { $atts['aria-invalid'] = 'false'; } $multiple = $tag->has_option( 'multiple' ); $include_blank = $tag->has_option( 'include_blank' ); $first_as_label = $tag->has_option( 'first_as_label' ); if ( $tag->has_option( 'size' ) ) { $size = $tag->get_option( 'size', 'int', true ); if ( $size ) { $atts['size'] = $size; } elseif ( $multiple ) { $atts['size'] = 4; } else { $atts['size'] = 1; } } if ( $data = (array) $tag->get_data_option() ) { $tag->values = array_merge( $tag->values, array_values( $data ) ); $tag->labels = array_merge( $tag->labels, array_values( $data ) ); } $values = $tag->values; $labels = $tag->labels; $default_choice = $tag->get_default_option( null, array( 'multiple' => $multiple, ) ); if ( $include_blank or empty( $values ) ) { array_unshift( $labels, __( '—Please choose an option—', 'contact-form-7' ) ); array_unshift( $values, '' ); } elseif ( $first_as_label ) { $values[0] = ''; } $html = ''; $hangover = wpcf7_get_hangover( $tag->name ); foreach ( $values as $key => $value ) { if ( $hangover ) { $selected = in_array( $value, (array) $hangover, true ); } else { $selected = in_array( $value, (array) $default_choice, true ); } $item_atts = array( 'value' => $value, 'selected' => $selected, ); $label = isset( $labels[$key] ) ? $labels[$key] : $value; $html .= sprintf( '', wpcf7_format_atts( $item_atts ), esc_html( $label ) ); } $atts['multiple'] = (bool) $multiple; $atts['name'] = $tag->name . ( $multiple ? '[]' : '' ); $html = sprintf( '%4$s', esc_attr( $tag->name ), wpcf7_format_atts( $atts ), $html, $validation_error ); return $html; } add_action( 'wpcf7_swv_create_schema', 'wpcf7_swv_add_select_rules', 10, 2 ); function wpcf7_swv_add_select_rules( $schema, $contact_form ) { $tags = $contact_form->scan_form_tags( array( 'type' => array( 'select*' ), ) ); foreach ( $tags as $tag ) { $schema->add_rule( wpcf7_swv_create_rule( 'required', array( 'field' => $tag->name, 'error' => wpcf7_get_message( 'invalid_required' ), ) ) ); } } /* Tag generator */ add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_menu', 25, 0 ); function wpcf7_add_tag_generator_menu() { $tag_generator = WPCF7_TagGenerator::get_instance(); $tag_generator->add( 'menu', __( 'drop-down menu', 'contact-form-7' ), 'wpcf7_tag_generator_menu' ); } function wpcf7_tag_generator_menu( $contact_form, $args = '' ) { $args = wp_parse_args( $args, array() ); $description = __( "Generate a form-tag for a drop-down menu. For more details, see %s.", 'contact-form-7' ); $desc_link = wpcf7_link( __( 'https://contactform7.com/checkboxes-radio-buttons-and-menus/', 'contact-form-7' ), __( 'Checkboxes, radio buttons and menus', 'contact-form-7' ) ); ?>



    %s

    ', esc_html( __( "CAPTCHAs are designed to distinguish spambots from humans, and are therefore helpless against human spammers. In contrast to CAPTCHAs, Akismet checks form submissions against the global database of spam; this means Akismet is a comprehensive solution against spam. This is why we consider Akismet to be the centerpiece of the spam prevention strategy.", 'contact-form-7' ) ) ); echo sprintf( '

    %s

    ', wpcf7_link( __( 'https://contactform7.com/spam-filtering-with-akismet/', 'contact-form-7' ), __( 'Spam filtering with Akismet', 'contact-form-7' ) ) ); if ( $this->is_active() ) { echo sprintf( '

    %s

    ', esc_html( __( "Akismet is active on this site.", 'contact-form-7' ) ) ); } } } modules/akismet/akismet.php000064400000014635150515101440012024 0ustar00add_service( 'akismet', WPCF7_Akismet::get_instance() ); } add_filter( 'wpcf7_spam', 'wpcf7_akismet', 10, 2 ); function wpcf7_akismet( $spam, $submission ) { if ( $spam ) { return $spam; } if ( ! wpcf7_akismet_is_available() ) { return false; } if ( ! $params = wpcf7_akismet_submitted_params() ) { return false; } $comment = array( 'comment_type' => 'contact-form', 'comment_author' => $params['author'], 'comment_author_email' => $params['author_email'], 'comment_author_url' => $params['author_url'], 'comment_content' => $params['content'], 'blog' => home_url(), 'blog_lang' => get_locale(), 'blog_charset' => get_option( 'blog_charset' ), 'user_ip' => $submission->get_meta( 'remote_ip' ), 'user_agent' => $submission->get_meta( 'user_agent' ), 'referrer' => isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : '', ); $datetime = date_create_immutable( '@' . $submission->get_meta( 'timestamp' ) ); if ( $datetime ) { $comment['comment_date_gmt'] = $datetime->format( DATE_ATOM ); } if ( $permalink = get_permalink() ) { $comment['permalink'] = $permalink; } $server_vars = array_diff_key( $_SERVER, array_flip( array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ) ) ); $comment = array_merge( $comment, $server_vars ); $comment = apply_filters( 'wpcf7_akismet_parameters', $comment ); if ( wpcf7_akismet_comment_check( $comment ) ) { $spam = true; $submission->add_spam_log( array( 'agent' => 'akismet', 'reason' => __( "Akismet returns a spam response.", 'contact-form-7' ), ) ); } else { $spam = false; } return $spam; } /** * Returns true if Akismet is active and has a valid API key. */ function wpcf7_akismet_is_available() { if ( is_callable( array( 'Akismet', 'get_api_key' ) ) ) { return (bool) Akismet::get_api_key(); } return false; } /** * Returns an array of parameters based on the current form submission. * Returns false if Akismet is not active on the contact form. */ function wpcf7_akismet_submitted_params() { $akismet_tags = array_filter( wpcf7_scan_form_tags(), static function ( $tag ) { $akismet_option = $tag->get_option( 'akismet', '(author|author_email|author_url)', true ); return (bool) $akismet_option; } ); if ( ! $akismet_tags ) { // Akismet is not active on this contact form. return false; } $params = array( 'author' => '', 'author_email' => '', 'author_url' => '', 'content' => '', ); foreach ( (array) $_POST as $key => $val ) { if ( '_wpcf7' == substr( $key, 0, 6 ) or '_wpnonce' == $key ) { continue; } $vals = array_filter( wpcf7_array_flatten( $val ), static function ( $val ) { return '' !== trim( $val ); } ); if ( empty( $vals ) ) { continue; } if ( $tags = wpcf7_scan_form_tags( array( 'name' => $key ) ) ) { $tag = $tags[0]; $akismet_option = $tag->get_option( 'akismet', '(author|author_email|author_url)', true ); if ( 'author' === $akismet_option ) { $params['author'] = sprintf( '%s %s', $params['author'], implode( ' ', $vals ) ); continue; } if ( 'author_email' === $akismet_option and '' === $params['author_email'] ) { $params['author_email'] = $vals[0]; continue; } if ( 'author_url' === $akismet_option and '' === $params['author_url'] ) { $params['author_url'] = $vals[0]; continue; } $vals = array_filter( $vals, static function ( $val ) use ( $tag ) { if ( wpcf7_form_tag_supports( $tag->type, 'selectable-values' ) and in_array( $val, $tag->labels ) ) { return false; } else { return true; } } ); } if ( $vals ) { $params['content'] .= "\n\n" . implode( ', ', $vals ); } } $params = array_map( 'trim', $params ); return $params; } /** * Sends data to Akismet. * * @param array $comment Submission and environment data. * @return bool True if Akismet called it spam, or false otherwise. */ function wpcf7_akismet_comment_check( $comment ) { $spam = false; $query_string = wpcf7_build_query( $comment ); if ( is_callable( array( 'Akismet', 'http_post' ) ) ) { $response = Akismet::http_post( $query_string, 'comment-check' ); } else { return $spam; } if ( 'true' == $response[1] ) { $spam = true; } if ( $submission = WPCF7_Submission::get_instance() ) { $submission->push( 'akismet', array( 'comment' => $comment, 'spam' => $spam, ) ); } return apply_filters( 'wpcf7_akismet_comment_check', $spam, $comment ); } add_filter( 'wpcf7_posted_data', 'wpcf7_akismet_posted_data', 10, 1 ); /** * Removes Akismet-related properties from the posted data. * * This does not affect the $_POST variable itself. * * @link https://plugins.trac.wordpress.org/browser/akismet/tags/5.0/_inc/akismet-frontend.js */ function wpcf7_akismet_posted_data( $posted_data ) { if ( wpcf7_akismet_is_available() ) { $posted_data = array_diff_key( $posted_data, array( 'ak_bib' => '', 'ak_bfs' => '', 'ak_bkpc' => '', 'ak_bkp' => '', 'ak_bmc' => '', 'ak_bmcc' => '', 'ak_bmk' => '', 'ak_bck' => '', 'ak_bmmc' => '', 'ak_btmc' => '', 'ak_bsc' => '', 'ak_bte' => '', 'ak_btec' => '', 'ak_bmm' => '', ) ); } return $posted_data; } add_filter( 'wpcf7_default_template', 'wpcf7_akismet_default_template', 10, 2 ); function wpcf7_akismet_default_template( $template, $prop ) { if ( ! wpcf7_akismet_is_available() ) { return $template; } if ( 'form' === $prop ) { $template = str_replace( array( '[text* your-name ', '[email* your-email ', ), array( '[text* your-name akismet:author ', '[email* your-email akismet:author_email ', ), $template ); $privacy_notice = sprintf( '%s %s', __( "This form uses Akismet to reduce spam.", 'contact-form-7' ), wpcf7_link( 'https://akismet.com/privacy/', __( "Learn how your data is processed.", 'contact-form-7' ), array( 'target' => '_blank', 'rel' => 'nofollow noopener', ) ) ); $template .= "\n\n" . $privacy_notice; } return $template; } modules/date.php000064400000017630150515101440007645 0ustar00 true, ) ); } function wpcf7_date_form_tag_handler( $tag ) { if ( empty( $tag->name ) ) { return ''; } $validation_error = wpcf7_get_validation_error( $tag->name ); $class = wpcf7_form_controls_class( $tag->type ); $class .= ' wpcf7-validates-as-date'; if ( $validation_error ) { $class .= ' wpcf7-not-valid'; } $atts = array(); $atts['class'] = $tag->get_class_option( $class ); $atts['id'] = $tag->get_id_option(); $atts['tabindex'] = $tag->get_option( 'tabindex', 'signed_int', true ); $atts['min'] = $tag->get_date_option( 'min' ); $atts['max'] = $tag->get_date_option( 'max' ); $atts['step'] = $tag->get_option( 'step', 'int', true ); $atts['readonly'] = $tag->has_option( 'readonly' ); $atts['autocomplete'] = $tag->get_option( 'autocomplete', '[-0-9a-zA-Z]+', true ); if ( $tag->is_required() ) { $atts['aria-required'] = 'true'; } if ( $validation_error ) { $atts['aria-invalid'] = 'true'; $atts['aria-describedby'] = wpcf7_get_validation_error_reference( $tag->name ); } else { $atts['aria-invalid'] = 'false'; } $value = (string) reset( $tag->values ); if ( $tag->has_option( 'placeholder' ) or $tag->has_option( 'watermark' ) ) { $atts['placeholder'] = $value; $value = ''; } $value = $tag->get_default_option( $value ); if ( $value ) { $datetime_obj = date_create_immutable( preg_replace( '/[_]+/', ' ', $value ), wp_timezone() ); if ( $datetime_obj ) { $value = $datetime_obj->format( 'Y-m-d' ); } } $value = wpcf7_get_hangover( $tag->name, $value ); $atts['value'] = $value; $atts['type'] = $tag->basetype; $atts['name'] = $tag->name; $html = sprintf( '%3$s', esc_attr( $tag->name ), wpcf7_format_atts( $atts ), $validation_error ); return $html; } add_action( 'wpcf7_swv_create_schema', 'wpcf7_swv_add_date_rules', 10, 2 ); function wpcf7_swv_add_date_rules( $schema, $contact_form ) { $tags = $contact_form->scan_form_tags( array( 'basetype' => array( 'date' ), ) ); foreach ( $tags as $tag ) { if ( $tag->is_required() ) { $schema->add_rule( wpcf7_swv_create_rule( 'required', array( 'field' => $tag->name, 'error' => wpcf7_get_message( 'invalid_required' ), ) ) ); } $schema->add_rule( wpcf7_swv_create_rule( 'date', array( 'field' => $tag->name, 'error' => wpcf7_get_message( 'invalid_date' ), ) ) ); $min = $tag->get_date_option( 'min' ); $max = $tag->get_date_option( 'max' ); if ( false !== $min ) { $schema->add_rule( wpcf7_swv_create_rule( 'mindate', array( 'field' => $tag->name, 'threshold' => $min, 'error' => wpcf7_get_message( 'date_too_early' ), ) ) ); } if ( false !== $max ) { $schema->add_rule( wpcf7_swv_create_rule( 'maxdate', array( 'field' => $tag->name, 'threshold' => $max, 'error' => wpcf7_get_message( 'date_too_late' ), ) ) ); } } } /* Messages */ add_filter( 'wpcf7_messages', 'wpcf7_date_messages', 10, 1 ); function wpcf7_date_messages( $messages ) { return array_merge( $messages, array( 'invalid_date' => array( 'description' => __( "Date format that the sender entered is invalid", 'contact-form-7' ), 'default' => __( "Please enter a date in YYYY-MM-DD format.", 'contact-form-7' ), ), 'date_too_early' => array( 'description' => __( "Date is earlier than minimum limit", 'contact-form-7' ), 'default' => __( "This field has a too early date.", 'contact-form-7' ), ), 'date_too_late' => array( 'description' => __( "Date is later than maximum limit", 'contact-form-7' ), 'default' => __( "This field has a too late date.", 'contact-form-7' ), ), ) ); } /* Tag generator */ add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_date', 19, 0 ); function wpcf7_add_tag_generator_date() { $tag_generator = WPCF7_TagGenerator::get_instance(); $tag_generator->add( 'date', __( 'date', 'contact-form-7' ), 'wpcf7_tag_generator_date' ); } function wpcf7_tag_generator_date( $contact_form, $args = '' ) { $args = wp_parse_args( $args, array() ); $type = 'date'; $description = __( "Generate a form-tag for a date input field. For more details, see %s.", 'contact-form-7' ); $desc_link = wpcf7_link( __( 'https://contactform7.com/date-field/', 'contact-form-7' ), __( 'Date field', 'contact-form-7' ) ); ?>


    true, ) ); } function wpcf7_acceptance_form_tag_handler( $tag ) { if ( empty( $tag->name ) ) { return ''; } $validation_error = wpcf7_get_validation_error( $tag->name ); $class = wpcf7_form_controls_class( $tag->type ); if ( $validation_error ) { $class .= ' wpcf7-not-valid'; } if ( $tag->has_option( 'invert' ) ) { $class .= ' invert'; } if ( $tag->has_option( 'optional' ) ) { $class .= ' optional'; } $atts = array( 'class' => trim( $class ), ); $item_atts = array( 'type' => 'checkbox', 'name' => $tag->name, 'value' => '1', 'tabindex' => $tag->get_option( 'tabindex', 'signed_int', true ), 'checked' => $tag->has_option( 'default:on' ), 'class' => $tag->get_class_option() ? $tag->get_class_option() : null, 'id' => $tag->get_id_option(), ); if ( $validation_error ) { $item_atts['aria-invalid'] = 'true'; $item_atts['aria-describedby'] = wpcf7_get_validation_error_reference( $tag->name ); } else { $item_atts['aria-invalid'] = 'false'; } $item_atts = wpcf7_format_atts( $item_atts ); $content = empty( $tag->content ) ? (string) reset( $tag->values ) : $tag->content; $content = trim( $content ); if ( $content ) { if ( $tag->has_option( 'label_first' ) ) { $html = sprintf( '%2$s', $item_atts, $content ); } else { $html = sprintf( '%2$s', $item_atts, $content ); } $html = sprintf( '', $html ); } else { $html = sprintf( '', $item_atts ); } $html = sprintf( '%3$s%4$s', esc_attr( $tag->name ), wpcf7_format_atts( $atts ), $html, $validation_error ); return $html; } /* Validation filter */ add_filter( 'wpcf7_validate_acceptance', 'wpcf7_acceptance_validation_filter', 10, 2 ); function wpcf7_acceptance_validation_filter( $result, $tag ) { if ( ! wpcf7_acceptance_as_validation() ) { return $result; } if ( $tag->has_option( 'optional' ) ) { return $result; } $name = $tag->name; $value = ( ! empty( $_POST[$name] ) ? 1 : 0 ); $invert = $tag->has_option( 'invert' ); if ( $invert and $value or ! $invert and ! $value ) { $result->invalidate( $tag, wpcf7_get_message( 'accept_terms' ) ); } return $result; } /* Acceptance filter */ add_filter( 'wpcf7_acceptance', 'wpcf7_acceptance_filter', 10, 2 ); function wpcf7_acceptance_filter( $accepted, $submission ) { $tags = wpcf7_scan_form_tags( array( 'type' => 'acceptance' ) ); foreach ( $tags as $tag ) { $name = $tag->name; if ( empty( $name ) ) { continue; } $value = ( ! empty( $_POST[$name] ) ? 1 : 0 ); $content = empty( $tag->content ) ? (string) reset( $tag->values ) : $tag->content; $content = trim( $content ); if ( $value and $content ) { $submission->add_consent( $name, $content ); } if ( $tag->has_option( 'optional' ) ) { continue; } $invert = $tag->has_option( 'invert' ); if ( $invert and $value or ! $invert and ! $value ) { $accepted = false; } } return $accepted; } add_filter( 'wpcf7_form_class_attr', 'wpcf7_acceptance_form_class_attr', 10, 1 ); function wpcf7_acceptance_form_class_attr( $class_attr ) { if ( wpcf7_acceptance_as_validation() ) { return $class_attr . ' wpcf7-acceptance-as-validation'; } return $class_attr; } function wpcf7_acceptance_as_validation() { if ( ! $contact_form = wpcf7_get_current_contact_form() ) { return false; } return $contact_form->is_true( 'acceptance_as_validation' ); } add_filter( 'wpcf7_mail_tag_replaced_acceptance', 'wpcf7_acceptance_mail_tag', 10, 4 ); function wpcf7_acceptance_mail_tag( $replaced, $submitted, $html, $mail_tag ) { $form_tag = $mail_tag->corresponding_form_tag(); if ( ! $form_tag ) { return $replaced; } if ( ! empty( $submitted ) ) { $replaced = __( 'Consented', 'contact-form-7' ); } else { $replaced = __( 'Not consented', 'contact-form-7' ); } $content = empty( $form_tag->content ) ? (string) reset( $form_tag->values ) : $form_tag->content; if ( ! $html ) { $content = wp_strip_all_tags( $content ); } $content = trim( $content ); if ( $content ) { $replaced = sprintf( /* translators: 1: 'Consented' or 'Not consented', 2: conditions */ _x( '%1$s: %2$s', 'mail output for acceptance checkboxes', 'contact-form-7' ), $replaced, $content ); } return $replaced; } /* Tag generator */ add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_acceptance', 35, 0 ); function wpcf7_add_tag_generator_acceptance() { $tag_generator = WPCF7_TagGenerator::get_instance(); $tag_generator->add( 'acceptance', __( 'acceptance', 'contact-form-7' ), 'wpcf7_tag_generator_acceptance' ); } function wpcf7_tag_generator_acceptance( $contact_form, $args = '' ) { $args = wp_parse_args( $args, array() ); $type = 'acceptance'; $description = __( "Generate a form-tag for an acceptance checkbox. For more details, see %s.", 'contact-form-7' ); $desc_link = wpcf7_link( __( 'https://contactform7.com/acceptance-checkbox/', 'contact-form-7' ), __( 'Acceptance checkbox', 'contact-form-7' ) ); ?>
    true, ) ); } function wpcf7_number_form_tag_handler( $tag ) { if ( empty( $tag->name ) ) { return ''; } $validation_error = wpcf7_get_validation_error( $tag->name ); $class = wpcf7_form_controls_class( $tag->type ); $class .= ' wpcf7-validates-as-number'; if ( $validation_error ) { $class .= ' wpcf7-not-valid'; } $atts = array(); $atts['class'] = $tag->get_class_option( $class ); $atts['id'] = $tag->get_id_option(); $atts['tabindex'] = $tag->get_option( 'tabindex', 'signed_int', true ); $atts['min'] = $tag->get_option( 'min', 'signed_num', true ); $atts['max'] = $tag->get_option( 'max', 'signed_num', true ); $atts['step'] = $tag->get_option( 'step', 'num', true ); $atts['readonly'] = $tag->has_option( 'readonly' ); $atts['autocomplete'] = $tag->get_option( 'autocomplete', '[-0-9a-zA-Z]+', true ); if ( $tag->is_required() ) { $atts['aria-required'] = 'true'; } if ( $validation_error ) { $atts['aria-invalid'] = 'true'; $atts['aria-describedby'] = wpcf7_get_validation_error_reference( $tag->name ); } else { $atts['aria-invalid'] = 'false'; } $value = (string) reset( $tag->values ); if ( $tag->has_option( 'placeholder' ) or $tag->has_option( 'watermark' ) ) { $atts['placeholder'] = $value; $value = ''; } $value = $tag->get_default_option( $value ); $value = wpcf7_get_hangover( $tag->name, $value ); $atts['value'] = $value; if ( 'range' === $tag->basetype ) { if ( ! wpcf7_is_number( $atts['min'] ) ) { $atts['min'] = '0'; } if ( ! wpcf7_is_number( $atts['max'] ) ) { $atts['max'] = '100'; } if ( '' === $atts['value'] ) { if ( $atts['min'] < $atts['max'] ) { $atts['value'] = ( $atts['min'] + $atts['max'] ) / 2; } else { $atts['value'] = $atts['min']; } } } $atts['type'] = $tag->basetype; $atts['name'] = $tag->name; $html = sprintf( '%3$s', esc_attr( $tag->name ), wpcf7_format_atts( $atts ), $validation_error ); return $html; } add_action( 'wpcf7_swv_create_schema', 'wpcf7_swv_add_number_rules', 10, 2 ); function wpcf7_swv_add_number_rules( $schema, $contact_form ) { $tags = $contact_form->scan_form_tags( array( 'basetype' => array( 'number', 'range' ), ) ); foreach ( $tags as $tag ) { if ( $tag->is_required() ) { $schema->add_rule( wpcf7_swv_create_rule( 'required', array( 'field' => $tag->name, 'error' => wpcf7_get_message( 'invalid_required' ), ) ) ); } $schema->add_rule( wpcf7_swv_create_rule( 'number', array( 'field' => $tag->name, 'error' => wpcf7_get_message( 'invalid_number' ), ) ) ); $min = $tag->get_option( 'min', 'signed_num', true ); $max = $tag->get_option( 'max', 'signed_num', true ); if ( 'range' === $tag->basetype ) { if ( ! wpcf7_is_number( $min ) ) { $min = '0'; } if ( ! wpcf7_is_number( $max ) ) { $max = '100'; } } if ( wpcf7_is_number( $min ) ) { $schema->add_rule( wpcf7_swv_create_rule( 'minnumber', array( 'field' => $tag->name, 'threshold' => $min, 'error' => wpcf7_get_message( 'number_too_small' ), ) ) ); } if ( wpcf7_is_number( $max ) ) { $schema->add_rule( wpcf7_swv_create_rule( 'maxnumber', array( 'field' => $tag->name, 'threshold' => $max, 'error' => wpcf7_get_message( 'number_too_large' ), ) ) ); } } } /* Messages */ add_filter( 'wpcf7_messages', 'wpcf7_number_messages', 10, 1 ); function wpcf7_number_messages( $messages ) { return array_merge( $messages, array( 'invalid_number' => array( 'description' => __( "Number format that the sender entered is invalid", 'contact-form-7' ), 'default' => __( "Please enter a number.", 'contact-form-7' ), ), 'number_too_small' => array( 'description' => __( "Number is smaller than minimum limit", 'contact-form-7' ), 'default' => __( "This field has a too small number.", 'contact-form-7' ), ), 'number_too_large' => array( 'description' => __( "Number is larger than maximum limit", 'contact-form-7' ), 'default' => __( "This field has a too large number.", 'contact-form-7' ), ), ) ); } /* Tag generator */ add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_number', 18, 0 ); function wpcf7_add_tag_generator_number() { $tag_generator = WPCF7_TagGenerator::get_instance(); $tag_generator->add( 'number', __( 'number', 'contact-form-7' ), 'wpcf7_tag_generator_number' ); } function wpcf7_tag_generator_number( $contact_form, $args = '' ) { $args = wp_parse_args( $args, array() ); $type = 'number'; $description = __( "Generate a form-tag for a field for numeric value input. For more details, see %s.", 'contact-form-7' ); $desc_link = wpcf7_link( __( 'https://contactform7.com/number-fields/', 'contact-form-7' ), __( 'Number fields', 'contact-form-7' ) ); ?>



    in_demo_mode() ) { return; } $cases = (array) apply_filters( 'wpcf7_flamingo_submit_if', array( 'spam', 'mail_sent', 'mail_failed' ) ); if ( empty( $result['status'] ) or ! in_array( $result['status'], $cases ) ) { return; } $submission = WPCF7_Submission::get_instance(); if ( ! $submission or ! $posted_data = $submission->get_posted_data() ) { return; } if ( $submission->get_meta( 'do_not_store' ) ) { return; } // Exclude do-not-store form-tag values. $posted_data = array_filter( $posted_data, static function ( $name ) use ( $contact_form ) { return ! $contact_form->scan_form_tags( array( 'name' => $name, 'feature' => 'do-not-store', ) ); }, ARRAY_FILTER_USE_KEY ); $email = wpcf7_flamingo_get_value( 'email', $contact_form ); $name = wpcf7_flamingo_get_value( 'name', $contact_form ); $subject = wpcf7_flamingo_get_value( 'subject', $contact_form ); $meta = array(); $special_mail_tags = array( 'serial_number', 'remote_ip', 'user_agent', 'url', 'date', 'time', 'post_id', 'post_name', 'post_title', 'post_url', 'post_author', 'post_author_email', 'site_title', 'site_description', 'site_url', 'site_admin_email', 'user_login', 'user_email', 'user_display_name', ); foreach ( $special_mail_tags as $smt ) { $tagname = sprintf( '_%s', $smt ); $mail_tag = new WPCF7_MailTag( sprintf( '[%s]', $tagname ), $tagname, '' ); $meta[$smt] = apply_filters( 'wpcf7_special_mail_tags', null, $tagname, false, $mail_tag ); } $timestamp = $submission->get_meta( 'timestamp' ); if ( $timestamp and $datetime = date_create( '@' . $timestamp ) ) { $datetime->setTimezone( wp_timezone() ); $last_contacted = $datetime->format( 'Y-m-d H:i:s' ); } else { $last_contacted = '0000-00-00 00:00:00'; } if ( 'mail_sent' == $result['status'] ) { $flamingo_contact = Flamingo_Contact::add( array( 'email' => $email, 'name' => $name, 'last_contacted' => $last_contacted, ) ); } $post_meta = get_post_meta( $contact_form->id(), '_flamingo', true ); $channel_id = isset( $post_meta['channel'] ) ? (int) $post_meta['channel'] : wpcf7_flamingo_add_channel( $contact_form->name(), $contact_form->title() ); if ( $channel_id ) { if ( ! isset( $post_meta['channel'] ) or $post_meta['channel'] !== $channel_id ) { $post_meta = empty( $post_meta ) ? array() : (array) $post_meta; $post_meta = array_merge( $post_meta, array( 'channel' => $channel_id, ) ); update_post_meta( $contact_form->id(), '_flamingo', $post_meta ); } $channel = get_term( $channel_id, Flamingo_Inbound_Message::channel_taxonomy ); if ( ! $channel or is_wp_error( $channel ) ) { $channel = 'contact-form-7'; } else { $channel = $channel->slug; } } else { $channel = 'contact-form-7'; } $args = array( 'channel' => $channel, 'status' => $submission->get_status(), 'subject' => $subject, 'from' => trim( sprintf( '%s <%s>', $name, $email ) ), 'from_name' => $name, 'from_email' => $email, 'fields' => $posted_data, 'meta' => $meta, 'akismet' => $submission->pull( 'akismet' ), 'spam' => ( 'spam' == $result['status'] ), 'consent' => $submission->collect_consent(), 'timestamp' => $timestamp, 'posted_data_hash' => $submission->get_posted_data_hash(), ); if ( $args['spam'] ) { $args['spam_log'] = $submission->get_spam_log(); } $args['recaptcha'] = $submission->pull( 'recaptcha' ); $args = apply_filters( 'wpcf7_flamingo_inbound_message_parameters', $args ); $flamingo_inbound = Flamingo_Inbound_Message::add( $args ); if ( empty( $flamingo_contact ) ) { $flamingo_contact_id = 0; } elseif ( method_exists( $flamingo_contact, 'id' ) ) { $flamingo_contact_id = $flamingo_contact->id(); } else { $flamingo_contact_id = $flamingo_contact->id; } if ( empty( $flamingo_inbound ) ) { $flamingo_inbound_id = 0; } elseif ( method_exists( $flamingo_inbound, 'id' ) ) { $flamingo_inbound_id = $flamingo_inbound->id(); } else { $flamingo_inbound_id = $flamingo_inbound->id; } $result += array( 'flamingo_contact_id' => absint( $flamingo_contact_id ), 'flamingo_inbound_id' => absint( $flamingo_inbound_id ), ); do_action( 'wpcf7_after_flamingo', $result ); } function wpcf7_flamingo_get_value( $field, $contact_form ) { if ( empty( $field ) or empty( $contact_form ) ) { return false; } $value = ''; if ( in_array( $field, array( 'email', 'name', 'subject' ) ) ) { $template = $contact_form->pref( 'flamingo_' . $field ); if ( null === $template ) { $template = sprintf( '[your-%s]', $field ); } else { $template = trim( wpcf7_strip_quote( $template ) ); } $value = wpcf7_mail_replace_tags( $template ); } $value = apply_filters( 'wpcf7_flamingo_get_value', $value, $field, $contact_form ); return $value; } function wpcf7_flamingo_add_channel( $slug, $name = '' ) { if ( ! class_exists( 'Flamingo_Inbound_Message' ) ) { return false; } $parent = term_exists( 'contact-form-7', Flamingo_Inbound_Message::channel_taxonomy ); if ( ! $parent ) { $parent = wp_insert_term( __( 'Contact Form 7', 'contact-form-7' ), Flamingo_Inbound_Message::channel_taxonomy, array( 'slug' => 'contact-form-7' ) ); if ( is_wp_error( $parent ) ) { return false; } } $parent = (int) $parent['term_id']; if ( ! is_taxonomy_hierarchical( Flamingo_Inbound_Message::channel_taxonomy ) ) { // backward compat for Flamingo 1.0.4 and lower return $parent; } if ( empty( $name ) ) { $name = $slug; } $channel = term_exists( $slug, Flamingo_Inbound_Message::channel_taxonomy, $parent ); if ( ! $channel ) { $channel = wp_insert_term( $name, Flamingo_Inbound_Message::channel_taxonomy, array( 'slug' => $slug, 'parent' => $parent ) ); if ( is_wp_error( $channel ) ) { return false; } } return (int) $channel['term_id']; } add_action( 'wpcf7_after_update', 'wpcf7_flamingo_update_channel', 10, 1 ); function wpcf7_flamingo_update_channel( $contact_form ) { if ( ! class_exists( 'Flamingo_Inbound_Message' ) ) { return false; } $post_meta = get_post_meta( $contact_form->id(), '_flamingo', true ); $channel = isset( $post_meta['channel'] ) ? get_term( $post_meta['channel'], Flamingo_Inbound_Message::channel_taxonomy ) : get_term_by( 'slug', $contact_form->name(), Flamingo_Inbound_Message::channel_taxonomy ); if ( ! $channel or is_wp_error( $channel ) ) { return; } if ( $channel->name !== wp_unslash( $contact_form->title() ) ) { wp_update_term( $channel->term_id, Flamingo_Inbound_Message::channel_taxonomy, array( 'name' => $contact_form->title(), 'slug' => $contact_form->name(), 'parent' => $channel->parent, ) ); } } add_filter( 'wpcf7_special_mail_tags', 'wpcf7_flamingo_serial_number', 10, 4 ); /** * Returns output string of a special mail-tag. * * @param string $output The string to be output. * @param string $name The tag name of the special mail-tag. * @param bool $html Whether the mail-tag is used in an HTML content. * @param WPCF7_MailTag $mail_tag An object representation of the mail-tag. * @return string Output of the given special mail-tag. */ function wpcf7_flamingo_serial_number( $output, $name, $html, $mail_tag = null ) { if ( ! $mail_tag instanceof WPCF7_MailTag ) { wpcf7_doing_it_wrong( sprintf( '%s()', __FUNCTION__ ), __( 'The fourth parameter ($mail_tag) must be an instance of the WPCF7_MailTag class.', 'contact-form-7' ), '5.2.2' ); } if ( '_serial_number' != $name ) { return $output; } if ( ! class_exists( 'Flamingo_Inbound_Message' ) or ! method_exists( 'Flamingo_Inbound_Message', 'count' ) ) { return $output; } if ( ! $contact_form = WPCF7_ContactForm::get_current() ) { return $output; } $post_meta = get_post_meta( $contact_form->id(), '_flamingo', true ); $channel_id = isset( $post_meta['channel'] ) ? (int) $post_meta['channel'] : wpcf7_flamingo_add_channel( $contact_form->name(), $contact_form->title() ); if ( $channel_id ) { return 1 + (int) Flamingo_Inbound_Message::count( array( 'channel_id' => $channel_id ) ); } return 0; } modules/hidden.php000064400000001410150515101440010150 0ustar00 true, 'display-hidden' => true, ) ); } function wpcf7_hidden_form_tag_handler( $tag ) { if ( empty( $tag->name ) ) { return ''; } $atts = array(); $class = wpcf7_form_controls_class( $tag->type ); $atts['class'] = $tag->get_class_option( $class ); $atts['id'] = $tag->get_id_option(); $value = (string) reset( $tag->values ); $value = $tag->get_default_option( $value ); $atts['value'] = $value; $atts['type'] = 'hidden'; $atts['name'] = $tag->name; $atts = wpcf7_format_atts( $atts ); $html = sprintf( '', $atts ); return $html; } modules/sendinblue/sendinblue.php000064400000011550150515101440013203 0ustar00add_service( 'sendinblue', WPCF7_Sendinblue::get_instance() ); } add_action( 'wpcf7_submit', 'wpcf7_sendinblue_submit', 10, 2 ); /** * Callback to the wpcf7_submit action hook. Creates a contact * based on the submission. */ function wpcf7_sendinblue_submit( $contact_form, $result ) { if ( $contact_form->in_demo_mode() ) { return; } $service = WPCF7_Sendinblue::get_instance(); if ( ! $service->is_active() ) { return; } if ( empty( $result['posted_data_hash'] ) ) { return; } if ( empty( $result['status'] ) or ! in_array( $result['status'], array( 'mail_sent', 'mail_failed' ) ) ) { return; } $submission = WPCF7_Submission::get_instance(); $consented = true; foreach ( $contact_form->scan_form_tags( 'feature=name-attr' ) as $tag ) { if ( $tag->has_option( 'consent_for:sendinblue' ) and null == $submission->get_posted_data( $tag->name ) ) { $consented = false; break; } } if ( ! $consented ) { return; } $prop = wp_parse_args( $contact_form->prop( 'sendinblue' ), array( 'enable_contact_list' => false, 'contact_lists' => array(), 'enable_transactional_email' => false, 'email_template' => 0, ) ); if ( ! $prop['enable_contact_list'] ) { return; } $attributes = wpcf7_sendinblue_collect_parameters(); $params = array( 'contact' => array(), 'email' => array(), ); if ( ! empty( $attributes['EMAIL'] ) or ! empty( $attributes['SMS'] ) ) { $params['contact'] = apply_filters( 'wpcf7_sendinblue_contact_parameters', array( 'email' => $attributes['EMAIL'], 'attributes' => (object) $attributes, 'listIds' => (array) $prop['contact_lists'], 'updateEnabled' => false, ) ); } if ( $prop['enable_transactional_email'] and $prop['email_template'] ) { $first_name = isset( $attributes['FIRSTNAME'] ) ? trim( $attributes['FIRSTNAME'] ) : ''; $last_name = isset( $attributes['LASTNAME'] ) ? trim( $attributes['LASTNAME'] ) : ''; if ( $first_name or $last_name ) { $email_to_name = sprintf( /* translators: 1: first name, 2: last name */ _x( '%1$s %2$s', 'personal name', 'contact-form-7' ), $first_name, $last_name ); } else { $email_to_name = ''; } $params['email'] = apply_filters( 'wpcf7_sendinblue_email_parameters', array( 'templateId' => absint( $prop['email_template'] ), 'to' => array( array( 'name' => $email_to_name, 'email' => $attributes['EMAIL'], ), ), 'params' => (object) $attributes, 'tags' => array( 'Contact Form 7' ), ) ); } if ( is_email( $attributes['EMAIL'] ) ) { $token = null; do_action_ref_array( 'wpcf7_doi', array( 'wpcf7_sendinblue', array( 'email_to' => $attributes['EMAIL'], 'properties' => $params, ), &$token, ) ); if ( isset( $token ) ) { return; } } if ( ! empty( $params['contact'] ) ) { $contact_id = $service->create_contact( $params['contact'] ); if ( $contact_id and ! empty( $params['email'] ) ) { $service->send_email( $params['email'] ); } } } /** * Collects parameters for Sendinblue contact data based on submission. * * @return array Sendinblue contact parameters. */ function wpcf7_sendinblue_collect_parameters() { $params = array(); $submission = WPCF7_Submission::get_instance(); foreach ( (array) $submission->get_posted_data() as $name => $val ) { $name = strtoupper( $name ); if ( 'YOUR-' == substr( $name, 0, 5 ) ) { $name = substr( $name, 5 ); } if ( $val ) { $params += array( $name => $val, ); } } if ( isset( $params['SMS'] ) ) { $sms = implode( ' ', (array) $params['SMS'] ); $sms = trim( $sms ); $plus = '+' == substr( $sms, 0, 1 ) ? '+' : ''; $sms = preg_replace( '/[^0-9]/', '', $sms ); if ( 6 < strlen( $sms ) and strlen( $sms ) < 18 ) { $params['SMS'] = $plus . $sms; } else { // Invalid phone number unset( $params['SMS'] ); } } if ( isset( $params['NAME'] ) ) { $your_name = implode( ' ', (array) $params['NAME'] ); $your_name = explode( ' ', $your_name ); if ( ! isset( $params['LASTNAME'] ) ) { $params['LASTNAME'] = implode( ' ', array_slice( $your_name, 1 ) ); } if ( ! isset( $params['FIRSTNAME'] ) ) { $params['FIRSTNAME'] = implode( ' ', array_slice( $your_name, 0, 1 ) ); } } $params = apply_filters( 'wpcf7_sendinblue_collect_parameters', $params ); return $params; } modules/sendinblue/service.php000064400000022417150515101440012517 0ustar00api_key = $option['api_key']; } } public function get_title() { return __( 'Brevo (formerly Sendinblue)', 'contact-form-7' ); } public function is_active() { return (bool) $this->get_api_key(); } public function get_api_key() { return $this->api_key; } public function get_categories() { return array( 'email_marketing' ); } public function icon() { } public function link() { echo wpcf7_link( 'https://www.brevo.com/?tap_a=30591-fb13f0&tap_s=1031580-b1bb1d', 'brevo.com' ); } protected function log( $url, $request, $response ) { wpcf7_log_remote_request( $url, $request, $response ); } protected function menu_page_url( $args = '' ) { $args = wp_parse_args( $args, array() ); $url = menu_page_url( 'wpcf7-integration', false ); $url = add_query_arg( array( 'service' => 'sendinblue' ), $url ); if ( ! empty( $args ) ) { $url = add_query_arg( $args, $url ); } return $url; } protected function save_data() { WPCF7::update_option( 'sendinblue', array( 'api_key' => $this->api_key, ) ); } protected function reset_data() { $this->api_key = null; $this->save_data(); } public function load( $action = '' ) { if ( 'setup' == $action and 'POST' == $_SERVER['REQUEST_METHOD'] ) { check_admin_referer( 'wpcf7-sendinblue-setup' ); if ( ! empty( $_POST['reset'] ) ) { $this->reset_data(); $redirect_to = $this->menu_page_url( 'action=setup' ); } else { $this->api_key = isset( $_POST['api_key'] ) ? trim( $_POST['api_key'] ) : ''; $confirmed = $this->confirm_key(); if ( true === $confirmed ) { $redirect_to = $this->menu_page_url( array( 'message' => 'success', ) ); $this->save_data(); } elseif ( false === $confirmed ) { $redirect_to = $this->menu_page_url( array( 'action' => 'setup', 'message' => 'unauthorized', ) ); } else { $redirect_to = $this->menu_page_url( array( 'action' => 'setup', 'message' => 'invalid', ) ); } } wp_safe_redirect( $redirect_to ); exit(); } } public function admin_notice( $message = '' ) { if ( 'unauthorized' == $message ) { echo sprintf( '

    %1$s: %2$s

    ', esc_html( __( "Error", 'contact-form-7' ) ), esc_html( __( "You have not been authenticated. Make sure the provided API key is correct.", 'contact-form-7' ) ) ); } if ( 'invalid' == $message ) { echo sprintf( '

    %1$s: %2$s

    ', esc_html( __( "Error", 'contact-form-7' ) ), esc_html( __( "Invalid key values.", 'contact-form-7' ) ) ); } if ( 'success' == $message ) { echo sprintf( '

    %s

    ', esc_html( __( 'Settings saved.', 'contact-form-7' ) ) ); } } public function display( $action = '' ) { echo sprintf( '

    %s

    ', esc_html( __( "Store and organize your contacts while protecting user privacy on Brevo, the leading CRM & email marketing platform in Europe. Brevo offers unlimited contacts and advanced marketing features.", 'contact-form-7' ) ) ); echo sprintf( '

    %s

    ', wpcf7_link( __( 'https://contactform7.com/sendinblue-integration/', 'contact-form-7' ), __( 'Brevo (formerly Sendinblue) integration', 'contact-form-7' ) ) ); if ( $this->is_active() ) { echo sprintf( '

    %s

    ', esc_html( __( "Brevo is active on this site.", 'contact-form-7' ) ) ); } if ( 'setup' == $action ) { $this->display_setup(); } else { echo sprintf( '

    %2$s

    ', esc_url( $this->menu_page_url( 'action=setup' ) ), esc_html( __( 'Setup integration', 'contact-form-7' ) ) ); } } private function display_setup() { $api_key = $this->get_api_key(); ?>
    is_active() ) { echo esc_html( wpcf7_mask_password( $api_key, 4, 8 ) ); echo sprintf( '', esc_attr( $api_key ) ); } else { echo sprintf( '', esc_attr( $api_key ) ); } ?>
    is_active() ) { submit_button( _x( 'Remove key', 'API keys', 'contact-form-7' ), 'small', 'reset' ); } else { submit_button( __( 'Save changes', 'contact-form-7' ) ); } ?>
    array( 'Accept' => 'application/json', 'Content-Type' => 'application/json; charset=utf-8', 'API-Key' => $this->get_api_key(), ), ); $response = wp_remote_get( $endpoint, $request ); $response_code = (int) wp_remote_retrieve_response_code( $response ); if ( 200 === $response_code ) { // 200 OK return true; } elseif ( 401 === $response_code ) { // 401 Unauthorized return false; } elseif ( 400 <= $response_code ) { if ( WP_DEBUG ) { $this->log( $endpoint, $request, $response ); } } } public function get_lists() { $endpoint = add_query_arg( array( 'limit' => 50, 'offset' => 0, ), 'https://api.sendinblue.com/v3/contacts/lists' ); $request = array( 'headers' => array( 'Accept' => 'application/json', 'Content-Type' => 'application/json; charset=utf-8', 'API-Key' => $this->get_api_key(), ), ); $response = wp_remote_get( $endpoint, $request ); $response_code = (int) wp_remote_retrieve_response_code( $response ); if ( 200 === $response_code ) { // 200 OK $response_body = wp_remote_retrieve_body( $response ); $response_body = json_decode( $response_body, true ); if ( empty( $response_body['lists'] ) ) { return array(); } else { return (array) $response_body['lists']; } } elseif ( 400 <= $response_code ) { if ( WP_DEBUG ) { $this->log( $endpoint, $request, $response ); } } } public function get_templates() { $endpoint = add_query_arg( array( 'templateStatus' => 'true', 'limit' => 100, 'offset' => 0, ), 'https://api.sendinblue.com/v3/smtp/templates' ); $request = array( 'headers' => array( 'Accept' => 'application/json', 'Content-Type' => 'application/json; charset=utf-8', 'API-Key' => $this->get_api_key(), ), ); $response = wp_remote_get( $endpoint, $request ); $response_code = (int) wp_remote_retrieve_response_code( $response ); if ( 200 === $response_code ) { // 200 OK $response_body = wp_remote_retrieve_body( $response ); $response_body = json_decode( $response_body, true ); if ( empty( $response_body['templates'] ) ) { return array(); } else { return (array) $response_body['templates']; } } elseif ( 400 <= $response_code ) { if ( WP_DEBUG ) { $this->log( $endpoint, $request, $response ); } } } public function create_contact( $properties ) { $endpoint = 'https://api.sendinblue.com/v3/contacts'; $request = array( 'headers' => array( 'Accept' => 'application/json', 'Content-Type' => 'application/json; charset=utf-8', 'API-Key' => $this->get_api_key(), ), 'body' => json_encode( $properties ), ); $response = wp_remote_post( $endpoint, $request ); $response_code = (int) wp_remote_retrieve_response_code( $response ); if ( in_array( $response_code, array( 201, 204 ), true ) ) { $contact_id = wp_remote_retrieve_body( $response ); return $contact_id; } elseif ( 400 <= $response_code ) { if ( WP_DEBUG ) { $this->log( $endpoint, $request, $response ); } } return false; } public function send_email( $properties ) { $endpoint = 'https://api.sendinblue.com/v3/smtp/email'; $request = array( 'headers' => array( 'Accept' => 'application/json', 'Content-Type' => 'application/json; charset=utf-8', 'API-Key' => $this->get_api_key(), ), 'body' => json_encode( $properties ), ); $response = wp_remote_post( $endpoint, $request ); $response_code = (int) wp_remote_retrieve_response_code( $response ); if ( 201 === $response_code ) { // 201 Transactional email sent $message_id = wp_remote_retrieve_body( $response ); return $message_id; } elseif ( 400 <= $response_code ) { if ( WP_DEBUG ) { $this->log( $endpoint, $request, $response ); } } return false; } } modules/sendinblue/doi.php000064400000004433150515101440011630 0ustar00 apply_filters( 'wpcf7_sendinblue_doi_optin_callback', 'wpcf7_sendinblue_doi_default_optin_callback' ), 'email_callback' => apply_filters( 'wpcf7_sendinblue_doi_email_callback', 'wpcf7_sendinblue_doi_default_email_callback' ), ) ); } /** * Default optin_callback function. */ function wpcf7_sendinblue_doi_default_optin_callback( $properties ) { $service = WPCF7_Sendinblue::get_instance(); if ( ! $service->is_active() ) { return; } if ( ! empty( $properties['contact'] ) ) { $contact_id = $service->create_contact( $properties['contact'] ); if ( $contact_id and ! empty( $properties['email'] ) ) { $service->send_email( $properties['email'] ); } } } /** * Default email_callback function. */ function wpcf7_sendinblue_doi_default_email_callback( $args ) { if ( ! isset( $args['token'] ) or ! isset( $args['email_to'] ) ) { return; } $site_title = wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ); $link = add_query_arg( array( 'doitoken' => $args['token'] ), home_url() ); $to = $args['email_to']; $subject = sprintf( /* translators: %s: blog name */ __( 'Opt-in confirmation from %s', 'contact-form-7' ), $site_title ); $message = sprintf( /* translators: 1: blog name, 2: confirmation link */ __( 'Hello, This is a confirmation email sent from %1$s. We have received your submission to our web form, according to which you have allowed us to add you to our contact list. But, the process has not yet been completed. To complete it, please click the following link. %2$s If it was not your intention, or if you have no idea why you received this message, please do not click on the link, and ignore this message. We will never collect or use your personal data without your clear consent. Sincerely, %1$s', 'contact-form-7' ), $site_title, $link ); wp_mail( $to, $subject, $message ); } modules/sendinblue/contact-form-properties.php000064400000015405150515101440015644 0ustar00is_active() ) { $properties += array( 'sendinblue' => array(), ); } return $properties; } add_action( 'wpcf7_save_contact_form', 'wpcf7_sendinblue_save_contact_form', 10, 3 ); /** * Saves the sendinblue property value. */ function wpcf7_sendinblue_save_contact_form( $contact_form, $args, $context ) { $service = WPCF7_Sendinblue::get_instance(); if ( ! $service->is_active() ) { return; } $prop = isset( $_POST['wpcf7-sendinblue'] ) ? (array) $_POST['wpcf7-sendinblue'] : array(); $prop = wp_parse_args( $prop, array( 'enable_contact_list' => false, 'contact_lists' => array(), 'enable_transactional_email' => false, 'email_template' => 0, ) ); $prop['contact_lists'] = array_map( 'absint', $prop['contact_lists'] ); $prop['email_template'] = absint( $prop['email_template'] ); $contact_form->set_properties( array( 'sendinblue' => $prop, ) ); } add_filter( 'wpcf7_editor_panels', 'wpcf7_sendinblue_editor_panels', 10, 1 ); /** * Builds the editor panel for the sendinblue property. */ function wpcf7_sendinblue_editor_panels( $panels ) { $service = WPCF7_Sendinblue::get_instance(); if ( ! $service->is_active() ) { return $panels; } $contact_form = WPCF7_ContactForm::get_current(); $prop = wp_parse_args( $contact_form->prop( 'sendinblue' ), array( 'enable_contact_list' => false, 'contact_lists' => array(), 'enable_transactional_email' => false, 'email_template' => 0, ) ); $editor_panel = static function () use ( $prop, $service ) { $description = sprintf( esc_html( __( "You can set up the Brevo integration here. For details, see %s.", 'contact-form-7' ) ), wpcf7_link( __( 'https://contactform7.com/sendinblue-integration/', 'contact-form-7' ), __( 'Brevo (formerly Sendinblue) integration', 'contact-form-7' ) ) ); $lists = $service->get_lists(); $templates = $service->get_templates(); ?>

    array( 'title' => __( 'Brevo', 'contact-form-7' ), 'callback' => $editor_panel, ), ); return $panels; } modules/constant-contact/service.php000064400000027636150515101440013661 0ustar00authorization_endpoint = self::authorization_endpoint; $this->token_endpoint = self::token_endpoint; $option = (array) WPCF7::get_option( self::service_name ); if ( isset( $option['client_id'] ) ) { $this->client_id = $option['client_id']; } if ( isset( $option['client_secret'] ) ) { $this->client_secret = $option['client_secret']; } if ( isset( $option['access_token'] ) ) { $this->access_token = $option['access_token']; } if ( isset( $option['refresh_token'] ) ) { $this->refresh_token = $option['refresh_token']; } if ( $this->is_active() ) { if ( isset( $option['contact_lists'] ) ) { $this->contact_lists = $option['contact_lists']; } } add_action( 'wpcf7_admin_init', array( $this, 'auth_redirect' ) ); } public function auth_redirect() { $auth = isset( $_GET['auth'] ) ? trim( $_GET['auth'] ) : ''; if ( self::service_name === $auth and current_user_can( 'wpcf7_manage_integration' ) ) { $redirect_to = add_query_arg( array( 'service' => self::service_name, 'action' => 'auth_redirect', 'code' => isset( $_GET['code'] ) ? trim( $_GET['code'] ) : '', 'state' => isset( $_GET['state'] ) ? trim( $_GET['state'] ) : '', ), menu_page_url( 'wpcf7-integration', false ) ); wp_safe_redirect( $redirect_to ); exit(); } } protected function save_data() { $option = array_merge( (array) WPCF7::get_option( self::service_name ), array( 'client_id' => $this->client_id, 'client_secret' => $this->client_secret, 'access_token' => $this->access_token, 'refresh_token' => $this->refresh_token, 'contact_lists' => $this->contact_lists, ) ); WPCF7::update_option( self::service_name, $option ); } protected function reset_data() { $this->client_id = ''; $this->client_secret = ''; $this->access_token = ''; $this->refresh_token = ''; $this->contact_lists = array(); $this->save_data(); } public function get_title() { return __( 'Constant Contact', 'contact-form-7' ); } public function get_categories() { return array( 'email_marketing' ); } public function icon() { } public function link() { echo sprintf( '%2$s', 'https://constant-contact.evyy.net/c/1293104/205991/3411', 'constantcontact.com' ); } protected function get_redirect_uri() { return admin_url( '/?auth=' . self::service_name ); } protected function menu_page_url( $args = '' ) { $args = wp_parse_args( $args, array() ); $url = menu_page_url( 'wpcf7-integration', false ); $url = add_query_arg( array( 'service' => self::service_name ), $url ); if ( ! empty( $args ) ) { $url = add_query_arg( $args, $url ); } return $url; } public function load( $action = '' ) { if ( 'auth_redirect' == $action ) { $code = isset( $_GET['code'] ) ? urldecode( $_GET['code'] ) : ''; $state = isset( $_GET['state'] ) ? urldecode( $_GET['state'] ) : ''; if ( $code and $state and wpcf7_verify_nonce( $state, 'wpcf7_constant_contact_authorize' ) ) { $response = $this->request_token( $code ); } if ( ! empty( $this->access_token ) ) { $message = 'success'; } else { $message = 'failed'; } wp_safe_redirect( $this->menu_page_url( array( 'action' => 'setup', 'message' => $message, ) ) ); exit(); } if ( 'setup' == $action and 'POST' == $_SERVER['REQUEST_METHOD'] ) { check_admin_referer( 'wpcf7-constant-contact-setup' ); if ( ! empty( $_POST['reset'] ) ) { $this->reset_data(); } else { $this->client_id = isset( $_POST['client_id'] ) ? trim( $_POST['client_id'] ) : ''; $this->client_secret = isset( $_POST['client_secret'] ) ? trim( $_POST['client_secret'] ) : ''; $this->save_data(); $this->authorize( 'contact_data offline_access' ); } wp_safe_redirect( $this->menu_page_url( 'action=setup' ) ); exit(); } } protected function authorize( $scope = '' ) { $endpoint = add_query_arg( array_map( 'urlencode', array( 'response_type' => 'code', 'client_id' => $this->client_id, 'redirect_uri' => $this->get_redirect_uri(), 'scope' => $scope, 'state' => wpcf7_create_nonce( 'wpcf7_constant_contact_authorize' ), ) ), $this->authorization_endpoint ); if ( wp_redirect( sanitize_url( $endpoint ) ) ) { exit(); } } public function email_exists( $email ) { $endpoint = add_query_arg( array( 'email' => $email, 'status' => 'all', ), 'https://api.cc.email/v3/contacts' ); $request = array( 'method' => 'GET', 'headers' => array( 'Accept' => 'application/json', 'Content-Type' => 'application/json; charset=utf-8', ), ); $response = $this->remote_request( $endpoint, $request ); if ( 400 <= (int) wp_remote_retrieve_response_code( $response ) ) { if ( WP_DEBUG ) { $this->log( $endpoint, $request, $response ); } return false; } $response_body = wp_remote_retrieve_body( $response ); if ( empty( $response_body ) ) { return false; } $response_body = json_decode( $response_body, true ); return ! empty( $response_body['contacts'] ); } public function create_contact( $properties ) { $endpoint = 'https://api.cc.email/v3/contacts'; $request = array( 'method' => 'POST', 'headers' => array( 'Accept' => 'application/json', 'Content-Type' => 'application/json; charset=utf-8', ), 'body' => json_encode( $properties ), ); $response = $this->remote_request( $endpoint, $request ); if ( 400 <= (int) wp_remote_retrieve_response_code( $response ) ) { if ( WP_DEBUG ) { $this->log( $endpoint, $request, $response ); } return false; } } public function get_contact_lists() { $endpoint = 'https://api.cc.email/v3/contact_lists'; $request = array( 'method' => 'GET', 'headers' => array( 'Accept' => 'application/json', 'Content-Type' => 'application/json; charset=utf-8', ), ); $response = $this->remote_request( $endpoint, $request ); if ( 400 <= (int) wp_remote_retrieve_response_code( $response ) ) { if ( WP_DEBUG ) { $this->log( $endpoint, $request, $response ); } return false; } $response_body = wp_remote_retrieve_body( $response ); if ( empty( $response_body ) ) { return false; } $response_body = json_decode( $response_body, true ); if ( ! empty( $response_body['lists'] ) ) { return (array) $response_body['lists']; } else { return array(); } } public function update_contact_lists( $selection = array() ) { $contact_lists = array(); $contact_lists_on_api = $this->get_contact_lists(); if ( false !== $contact_lists_on_api ) { foreach ( (array) $contact_lists_on_api as $list ) { if ( isset( $list['list_id'] ) ) { $list_id = trim( $list['list_id'] ); } else { continue; } if ( isset( $this->contact_lists[$list_id]['selected'] ) ) { $list['selected'] = $this->contact_lists[$list_id]['selected']; } else { $list['selected'] = array(); } $contact_lists[$list_id] = $list; } } else { $contact_lists = $this->contact_lists; } foreach ( (array) $selection as $key => $ids_or_names ) { foreach( $contact_lists as $list_id => $list ) { if ( in_array( $list['list_id'], (array) $ids_or_names, true ) or in_array( $list['name'], (array) $ids_or_names, true ) ) { $contact_lists[$list_id]['selected'][$key] = true; } else { unset( $contact_lists[$list_id]['selected'][$key] ); } } } $this->contact_lists = $contact_lists; if ( $selection ) { $this->save_data(); } return $this->contact_lists; } public function admin_notice( $message = '' ) { switch ( $message ) { case 'success': echo sprintf( '

    %s

    ', esc_html( __( "Connection established.", 'contact-form-7' ) ) ); break; case 'failed': echo sprintf( '

    %1$s: %2$s

    ', esc_html( __( "Error", 'contact-form-7' ) ), esc_html( __( "Failed to establish connection. Please double-check your configuration.", 'contact-form-7' ) ) ); break; case 'updated': echo sprintf( '

    %s

    ', esc_html( __( "Configuration updated.", 'contact-form-7' ) ) ); break; } } public function display( $action = '' ) { echo sprintf( '

    %s

    ', esc_html( __( "The Constant Contact integration module allows you to send contact data collected through your contact forms to the Constant Contact API. You can create reliable email subscription services in a few easy steps.", 'contact-form-7' ) ) ); echo sprintf( '

    %s

    ', wpcf7_link( __( 'https://contactform7.com/constant-contact-integration/', 'contact-form-7' ), __( 'Constant Contact integration', 'contact-form-7' ) ) ); if ( $this->is_active() ) { echo sprintf( '

    %s

    ', esc_html( __( "This site is connected to the Constant Contact API.", 'contact-form-7' ) ) ); } if ( 'setup' == $action ) { $this->display_setup(); } else { echo sprintf( '

    %2$s

    ', esc_url( $this->menu_page_url( 'action=setup' ) ), esc_html( __( 'Setup Integration', 'contact-form-7' ) ) ); } } private function display_setup() { ?>
    is_active() ) { echo esc_html( $this->client_id ); echo sprintf( '', esc_attr( $this->client_id ) ); } else { echo sprintf( '', esc_attr( $this->client_id ) ); } ?>
    is_active() ) { echo esc_html( wpcf7_mask_password( $this->client_secret, 4, 4 ) ); echo sprintf( '', esc_attr( $this->client_secret ) ); } else { echo sprintf( '', esc_attr( $this->client_secret ) ); } ?>
    ', $this->get_redirect_uri() ); ?>

    is_active() ) { submit_button( _x( 'Reset Keys', 'API keys', 'contact-form-7' ), 'small', 'reset' ); } else { submit_button( __( 'Connect to the Constant Contact API', 'contact-form-7' ) ); } ?>
    apply_filters( 'wpcf7_constant_contact_doi_optin_callback', 'wpcf7_constant_contact_doi_default_optin_callback' ), 'email_callback' => apply_filters( 'wpcf7_constant_contact_doi_email_callback', 'wpcf7_constant_contact_doi_default_email_callback' ), ) ); } /** * Default optin_callback function. */ function wpcf7_constant_contact_doi_default_optin_callback( $properties ) { $service = WPCF7_ConstantContact::get_instance(); if ( $service->is_active() ) { $service->create_contact( $properties ); } } /** * Default email_callback function. */ function wpcf7_constant_contact_doi_default_email_callback( $args ) { if ( ! isset( $args['token'] ) or ! isset( $args['email_to'] ) ) { return; } $site_title = wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ); $link = add_query_arg( array( 'doitoken' => $args['token'] ), home_url() ); $to = $args['email_to']; $subject = sprintf( /* translators: %s: blog name */ __( 'Opt-in confirmation from %s', 'contact-form-7' ), $site_title ); $message = sprintf( /* translators: 1: blog name, 2: confirmation link */ __( 'Hello, This is a confirmation email sent from %1$s. We have received your submission to our web form, according to which you have allowed us to add you to our contact list. But, the process has not yet been completed. To complete it, please click the following link. %2$s If it was not your intention, or if you have no idea why you received this message, please do not click on the link, and ignore this message. We will never collect or use your personal data without your clear consent. Sincerely, %1$s', 'contact-form-7' ), $site_title, $link ); wp_mail( $to, $subject, $message ); } modules/constant-contact/constant-contact.php000064400000005211150515101440015464 0ustar00add_service( 'constant_contact', $service ); } add_action( 'wpcf7_submit', 'wpcf7_constant_contact_submit', 10, 2 ); /** * Callback to the wpcf7_submit action hook. Creates a contact * based on the submission. */ function wpcf7_constant_contact_submit( $contact_form, $result ) { $service = WPCF7_ConstantContact::get_instance(); if ( ! $service->is_active() ) { return; } if ( $contact_form->in_demo_mode() ) { return; } $do_submit = true; if ( empty( $result['status'] ) or ! in_array( $result['status'], array( 'mail_sent' ) ) ) { $do_submit = false; } $prop = $contact_form->prop( 'constant_contact' ); if ( empty( $prop['enable_contact_list'] ) ) { $do_submit = false; } $do_submit = apply_filters( 'wpcf7_constant_contact_submit', $do_submit, $contact_form, $result ); if ( ! $do_submit ) { return; } $submission = WPCF7_Submission::get_instance(); $consented = true; foreach ( $contact_form->scan_form_tags( 'feature=name-attr' ) as $tag ) { if ( $tag->has_option( 'consent_for:constant_contact' ) and null == $submission->get_posted_data( $tag->name ) ) { $consented = false; break; } } if ( ! $consented ) { return; } $request_builder_class_name = apply_filters( 'wpcf7_constant_contact_contact_post_request_builder', 'WPCF7_ConstantContact_ContactPostRequest' ); if ( ! class_exists( $request_builder_class_name ) ) { return; } $request_builder = new $request_builder_class_name; $request_builder->build( $submission ); if ( ! $request_builder->is_valid() ) { return; } $email = $request_builder->get_email_address(); if ( $email ) { if ( $service->email_exists( $email ) ) { return; } $token = null; do_action_ref_array( 'wpcf7_doi', array( 'wpcf7_constant_contact', array( 'email_to' => $email, 'properties' => $request_builder->to_array(), ), &$token, ) ); if ( isset( $token ) ) { return; } } $service->create_contact( $request_builder->to_array() ); } modules/constant-contact/contact-form-properties.php000064400000013654150515101440017002 0ustar00is_active() ) { $properties += array( 'constant_contact' => array(), ); } return $properties; } add_filter( 'wpcf7_contact_form_property_constant_contact', 'wpcf7_constant_contact_setup_property', 10, 2 ); /** * Sets up the constant_contact property value. For back-compat, this attempts * to take over the value from old settings if the property is empty. */ function wpcf7_constant_contact_setup_property( $property, $contact_form ) { if ( ! empty( $property ) ) { $property = wp_parse_args( $property, array( 'enable_contact_list' => false, 'contact_lists' => array(), ) ); return $property; } $property = array( 'enable_contact_list' => true, 'contact_lists' => array(), ); if ( $contact_form->initial() ) { return $property; } $service_option = (array) WPCF7::get_option( 'constant_contact' ); $property['enable_contact_list'] = ! $contact_form->is_false( 'constant_contact' ); if ( isset( $service_option['contact_lists'] ) ) { $contact_lists = (array) $service_option['contact_lists']; $contact_lists_selected = array(); foreach ( $contact_lists as $list ) { if ( empty( $list['selected'] ) ) { continue; } foreach ( (array) $list['selected'] as $key => $val ) { if ( ! isset( $contact_lists_selected[$key] ) ) { $contact_lists_selected[$key] = array(); } $contact_lists_selected[$key][] = $list['list_id']; } } $related_keys = array( sprintf( 'wpcf7_contact_form:%d', $contact_form->id() ), 'default', ); foreach ( $related_keys as $key ) { if ( ! empty( $contact_lists_selected[$key] ) ) { $property['contact_lists'] = $contact_lists_selected[$key]; break; } } } return $property; } add_action( 'wpcf7_save_contact_form', 'wpcf7_constant_contact_save_contact_form', 10, 1 ); /** * Saves the constant_contact property value. */ function wpcf7_constant_contact_save_contact_form( $contact_form ) { $service = WPCF7_ConstantContact::get_instance(); if ( ! $service->is_active() ) { return; } $prop = isset( $_POST['wpcf7-ctct'] ) ? (array) $_POST['wpcf7-ctct'] : array(); $prop = wp_parse_args( $prop, array( 'enable_contact_list' => false, 'contact_lists' => array(), ) ); $contact_form->set_properties( array( 'constant_contact' => $prop, ) ); } add_filter( 'wpcf7_editor_panels', 'wpcf7_constant_contact_editor_panels', 10, 1 ); /** * Builds the editor panel for the constant_contact property. */ function wpcf7_constant_contact_editor_panels( $panels ) { $service = WPCF7_ConstantContact::get_instance(); if ( ! $service->is_active() ) { return $panels; } $contact_form = WPCF7_ContactForm::get_current(); $prop = wp_parse_args( $contact_form->prop( 'constant_contact' ), array( 'enable_contact_list' => false, 'contact_lists' => array(), ) ); $editor_panel = static function () use ( $prop, $service ) { $description = sprintf( esc_html( __( "You can set up the Constant Contact integration here. For details, see %s.", 'contact-form-7' ) ), wpcf7_link( __( 'https://contactform7.com/constant-contact-integration/', 'contact-form-7' ), __( 'Constant Contact integration', 'contact-form-7' ) ) ); $lists = $service->get_contact_lists(); ?>

    array( 'title' => __( 'Constant Contact', 'contact-form-7' ), 'callback' => $editor_panel, ), ); return $panels; } modules/constant-contact/contact-post-request.php000064400000017453150515101440016321 0ustar00set_create_source( 'Contact' ); $this->set_first_name( $submission->get_posted_string( 'your-first-name' ) ); $this->set_last_name( $submission->get_posted_string( 'your-last-name' ) ); if ( ! ( $this->first_name || $this->last_name ) and $your_name = $submission->get_posted_string( 'your-name' ) ) { $your_name = preg_split( '/[\s]+/', $your_name, 2 ); $this->set_first_name( array_shift( $your_name ) ); $this->set_last_name( array_shift( $your_name ) ); } $this->set_email_address( $submission->get_posted_string( 'your-email' ), 'implicit' ); $this->set_job_title( $submission->get_posted_string( 'your-job-title' ) ); $this->set_company_name( $submission->get_posted_string( 'your-company-name' ) ); $this->set_birthday( $submission->get_posted_string( 'your-birthday-month' ), $submission->get_posted_string( 'your-birthday-day' ) ); if ( ! ( $this->birthday_month && $this->birthday_day ) ) { $date = $submission->get_posted_string( 'your-birthday' ); if ( preg_match( '/^(\d{4})-(\d{2})-(\d{2})$/', $date, $matches ) ) { $this->set_birthday( $matches[2], $matches[3] ); } } $this->set_anniversary( $submission->get_posted_string( 'your-anniversary' ) ); $this->add_phone_number( $submission->get_posted_string( 'your-phone-number' ) ); $this->add_street_address( $submission->get_posted_string( 'your-address-street' ), $submission->get_posted_string( 'your-address-city' ), $submission->get_posted_string( 'your-address-state' ), $submission->get_posted_string( 'your-address-postal-code' ), $submission->get_posted_string( 'your-address-country' ) ); $service_option = (array) WPCF7::get_option( 'constant_contact' ); $contact_lists = isset( $service_option['contact_lists'] ) ? $service_option['contact_lists'] : array(); $contact_form = $submission->get_contact_form(); $prop = $contact_form->prop( 'constant_contact' ); if ( ! empty( $prop['enable_contact_list'] ) and ! empty( $prop['contact_lists'] ) ) { foreach ( (array) $prop['contact_lists'] as $list_id ) { $this->add_list_membership( $list_id ); } } } public function is_valid() { return $this->create_source && ( $this->email_address || $this->first_name || $this->last_name ); } public function to_array() { $output = array( 'email_address' => $this->email_address, 'first_name' => $this->first_name, 'last_name' => $this->last_name, 'job_title' => $this->job_title, 'company_name' => $this->company_name, 'create_source' => $this->create_source, 'birthday_month' => $this->birthday_month, 'birthday_day' => $this->birthday_day, 'anniversary' => $this->anniversary, 'custom_fields' => $this->custom_fields, 'phone_numbers' => $this->phone_numbers, 'street_addresses' => $this->street_addresses, 'list_memberships' => $this->list_memberships, ); return array_filter( $output ); } public function get_email_address() { if ( isset( $this->email_address['address'] ) ) { return $this->email_address['address']; } return ''; } public function set_email_address( $address, $permission_to_send = '' ) { if ( ! wpcf7_is_email( $address ) or 80 < $this->strlen( $address ) ) { return false; } $types_of_permission = array( 'implicit', 'explicit', 'deprecate', 'pending', 'unsubscribe', 'temp_hold', 'not_set', ); if ( ! in_array( $permission_to_send, $types_of_permission ) ) { $permission_to_send = 'implicit'; } return $this->email_address = array( 'address' => $address, 'permission_to_send' => $permission_to_send, ); } public function set_first_name( $first_name ) { $first_name = trim( $first_name ); if ( empty( $first_name ) or 50 < $this->strlen( $first_name ) ) { return false; } return $this->first_name = $first_name; } public function set_last_name( $last_name ) { $last_name = trim( $last_name ); if ( empty( $last_name ) or 50 < $this->strlen( $last_name ) ) { return false; } return $this->last_name = $last_name; } public function set_job_title( $job_title ) { $job_title = trim( $job_title ); if ( empty( $job_title ) or 50 < $this->strlen( $job_title ) ) { return false; } return $this->job_title = $job_title; } public function set_company_name( $company_name ) { $company_name = trim( $company_name ); if ( empty( $company_name ) or 50 < $this->strlen( $company_name ) ) { return false; } return $this->company_name = $company_name; } public function set_create_source( $create_source ) { if ( ! in_array( $create_source, array( 'Contact', 'Account' ) ) ) { return false; } return $this->create_source = $create_source; } public function set_birthday( $month, $day ) { $month = (int) $month; $day = (int) $day; if ( $month < 1 || 12 < $month or $day < 1 || 31 < $day ) { return false; } $this->birthday_month = $month; $this->birthday_day = $day; return array( $this->birthday_month, $this->birthday_day ); } public function set_anniversary( $anniversary ) { $pattern = sprintf( '#^(%s)$#', implode( '|', array( '\d{1,2}/\d{1,2}/\d{4}', '\d{4}/\d{1,2}/\d{1,2}', '\d{4}-\d{1,2}-\d{1,2}', '\d{1,2}-\d{1,2}-\d{4}', ) ) ); if ( ! preg_match( $pattern, $anniversary ) ) { return false; } return $this->anniversary = $anniversary; } public function add_custom_field( $custom_field_id, $value ) { $uuid_pattern = '/^[0-9a-f-]+$/i'; $value = trim( $value ); if ( 25 <= count( $this->custom_fields ) or ! preg_match( $uuid_pattern, $custom_field_id ) or 255 < $this->strlen( $value ) ) { return false; } return $this->custom_fields[] = array( 'custom_field_id' => $custom_field_id, 'value' => $value, ); } public function add_phone_number( $phone_number, $kind = 'home' ) { $phone_number = trim( $phone_number ); if ( empty( $phone_number ) or ! wpcf7_is_tel( $phone_number ) or 25 < $this->strlen( $phone_number ) or 2 <= count( $this->phone_numbers ) or ! in_array( $kind, array( 'home', 'work', 'other' ) ) ) { return false; } return $this->phone_numbers[] = array( 'phone_number' => $phone_number, 'kind' => $kind, ); } public function add_street_address( $street, $city, $state, $postal_code, $country, $kind = 'home' ) { $street = trim( $street ); $city = trim( $city ); $state = trim( $state ); $postal_code = trim( $postal_code ); $country = trim( $country ); if ( ! ( $street || $city || $state || $postal_code || $country ) or 1 <= count( $this->street_addresses ) or ! in_array( $kind, array( 'home', 'work', 'other' ) ) or 255 < $this->strlen( $street ) or 50 < $this->strlen( $city ) or 50 < $this->strlen( $state ) or 50 < $this->strlen( $postal_code ) or 50 < $this->strlen( $country ) ) { return false; } return $this->street_addresses[] = array( 'kind' => $kind, 'street' => $street, 'city' => $city, 'state' => $state, 'postal_code' => $postal_code, 'country' => $country, ); } public function add_list_membership( $list_id ) { $uuid_pattern = '/^[0-9a-f-]+$/i'; if ( 50 <= count( $this->list_memberships ) or ! preg_match( $uuid_pattern, $list_id ) ) { return false; } return $this->list_memberships[] = $list_id; } protected function strlen( $text ) { return wpcf7_count_code_units( $text ); } } modules/reflection.php000064400000004420150515101440011053 0ustar00 true, 'display-block' => true, 'not-for-mail' => true, ) ); wpcf7_add_form_tag( 'output', 'wpcf7_output_form_tag_handler', array( 'name-attr' => true, 'not-for-mail' => true, ) ); } /** * The form-tag handler for the reflection type. */ function wpcf7_reflection_form_tag_handler( $tag ) { if ( empty( $tag->name ) ) { return ''; } $values = $tag->values ? $tag->values : array( '' ); if ( ! wpcf7_get_validation_error( $tag->name ) ) { $hangover = array_filter( (array) wpcf7_get_hangover( $tag->name ) ); if ( $hangover ) { $values = $hangover; } } $content = array_reduce( $values, static function ( $carry, $item ) use ( $tag ) { $output_tag = sprintf( '%2$s', wpcf7_format_atts( array( 'name' => $tag->name, 'data-default' => $item, ) ), ( '' !== $item ) ? esc_html( $item ) : ' ' ); return $carry . $output_tag; }, '' ); $html = sprintf( '
    %2$s
    ', wpcf7_format_atts( array( 'data-reflection-of' => $tag->name, 'class' => $tag->get_class_option( wpcf7_form_controls_class( $tag->type ) ), 'id' => $tag->get_id_option(), ) ), $content ); return $html; } /** * The form-tag handler for the output type. */ function wpcf7_output_form_tag_handler( $tag ) { if ( empty( $tag->name ) ) { return ''; } $value = (string) reset( $tag->values ); if ( ! wpcf7_get_validation_error( $tag->name ) ) { $hangover = array_filter( (array) wpcf7_get_hangover( $tag->name ) ); if ( $hangover ) { $value = (string) reset( $hangover ); } } $html = sprintf( '%2$s', wpcf7_format_atts( array( 'data-reflection-of' => $tag->name, 'data-default' => $value, 'name' => $tag->name, 'class' => $tag->get_class_option( wpcf7_form_controls_class( $tag->type ) ), 'id' => $tag->get_id_option(), ) ), esc_html( $value ) ); return $html; } modules/stripe/index.asset.php000064400000000121150515101440012446 0ustar00 array(), 'version' => WPCF7_VERSION, ); modules/stripe/index.js000064400000007001150515101440011161 0ustar00document.addEventListener("DOMContentLoaded",(e=>{const t=()=>{const e=document.querySelectorAll("form.wpcf7-form .wpcf7-stripe");for(let t=0;t{const t=e.detail.unitTag,s=`${t}-ve-stripe-card-element`,n=document.querySelector(`#${t} form`),o=n.closest(".wpcf7").querySelector(".screen-reader-response"),d=n.querySelector(".wpcf7-stripe .wpcf7-form-control-wrap"),c=n.querySelector(".wpcf7-stripe button.first"),a=n.querySelector(".wpcf7-stripe button.second"),l=n.querySelector('[name="_wpcf7_stripe_payment_intent"]');if(!l)return;l.setAttribute("value","");const u=e=>{const t=o.querySelector("ul"),r=t.querySelector(`li#${s}`);r&&r.remove();const i=document.createElement("li");i.setAttribute("id",s),i.insertAdjacentText("beforeend",e.message),t.appendChild(i)},p=e=>{const t=d.querySelector(".wpcf7-form-control");t.classList.add("wpcf7-not-valid"),t.setAttribute("aria-describedby",s);const r=document.createElement("span");r.setAttribute("class","wpcf7-not-valid-tip"),r.setAttribute("aria-hidden","true"),r.insertAdjacentText("beforeend",e.message),d.appendChild(r),d.querySelectorAll("[aria-invalid]").forEach((e=>{e.setAttribute("aria-invalid","true")})),t.closest(".use-floating-validation-tip")&&(t.addEventListener("focus",(e=>{r.setAttribute("style","display: none")})),r.addEventListener("mouseover",(e=>{r.setAttribute("style","display: none")})))},f=()=>{o.querySelectorAll(`ul li#${s}`).forEach((e=>{e.remove()})),d.querySelectorAll(".wpcf7-not-valid-tip").forEach((e=>{e.remove()})),d.querySelectorAll("[aria-invalid]").forEach((e=>{e.setAttribute("aria-invalid","false")})),d.querySelectorAll(".wpcf7-form-control").forEach((e=>{e.removeAttribute("aria-describedby"),e.classList.remove("wpcf7-not-valid")}))};if("payment_required"===e.detail.status){const s=e.detail.apiResponse.stripe.payment_intent;s.id&&l.setAttribute("value",s.id);const o=i.getElement("card")||i.create("card");o.mount(`#${t} .wpcf7-stripe .card-element`),o.clear(),d.classList.remove("hidden"),c.classList.add("hidden"),a.classList.remove("hidden"),a.disabled=!0,o.addEventListener("change",(e=>{if(f(),e.error){const t={message:e.error.message};u(t),p(t),a.disabled=!0}else a.disabled=!1})),a.addEventListener("click",(e=>{f(),a.disabled=!0,n.classList.add("submitting"),wpcf7.blocked||r.confirmCardPayment(s.client_secret,{payment_method:{card:o}}).then((e=>{if(e.error){e.error.decline_code&&["fraudulent","lost_card","merchant_blacklist","pickup_card","restricted_card","security_violation","service_not_allowed","stolen_card","transaction_not_allowed"].includes(e.error.decline_code)&&(wpcf7.blocked=!0),n.classList.remove("submitting");const t={message:e.error.message};u(t),p(t)}else"succeeded"===e.paymentIntent.status&&wpcf7.submit(n)}))}))}else d.classList.add("hidden"),c.classList.remove("hidden"),a.classList.add("hidden"),["mail_sent","mail_failed"].includes(e.detail.status)&&(c.disabled=!0)}))}));modules/stripe/service.php000064400000013740150515101440011674 0ustar00api_keys = array( 'publishable' => $option['api_keys']['publishable'], 'secret' => $option['api_keys']['secret'], ); } } public function get_title() { return __( 'Stripe', 'contact-form-7' ); } public function is_active() { return (bool) $this->get_api_keys(); } public function api() { if ( $this->is_active() ) { $api = new WPCF7_Stripe_API( $this->api_keys['secret'] ); return $api; } } public function get_api_keys() { return $this->api_keys; } public function get_categories() { return array( 'payments' ); } public function icon() { } public function link() { echo wpcf7_link( 'https://stripe.com/', 'stripe.com' ); } protected function menu_page_url( $args = '' ) { $args = wp_parse_args( $args, array() ); $url = menu_page_url( 'wpcf7-integration', false ); $url = add_query_arg( array( 'service' => 'stripe' ), $url ); if ( ! empty( $args ) ) { $url = add_query_arg( $args, $url ); } return $url; } protected function save_data() { WPCF7::update_option( 'stripe', array( 'api_keys' => $this->api_keys, ) ); } protected function reset_data() { $this->api_keys = null; $this->save_data(); } public function load( $action = '' ) { if ( 'setup' == $action and 'POST' == $_SERVER['REQUEST_METHOD'] ) { check_admin_referer( 'wpcf7-stripe-setup' ); if ( ! empty( $_POST['reset'] ) ) { $this->reset_data(); $redirect_to = $this->menu_page_url( 'action=setup' ); } else { $publishable = isset( $_POST['publishable'] ) ? trim( $_POST['publishable'] ) : ''; $secret = isset( $_POST['secret'] ) ? trim( $_POST['secret'] ) : ''; if ( $publishable and $secret ) { $this->api_keys = array( 'publishable' => $publishable, 'secret' => $secret, ); $this->save_data(); $redirect_to = $this->menu_page_url( array( 'message' => 'success', ) ); } else { $redirect_to = $this->menu_page_url( array( 'action' => 'setup', 'message' => 'invalid', ) ); } } wp_safe_redirect( $redirect_to ); exit(); } } public function admin_notice( $message = '' ) { if ( 'invalid' == $message ) { echo sprintf( '

    %1$s: %2$s

    ', esc_html( __( "Error", 'contact-form-7' ) ), esc_html( __( "Invalid key values.", 'contact-form-7' ) ) ); } if ( 'success' == $message ) { echo sprintf( '

    %s

    ', esc_html( __( 'Settings saved.', 'contact-form-7' ) ) ); } } public function display( $action = '' ) { echo sprintf( '

    %s

    ', // https://stripe.com/docs/partners/support#intro esc_html( __( "Stripe is a simple and powerful way to accept payments online. Stripe has no setup fees, no monthly fees, and no hidden costs. Millions of businesses rely on Stripe’s software tools to accept payments securely and expand globally.", 'contact-form-7' ) ) ); echo sprintf( '

    %s

    ', wpcf7_link( __( 'https://contactform7.com/stripe-integration/', 'contact-form-7' ), __( 'Stripe integration', 'contact-form-7' ) ) ); if ( $this->is_active() ) { echo sprintf( '

    %s

    ', esc_html( __( "Stripe is active on this site.", 'contact-form-7' ) ) ); } if ( 'setup' == $action ) { $this->display_setup(); } elseif ( is_ssl() or WP_DEBUG ) { echo sprintf( '

    %2$s

    ', esc_url( $this->menu_page_url( 'action=setup' ) ), esc_html( __( 'Setup Integration', 'contact-form-7' ) ) ); } else { echo sprintf( '

    %s

    ', esc_html( __( "Stripe is not available on this site. It requires an HTTPS-enabled site.", 'contact-form-7' ) ) ); } } private function display_setup() { $api_keys = $this->get_api_keys(); if ( $api_keys ) { $publishable = $api_keys['publishable']; $secret = $api_keys['secret']; } else { $publishable = ''; $secret = ''; } ?>
    is_active() ) { echo esc_html( $publishable ); echo sprintf( '', esc_attr( $publishable ) ); } else { echo sprintf( '', esc_attr( $publishable ) ); } ?>
    is_active() ) { echo esc_html( wpcf7_mask_password( $secret ) ); echo sprintf( '', esc_attr( $secret ) ); } else { echo sprintf( '', esc_attr( $secret ) ); } ?>
    is_active() ) { submit_button( _x( 'Remove Keys', 'API keys', 'contact-form-7' ), 'small', 'reset' ); } else { submit_button( __( 'Save Changes', 'contact-form-7' ) ); } ?>
    add_service( 'stripe', WPCF7_Stripe::get_instance() ); } add_action( 'wpcf7_enqueue_scripts', 'wpcf7_stripe_enqueue_scripts', 10, 0 ); /** * Enqueues scripts and styles for the Stripe module. */ function wpcf7_stripe_enqueue_scripts() { $service = WPCF7_Stripe::get_instance(); if ( ! $service->is_active() ) { return; } wp_enqueue_style( 'wpcf7-stripe', wpcf7_plugin_url( 'modules/stripe/style.css' ), array(), WPCF7_VERSION, 'all' ); wp_register_script( 'stripe', 'https://js.stripe.com/v3/', array(), null ); $assets = array(); $asset_file = wpcf7_plugin_path( 'modules/stripe/index.asset.php' ); if ( file_exists( $asset_file ) ) { $assets = include( $asset_file ); } $assets = wp_parse_args( $assets, array( 'dependencies' => array(), 'version' => WPCF7_VERSION, ) ); wp_enqueue_script( 'wpcf7-stripe', wpcf7_plugin_url( 'modules/stripe/index.js' ), array_merge( $assets['dependencies'], array( 'wp-polyfill', 'contact-form-7', 'stripe', ) ), $assets['version'], true ); $api_keys = $service->get_api_keys(); if ( $api_keys['publishable'] ) { wp_localize_script( 'wpcf7-stripe', 'wpcf7_stripe', array( 'publishable_key' => $api_keys['publishable'], ) ); } } add_filter( 'wpcf7_skip_spam_check', 'wpcf7_stripe_skip_spam_check', 10, 2 ); /** * Skips the spam check if it is not necessary. * * @return bool True if the spam check is not necessary. */ function wpcf7_stripe_skip_spam_check( $skip_spam_check, $submission ) { $service = WPCF7_Stripe::get_instance(); if ( ! $service->is_active() ) { return $skip_spam_check; } if ( ! empty( $_POST['_wpcf7_stripe_payment_intent'] ) ) { $pi_id = trim( $_POST['_wpcf7_stripe_payment_intent'] ); $payment_intent = $service->api()->retrieve_payment_intent( $pi_id ); if ( isset( $payment_intent['status'] ) and ( 'succeeded' === $payment_intent['status'] ) ) { $submission->push( 'payment_intent', $pi_id ); } } if ( ! empty( $submission->pull( 'payment_intent' ) ) and $submission->verify_posted_data_hash() ) { $skip_spam_check = true; } return $skip_spam_check; } add_action( 'wpcf7_before_send_mail', 'wpcf7_stripe_before_send_mail', 10, 3 ); /** * Creates Stripe's Payment Intent. */ function wpcf7_stripe_before_send_mail( $contact_form, &$abort, $submission ) { $service = WPCF7_Stripe::get_instance(); if ( ! $service->is_active() ) { return; } $tags = $contact_form->scan_form_tags( array( 'type' => 'stripe' ) ); if ( ! $tags ) { return; } if ( ! empty( $submission->pull( 'payment_intent' ) ) ) { return; } $tag = $tags[0]; $amount = $tag->get_option( 'amount', 'int', true ); $currency = $tag->get_option( 'currency', '[a-zA-Z]{3}', true ); $payment_intent_params = apply_filters( 'wpcf7_stripe_payment_intent_parameters', array( 'amount' => $amount ? absint( $amount ) : null, 'currency' => $currency ? strtolower( $currency ) : null, 'receipt_email' => $submission->get_posted_data( 'your-email' ), ) ); $payment_intent = $service->api()->create_payment_intent( $payment_intent_params ); if ( $payment_intent ) { $submission->add_result_props( array( 'stripe' => array( 'payment_intent' => array( 'id' => $payment_intent['id'], 'client_secret' => $payment_intent['client_secret'], ), ), ) ); $submission->set_status( 'payment_required' ); $submission->set_response( __( "Payment is required. Please pay by credit card.", 'contact-form-7' ) ); } $abort = true; } /** * Returns payment link URL. * * @param string $pi_id Payment Intent ID. * @return string The URL. */ function wpcf7_stripe_get_payment_link( $pi_id ) { return sprintf( 'https://dashboard.stripe.com/payments/%s', urlencode( $pi_id ) ); } add_filter( 'wpcf7_special_mail_tags', 'wpcf7_stripe_smt', 10, 4 ); /** * Registers the [_stripe_payment_link] special mail-tag. */ function wpcf7_stripe_smt( $output, $tag_name, $html, $mail_tag = null ) { if ( '_stripe_payment_link' === $tag_name ) { $submission = WPCF7_Submission::get_instance(); $pi_id = $submission->pull( 'payment_intent' ); if ( ! empty( $pi_id ) ) { $output = wpcf7_stripe_get_payment_link( $pi_id ); } } return $output; } add_filter( 'wpcf7_flamingo_inbound_message_parameters', 'wpcf7_stripe_add_flamingo_inbound_message_params', 10, 1 ); /** * Adds Stripe-related meta data to Flamingo Inbound Message parameters. */ function wpcf7_stripe_add_flamingo_inbound_message_params( $args ) { $submission = WPCF7_Submission::get_instance(); $pi_id = $submission->pull( 'payment_intent' ); if ( empty( $pi_id ) ) { return $args; } $pi_link = wpcf7_stripe_get_payment_link( $pi_id ); $meta = (array) $args['meta']; $meta['stripe_payment_link'] = $pi_link; $args['meta'] = $meta; return $args; } add_action( 'wpcf7_init', 'wpcf7_add_form_tag_stripe', 10, 0 ); /** * Registers the stripe form-tag handler. */ function wpcf7_add_form_tag_stripe() { wpcf7_add_form_tag( 'stripe', 'wpcf7_stripe_form_tag_handler', array( 'display-block' => true, 'singular' => true, ) ); } /** * Defines the stripe form-tag handler. * * @return string HTML content that replaces a stripe form-tag. */ function wpcf7_stripe_form_tag_handler( $tag ) { $card_element = sprintf( '
    ', wpcf7_format_atts( array( 'class' => 'card-element wpcf7-form-control', 'aria-invalid' => 'false', ) ) ); $card_element = sprintf( '', $card_element ); $button_1_label = __( 'Proceed to checkout', 'contact-form-7' ); if ( isset( $tag->values[0] ) ) { $button_1_label = trim( $tag->values[0] ); } $button_1 = sprintf( '', wpcf7_format_atts( array( 'type' => 'submit', 'class' => 'first', ) ), esc_html( $button_1_label ) ); $button_2_label = __( 'Complete payment', 'contact-form-7' ); if ( isset( $tag->values[1] ) ) { $button_2_label = trim( $tag->values[1] ); } $button_2 = sprintf( '', wpcf7_format_atts( array( 'type' => 'button', 'class' => 'second hidden', ) ), esc_html( $button_2_label ) ); $buttons = sprintf( '%1$s %2$s', $button_1, $button_2 ); return sprintf( '
    %1$s %2$s %3$s
    ', $card_element, $buttons, '' ); } modules/stripe/api.php000064400000006664150515101440011014 0ustar00secret = $secret; } /** * Sends a debug information for a remote request to the PHP error log. * * @param string $url URL to retrieve. * @param array $request Request arguments. * @param array|WP_Error $response The response or WP_Error on failure. */ private function log( $url, $request, $response ) { wpcf7_log_remote_request( $url, $request, $response ); } /** * Returns default set of HTTP request headers used for Stripe API. * * @link https://stripe.com/docs/building-plugins#setappinfo * * @return array An associative array of headers. */ private function default_headers() { $app_info = array( 'name' => self::app_name, 'partner_id' => self::partner_id, 'url' => self::app_url, 'version' => WPCF7_VERSION, ); $ua = array( 'lang' => 'php', 'lang_version' => PHP_VERSION, 'application' => $app_info, ); $headers = array( 'Authorization' => sprintf( 'Bearer %s', $this->secret ), 'Stripe-Version' => self::api_version, 'X-Stripe-Client-User-Agent' => json_encode( $ua ), 'User-Agent' => sprintf( '%1$s/%2$s (%3$s)', self::app_name, WPCF7_VERSION, self::app_url ), ); return $headers; } /** * Creates a Payment Intent. * * @link https://stripe.com/docs/api/payment_intents/create * * @param string|array $args Optional. Arguments to control behavior. * @return array|bool An associative array if 200 OK, false otherwise. */ public function create_payment_intent( $args = '' ) { $args = wp_parse_args( $args, array( 'amount' => 0, 'currency' => '', 'receipt_email' => '', ) ); if ( ! is_email( $args['receipt_email'] ) ) { unset( $args['receipt_email'] ); } $endpoint = 'https://api.stripe.com/v1/payment_intents'; $request = array( 'headers' => $this->default_headers(), 'body' => $args, ); $response = wp_remote_post( sanitize_url( $endpoint ), $request ); if ( 200 != wp_remote_retrieve_response_code( $response ) ) { if ( WP_DEBUG ) { $this->log( $endpoint, $request, $response ); } return false; } $response_body = wp_remote_retrieve_body( $response ); $response_body = json_decode( $response_body, true ); return $response_body; } /** * Retrieve a Payment Intent. * * @link https://stripe.com/docs/api/payment_intents/retrieve * * @param string $id Payment Intent identifier. * @return array|bool An associative array if 200 OK, false otherwise. */ public function retrieve_payment_intent( $id ) { $endpoint = sprintf( 'https://api.stripe.com/v1/payment_intents/%s', urlencode( $id ) ); $request = array( 'headers' => $this->default_headers(), ); $response = wp_remote_get( sanitize_url( $endpoint ), $request ); if ( 200 != wp_remote_retrieve_response_code( $response ) ) { if ( WP_DEBUG ) { $this->log( $endpoint, $request, $response ); } return false; } $response_body = wp_remote_retrieve_body( $response ); $response_body = json_decode( $response_body, true ); return $response_body; } } modules/stripe/style.css000064400000000473150515101440011374 0ustar00.wpcf7 .wpcf7-stripe .wpcf7-form-control-wrap { margin: .6em 0; } .wpcf7 .wpcf7-stripe .wpcf7-form-control { display: block; background: #f6f7f7; padding: 12px 12px; border: 1px solid #787c82; } .wpcf7 .wpcf7-stripe button:disabled { cursor: not-allowed; } .wpcf7 .wpcf7-stripe .hidden { display: none; } includes/validation-functions.php000064400000013547150515101440013231 0ustar00$/', $mailbox, $matches ) ) { $addr_spec = $matches[1]; } else { $addr_spec = $mailbox; } if ( ! wpcf7_is_email( $addr_spec ) ) { return false; } $addresses[] = $addr_spec; } return $addresses; } /** * Checks whether an email address belongs to a domain. * * @param string $email A mailbox or a comma-separated list of mailboxes. * @param string $domain Internet domain name. * @return bool True if all of the email addresses belong to the domain, * false if not. */ function wpcf7_is_email_in_domain( $email, $domain ) { $email_list = wpcf7_is_mailbox_list( $email ); if ( false === $email_list ) { return false; } $domain = strtolower( $domain ); foreach ( $email_list as $email ) { $email_domain = substr( $email, strrpos( $email, '@' ) + 1 ); $email_domain = strtolower( $email_domain ); $domain_parts = explode( '.', $domain ); do { $site_domain = implode( '.', $domain_parts ); if ( $site_domain == $email_domain ) { continue 2; } array_shift( $domain_parts ); } while ( $domain_parts ); return false; } return true; } /** * Checks whether an email address belongs to the site domain. */ function wpcf7_is_email_in_site_domain( $email ) { if ( wpcf7_is_localhost() ) { return true; } $homes = array( home_url(), network_home_url(), ); $homes = array_unique( $homes ); foreach ( $homes as $home ) { $sitename = wp_parse_url( $home, PHP_URL_HOST ); if ( WP_Http::is_ip_address( $sitename ) ) { return true; } if ( wpcf7_is_email_in_domain( $email, $sitename ) ) { return true; } } return false; } /** * Verifies that a given file path is under the directories that WordPress * manages for user contents. * * Returns false if the file at the given path does not exist yet. * * @param string $path A file path. * @return bool True if the path is under the content directories, * false otherwise. */ function wpcf7_is_file_path_in_content_dir( $path ) { if ( $real_path = realpath( $path ) ) { $path = $real_path; } else { return false; } if ( 0 === strpos( $path, realpath( WP_CONTENT_DIR ) ) ) { return true; } if ( defined( 'UPLOADS' ) and 0 === strpos( $path, realpath( ABSPATH . UPLOADS ) ) ) { return true; } return false; } includes/submission.php000064400000053060150515101440011256 0ustar00proceed(); return self::$instance; } else { return null; } } else { if ( empty( self::$instance ) ) { return null; } else { return self::$instance; } } } /** * Returns true if this submission is created via WP REST API. */ public static function is_restful() { return defined( 'REST_REQUEST' ) && REST_REQUEST; } /** * Constructor. */ private function __construct( WPCF7_ContactForm $contact_form, $args = '' ) { $args = wp_parse_args( $args, array( 'skip_mail' => false, ) ); $this->contact_form = $contact_form; $this->skip_mail = (bool) $args['skip_mail']; } /** * The main logic of submission. */ private function proceed() { $callback = function () { $contact_form = $this->contact_form; $this->setup_meta_data(); $this->setup_posted_data(); if ( $this->is( 'init' ) and ! $this->validate() ) { $this->set_status( 'validation_failed' ); $this->set_response( $contact_form->message( 'validation_error' ) ); } if ( $this->is( 'init' ) and ! $this->accepted() ) { $this->set_status( 'acceptance_missing' ); $this->set_response( $contact_form->message( 'accept_terms' ) ); } if ( $this->is( 'init' ) and $this->spam() ) { $this->set_status( 'spam' ); $this->set_response( $contact_form->message( 'spam' ) ); } if ( $this->is( 'init' ) and ! $this->unship_uploaded_files() ) { $this->set_status( 'validation_failed' ); $this->set_response( $contact_form->message( 'validation_error' ) ); } if ( $this->is( 'init' ) ) { $abort = ! $this->before_send_mail(); if ( $abort ) { if ( $this->is( 'init' ) ) { $this->set_status( 'aborted' ); } if ( '' === $this->get_response() ) { $this->set_response( $contact_form->filter_message( __( "Sending mail has been aborted.", 'contact-form-7' ) ) ); } } elseif ( $this->mail() ) { $this->set_status( 'mail_sent' ); $this->set_response( $contact_form->message( 'mail_sent_ok' ) ); do_action( 'wpcf7_mail_sent', $contact_form ); } else { $this->set_status( 'mail_failed' ); $this->set_response( $contact_form->message( 'mail_sent_ng' ) ); do_action( 'wpcf7_mail_failed', $contact_form ); } } $this->remove_uploaded_files(); }; wpcf7_switch_locale( $this->contact_form->locale(), $callback ); } /** * Returns the current status property. */ public function get_status() { return $this->status; } /** * Sets the status property. * * @param string $status The status. */ public function set_status( $status ) { if ( preg_match( '/^[a-z][0-9a-z_]+$/', $status ) ) { $this->status = $status; return true; } return false; } /** * Returns true if the specified status is identical to the current * status property. * * @param string $status The status to compare. */ public function is( $status ) { return $this->status === $status; } /** * Returns an associative array of submission result properties. * * @return array Submission result properties. */ public function get_result() { $result = array_merge( $this->result_props, array( 'status' => $this->get_status(), 'message' => $this->get_response(), ) ); if ( $this->is( 'validation_failed' ) ) { $result['invalid_fields'] = $this->get_invalid_fields(); } switch ( $this->get_status() ) { case 'init': case 'validation_failed': case 'acceptance_missing': case 'spam': $result['posted_data_hash'] = ''; break; default: $result['posted_data_hash'] = $this->get_posted_data_hash(); break; } $result = apply_filters( 'wpcf7_submission_result', $result, $this ); return $result; } /** * Adds items to the array of submission result properties. * * @param string|array|object $args Value to add to result properties. * @return array Added result properties. */ public function add_result_props( $args = '' ) { $args = wp_parse_args( $args, array() ); $this->result_props = array_merge( $this->result_props, $args ); return $args; } /** * Retrieves the response property. * * @return string The current response property value. */ public function get_response() { return $this->response; } /** * Sets the response property. * * @param string $response New response property value. */ public function set_response( $response ) { $this->response = $response; return true; } /** * Retrieves the contact form property. * * @return WPCF7_ContactForm A contact form object. */ public function get_contact_form() { return $this->contact_form; } /** * Search an invalid field by field name. * * @param string $name The field name. * @return array|bool An associative array of validation error * or false when no invalid field. */ public function get_invalid_field( $name ) { if ( isset( $this->invalid_fields[$name] ) ) { return $this->invalid_fields[$name]; } else { return false; } } /** * Retrieves all invalid fields. * * @return array Invalid fields. */ public function get_invalid_fields() { return $this->invalid_fields; } /** * Retrieves meta information. * * @param string $name Name of the meta information. * @return string|null The meta information of the given name if it exists, * null otherwise. */ public function get_meta( $name ) { if ( isset( $this->meta[$name] ) ) { return $this->meta[$name]; } } /** * Collects meta information about this submission. */ private function setup_meta_data() { $timestamp = time(); $remote_ip = $this->get_remote_ip_addr(); $remote_port = isset( $_SERVER['REMOTE_PORT'] ) ? (int) $_SERVER['REMOTE_PORT'] : ''; $user_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? substr( $_SERVER['HTTP_USER_AGENT'], 0, 254 ) : ''; $url = $this->get_request_url(); $unit_tag = isset( $_POST['_wpcf7_unit_tag'] ) ? wpcf7_sanitize_unit_tag( $_POST['_wpcf7_unit_tag'] ) : ''; $container_post_id = isset( $_POST['_wpcf7_container_post'] ) ? (int) $_POST['_wpcf7_container_post'] : 0; $current_user_id = get_current_user_id(); $do_not_store = $this->contact_form->is_true( 'do_not_store' ); $this->meta = array( 'timestamp' => $timestamp, 'remote_ip' => $remote_ip, 'remote_port' => $remote_port, 'user_agent' => $user_agent, 'url' => $url, 'unit_tag' => $unit_tag, 'container_post_id' => $container_post_id, 'current_user_id' => $current_user_id, 'do_not_store' => $do_not_store, ); return $this->meta; } /** * Retrieves user input data through this submission. * * @param string $name Optional field name. * @return string|array|null The user input of the field, or array of all * fields values if no field name specified. */ public function get_posted_data( $name = '' ) { if ( ! empty( $name ) ) { if ( isset( $this->posted_data[$name] ) ) { return $this->posted_data[$name]; } else { return null; } } return $this->posted_data; } /** * Retrieves a user input string value through the specified field. * * @param string $name Field name. * @return string The user input. If the input is an array, * the first item in the array. */ public function get_posted_string( $name ) { $data = $this->get_posted_data( $name ); $data = wpcf7_array_flatten( $data ); if ( empty( $data ) ) { return ''; } // Returns the first array item. return trim( reset( $data ) ); } /** * Constructs posted data property based on user input values. */ private function setup_posted_data() { $posted_data = array_filter( (array) $_POST, static function ( $key ) { return '_' !== substr( $key, 0, 1 ); }, ARRAY_FILTER_USE_KEY ); $posted_data = wp_unslash( $posted_data ); $posted_data = $this->sanitize_posted_data( $posted_data ); $tags = $this->contact_form->scan_form_tags(); foreach ( (array) $tags as $tag ) { if ( empty( $tag->name ) ) { continue; } $type = $tag->type; $name = $tag->name; $pipes = $tag->pipes; $value_orig = $value = ''; if ( isset( $posted_data[$name] ) ) { $value_orig = $value = $posted_data[$name]; } if ( WPCF7_USE_PIPE and $pipes instanceof WPCF7_Pipes and ! $pipes->zero() ) { if ( is_array( $value_orig ) ) { $value = array(); foreach ( $value_orig as $v ) { $value[] = $pipes->do_pipe( $v ); } } else { $value = $pipes->do_pipe( $value_orig ); } } if ( wpcf7_form_tag_supports( $type, 'selectable-values' ) ) { $value = (array) $value; if ( $tag->has_option( 'free_text' ) and isset( $posted_data[$name . '_free_text'] ) ) { $last_val = array_pop( $value ); list( $tied_item ) = array_slice( WPCF7_USE_PIPE ? $tag->pipes->collect_afters() : $tag->values, -1, 1 ); list( $last_val, $tied_item ) = array_map( static function ( $item ) { return wpcf7_canonicalize( $item, array( 'strto' => 'as-is', ) ); }, array( $last_val, $tied_item ) ); if ( $last_val === $tied_item ) { $value[] = sprintf( '%s %s', $last_val, $posted_data[$name . '_free_text'] ); } else { $value[] = $last_val; } unset( $posted_data[$name . '_free_text'] ); } } $value = apply_filters( "wpcf7_posted_data_{$type}", $value, $value_orig, $tag ); $posted_data[$name] = $value; if ( $tag->has_option( 'consent_for:storage' ) and empty( $posted_data[$name] ) ) { $this->meta['do_not_store'] = true; } } $this->posted_data = apply_filters( 'wpcf7_posted_data', $posted_data ); $this->posted_data_hash = $this->create_posted_data_hash(); return $this->posted_data; } /** * Sanitizes user input data. */ private function sanitize_posted_data( $value ) { if ( is_array( $value ) ) { $value = array_map( array( $this, 'sanitize_posted_data' ), $value ); } elseif ( is_string( $value ) ) { $value = wp_check_invalid_utf8( $value ); $value = wp_kses_no_null( $value ); } return $value; } /** * Returns the time-dependent variable for hash creation. * * @return float Float value rounded up to the next highest integer. */ private function posted_data_hash_tick() { return ceil( time() / ( HOUR_IN_SECONDS / 2 ) ); } /** * Creates a hash string based on posted data, the remote IP address, * contact form location, and window of time. * * @param string $tick Optional. If not specified, result of * posted_data_hash_tick() will be used. * @return string The hash. */ private function create_posted_data_hash( $tick = '' ) { if ( '' === $tick ) { $tick = $this->posted_data_hash_tick(); } $hash = wp_hash( wpcf7_flat_join( array_merge( array( $tick, $this->get_meta( 'remote_ip' ), $this->get_meta( 'unit_tag' ), ), $this->posted_data ) ), 'wpcf7_submission' ); return $hash; } /** * Returns the hash string created for this submission. * * @return string The current hash for the submission. */ public function get_posted_data_hash() { return $this->posted_data_hash; } /** * Verifies that the given string is equivalent to the posted data hash. * * @param string $hash Optional. This value will be compared to the * current posted data hash for the submission. If not * specified, the value of $_POST['_wpcf7_posted_data_hash'] * will be used. * @return int|bool 1 if $hash is created 0-30 minutes ago, * 2 if $hash is created 30-60 minutes ago, * false if $hash is invalid. */ public function verify_posted_data_hash( $hash = '' ) { if ( '' === $hash and ! empty( $_POST['_wpcf7_posted_data_hash'] ) ) { $hash = trim( $_POST['_wpcf7_posted_data_hash'] ); } if ( '' === $hash ) { return false; } $tick = $this->posted_data_hash_tick(); // Hash created 0-30 minutes ago. $expected_1 = $this->create_posted_data_hash( $tick ); if ( hash_equals( $expected_1, $hash ) ) { return 1; } // Hash created 30-60 minutes ago. $expected_2 = $this->create_posted_data_hash( $tick - 1 ); if ( hash_equals( $expected_2, $hash ) ) { return 2; } return false; } /** * Retrieves the remote IP address of this submission. */ private function get_remote_ip_addr() { $ip_addr = ''; if ( isset( $_SERVER['REMOTE_ADDR'] ) and WP_Http::is_ip_address( $_SERVER['REMOTE_ADDR'] ) ) { $ip_addr = $_SERVER['REMOTE_ADDR']; } return apply_filters( 'wpcf7_remote_ip_addr', $ip_addr ); } /** * Retrieves the request URL of this submission. */ private function get_request_url() { $home_url = untrailingslashit( home_url() ); if ( self::is_restful() ) { $referer = isset( $_SERVER['HTTP_REFERER'] ) ? trim( $_SERVER['HTTP_REFERER'] ) : ''; if ( $referer and 0 === strpos( $referer, $home_url ) ) { return sanitize_url( $referer ); } } $url = preg_replace( '%(?invalid_fields ) { return false; } $result = new WPCF7_Validation(); $this->contact_form->validate_schema( array( 'text' => true, 'file' => false, 'field' => array(), ), $result ); $tags = $this->contact_form->scan_form_tags( array( 'feature' => '! file-uploading', ) ); foreach ( $tags as $tag ) { $type = $tag->type; $result = apply_filters( "wpcf7_validate_{$type}", $result, $tag ); } $result = apply_filters( 'wpcf7_validate', $result, $tags ); $this->invalid_fields = $result->get_invalid_fields(); return $result->is_valid(); } /** * Returns true if user consent is obtained. */ private function accepted() { return apply_filters( 'wpcf7_acceptance', true, $this ); } /** * Adds user consent data to this submission. * * @param string $name Field name. * @param string $conditions Conditions of consent. */ public function add_consent( $name, $conditions ) { $this->consent[$name] = $conditions; return true; } /** * Collects user consent data. * * @return array User consent data. */ public function collect_consent() { return (array) $this->consent; } /** * Executes spam protections. * * @return bool True if spam captured. */ private function spam() { $spam = false; $skip_spam_check = apply_filters( 'wpcf7_skip_spam_check', $this->skip_spam_check, $this ); if ( $skip_spam_check ) { return $spam; } if ( $this->contact_form->is_true( 'subscribers_only' ) and current_user_can( 'wpcf7_submit', $this->contact_form->id() ) ) { return $spam; } $user_agent = (string) $this->get_meta( 'user_agent' ); if ( strlen( $user_agent ) < 2 ) { $spam = true; $this->add_spam_log( array( 'agent' => 'wpcf7', 'reason' => __( "User-Agent string is unnaturally short.", 'contact-form-7' ), ) ); } if ( ! $this->verify_nonce() ) { $spam = true; $this->add_spam_log( array( 'agent' => 'wpcf7', 'reason' => __( "Submitted nonce is invalid.", 'contact-form-7' ), ) ); } return apply_filters( 'wpcf7_spam', $spam, $this ); } /** * Adds a spam log. * * @link https://contactform7.com/2019/05/31/why-is-this-message-marked-spam/ */ public function add_spam_log( $args = '' ) { $args = wp_parse_args( $args, array( 'agent' => '', 'reason' => '', ) ); $this->spam_log[] = $args; } /** * Retrieves the spam logging data. * * @return array Spam logging data. */ public function get_spam_log() { return $this->spam_log; } /** * Verifies that a correct security nonce was used. */ private function verify_nonce() { if ( ! $this->contact_form->nonce_is_active() or ! is_user_logged_in() ) { return true; } $nonce = isset( $_POST['_wpnonce'] ) ? $_POST['_wpnonce'] : ''; return wpcf7_verify_nonce( $nonce ); } /** * Function called just before sending email. */ private function before_send_mail() { $abort = false; do_action_ref_array( 'wpcf7_before_send_mail', array( $this->contact_form, &$abort, $this, ) ); return ! $abort; } /** * Sends emails based on user input values and contact form email templates. */ private function mail() { $contact_form = $this->contact_form; $skip_mail = apply_filters( 'wpcf7_skip_mail', $this->skip_mail, $contact_form ); if ( $skip_mail ) { return true; } $result = WPCF7_Mail::send( $contact_form->prop( 'mail' ), 'mail' ); if ( $result ) { $additional_mail = array(); if ( $mail_2 = $contact_form->prop( 'mail_2' ) and $mail_2['active'] ) { $additional_mail['mail_2'] = $mail_2; } $additional_mail = apply_filters( 'wpcf7_additional_mail', $additional_mail, $contact_form ); foreach ( $additional_mail as $name => $template ) { WPCF7_Mail::send( $template, $name ); } return true; } return false; } /** * Retrieves files uploaded through this submission. */ public function uploaded_files() { return $this->uploaded_files; } /** * Adds a file to the uploaded files array. * * @param string $name Field name. * @param string|array $file_path File path or array of file paths. */ private function add_uploaded_file( $name, $file_path ) { if ( ! wpcf7_is_name( $name ) ) { return false; } $paths = (array) $file_path; $uploaded_files = array(); $hash_strings = array(); foreach ( $paths as $path ) { if ( @is_file( $path ) and @is_readable( $path ) ) { $uploaded_files[] = $path; $hash_strings[] = md5_file( $path ); } } $this->uploaded_files[$name] = $uploaded_files; if ( empty( $this->posted_data[$name] ) ) { $this->posted_data[$name] = implode( ' ', $hash_strings ); } } /** * Removes uploaded files. */ private function remove_uploaded_files() { foreach ( (array) $this->uploaded_files as $file_path ) { $paths = (array) $file_path; foreach ( $paths as $path ) { wpcf7_rmdir_p( $path ); if ( $dir = dirname( $path ) and false !== ( $files = scandir( $dir ) ) and ! array_diff( $files, array( '.', '..' ) ) ) { // remove parent dir if it's empty. rmdir( $dir ); } } } } /** * Moves uploaded files to the tmp directory and validates them. * * @return bool True if no invalid file is found. */ private function unship_uploaded_files() { $result = new WPCF7_Validation(); $tags = $this->contact_form->scan_form_tags( array( 'feature' => 'file-uploading', ) ); foreach ( $tags as $tag ) { if ( empty( $_FILES[$tag->name] ) ) { continue; } $file = $_FILES[$tag->name]; $args = array( 'tag' => $tag, 'name' => $tag->name, 'required' => $tag->is_required(), 'filetypes' => $tag->get_option( 'filetypes' ), 'limit' => $tag->get_limit_option(), 'schema' => $this->contact_form->get_schema(), ); $new_files = wpcf7_unship_uploaded_file( $file, $args ); if ( is_wp_error( $new_files ) ) { $result->invalidate( $tag, $new_files ); } else { $this->add_uploaded_file( $tag->name, $new_files ); } $result = apply_filters( "wpcf7_validate_{$tag->type}", $result, $tag, array( 'uploaded_files' => $new_files, ) ); } $this->invalid_fields = $result->get_invalid_fields(); return $result->is_valid(); } /** * Adds extra email attachment files that are independent from form fields. * * @param string|array $file_path A file path or an array of file paths. * @param string $template Optional. The name of the template to which * the files are attached. * @return bool True if it succeeds to attach a file at least, * or false otherwise. */ public function add_extra_attachments( $file_path, $template = 'mail' ) { if ( ! did_action( 'wpcf7_before_send_mail' ) ) { return false; } $extra_attachments = array(); foreach ( (array) $file_path as $path ) { $path = path_join( WP_CONTENT_DIR, $path ); if ( file_exists( $path ) ) { $extra_attachments[] = $path; } } if ( empty( $extra_attachments ) ) { return false; } if ( ! isset( $this->extra_attachments[$template] ) ) { $this->extra_attachments[$template] = array(); } $this->extra_attachments[$template] = array_merge( $this->extra_attachments[$template], $extra_attachments ); return true; } /** * Returns extra email attachment files. * * @param string $template An email template name. * @return array Array of file paths. */ public function extra_attachments( $template ) { if ( isset( $this->extra_attachments[$template] ) ) { return (array) $this->extra_attachments[$template]; } return array(); } } includes/pocket-holder.php000064400000000505150515101440011617 0ustar00pocket[$key] ) ) { return $this->pocket[$key]; } } public function push( $key, $value ) { $this->pocket[$key] = $value; } } includes/swv/swv.php000064400000013764150515101440010530 0ustar00 'WPCF7_SWV_RequiredRule', 'requiredfile' => 'WPCF7_SWV_RequiredFileRule', 'email' => 'WPCF7_SWV_EmailRule', 'url' => 'WPCF7_SWV_URLRule', 'tel' => 'WPCF7_SWV_TelRule', 'number' => 'WPCF7_SWV_NumberRule', 'date' => 'WPCF7_SWV_DateRule', 'time' => 'WPCF7_SWV_TimeRule', 'file' => 'WPCF7_SWV_FileRule', 'enum' => 'WPCF7_SWV_EnumRule', 'dayofweek' => 'WPCF7_SWV_DayofweekRule', 'minitems' => 'WPCF7_SWV_MinItemsRule', 'maxitems' => 'WPCF7_SWV_MaxItemsRule', 'minlength' => 'WPCF7_SWV_MinLengthRule', 'maxlength' => 'WPCF7_SWV_MaxLengthRule', 'minnumber' => 'WPCF7_SWV_MinNumberRule', 'maxnumber' => 'WPCF7_SWV_MaxNumberRule', 'mindate' => 'WPCF7_SWV_MinDateRule', 'maxdate' => 'WPCF7_SWV_MaxDateRule', 'minfilesize' => 'WPCF7_SWV_MinFileSizeRule', 'maxfilesize' => 'WPCF7_SWV_MaxFileSizeRule', ); return apply_filters( 'wpcf7_swv_available_rules', $rules ); } add_action( 'wpcf7_init', 'wpcf7_swv_load_rules', 10, 0 ); /** * Loads SWV fules. */ function wpcf7_swv_load_rules() { $rules = wpcf7_swv_available_rules(); foreach ( array_keys( $rules ) as $rule ) { $file = sprintf( '%s.php', $rule ); $path = path_join( WPCF7_PLUGIN_DIR . '/includes/swv/rules', $file ); if ( file_exists( $path ) ) { include_once $path; } } } /** * Creates an SWV rule object. * * @param string $rule_name Rule name. * @param string|array $properties Optional. Rule properties. * @return WPCF7_SWV_Rule|null The rule object, or null if it failed. */ function wpcf7_swv_create_rule( $rule_name, $properties = '' ) { $rules = wpcf7_swv_available_rules(); if ( isset( $rules[$rule_name] ) ) { return new $rules[$rule_name]( $properties ); } } /** * Returns an associative array of JSON Schema for Contact Form 7 SWV. */ function wpcf7_swv_get_meta_schema() { return array( '$schema' => 'https://json-schema.org/draft/2020-12/schema', 'title' => 'Contact Form 7 SWV', 'description' => 'Contact Form 7 SWV meta-schema', 'type' => 'object', 'properties' => array( 'version' => array( 'type' => 'string', ), 'locale' => array( 'type' => 'string', ), 'rules' => array( 'type' => 'array', 'items' => array( 'type' => 'object', 'properties' => array( 'rule' => array( 'type' => 'string', 'enum' => array_keys( wpcf7_swv_available_rules() ), ), 'field' => array( 'type' => 'string', 'pattern' => '^[A-Za-z][-A-Za-z0-9_:]*$', ), 'error' => array( 'type' => 'string', ), 'accept' => array( 'type' => 'array', 'items' => array( 'type' => 'string', ), ), 'threshold' => array( 'type' => 'string', ), ), 'required' => array( 'rule' ), ), ), ), ); } /** * The base class of SWV rules. */ abstract class WPCF7_SWV_Rule { protected $properties = array(); public function __construct( $properties = '' ) { $this->properties = wp_parse_args( $properties, array() ); } /** * Returns true if this rule matches the given context. * * @param array $context Context. */ public function matches( $context ) { $field = $this->get_property( 'field' ); if ( ! empty( $context['field'] ) ) { if ( $field and ! in_array( $field, (array) $context['field'], true ) ) { return false; } } return true; } /** * Validates with this rule's logic. * * @param array $context Context. */ public function validate( $context ) { return true; } /** * Converts the properties to an array. * * @return array Array of properties. */ public function to_array() { $properties = (array) $this->properties; if ( defined( 'static::rule_name' ) and static::rule_name ) { $properties = array( 'rule' => static::rule_name ) + $properties; } return $properties; } /** * Returns the property value specified by the given property name. * * @param string $name Property name. * @return mixed Property value. */ public function get_property( $name ) { if ( isset( $this->properties[$name] ) ) { return $this->properties[$name]; } } } /** * The base class of SWV composite rules. */ abstract class WPCF7_SWV_CompositeRule extends WPCF7_SWV_Rule { protected $rules = array(); /** * Adds a sub-rule to this composite rule. * * @param WPCF7_SWV_Rule $rule Sub-rule to be added. */ public function add_rule( $rule ) { if ( $rule instanceof WPCF7_SWV_Rule ) { $this->rules[] = $rule; } } /** * Returns an iterator of sub-rules. */ public function rules() { foreach ( $this->rules as $rule ) { yield $rule; } } /** * Returns true if this rule matches the given context. * * @param array $context Context. */ public function matches( $context ) { return true; } /** * Validates with this rule's logic. * * @param array $context Context. */ public function validate( $context ) { foreach ( $this->rules() as $rule ) { if ( $rule->matches( $context ) ) { $result = $rule->validate( $context ); if ( is_wp_error( $result ) ) { return $result; } } } return true; } /** * Converts the properties to an array. * * @return array Array of properties. */ public function to_array() { $rules_arrays = array_map( static function ( $rule ) { return $rule->to_array(); }, $this->rules ); return array_merge( parent::to_array(), array( 'rules' => $rules_arrays, ) ); } } /** * The schema class as a composite rule. */ class WPCF7_SWV_Schema extends WPCF7_SWV_CompositeRule { const version = 'Contact Form 7 SWV Schema 2023-07'; public function __construct( $properties = '' ) { $this->properties = wp_parse_args( $properties, array( 'version' => self::version, ) ); } } includes/swv/rules/maxnumber.php000064400000001523150515101440013027 0ustar00get_property( 'field' ); $input = isset( $_POST[$field] ) ? $_POST[$field] : ''; $input = wpcf7_array_flatten( $input ); $input = wpcf7_exclude_blank( $input ); $threshold = $this->get_property( 'threshold' ); if ( ! wpcf7_is_number( $threshold ) ) { return true; } foreach ( $input as $i ) { if ( wpcf7_is_number( $i ) and (float) $threshold < (float) $i ) { return new WP_Error( 'wpcf7_invalid_maxnumber', $this->get_property( 'error' ) ); } } return true; } } includes/swv/rules/minnumber.php000064400000001523150515101440013025 0ustar00get_property( 'field' ); $input = isset( $_POST[$field] ) ? $_POST[$field] : ''; $input = wpcf7_array_flatten( $input ); $input = wpcf7_exclude_blank( $input ); $threshold = $this->get_property( 'threshold' ); if ( ! wpcf7_is_number( $threshold ) ) { return true; } foreach ( $input as $i ) { if ( wpcf7_is_number( $i ) and (float) $i < (float) $threshold ) { return new WP_Error( 'wpcf7_invalid_minnumber', $this->get_property( 'error' ) ); } } return true; } } includes/swv/rules/maxitems.php000064400000001423150515101440012657 0ustar00get_property( 'field' ); $input = isset( $_POST[$field] ) ? $_POST[$field] : ''; $input = wpcf7_array_flatten( $input ); $input = wpcf7_exclude_blank( $input ); $threshold = $this->get_property( 'threshold' ); if ( ! wpcf7_is_number( $threshold ) ) { return true; } if ( (int) $threshold < count( $input ) ) { return new WP_Error( 'wpcf7_invalid_maxitems', $this->get_property( 'error' ) ); } return true; } } includes/swv/rules/time.php000064400000001254150515101440011770 0ustar00get_property( 'field' ); $input = isset( $_POST[$field] ) ? $_POST[$field] : ''; $input = wpcf7_array_flatten( $input ); $input = wpcf7_exclude_blank( $input ); foreach ( $input as $i ) { if ( ! wpcf7_is_time( $i ) ) { return new WP_Error( 'wpcf7_invalid_time', $this->get_property( 'error' ) ); } } return true; } } includes/swv/rules/requiredfile.php000064400000001267150515101440013516 0ustar00get_property( 'field' ); $input = isset( $_FILES[$field]['tmp_name'] ) ? $_FILES[$field]['tmp_name'] : ''; $input = wpcf7_array_flatten( $input ); $input = wpcf7_exclude_blank( $input ); if ( empty( $input ) ) { return new WP_Error( 'wpcf7_invalid_requiredfile', $this->get_property( 'error' ) ); } return true; } } includes/swv/rules/file.php000064400000002640150515101440011751 0ustar00get_property( 'field' ); $input = isset( $_FILES[$field]['name'] ) ? $_FILES[$field]['name'] : ''; $input = wpcf7_array_flatten( $input ); $input = wpcf7_exclude_blank( $input ); $acceptable_filetypes = array(); foreach ( (array) $this->get_property( 'accept' ) as $accept ) { if ( false === strpos( $accept, '/' ) ) { $acceptable_filetypes[] = strtolower( $accept ); } else { foreach ( wpcf7_convert_mime_to_ext( $accept ) as $ext ) { $acceptable_filetypes[] = sprintf( '.%s', strtolower( trim( $ext, ' .' ) ) ); } } } $acceptable_filetypes = array_unique( $acceptable_filetypes ); foreach ( $input as $i ) { $last_period_pos = strrpos( $i, '.' ); if ( false === $last_period_pos ) { // no period return new WP_Error( 'wpcf7_invalid_file', $this->get_property( 'error' ) ); } $suffix = strtolower( substr( $i, $last_period_pos ) ); if ( ! in_array( $suffix, $acceptable_filetypes, true ) ) { return new WP_Error( 'wpcf7_invalid_file', $this->get_property( 'error' ) ); } } return true; } } includes/swv/rules/email.php000064400000001260150515101440012116 0ustar00get_property( 'field' ); $input = isset( $_POST[$field] ) ? $_POST[$field] : ''; $input = wpcf7_array_flatten( $input ); $input = wpcf7_exclude_blank( $input ); foreach ( $input as $i ) { if ( ! wpcf7_is_email( $i ) ) { return new WP_Error( 'wpcf7_invalid_email', $this->get_property( 'error' ) ); } } return true; } } includes/swv/rules/maxfilesize.php000064400000001434150515101440013352 0ustar00get_property( 'field' ); $input = isset( $_FILES[$field]['size'] ) ? $_FILES[$field]['size'] : ''; $input = wpcf7_array_flatten( $input ); $input = wpcf7_exclude_blank( $input ); if ( empty( $input ) ) { return true; } $threshold = $this->get_property( 'threshold' ); if ( $threshold < array_sum( $input ) ) { return new WP_Error( 'wpcf7_invalid_maxfilesize', $this->get_property( 'error' ) ); } return true; } } includes/swv/rules/enum.php000064400000001674150515101440012004 0ustar00get_property( 'field' ); $input = isset( $_POST[$field] ) ? $_POST[$field] : ''; $input = wpcf7_array_flatten( $input ); $input = wpcf7_exclude_blank( $input ); $acceptable_values = (array) $this->get_property( 'accept' ); $acceptable_values = array_map( 'strval', $acceptable_values ); $acceptable_values = array_filter( $acceptable_values ); $acceptable_values = array_unique( $acceptable_values ); foreach ( $input as $i ) { if ( ! in_array( $i, $acceptable_values, true ) ) { return new WP_Error( 'wpcf7_invalid_enum', $this->get_property( 'error' ) ); } } return true; } } includes/swv/rules/tel.php000064400000001250150515101440011612 0ustar00get_property( 'field' ); $input = isset( $_POST[$field] ) ? $_POST[$field] : ''; $input = wpcf7_array_flatten( $input ); $input = wpcf7_exclude_blank( $input ); foreach ( $input as $i ) { if ( ! wpcf7_is_tel( $i ) ) { return new WP_Error( 'wpcf7_invalid_tel', $this->get_property( 'error' ) ); } } return true; } } includes/swv/rules/minlength.php000064400000001545150515101440013022 0ustar00get_property( 'field' ); $input = isset( $_POST[$field] ) ? $_POST[$field] : ''; $input = wpcf7_array_flatten( $input ); $input = wpcf7_exclude_blank( $input ); if ( empty( $input ) ) { return true; } $total = 0; foreach ( $input as $i ) { $total += wpcf7_count_code_units( $i ); } $threshold = (int) $this->get_property( 'threshold' ); if ( $threshold <= $total ) { return true; } else { return new WP_Error( 'wpcf7_invalid_minlength', $this->get_property( 'error' ) ); } } } includes/swv/rules/url.php000064400000001250150515101440011630 0ustar00get_property( 'field' ); $input = isset( $_POST[$field] ) ? $_POST[$field] : ''; $input = wpcf7_array_flatten( $input ); $input = wpcf7_exclude_blank( $input ); foreach ( $input as $i ) { if ( ! wpcf7_is_url( $i ) ) { return new WP_Error( 'wpcf7_invalid_url', $this->get_property( 'error' ) ); } } return true; } } includes/swv/rules/minitems.php000064400000001423150515101440012655 0ustar00get_property( 'field' ); $input = isset( $_POST[$field] ) ? $_POST[$field] : ''; $input = wpcf7_array_flatten( $input ); $input = wpcf7_exclude_blank( $input ); $threshold = $this->get_property( 'threshold' ); if ( ! wpcf7_is_number( $threshold ) ) { return true; } if ( count( $input ) < (int) $threshold ) { return new WP_Error( 'wpcf7_invalid_minitems', $this->get_property( 'error' ) ); } return true; } } includes/swv/rules/mindate.php000064400000001471150515101440012454 0ustar00get_property( 'field' ); $input = isset( $_POST[$field] ) ? $_POST[$field] : ''; $input = wpcf7_array_flatten( $input ); $input = wpcf7_exclude_blank( $input ); $threshold = $this->get_property( 'threshold' ); if ( ! wpcf7_is_date( $threshold ) ) { return true; } foreach ( $input as $i ) { if ( wpcf7_is_date( $i ) and $i < $threshold ) { return new WP_Error( 'wpcf7_invalid_mindate', $this->get_property( 'error' ) ); } } return true; } } includes/swv/rules/date.php000064400000001254150515101440011747 0ustar00get_property( 'field' ); $input = isset( $_POST[$field] ) ? $_POST[$field] : ''; $input = wpcf7_array_flatten( $input ); $input = wpcf7_exclude_blank( $input ); foreach ( $input as $i ) { if ( ! wpcf7_is_date( $i ) ) { return new WP_Error( 'wpcf7_invalid_date', $this->get_property( 'error' ) ); } } return true; } } includes/swv/rules/number.php000064400000001264150515101440012323 0ustar00get_property( 'field' ); $input = isset( $_POST[$field] ) ? $_POST[$field] : ''; $input = wpcf7_array_flatten( $input ); $input = wpcf7_exclude_blank( $input ); foreach ( $input as $i ) { if ( ! wpcf7_is_number( $i ) ) { return new WP_Error( 'wpcf7_invalid_number', $this->get_property( 'error' ) ); } } return true; } } includes/swv/rules/dayofweek.php000064400000002137150515101440013011 0ustar00get_property( 'field' ); $input = isset( $_POST[$field] ) ? $_POST[$field] : ''; $input = wpcf7_array_flatten( $input ); $input = wpcf7_exclude_blank( $input ); $acceptable_values = (array) $this->get_property( 'accept' ); $acceptable_values = array_map( 'intval', $acceptable_values ); $acceptable_values = array_filter( $acceptable_values ); $acceptable_values = array_unique( $acceptable_values ); foreach ( $input as $i ) { if ( wpcf7_is_date( $i ) ) { $datetime = date_create_immutable( $i, wp_timezone() ); $dow = (int) $datetime->format( 'N' ); if ( ! in_array( $dow, $acceptable_values, true ) ) { return new WP_Error( 'wpcf7_invalid_dayofweek', $this->get_property( 'error' ) ); } } } return true; } } includes/swv/rules/maxlength.php000064400000001545150515101440013024 0ustar00get_property( 'field' ); $input = isset( $_POST[$field] ) ? $_POST[$field] : ''; $input = wpcf7_array_flatten( $input ); $input = wpcf7_exclude_blank( $input ); if ( empty( $input ) ) { return true; } $total = 0; foreach ( $input as $i ) { $total += wpcf7_count_code_units( $i ); } $threshold = (int) $this->get_property( 'threshold' ); if ( $total <= $threshold ) { return true; } else { return new WP_Error( 'wpcf7_invalid_maxlength', $this->get_property( 'error' ) ); } } } includes/swv/rules/minfilesize.php000064400000001434150515101440013350 0ustar00get_property( 'field' ); $input = isset( $_FILES[$field]['size'] ) ? $_FILES[$field]['size'] : ''; $input = wpcf7_array_flatten( $input ); $input = wpcf7_exclude_blank( $input ); if ( empty( $input ) ) { return true; } $threshold = $this->get_property( 'threshold' ); if ( array_sum( $input ) < $threshold ) { return new WP_Error( 'wpcf7_invalid_minfilesize', $this->get_property( 'error' ) ); } return true; } } includes/swv/rules/maxdate.php000064400000001471150515101440012456 0ustar00get_property( 'field' ); $input = isset( $_POST[$field] ) ? $_POST[$field] : ''; $input = wpcf7_array_flatten( $input ); $input = wpcf7_exclude_blank( $input ); $threshold = $this->get_property( 'threshold' ); if ( ! wpcf7_is_date( $threshold ) ) { return true; } foreach ( $input as $i ) { if ( wpcf7_is_date( $i ) and $threshold < $i ) { return new WP_Error( 'wpcf7_invalid_maxdate', $this->get_property( 'error' ) ); } } return true; } } includes/swv/rules/required.php000064400000001216150515101440012650 0ustar00get_property( 'field' ); $input = isset( $_POST[$field] ) ? $_POST[$field] : ''; $input = wpcf7_array_flatten( $input ); $input = wpcf7_exclude_blank( $input ); if ( empty( $input ) ) { return new WP_Error( 'wpcf7_invalid_required', $this->get_property( 'error' ) ); } return true; } } includes/swv/script-loader.php000064400000000774150515101440012456 0ustar00 array(), 'version' => WPCF7_VERSION, ) ); wp_register_script( 'swv', wpcf7_plugin_url( 'includes/swv/js/index.js' ), $assets['dependencies'], $assets['version'], true ); }, 10, 0 ); includes/swv/schema-holder.php000064400000002340150515101440012410 0ustar00schema ) ) { return $this->schema; } $schema = new WPCF7_SWV_Schema( array( 'locale' => isset( $this->locale ) ? $this->locale : '', ) ); do_action( 'wpcf7_swv_create_schema', $schema, $this ); return $this->schema = $schema; } /** * Validates form inputs based on the schema and given context. */ public function validate_schema( $context, WPCF7_Validation $validity ) { $callback = static function ( $rule ) use ( &$callback, $context, $validity ) { if ( ! $rule->matches( $context ) ) { return; } if ( $rule instanceof WPCF7_SWV_CompositeRule ) { foreach ( $rule->rules() as $child_rule ) { call_user_func( $callback, $child_rule ); } } else { $field = $rule->get_property( 'field' ); if ( $validity->is_valid( $field ) ) { $result = $rule->validate( $context ); if ( is_wp_error( $result ) ) { $validity->invalidate( $field, $result ); } } } }; call_user_func( $callback, $this->get_schema() ); } } includes/swv/js/index.asset.php000064400000000121150515101440012531 0ustar00 array(), 'version' => WPCF7_VERSION, ); includes/swv/js/index.js000064400000025022150515101440011247 0ustar00(()=>{"use strict";var t={d:(e,s)=>{for(var i in s)t.o(s,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:s[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};function s(t){if(this.formData={},this.tree={},!(t instanceof FormData))return this;this.formData=t;const e=()=>{const t=new Map;return t.largestIndex=0,t.set=function(e,s){""===e?e=t.largestIndex++:/^[0-9]+$/.test(e)&&(e=parseInt(e),t.largestIndex<=e&&(t.largestIndex=e+1)),Map.prototype.set.call(t,e,s)},t};this.tree=e();const s=/^(?[a-z][-a-z0-9_:]*)(?(?:\[(?:[a-z][-a-z0-9_:]*|[0-9]*)\])*)/i;for(const[t,i]of this.formData){const n=t.match(s);if(n)if(""===n.groups.array)this.tree.set(n.groups.name,i);else{const t=[...n.groups.array.matchAll(/\[([a-z][-a-z0-9_:]*|[0-9]*)\]/gi)].map((([t,e])=>e));t.unshift(n.groups.name);const s=t.pop();t.reduce(((t,s)=>{if(/^[0-9]+$/.test(s)&&(s=parseInt(s)),t.get(s)instanceof Map)return t.get(s);const i=e();return t.set(s,i),i}),this.tree).set(s,i)}}}t.r(e),t.d(e,{date:()=>d,dayofweek:()=>u,email:()=>r,enum:()=>h,file:()=>f,maxdate:()=>z,maxfilesize:()=>I,maxitems:()=>v,maxlength:()=>x,maxnumber:()=>b,mindate:()=>A,minfilesize:()=>$,minitems:()=>g,minlength:()=>w,minnumber:()=>y,number:()=>c,required:()=>o,requiredfile:()=>a,tel:()=>l,time:()=>m,url:()=>p}),s.prototype.entries=function(){return this.tree.entries()},s.prototype.get=function(t){return this.tree.get(t)},s.prototype.getAll=function(t){if(!this.has(t))return[];const e=t=>{const s=[];if(t instanceof Map)for(const[i,n]of t)s.push(...e(n));else""!==t&&s.push(t);return s};return e(this.get(t))},s.prototype.has=function(t){return this.tree.has(t)},s.prototype.keys=function(){return this.tree.keys()},s.prototype.values=function(){return this.tree.values()};const i=s;function n({rule:t,field:e,error:s,...i}){this.rule=t,this.field=e,this.error=s,this.properties=i}const o=function(t){if(0===t.getAll(this.field).length)throw new n(this)},a=function(t){if(0===t.getAll(this.field).length)throw new n(this)},r=function(t){if(!t.getAll(this.field).every((t=>{if((t=t.trim()).length<6)return!1;if(-1===t.indexOf("@",1))return!1;if(t.indexOf("@")!==t.lastIndexOf("@"))return!1;const[e,s]=t.split("@",2);if(!/^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]+$/.test(e))return!1;if(/\.{2,}/.test(s))return!1;if(/(?:^[ \t\n\r\0\x0B.]|[ \t\n\r\0\x0B.]$)/.test(s))return!1;const i=s.split(".");if(i.length<2)return!1;for(const t of i){if(/(?:^[ \t\n\r\0\x0B-]|[ \t\n\r\0\x0B-]$)/.test(t))return!1;if(!/^[a-z0-9-]+$/i.test(t))return!1}return!0})))throw new n(this)},p=function(t){const e=t.getAll(this.field);if(!e.every((t=>{if(""===(t=t.trim()))return!1;try{return(t=>-1!==["http","https","ftp","ftps","mailto","news","irc","irc6","ircs","gopher","nntp","feed","telnet","mms","rtsp","sms","svn","tel","fax","xmpp","webcal","urn"].indexOf(t))(new URL(t).protocol.replace(/:$/,""))}catch{return!1}})))throw new n(this)},l=function(t){if(!t.getAll(this.field).every((t=>(t=(t=t.trim()).replaceAll(/[()/.*#\s-]+/g,""),/^[+]?[0-9]+$/.test(t)))))throw new n(this)},c=function(t){if(!t.getAll(this.field).every((t=>(t=t.trim(),!!/^[-]?[0-9]+(?:[eE][+-]?[0-9]+)?$/.test(t)||!!/^[-]?(?:[0-9]+)?[.][0-9]+(?:[eE][+-]?[0-9]+)?$/.test(t)))))throw new n(this)},d=function(t){if(!t.getAll(this.field).every((t=>{if(t=t.trim(),!/^[0-9]{4,}-[0-9]{2}-[0-9]{2}$/.test(t))return!1;const e=new Date(t);return!Number.isNaN(e.valueOf())})))throw new n(this)},m=function(t){if(!t.getAll(this.field).every((t=>{const e=t.trim().match(/^([0-9]{2})\:([0-9]{2})(?:\:([0-9]{2}))?$/);if(!e)return!1;const s=parseInt(e[1]),i=parseInt(e[2]),n=e[3]?parseInt(e[3]):0;return 0<=s&&s<=23&&0<=i&&i<=59&&0<=n&&n<=59})))throw new n(this)},f=function(t){if(!t.getAll(this.field).every((t=>t instanceof File&&this.accept?.some((e=>/^\.[a-z0-9]+$/i.test(e)?t.name.toLowerCase().endsWith(e.toLowerCase()):(t=>{const e=[],s=t.match(/^(?[a-z]+)\/(?[*]|[a-z0-9.+-]+)$/i);if(s){const t=s.groups.toplevel.toLowerCase(),i=s.groups.sub.toLowerCase();for(const[n,o]of(()=>{const t=new Map;return t.set("jpg|jpeg|jpe","image/jpeg"),t.set("gif","image/gif"),t.set("png","image/png"),t.set("bmp","image/bmp"),t.set("tiff|tif","image/tiff"),t.set("webp","image/webp"),t.set("ico","image/x-icon"),t.set("heic","image/heic"),t.set("asf|asx","video/x-ms-asf"),t.set("wmv","video/x-ms-wmv"),t.set("wmx","video/x-ms-wmx"),t.set("wm","video/x-ms-wm"),t.set("avi","video/avi"),t.set("divx","video/divx"),t.set("flv","video/x-flv"),t.set("mov|qt","video/quicktime"),t.set("mpeg|mpg|mpe","video/mpeg"),t.set("mp4|m4v","video/mp4"),t.set("ogv","video/ogg"),t.set("webm","video/webm"),t.set("mkv","video/x-matroska"),t.set("3gp|3gpp","video/3gpp"),t.set("3g2|3gp2","video/3gpp2"),t.set("txt|asc|c|cc|h|srt","text/plain"),t.set("csv","text/csv"),t.set("tsv","text/tab-separated-values"),t.set("ics","text/calendar"),t.set("rtx","text/richtext"),t.set("css","text/css"),t.set("htm|html","text/html"),t.set("vtt","text/vtt"),t.set("dfxp","application/ttaf+xml"),t.set("mp3|m4a|m4b","audio/mpeg"),t.set("aac","audio/aac"),t.set("ra|ram","audio/x-realaudio"),t.set("wav","audio/wav"),t.set("ogg|oga","audio/ogg"),t.set("flac","audio/flac"),t.set("mid|midi","audio/midi"),t.set("wma","audio/x-ms-wma"),t.set("wax","audio/x-ms-wax"),t.set("mka","audio/x-matroska"),t.set("rtf","application/rtf"),t.set("js","application/javascript"),t.set("pdf","application/pdf"),t.set("swf","application/x-shockwave-flash"),t.set("class","application/java"),t.set("tar","application/x-tar"),t.set("zip","application/zip"),t.set("gz|gzip","application/x-gzip"),t.set("rar","application/rar"),t.set("7z","application/x-7z-compressed"),t.set("exe","application/x-msdownload"),t.set("psd","application/octet-stream"),t.set("xcf","application/octet-stream"),t.set("doc","application/msword"),t.set("pot|pps|ppt","application/vnd.ms-powerpoint"),t.set("wri","application/vnd.ms-write"),t.set("xla|xls|xlt|xlw","application/vnd.ms-excel"),t.set("mdb","application/vnd.ms-access"),t.set("mpp","application/vnd.ms-project"),t.set("docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"),t.set("docm","application/vnd.ms-word.document.macroEnabled.12"),t.set("dotx","application/vnd.openxmlformats-officedocument.wordprocessingml.template"),t.set("dotm","application/vnd.ms-word.template.macroEnabled.12"),t.set("xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"),t.set("xlsm","application/vnd.ms-excel.sheet.macroEnabled.12"),t.set("xlsb","application/vnd.ms-excel.sheet.binary.macroEnabled.12"),t.set("xltx","application/vnd.openxmlformats-officedocument.spreadsheetml.template"),t.set("xltm","application/vnd.ms-excel.template.macroEnabled.12"),t.set("xlam","application/vnd.ms-excel.addin.macroEnabled.12"),t.set("pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"),t.set("pptm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"),t.set("ppsx","application/vnd.openxmlformats-officedocument.presentationml.slideshow"),t.set("ppsm","application/vnd.ms-powerpoint.slideshow.macroEnabled.12"),t.set("potx","application/vnd.openxmlformats-officedocument.presentationml.template"),t.set("potm","application/vnd.ms-powerpoint.template.macroEnabled.12"),t.set("ppam","application/vnd.ms-powerpoint.addin.macroEnabled.12"),t.set("sldx","application/vnd.openxmlformats-officedocument.presentationml.slide"),t.set("sldm","application/vnd.ms-powerpoint.slide.macroEnabled.12"),t.set("onetoc|onetoc2|onetmp|onepkg","application/onenote"),t.set("oxps","application/oxps"),t.set("xps","application/vnd.ms-xpsdocument"),t.set("odt","application/vnd.oasis.opendocument.text"),t.set("odp","application/vnd.oasis.opendocument.presentation"),t.set("ods","application/vnd.oasis.opendocument.spreadsheet"),t.set("odg","application/vnd.oasis.opendocument.graphics"),t.set("odc","application/vnd.oasis.opendocument.chart"),t.set("odb","application/vnd.oasis.opendocument.database"),t.set("odf","application/vnd.oasis.opendocument.formula"),t.set("wp|wpd","application/wordperfect"),t.set("key","application/vnd.apple.keynote"),t.set("numbers","application/vnd.apple.numbers"),t.set("pages","application/vnd.apple.pages"),t})())("*"===i&&o.startsWith(t+"/")||o===s[0])&&e.push(...n.split("|"))}return e})(e).some((e=>(e="."+e.trim(),t.name.toLowerCase().endsWith(e.toLowerCase())))))))))throw new n(this)},h=function(t){if(!t.getAll(this.field).every((t=>this.accept?.some((e=>t===String(e))))))throw new n(this)},u=function(t){if(!t.getAll(this.field).every((t=>{const e=0===(s=new Date(t).getDay())?7:s;var s;return this.accept?.some((t=>e===parseInt(t)))})))throw new n(this)},g=function(t){if(t.getAll(this.field).length{"string"==typeof t&&(s+=t.length)})),0!==s&&s{"string"==typeof t&&(s+=t.length)})),parseInt(this.threshold)!(parseFloat(t)!(parseFloat(this.threshold)(t=t.trim(),!(/^[0-9]{4,}-[0-9]{2}-[0-9]{2}$/.test(t)&&/^[0-9]{4,}-[0-9]{2}-[0-9]{2}$/.test(this.threshold)&&t(t=t.trim(),!(/^[0-9]{4,}-[0-9]{2}-[0-9]{2}$/.test(t)&&/^[0-9]{4,}-[0-9]{2}-[0-9]{2}$/.test(this.threshold)&&this.threshold{t instanceof File&&(s+=t.size)})),s{t instanceof File&&(s+=t.size)})),parseInt(this.threshold){const a=(t.rules??[]).filter((({rule:t,...s})=>"function"==typeof e[t]&&("function"!=typeof e[t].matches||e[t].matches(s,o))));if(!a.length)return new Map;const r=new i(s),p=a.reduce(((t,s)=>{const{rule:i,...o}=s;if(t.get(o.field)?.error)return t;try{e[i].call({rule:i,...o},r)}catch(e){if(e instanceof n)return t.set(o.field,e)}return t}),new Map);for(const t of r.keys())p.has(t)||p.set(t,{validInputs:r.getAll(t)});return p},...null!==(E=window.swv)&&void 0!==E?E:{}}})();includes/shortcodes.php000064400000005226150515101440011241 0ustar00get_scanned_tags(); } public function add_shortcode( $tag, $callback, $has_name = false ) { wpcf7_deprecated_function( __METHOD__, '4.6', 'WPCF7_FormTagsManager::add' ); return self::$form_tags_manager->add( $tag, $callback, $has_name ); } public function remove_shortcode( $tag ) { wpcf7_deprecated_function( __METHOD__, '4.6', 'WPCF7_FormTagsManager::remove' ); return self::$form_tags_manager->remove( $tag ); } public function normalize_shortcode( $content ) { wpcf7_deprecated_function( __METHOD__, '4.6', 'WPCF7_FormTagsManager::normalize' ); return self::$form_tags_manager->normalize( $content ); } public function do_shortcode( $content, $exec = true ) { wpcf7_deprecated_function( __METHOD__, '4.6', 'WPCF7_FormTagsManager::replace_all' ); if ( $exec ) { return self::$form_tags_manager->replace_all( $content ); } else { return self::$form_tags_manager->scan( $content ); } } public function scan_shortcode( $content ) { wpcf7_deprecated_function( __METHOD__, '4.6', 'WPCF7_FormTagsManager::scan' ); return self::$form_tags_manager->scan( $content ); } } class WPCF7_Shortcode extends WPCF7_FormTag { public function __construct( $tag ) { wpcf7_deprecated_function( 'WPCF7_Shortcode', '4.6', 'WPCF7_FormTag' ); parent::__construct( $tag ); } } includes/form-tag.php000064400000032633150515101440010602 0ustar00 $value ) { if ( property_exists( __CLASS__, $key ) ) { $this->{$key} = $value; } } } } /** * Returns true if the type has a trailing asterisk. */ public function is_required() { return str_ends_with( $this->type, '*' ); } /** * Returns true if the form-tag has a specified option. */ public function has_option( $option_name ) { $pattern = sprintf( '/^%s(:.+)?$/i', preg_quote( $option_name, '/' ) ); return (bool) preg_grep( $pattern, $this->options ); } /** * Retrieves option values with the specified option name. * * @param string $option_name Option name. * @param string $pattern Optional. A regular expression pattern or one of * the keys of preset patterns. If specified, only options * whose value part matches this pattern will be returned. * @param bool $single Optional. If true, only the first matching option * will be returned. Default false. * @return string|array|bool The option value or an array of option values. * False if there is no option matches the pattern. */ public function get_option( $option_name, $pattern = '', $single = false ) { $preset_patterns = array( 'date' => '[0-9]{4}-[0-9]{2}-[0-9]{2}', 'int' => '[0-9]+', 'signed_int' => '[-]?[0-9]+', 'num' => '(?:[0-9]+|(?:[0-9]+)?[.][0-9]+)', 'signed_num' => '[-]?(?:[0-9]+|(?:[0-9]+)?[.][0-9]+)', 'class' => '[-0-9a-zA-Z_]+', 'id' => '[-0-9a-zA-Z_]+', ); if ( isset( $preset_patterns[$pattern] ) ) { $pattern = $preset_patterns[$pattern]; } if ( '' == $pattern ) { $pattern = '.+'; } $pattern = sprintf( '/^%s:%s$/i', preg_quote( $option_name, '/' ), $pattern ); if ( $single ) { $matches = $this->get_first_match_option( $pattern ); if ( ! $matches ) { return false; } return substr( $matches[0], strlen( $option_name ) + 1 ); } else { $matches_a = $this->get_all_match_options( $pattern ); if ( ! $matches_a ) { return false; } $results = array(); foreach ( $matches_a as $matches ) { $results[] = substr( $matches[0], strlen( $option_name ) + 1 ); } return $results; } } /** * Retrieves the id option value from the form-tag. */ public function get_id_option() { static $used = array(); $option = $this->get_option( 'id', 'id', true ); if ( ! $option or str_starts_with( $option, 'wpcf7' ) or in_array( $option, $used, true ) ) { return false; } $used[] = $option; return $option; } /** * Retrieves the class option value from the form-tag. * * @param string|array $default_classes Optional. Preset classes as an array * or a whitespace-separated list. Default empty string. * @return string|bool A whitespace-separated list of classes. * False if there is no class to return. */ public function get_class_option( $default_classes = '' ) { if ( is_string( $default_classes ) ) { $default_classes = explode( ' ', $default_classes ); } $options = array_merge( (array) $default_classes, (array) $this->get_option( 'class' ) ); $options = array_map( 'sanitize_html_class', $options ); $options = array_filter( array_unique( $options ) ); if ( empty( $options ) ) { return false; } return implode( ' ', $options ); } /** * Retrieves the size option value from the form-tag. * * @param string $default_value Optional default value. * @return string The option value. */ public function get_size_option( $default_value = false ) { $option = $this->get_option( 'size', 'int', true ); if ( $option ) { return $option; } $matches_a = $this->get_all_match_options( '%^([0-9]*)/[0-9]*$%' ); foreach ( (array) $matches_a as $matches ) { if ( isset( $matches[1] ) and '' !== $matches[1] ) { return $matches[1]; } } return $default_value; } /** * Retrieves the maxlength option value from the form-tag. * * @param string $default_value Optional default value. * @return string The option value. */ public function get_maxlength_option( $default_value = false ) { $option = $this->get_option( 'maxlength', 'int', true ); if ( $option ) { return $option; } $matches_a = $this->get_all_match_options( '%^(?:[0-9]*x?[0-9]*)?/([0-9]+)$%' ); foreach ( (array) $matches_a as $matches ) { if ( isset( $matches[1] ) and '' !== $matches[1] ) { return $matches[1]; } } return $default_value; } /** * Retrieves the minlength option value from the form-tag. * * @param string $default_value Optional default value. * @return string The option value. */ public function get_minlength_option( $default_value = false ) { $option = $this->get_option( 'minlength', 'int', true ); if ( $option ) { return $option; } else { return $default_value; } } /** * Retrieves the cols option value from the form-tag. * * @param string $default_value Optional default value. * @return string The option value. */ public function get_cols_option( $default_value = false ) { $option = $this->get_option( 'cols', 'int', true ); if ( $option ) { return $option; } $matches_a = $this->get_all_match_options( '%^([0-9]*)x([0-9]*)(?:/[0-9]+)?$%' ); foreach ( (array) $matches_a as $matches ) { if ( isset( $matches[1] ) and '' !== $matches[1] ) { return $matches[1]; } } return $default_value; } /** * Retrieves the rows option value from the form-tag. * * @param string $default_value Optional default value. * @return string The option value. */ public function get_rows_option( $default_value = false ) { $option = $this->get_option( 'rows', 'int', true ); if ( $option ) { return $option; } $matches_a = $this->get_all_match_options( '%^([0-9]*)x([0-9]*)(?:/[0-9]+)?$%' ); foreach ( (array) $matches_a as $matches ) { if ( isset( $matches[2] ) and '' !== $matches[2] ) { return $matches[2]; } } return $default_value; } /** * Retrieves a date-type option value from the form-tag. * * @param string $option_name A date-type option name, such as 'min' or 'max'. * @return string|bool The option value in YYYY-MM-DD format. False if the * option does not exist or the date value is invalid. */ public function get_date_option( $option_name ) { $option_value = $this->get_option( $option_name, '', true ); if ( empty( $option_value ) ) { return false; } $date = apply_filters( 'wpcf7_form_tag_date_option', null, array( $option_name => $option_value ) ); if ( $date ) { $date_pattern = '/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/'; if ( preg_match( $date_pattern, $date, $matches ) and checkdate( $matches[2], $matches[3], $matches[1] ) ) { return $date; } } else { $datetime_obj = date_create_immutable( preg_replace( '/[_]+/', ' ', $option_value ), wp_timezone() ); if ( $datetime_obj ) { return $datetime_obj->format( 'Y-m-d' ); } } return false; } /** * Retrieves the default option value from the form-tag. * * @param string|array $default_value Optional default value. * @param string|array $args Optional options for the option value retrieval. * @return string|array The option value. If the multiple option is enabled, * an array of option values. */ public function get_default_option( $default_value = '', $args = '' ) { $args = wp_parse_args( $args, array( 'multiple' => false, 'shifted' => false, ) ); $options = (array) $this->get_option( 'default' ); $values = array(); if ( empty( $options ) ) { return $args['multiple'] ? $values : $default_value; } foreach ( $options as $opt ) { $opt = sanitize_key( $opt ); if ( 'user_' == substr( $opt, 0, 5 ) and is_user_logged_in() ) { $primary_props = array( 'user_login', 'user_email', 'user_url' ); $opt = in_array( $opt, $primary_props ) ? $opt : substr( $opt, 5 ); $user = wp_get_current_user(); $user_prop = $user->get( $opt ); if ( ! empty( $user_prop ) ) { if ( $args['multiple'] ) { $values[] = $user_prop; } else { return $user_prop; } } } elseif ( 'post_meta' === $opt and in_the_loop() ) { if ( $args['multiple'] ) { $values = array_merge( $values, get_post_meta( get_the_ID(), $this->name ) ); } else { $val = (string) get_post_meta( get_the_ID(), $this->name, true ); if ( strlen( $val ) ) { return $val; } } } elseif ( 'get' === $opt and isset( $_GET[$this->name] ) ) { $vals = (array) $_GET[$this->name]; $vals = array_map( 'wpcf7_sanitize_query_var', $vals ); if ( $args['multiple'] ) { $values = array_merge( $values, $vals ); } else { $val = isset( $vals[0] ) ? (string) $vals[0] : ''; if ( strlen( $val ) ) { return $val; } } } elseif ( 'post' === $opt and isset( $_POST[$this->name] ) ) { $vals = (array) $_POST[$this->name]; $vals = array_map( 'wpcf7_sanitize_query_var', $vals ); if ( $args['multiple'] ) { $values = array_merge( $values, $vals ); } else { $val = isset( $vals[0] ) ? (string) $vals[0] : ''; if ( strlen( $val ) ) { return $val; } } } elseif ( 'shortcode_attr' === $opt ) { if ( $contact_form = WPCF7_ContactForm::get_current() ) { $val = $contact_form->shortcode_attr( $this->name ); if ( strlen( $val ) ) { if ( $args['multiple'] ) { $values[] = $val; } else { return $val; } } } } elseif ( preg_match( '/^[0-9_]+$/', $opt ) ) { $nums = explode( '_', $opt ); foreach ( $nums as $num ) { $num = absint( $num ); $num = $args['shifted'] ? $num : $num - 1; if ( isset( $this->values[$num] ) ) { if ( $args['multiple'] ) { $values[] = $this->values[$num]; } else { return $this->values[$num]; } } } } } if ( $args['multiple'] ) { $values = array_unique( $values ); return $values; } else { return $default_value; } } /** * Retrieves the data option value from the form-tag. * * @param string|array $args Optional options for the option value retrieval. * @return mixed The option value. */ public function get_data_option( $args = '' ) { $options = (array) $this->get_option( 'data' ); return apply_filters( 'wpcf7_form_tag_data_option', null, $options, $args ); } /** * Retrieves the limit option value from the form-tag. * * @param int $default_value Optional default value. Default 1048576. * @return int The option value. */ public function get_limit_option( $default_value = MB_IN_BYTES ) { $pattern = '/^limit:([1-9][0-9]*)([kKmM]?[bB])?$/'; $matches = $this->get_first_match_option( $pattern ); if ( $matches ) { $size = (int) $matches[1]; if ( ! empty( $matches[2] ) ) { $kbmb = strtolower( $matches[2] ); if ( 'kb' === $kbmb ) { $size *= KB_IN_BYTES; } elseif ( 'mb' === $kbmb ) { $size *= MB_IN_BYTES; } } return $size; } return (int) $default_value; } /** * Retrieves the value of the first option matches the given * regular expression pattern. * * @param string $pattern Regular expression pattern. * @return array|bool Option value as an array of matched strings. * False if there is no option matches the pattern. */ public function get_first_match_option( $pattern ) { foreach( (array) $this->options as $option ) { if ( preg_match( $pattern, $option, $matches ) ) { return $matches; } } return false; } /** * Retrieves values of options that match the given * regular expression pattern. * * @param string $pattern Regular expression pattern. * @return array Array of arrays of strings that match the pattern. */ public function get_all_match_options( $pattern ) { $result = array(); foreach( (array) $this->options as $option ) { if ( preg_match( $pattern, $option, $matches ) ) { $result[] = $matches; } } return $result; } /** * Assigns a value to the specified offset. * * @link https://www.php.net/manual/en/arrayaccess.offsetset.php */ #[ReturnTypeWillChange] public function offsetSet( $offset, $value ) { if ( property_exists( __CLASS__, $offset ) ) { $this->{$offset} = $value; } } /** * Returns the value at specified offset. * * @link https://www.php.net/manual/en/arrayaccess.offsetget.php */ #[ReturnTypeWillChange] public function offsetGet( $offset ) { if ( property_exists( __CLASS__, $offset ) ) { return $this->{$offset}; } return null; } /** * Returns true if the specified offset exists. * * @link https://www.php.net/manual/en/arrayaccess.offsetexists.php */ #[ReturnTypeWillChange] public function offsetExists( $offset ) { return property_exists( __CLASS__, $offset ); } /** * Unsets an offset. * * @link https://www.php.net/manual/en/arrayaccess.offsetunset.php */ #[ReturnTypeWillChange] public function offsetUnset( $offset ) { } } includes/file.php000064400000024204150515101440010000 0ustar00 false, 'filetypes' => '', 'limit' => MB_IN_BYTES, ) ); foreach ( array( 'name', 'size', 'tmp_name', 'error' ) as $key ) { if ( ! isset( $file[$key] ) ) { $file[$key] = array(); } } $names = wpcf7_array_flatten( $file['name'] ); $sizes = wpcf7_array_flatten( $file['size'] ); $tmp_names = wpcf7_array_flatten( $file['tmp_name'] ); $errors = wpcf7_array_flatten( $file['error'] ); foreach ( $errors as $error ) { if ( ! empty( $error ) and UPLOAD_ERR_NO_FILE !== $error ) { return new WP_Error( 'wpcf7_upload_failed_php_error', wpcf7_get_message( 'upload_failed_php_error' ) ); } } if ( isset( $args['schema'] ) and isset( $args['name'] ) ) { $result = $args['schema']->validate( array( 'file' => true, 'field' => $args['name'], ) ); if ( is_wp_error( $result ) ) { return $result; } } // Move uploaded file to tmp dir $uploads_dir = wpcf7_upload_tmp_dir(); $uploads_dir = wpcf7_maybe_add_random_dir( $uploads_dir ); $uploaded_files = array(); foreach ( $names as $key => $name ) { $tmp_name = $tmp_names[$key]; if ( empty( $tmp_name ) or ! is_uploaded_file( $tmp_name ) ) { continue; } $filename = $name; $filename = wpcf7_canonicalize( $filename, array( 'strto' => 'as-is' ) ); $filename = wpcf7_antiscript_file_name( $filename ); $filename = apply_filters( 'wpcf7_upload_file_name', $filename, $name, $args ); $filename = wp_unique_filename( $uploads_dir, $filename ); $new_file = path_join( $uploads_dir, $filename ); if ( false === @move_uploaded_file( $tmp_name, $new_file ) ) { return new WP_Error( 'wpcf7_upload_failed', wpcf7_get_message( 'upload_failed' ) ); } // Make sure the uploaded file is only readable for the owner process chmod( $new_file, 0400 ); $uploaded_files[] = $new_file; } return $uploaded_files; } add_filter( 'wpcf7_messages', 'wpcf7_file_messages', 10, 1 ); /** * A wpcf7_messages filter callback that adds messages for * file-uploading fields. */ function wpcf7_file_messages( $messages ) { return array_merge( $messages, array( 'upload_failed' => array( 'description' => __( "Uploading a file fails for any reason", 'contact-form-7' ), 'default' => __( "There was an unknown error uploading the file.", 'contact-form-7' ), ), 'upload_file_type_invalid' => array( 'description' => __( "Uploaded file is not allowed for file type", 'contact-form-7' ), 'default' => __( "You are not allowed to upload files of this type.", 'contact-form-7' ), ), 'upload_file_too_large' => array( 'description' => __( "Uploaded file is too large", 'contact-form-7' ), 'default' => __( "The uploaded file is too large.", 'contact-form-7' ), ), 'upload_failed_php_error' => array( 'description' => __( "Uploading a file fails for PHP error", 'contact-form-7' ), 'default' => __( "There was an error uploading the file.", 'contact-form-7' ), ), ) ); } add_filter( 'wpcf7_form_enctype', 'wpcf7_file_form_enctype_filter', 10, 1 ); /** * A wpcf7_form_enctype filter callback that sets the enctype attribute * to multipart/form-data if the form has file-uploading fields. */ function wpcf7_file_form_enctype_filter( $enctype ) { $multipart = (bool) wpcf7_scan_form_tags( array( 'feature' => 'file-uploading', ) ); if ( $multipart ) { $enctype = 'multipart/form-data'; } return $enctype; } /** * Converts a MIME type string to an array of corresponding file extensions. * * @param string $mime MIME type. * Wildcard (*) is available for the subtype part. * @return array Corresponding file extensions. */ function wpcf7_convert_mime_to_ext( $mime ) { static $mime_types = array(); $mime_types = wp_get_mime_types(); $results = array(); if ( preg_match( '%^([a-z]+)/([*]|[a-z0-9.+-]+)$%i', $mime, $matches ) ) { foreach ( $mime_types as $key => $val ) { if ( '*' === $matches[2] and str_starts_with( $val, $matches[1] . '/' ) or $val === $matches[0] ) { $results = array_merge( $results, explode( '|', $key ) ); } } } $results = array_unique( $results ); $results = array_filter( $results ); $results = array_values( $results ); return $results; } /** * Returns a formatted list of acceptable filetypes. * * @param string|array $types Optional. Array of filetypes. * @param string $format Optional. Pre-defined format designator. * @return string Formatted list of acceptable filetypes. */ function wpcf7_acceptable_filetypes( $types = 'default', $format = 'regex' ) { if ( 'default' === $types or empty( $types ) ) { $types = array( 'audio/*', 'video/*', 'image/*', ); } else { $types = array_map( static function ( $type ) { if ( is_string( $type ) ) { return preg_split( '/[\s|,]+/', strtolower( $type ) ); } }, (array) $types ); $types = wpcf7_array_flatten( $types ); $types = array_filter( array_unique( $types ) ); } if ( 'attr' === $format or 'attribute' === $format ) { $types = array_map( static function ( $type ) { if ( false === strpos( $type, '/' ) ) { return sprintf( '.%s', trim( $type, '.' ) ); } elseif ( preg_match( '%^([a-z]+)/[*]$%i', $type, $matches ) ) { if ( in_array( $matches[1], array( 'audio', 'video', 'image' ) ) ) { return $type; } else { return ''; } } elseif ( wpcf7_convert_mime_to_ext( $type ) ) { return $type; } }, $types ); $types = array_filter( $types ); return implode( ',', $types ); } elseif ( 'regex' === $format ) { $types = array_map( static function ( $type ) { if ( false === strpos( $type, '/' ) ) { return preg_quote( trim( $type, '.' ) ); } elseif ( $type = wpcf7_convert_mime_to_ext( $type ) ) { return $type; } }, $types ); $types = wpcf7_array_flatten( $types ); $types = array_filter( array_unique( $types ) ); return implode( '|', $types ); } return ''; } add_action( 'wpcf7_init', 'wpcf7_init_uploads', 10, 0 ); /** * Initializes the temporary directory for uploaded files. */ function wpcf7_init_uploads() { $dir = wpcf7_upload_tmp_dir(); if ( is_dir( $dir ) and is_writable( $dir ) ) { $htaccess_file = path_join( $dir, '.htaccess' ); if ( file_exists( $htaccess_file ) ) { list( $first_line_comment ) = (array) file( $htaccess_file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES ); if ( '# Apache 2.4+' === $first_line_comment ) { return; } } if ( $handle = @fopen( $htaccess_file, 'w' ) ) { fwrite( $handle, "# Apache 2.4+\n" ); fwrite( $handle, "\n" ); fwrite( $handle, " Require all denied\n" ); fwrite( $handle, "\n" ); fwrite( $handle, "\n" ); fwrite( $handle, "# Apache 2.2\n" ); fwrite( $handle, "\n" ); fwrite( $handle, " Deny from all\n" ); fwrite( $handle, "\n" ); fclose( $handle ); } } } /** * Creates a child directory with a randomly generated name. * * @param string $dir The parent directory path. * @return string The child directory path if created, otherwise the parent. */ function wpcf7_maybe_add_random_dir( $dir ) { do { $rand_max = mt_getrandmax(); $rand = zeroise( mt_rand( 0, $rand_max ), strlen( $rand_max ) ); $dir_new = path_join( $dir, $rand ); } while ( file_exists( $dir_new ) ); if ( wp_mkdir_p( $dir_new ) ) { return $dir_new; } return $dir; } /** * Returns the directory path for uploaded files. * * @return string Directory path. */ function wpcf7_upload_tmp_dir() { if ( defined( 'WPCF7_UPLOADS_TMP_DIR' ) ) { $dir = path_join( WP_CONTENT_DIR, WPCF7_UPLOADS_TMP_DIR ); wp_mkdir_p( $dir ); if ( wpcf7_is_file_path_in_content_dir( $dir ) ) { return $dir; } } $dir = path_join( wpcf7_upload_dir( 'dir' ), 'wpcf7_uploads' ); wp_mkdir_p( $dir ); return $dir; } add_action( 'shutdown', 'wpcf7_cleanup_upload_files', 20, 0 ); /** * Cleans up files in the temporary directory for uploaded files. * * @param int $seconds Files older than this are removed. Default 60. * @param int $max Maximum number of files to be removed in a function call. * Default 100. */ function wpcf7_cleanup_upload_files( $seconds = 60, $max = 100 ) { $dir = trailingslashit( wpcf7_upload_tmp_dir() ); if ( ! is_dir( $dir ) or ! is_readable( $dir ) or ! wp_is_writable( $dir ) ) { return; } $seconds = absint( $seconds ); $max = absint( $max ); $count = 0; if ( $handle = opendir( $dir ) ) { while ( false !== ( $file = readdir( $handle ) ) ) { if ( '.' == $file or '..' == $file or '.htaccess' == $file ) { continue; } $mtime = @filemtime( path_join( $dir, $file ) ); if ( $mtime and time() < $mtime + $seconds ) { // less than $seconds old continue; } wpcf7_rmdir_p( path_join( $dir, $file ) ); $count += 1; if ( $max <= $count ) { break; } } closedir( $handle ); } } add_action( 'wpcf7_admin_warnings', 'wpcf7_file_display_warning_message', 10, 3 ); /** * Displays warning messages about file-uploading fields. */ function wpcf7_file_display_warning_message( $page, $action, $object ) { if ( $object instanceof WPCF7_ContactForm ) { $contact_form = $object; } else { return; } $has_tags = (bool) $contact_form->scan_form_tags( array( 'feature' => 'file-uploading', ) ); if ( ! $has_tags ) { return; } $uploads_dir = wpcf7_upload_tmp_dir(); if ( ! is_dir( $uploads_dir ) or ! wp_is_writable( $uploads_dir ) ) { $message = sprintf( /* translators: %s: the path of the temporary folder */ __( 'This contact form has file uploading fields, but the temporary folder for the files (%s) does not exist or is not writable. You can create the folder or change its permission manually.', 'contact-form-7' ), $uploads_dir ); echo sprintf( '

    %s

    ', esc_html( $message ) ); } } includes/rest-api.php000064400000031325150515101440010607 0ustar00register_routes(); }, 10, 0 ); class WPCF7_REST_Controller { const route_namespace = 'contact-form-7/v1'; public function register_routes() { register_rest_route( self::route_namespace, '/contact-forms', array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_contact_forms' ), 'permission_callback' => static function () { if ( current_user_can( 'wpcf7_read_contact_forms' ) ) { return true; } else { return new WP_Error( 'wpcf7_forbidden', __( "You are not allowed to access contact forms.", 'contact-form-7' ), array( 'status' => 403 ) ); } }, ), array( 'methods' => WP_REST_Server::CREATABLE, 'callback' => array( $this, 'create_contact_form' ), 'permission_callback' => static function () { if ( current_user_can( 'wpcf7_edit_contact_forms' ) ) { return true; } else { return new WP_Error( 'wpcf7_forbidden', __( "You are not allowed to create a contact form.", 'contact-form-7' ), array( 'status' => 403 ) ); } }, ), ) ); register_rest_route( self::route_namespace, '/contact-forms/(?P\d+)', array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_contact_form' ), 'permission_callback' => static function ( WP_REST_Request $request ) { $id = (int) $request->get_param( 'id' ); if ( current_user_can( 'wpcf7_edit_contact_form', $id ) ) { return true; } else { return new WP_Error( 'wpcf7_forbidden', __( "You are not allowed to access the requested contact form.", 'contact-form-7' ), array( 'status' => 403 ) ); } }, ), array( 'methods' => WP_REST_Server::EDITABLE, 'callback' => array( $this, 'update_contact_form' ), 'permission_callback' => static function ( WP_REST_Request $request ) { $id = (int) $request->get_param( 'id' ); if ( current_user_can( 'wpcf7_edit_contact_form', $id ) ) { return true; } else { return new WP_Error( 'wpcf7_forbidden', __( "You are not allowed to access the requested contact form.", 'contact-form-7' ), array( 'status' => 403 ) ); } }, ), array( 'methods' => WP_REST_Server::DELETABLE, 'callback' => array( $this, 'delete_contact_form' ), 'permission_callback' => static function ( WP_REST_Request $request ) { $id = (int) $request->get_param( 'id' ); if ( current_user_can( 'wpcf7_delete_contact_form', $id ) ) { return true; } else { return new WP_Error( 'wpcf7_forbidden', __( "You are not allowed to access the requested contact form.", 'contact-form-7' ), array( 'status' => 403 ) ); } }, ), ) ); register_rest_route( self::route_namespace, '/contact-forms/(?P\d+)/feedback', array( array( 'methods' => WP_REST_Server::CREATABLE, 'callback' => array( $this, 'create_feedback' ), 'permission_callback' => '__return_true', ), ) ); register_rest_route( self::route_namespace, '/contact-forms/(?P\d+)/feedback/schema', array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_schema' ), 'permission_callback' => '__return_true', ), 'schema' => 'wpcf7_swv_get_meta_schema', ) ); register_rest_route( self::route_namespace, '/contact-forms/(?P\d+)/refill', array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_refill' ), 'permission_callback' => '__return_true', ), ) ); } public function get_contact_forms( WP_REST_Request $request ) { $args = array(); $per_page = $request->get_param( 'per_page' ); if ( null !== $per_page ) { $args['posts_per_page'] = (int) $per_page; } $offset = $request->get_param( 'offset' ); if ( null !== $offset ) { $args['offset'] = (int) $offset; } $order = $request->get_param( 'order' ); if ( null !== $order ) { $args['order'] = (string) $order; } $orderby = $request->get_param( 'orderby' ); if ( null !== $orderby ) { $args['orderby'] = (string) $orderby; } $search = $request->get_param( 'search' ); if ( null !== $search ) { $args['s'] = (string) $search; } $items = WPCF7_ContactForm::find( $args ); $response = array(); foreach ( $items as $item ) { $response[] = array( 'id' => $item->id(), 'hash' => $item->hash(), 'slug' => $item->name(), 'title' => $item->title(), 'locale' => $item->locale(), ); } return rest_ensure_response( $response ); } public function create_contact_form( WP_REST_Request $request ) { $id = (int) $request->get_param( 'id' ); if ( $id ) { return new WP_Error( 'wpcf7_post_exists', __( "Cannot create existing contact form.", 'contact-form-7' ), array( 'status' => 400 ) ); } $args = $request->get_params(); $args['id'] = -1; // Create $context = $request->get_param( 'context' ); $item = wpcf7_save_contact_form( $args, $context ); if ( ! $item ) { return new WP_Error( 'wpcf7_cannot_save', __( "There was an error saving the contact form.", 'contact-form-7' ), array( 'status' => 500 ) ); } $response = array( 'id' => $item->id(), 'slug' => $item->name(), 'title' => $item->title(), 'locale' => $item->locale(), 'properties' => $this->get_properties( $item ), 'config_errors' => array(), ); if ( wpcf7_validate_configuration() ) { $config_validator = new WPCF7_ConfigValidator( $item ); $config_validator->validate(); $response['config_errors'] = $config_validator->collect_error_messages(); if ( 'save' == $context ) { $config_validator->save(); } } return rest_ensure_response( $response ); } public function get_contact_form( WP_REST_Request $request ) { $id = (int) $request->get_param( 'id' ); $item = wpcf7_contact_form( $id ); if ( ! $item ) { return new WP_Error( 'wpcf7_not_found', __( "The requested contact form was not found.", 'contact-form-7' ), array( 'status' => 404 ) ); } $response = array( 'id' => $item->id(), 'slug' => $item->name(), 'title' => $item->title(), 'locale' => $item->locale(), 'properties' => $this->get_properties( $item ), ); return rest_ensure_response( $response ); } public function update_contact_form( WP_REST_Request $request ) { $id = (int) $request->get_param( 'id' ); $item = wpcf7_contact_form( $id ); if ( ! $item ) { return new WP_Error( 'wpcf7_not_found', __( "The requested contact form was not found.", 'contact-form-7' ), array( 'status' => 404 ) ); } $args = $request->get_params(); $context = $request->get_param( 'context' ); $item = wpcf7_save_contact_form( $args, $context ); if ( ! $item ) { return new WP_Error( 'wpcf7_cannot_save', __( "There was an error saving the contact form.", 'contact-form-7' ), array( 'status' => 500 ) ); } $response = array( 'id' => $item->id(), 'slug' => $item->name(), 'title' => $item->title(), 'locale' => $item->locale(), 'properties' => $this->get_properties( $item ), 'config_errors' => array(), ); if ( wpcf7_validate_configuration() ) { $config_validator = new WPCF7_ConfigValidator( $item ); $config_validator->validate(); $response['config_errors'] = $config_validator->collect_error_messages(); if ( 'save' == $context ) { $config_validator->save(); } } return rest_ensure_response( $response ); } public function delete_contact_form( WP_REST_Request $request ) { $id = (int) $request->get_param( 'id' ); $item = wpcf7_contact_form( $id ); if ( ! $item ) { return new WP_Error( 'wpcf7_not_found', __( "The requested contact form was not found.", 'contact-form-7' ), array( 'status' => 404 ) ); } $result = $item->delete(); if ( ! $result ) { return new WP_Error( 'wpcf7_cannot_delete', __( "There was an error deleting the contact form.", 'contact-form-7' ), array( 'status' => 500 ) ); } $response = array( 'deleted' => true ); return rest_ensure_response( $response ); } public function create_feedback( WP_REST_Request $request ) { $content_type = $request->get_header( 'Content-Type' ); if ( ! str_starts_with( $content_type, 'multipart/form-data' ) ) { return new WP_Error( 'wpcf7_unsupported_media_type', __( "The request payload format is not supported.", 'contact-form-7' ), array( 'status' => 415 ) ); } $url_params = $request->get_url_params(); $item = null; if ( ! empty( $url_params['id'] ) ) { $item = wpcf7_contact_form( $url_params['id'] ); } if ( ! $item ) { return new WP_Error( 'wpcf7_not_found', __( "The requested contact form was not found.", 'contact-form-7' ), array( 'status' => 404 ) ); } $unit_tag = wpcf7_sanitize_unit_tag( $request->get_param( '_wpcf7_unit_tag' ) ); $result = $item->submit(); $response = array_merge( $result, array( 'into' => sprintf( '#%s', $unit_tag ), 'invalid_fields' => array(), ) ); if ( ! empty( $result['invalid_fields'] ) ) { $invalid_fields = array(); foreach ( (array) $result['invalid_fields'] as $name => $field ) { if ( ! wpcf7_is_name( $name ) ) { continue; } $name = strtr( $name, '.', '_' ); $invalid_fields[] = array( 'field' => $name, 'message' => $field['reason'], 'idref' => $field['idref'], 'error_id' => sprintf( '%1$s-ve-%2$s', $unit_tag, $name ), ); } $response['invalid_fields'] = $invalid_fields; } $response = wpcf7_apply_filters_deprecated( 'wpcf7_ajax_json_echo', array( $response, $result ), '5.2', 'wpcf7_feedback_response' ); $response = apply_filters( 'wpcf7_feedback_response', $response, $result ); return rest_ensure_response( $response ); } public function get_schema( WP_REST_Request $request ) { $url_params = $request->get_url_params(); $item = null; if ( ! empty( $url_params['id'] ) ) { $item = wpcf7_contact_form( $url_params['id'] ); } if ( ! $item ) { return new WP_Error( 'wpcf7_not_found', __( "The requested contact form was not found.", 'contact-form-7' ), array( 'status' => 404 ) ); } $schema = $item->get_schema(); $response = isset( $schema ) ? $schema->to_array() : array(); return rest_ensure_response( $response ); } public function get_refill( WP_REST_Request $request ) { $id = (int) $request->get_param( 'id' ); $item = wpcf7_contact_form( $id ); if ( ! $item ) { return new WP_Error( 'wpcf7_not_found', __( "The requested contact form was not found.", 'contact-form-7' ), array( 'status' => 404 ) ); } $response = wpcf7_apply_filters_deprecated( 'wpcf7_ajax_onload', array( array() ), '5.2', 'wpcf7_refill_response' ); $response = apply_filters( 'wpcf7_refill_response', array() ); return rest_ensure_response( $response ); } private function get_properties( WPCF7_ContactForm $contact_form ) { $properties = $contact_form->get_properties(); $properties['form'] = array( 'content' => (string) $properties['form'], 'fields' => array_map( static function ( WPCF7_FormTag $form_tag ) { return array( 'type' => $form_tag->type, 'basetype' => $form_tag->basetype, 'name' => $form_tag->name, 'options' => $form_tag->options, 'raw_values' => $form_tag->raw_values, 'labels' => $form_tag->labels, 'values' => $form_tag->values, 'pipes' => $form_tag->pipes instanceof WPCF7_Pipes ? $form_tag->pipes->to_array() : $form_tag->pipes, 'content' => $form_tag->content, ); }, $contact_form->scan_form_tags() ), ); $properties['additional_settings'] = array( 'content' => (string) $properties['additional_settings'], 'settings' => array_filter( array_map( static function ( $setting ) { $pattern = '/^([a-zA-Z0-9_]+)[\t ]*:(.*)$/'; if ( preg_match( $pattern, $setting, $matches ) ) { $name = trim( $matches[1] ); $value = trim( $matches[2] ); if ( in_array( $value, array( 'on', 'true' ), true ) ) { $value = true; } elseif ( in_array( $value, array( 'off', 'false' ), true ) ) { $value = false; } return array( $name, $value ); } return false; }, explode( "\n", $properties['additional_settings'] ) ) ), ); return $properties; } private function get_argument_schema() { return array( 'id' => array( 'description' => __( "Unique identifier for the contact form.", 'contact-form-7' ), 'type' => 'integer', 'required' => true, ), ); } } includes/block-editor/index.asset.php000064400000000305150515101440013660 0ustar00 array( 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-url', ), 'version' => WPCF7_VERSION, ); includes/block-editor/index.js000064400000012362150515101440012375 0ustar00(()=>{"use strict";var e={n:t=>{var l=t&&t.__esModule?()=>t.default:()=>t;return e.d(l,{a:l}),l},d:(t,l)=>{for(var a in l)e.o(l,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:l[a]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.wp.element,l=window.wp.i18n,a=window.wp.blocks,r=window.wp.blockEditor,o=(0,t.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 242.5 239.46"},(0,t.createElement)("defs",null,(0,t.createElement)("clipPath",{id:"clip-path",transform:"translate(1.72)"},(0,t.createElement)("circle",{className:"cls-1",cx:"119.73",cy:"119.73",r:"116.15",fill:"none"}))),(0,t.createElement)("g",{id:"Layer_2","data-name":"Layer 2"},(0,t.createElement)("g",{id:"Layer_1","data-name":"Layer 1"},(0,t.createElement)("g",{className:"cls-2",clipPath:"url(#clip-path)"},(0,t.createElement)("circle",{className:"cls-3",cx:"121.45",cy:"119.73",r:"116.15",fill:"#33c6f4"}),(0,t.createElement)("path",{className:"cls-4",d:"M239.32,167.79c-53.41-24-108.37-91.46-113-94.55s-10.84.77-10.84.77c-3.87-6.19-10.06.77-10.06.77C76.77,123.55.14,170.11.14,170.11S36.94,237.79,122,237.79C208.48,237.79,239.32,167.79,239.32,167.79Z",transform:"translate(1.72)",fill:"#1b447e"}),(0,t.createElement)("path",{className:"cls-5",d:"M67.48,116.58s15.48-7,12.38,4.65-15.48,28.64-11.61,29.41S83,140.58,86.06,142.12s5.42.78,3.87,6.2-3.1,9.29,0,9.29,5.42-7,9.29-13.94,10.06-3.87,12.38-1.55,9.29,15.49,14.71,13.94,8.51-8.52,6.19-24,1.55-20.12,1.55-20.12,4.64-2.32,13.16,8.51,24,27.09,26.31,26.32-10.83-17.8-7.74-19.35,15.48,2.32,21.68,7.74c0,0,2.12,8.87,2.12.36L126.31,73.24,115.47,74l-10.06.77S80.64,111.94,67.48,116.58Z",transform:"translate(1.72)",fill:"#fff"}),(0,t.createElement)("path",{className:"cls-6",d:"M239.32,170.11c-53.41-24-108.37-93.78-113-96.87s-10.84.77-10.84.77c-3.87-6.19-10.06.77-10.06.77C76.77,123.55.14,170.11.14,170.11",transform:"translate(1.72)",fill:"none",stroke:"#221e1f",strokeMiterlimit:"10",strokeWidth:"8px"})),(0,t.createElement)("circle",{className:"cls-6",cx:"121.45",cy:"119.73",r:"116.15",fill:"none",stroke:"#1b447e",strokeMiterlimit:"10",strokeWidth:"8px"})))),n=window.wp.components,c=window.wp.apiFetch;var s=e.n(c);const m=window.wp.url,i=e=>{let t="[contact-form-7]";return e.hash?t=t.replace(/\]$/,` id="${e.hash}"]`):e.id&&(t=t.replace(/\]$/,` id="${e.id}"]`)),e.title&&(t=t.replace(/\]$/,` title="${e.title}"]`)),e.htmlId&&(t=t.replace(/\]$/,` html_id="${e.htmlId}"]`)),e.htmlName&&(t=t.replace(/\]$/,` html_name="${e.htmlName}"]`)),e.htmlTitle&&(t=t.replace(/\]$/,` html_title="${e.htmlTitle}"]`)),e.htmlClass&&(t=t.replace(/\]$/,` html_class="${e.htmlClass}"]`)),"raw_form"===e.output&&(t=t.replace(/\]$/,` output="${e.output}"]`)),t},d=e=>{const t=ajaxurl.replace(/\/admin-ajax\.php$/,"/admin.php");return(0,m.addQueryArgs)(t,{page:"wpcf7",post:e.id,action:"edit"})},p={from:[],to:[{type:"block",blocks:["core/shortcode"],transform:e=>{const t=i(e);return(0,a.createBlock)("core/shortcode",{text:t})}}]};var h;window.wpcf7=null!==(h=window.wpcf7)&&void 0!==h?h:{contactForms:[]},(0,a.registerBlockType)("contact-form-7/contact-form-selector",{icon:o,transforms:p,edit:function(e){let{attributes:a,setAttributes:o}=e;const c=e=>e.reduce(((e,t)=>e.set(t.id,t)),new Map),[i,p]=(0,t.useState)((()=>{var e;return c(null!==(e=window.wpcf7.contactForms)&&void 0!==e?e:[])}));return(0,t.createElement)(t.Fragment,null,(0,t.createElement)(r.InspectorControls,null,a.id&&(0,t.createElement)(n.PanelBody,{title:a.title},(0,t.createElement)(n.ExternalLink,{href:d(a)},(0,l.__)("Edit this contact form","contact-form-7"))),a.id&&(0,t.createElement)(n.PanelBody,{title:(0,l.__)("Form attributes","contact-form-7"),initialOpen:!1},(0,t.createElement)(n.TextControl,{label:(0,l.__)("ID","contact-form-7"),value:a.htmlId,onChange:e=>o({htmlId:e}),help:(0,l.__)("Used for the id attribute value of the form element.","contact-form-7")}),(0,t.createElement)(n.TextControl,{label:(0,l.__)("Name","contact-form-7"),value:a.htmlName,onChange:e=>o({htmlName:e}),help:(0,l.__)("Used for the name attribute value of the form element.","contact-form-7")}),(0,t.createElement)(n.TextControl,{label:(0,l.__)("Title","contact-form-7"),value:a.htmlTitle,onChange:e=>o({htmlTitle:e}),help:(0,l.__)("Used for the aria-label attribute value of the form element.","contact-form-7")}),(0,t.createElement)(n.TextControl,{label:(0,l.__)("Class","contact-form-7"),value:a.htmlClass,onChange:e=>o({htmlClass:e}),help:(0,l.__)("Used for the class attribute value of the form element.","contact-form-7")}))),(0,t.createElement)("div",(0,r.useBlockProps)({className:"components-placeholder",style:{marginTop:"28px",marginBottom:"28px"}}),(0,t.createElement)(n.ComboboxControl,{label:(0,l.__)("Select a contact form:","contact-form-7"),options:(e=>{const t=[];for(const[l,a]of e)t.push({value:l,label:a.title});return t})(i),value:a.id,onChange:e=>{var t,l;return o({id:parseInt(e),hash:null===(t=i.get(parseInt(e)))||void 0===t?void 0:t.hash,title:null===(l=i.get(parseInt(e)))||void 0===l?void 0:l.title})},onFilterValueChange:e=>{(async e=>s()({path:(0,m.addQueryArgs)("/contact-form-7/v1/contact-forms",{posts_per_page:20,orderby:"modified",order:"DESC",...e})}).then((e=>e)))({search:e}).then((e=>{p(c(e))}))}})))},save:e=>{let{attributes:l}=e;const a=i(l);return(0,t.createElement)("div",r.useBlockProps.save(),a)}})})();includes/block-editor/block.json000064400000001320150515101440012705 0ustar00{ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 2, "name": "contact-form-7/contact-form-selector", "title": "Contact Form 7", "category": "widgets", "description": "Insert a contact form you have created with Contact Form 7.", "keywords": [ "form" ], "textdomain": "contact-form-7", "attributes": { "id": { "type": "integer" }, "hash": { "type": "string" }, "title": { "type": "string" }, "htmlId": { "type": "string" }, "htmlName": { "type": "string" }, "htmlTitle": { "type": "string" }, "htmlClass": { "type": "string" }, "output": { "enum": [ "form", "raw_form" ], "default": "form" } }, "editorScript": "file:./index.js" } includes/block-editor/block-editor.php000064400000003134150515101440014014 0ustar00 array( 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-url', ), 'version' => WPCF7_VERSION, ) ); wp_register_script( 'contact-form-7-block-editor', wpcf7_plugin_url( 'includes/block-editor/index.js' ), $assets['dependencies'], $assets['version'] ); wp_set_script_translations( 'contact-form-7-block-editor', 'contact-form-7' ); register_block_type( wpcf7_plugin_path( 'includes/block-editor' ), array( 'editor_script' => 'contact-form-7-block-editor', ) ); } add_action( 'enqueue_block_editor_assets', 'wpcf7_enqueue_block_editor_assets', 10, 0 ); function wpcf7_enqueue_block_editor_assets() { $contact_forms = array_map( static function ( $contact_form ) { return array( 'id' => $contact_form->id(), 'hash' => $contact_form->hash(), 'slug' => $contact_form->name(), 'title' => $contact_form->title(), 'locale' => $contact_form->locale(), ); }, WPCF7_ContactForm::find( array( 'posts_per_page' => 20, 'orderby' => 'modified', 'order' => 'DESC', ) ) ); wp_add_inline_script( 'contact-form-7-block-editor', sprintf( 'window.wpcf7 = {contactForms:%s};', json_encode( $contact_forms ) ), 'before' ); } includes/special-mail-tags.php000064400000014103150515101440012352 0ustar00get_meta( 'remote_ip' ) ) { return $remote_ip; } else { return ''; } } if ( '_user_agent' === $name ) { if ( $user_agent = $submission->get_meta( 'user_agent' ) ) { return $html ? esc_html( $user_agent ) : $user_agent; } else { return ''; } } if ( '_url' === $name ) { if ( $url = $submission->get_meta( 'url' ) ) { return $url; } else { return ''; } } if ( '_date' === $name or '_time' === $name ) { if ( $timestamp = $submission->get_meta( 'timestamp' ) ) { if ( '_date' === $name ) { return wp_date( get_option( 'date_format' ), $timestamp ); } if ( '_time' === $name ) { return wp_date( get_option( 'time_format' ), $timestamp ); } } return ''; } if ( '_invalid_fields' === $name ) { return count( $submission->get_invalid_fields() ); } return $output; } add_filter( 'wpcf7_special_mail_tags', 'wpcf7_post_related_smt', 10, 4 ); /** * Returns output string of a special mail-tag. * * @param string $output The string to be output. * @param string $name The tag name of the special mail-tag. * @param bool $html Whether the mail-tag is used in an HTML content. * @param WPCF7_MailTag $mail_tag An object representation of the mail-tag. * @return string Output of the given special mail-tag. */ function wpcf7_post_related_smt( $output, $name, $html, $mail_tag = null ) { if ( ! $mail_tag instanceof WPCF7_MailTag ) { wpcf7_doing_it_wrong( sprintf( '%s()', __FUNCTION__ ), __( 'The fourth parameter ($mail_tag) must be an instance of the WPCF7_MailTag class.', 'contact-form-7' ), '5.2.2' ); } if ( ! str_starts_with( $name, '_post_' ) ) { return $output; } $submission = WPCF7_Submission::get_instance(); if ( ! $submission ) { return $output; } $post_id = (int) $submission->get_meta( 'container_post_id' ); if ( ! $post_id or ! $post = get_post( $post_id ) ) { return ''; } if ( '_post_id' === $name ) { return (string) $post->ID; } if ( '_post_name' === $name ) { return $post->post_name; } if ( '_post_title' === $name ) { return $html ? esc_html( $post->post_title ) : $post->post_title; } if ( '_post_url' === $name ) { return get_permalink( $post->ID ); } $user = new WP_User( $post->post_author ); if ( '_post_author' === $name ) { return $user->display_name; } if ( '_post_author_email' === $name ) { return $user->user_email; } return $output; } add_filter( 'wpcf7_special_mail_tags', 'wpcf7_site_related_smt', 10, 4 ); /** * Returns output string of a special mail-tag. * * @param string $output The string to be output. * @param string $name The tag name of the special mail-tag. * @param bool $html Whether the mail-tag is used in an HTML content. * @param WPCF7_MailTag $mail_tag An object representation of the mail-tag. * @return string Output of the given special mail-tag. */ function wpcf7_site_related_smt( $output, $name, $html, $mail_tag = null ) { if ( ! $mail_tag instanceof WPCF7_MailTag ) { wpcf7_doing_it_wrong( sprintf( '%s()', __FUNCTION__ ), __( 'The fourth parameter ($mail_tag) must be an instance of the WPCF7_MailTag class.', 'contact-form-7' ), '5.2.2' ); } $filter = $html ? 'display' : 'raw'; if ( '_site_title' === $name ) { $output = get_bloginfo( 'name', $filter ); if ( ! $html ) { $output = wp_specialchars_decode( $output, ENT_QUOTES ); } return $output; } if ( '_site_description' === $name ) { $output = get_bloginfo( 'description', $filter ); if ( ! $html ) { $output = wp_specialchars_decode( $output, ENT_QUOTES ); } return $output; } if ( '_site_url' === $name ) { return get_bloginfo( 'url', $filter ); } if ( '_site_admin_email' === $name ) { return get_bloginfo( 'admin_email', $filter ); } return $output; } add_filter( 'wpcf7_special_mail_tags', 'wpcf7_user_related_smt', 10, 4 ); /** * Returns output string of a special mail-tag. * * @param string $output The string to be output. * @param string $name The tag name of the special mail-tag. * @param bool $html Whether the mail-tag is used in an HTML content. * @param WPCF7_MailTag $mail_tag An object representation of the mail-tag. * @return string Output of the given special mail-tag. */ function wpcf7_user_related_smt( $output, $name, $html, $mail_tag = null ) { if ( ! $mail_tag instanceof WPCF7_MailTag ) { wpcf7_doing_it_wrong( sprintf( '%s()', __FUNCTION__ ), __( 'The fourth parameter ($mail_tag) must be an instance of the WPCF7_MailTag class.', 'contact-form-7' ), '5.2.2' ); } if ( ! str_starts_with( $name, '_user_' ) or '_user_agent' === $name ) { return $output; } $submission = WPCF7_Submission::get_instance(); if ( ! $submission ) { return $output; } $user_id = (int) $submission->get_meta( 'current_user_id' ); if ( ! $user_id ) { return ''; } $primary_props = array( 'user_login', 'user_email', 'user_url' ); $opt = ltrim( $name, '_' ); $opt = in_array( $opt, $primary_props ) ? $opt : substr( $opt, 5 ); $user = new WP_User( $user_id ); if ( $user->has_prop( $opt ) ) { return $user->get( $opt ); } return ''; } includes/config-validator/messages.php000064400000001766150515101440014130 0ustar00contact_form->prop( 'messages' ); if ( ! $messages ) { return; } if ( isset( $messages['captcha_not_match'] ) and ! wpcf7_use_really_simple_captcha() ) { unset( $messages['captcha_not_match'] ); } foreach ( $messages as $key => $message ) { $section = sprintf( 'messages.%s', $key ); $this->detect_html_in_message( $section, $message ); } } /** * Detects errors of HTML uses in a message. * * @link https://contactform7.com/configuration-errors/html-in-message/ */ public function detect_html_in_message( $section, $content ) { $stripped = wp_strip_all_tags( $content ); if ( $stripped != $content ) { return $this->add_error( $section, 'html_in_message', array( 'message' => __( "HTML tags are used in a message.", 'contact-form-7' ), ) ); } return false; } } includes/config-validator/form.php000064400000014640150515101440013257 0ustar00contact_form->prop( 'form' ); $this->detect_multiple_controls_in_label( $section, $form ); $this->detect_unavailable_names( $section, $form ); $this->detect_unavailable_html_elements( $section, $form ); $this->detect_dots_in_names( $section, $form ); $this->detect_colons_in_names( $section, $form ); $this->detect_upload_filesize_overlimit( $section, $form ); } /** * Detects errors of multiple form controls in a single label. * * @link https://contactform7.com/configuration-errors/multiple-controls-in-label/ */ public function detect_multiple_controls_in_label( $section, $content ) { $pattern = '%(.+?)%s'; if ( preg_match_all( $pattern, $content, $matches ) ) { $form_tags_manager = WPCF7_FormTagsManager::get_instance(); foreach ( $matches[1] as $insidelabel ) { $tags = $form_tags_manager->scan( $insidelabel ); $fields_count = 0; foreach ( $tags as $tag ) { $is_multiple_controls_container = wpcf7_form_tag_supports( $tag->type, 'multiple-controls-container' ); $is_zero_controls_container = wpcf7_form_tag_supports( $tag->type, 'zero-controls-container' ); if ( $is_multiple_controls_container ) { $fields_count += count( $tag->values ); if ( $tag->has_option( 'free_text' ) ) { $fields_count += 1; } } elseif ( $is_zero_controls_container ) { $fields_count += 0; } elseif ( ! empty( $tag->name ) ) { $fields_count += 1; } if ( 1 < $fields_count ) { return $this->add_error( $section, 'multiple_controls_in_label', array( 'message' => __( "Multiple form controls are in a single label element.", 'contact-form-7' ), ) ); } } } } return false; } /** * Detects errors of unavailable form-tag names. * * @link https://contactform7.com/configuration-errors/unavailable-names/ */ public function detect_unavailable_names( $section, $content ) { $public_query_vars = array( 'm', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots', 'taxonomy', 'term', 'cpage', 'post_type', 'embed', ); $form_tags_manager = WPCF7_FormTagsManager::get_instance(); $ng_named_tags = $form_tags_manager->filter( $content, array( 'name' => $public_query_vars, ) ); $ng_names = array(); foreach ( $ng_named_tags as $tag ) { $ng_names[] = sprintf( '"%s"', $tag->name ); } if ( $ng_names ) { $ng_names = array_unique( $ng_names ); return $this->add_error( $section, 'unavailable_names', array( 'message' => /* translators: %names%: a list of form control names */ __( "Unavailable names (%names%) are used for form controls.", 'contact-form-7' ), 'params' => array( 'names' => implode( ', ', $ng_names ) ), ) ); } return false; } /** * Detects errors of unavailable HTML elements. * * @link https://contactform7.com/configuration-errors/unavailable-html-elements/ */ public function detect_unavailable_html_elements( $section, $content ) { $pattern = '%(?:]|)%i'; if ( preg_match( $pattern, $content ) ) { return $this->add_error( $section, 'unavailable_html_elements', array( 'message' => __( "Unavailable HTML elements are used in the form template.", 'contact-form-7' ), ) ); } return false; } /** * Detects errors of dots in form-tag names. * * @link https://contactform7.com/configuration-errors/dots-in-names/ */ public function detect_dots_in_names( $section, $content ) { $form_tags_manager = WPCF7_FormTagsManager::get_instance(); $tags = $form_tags_manager->filter( $content, array( 'feature' => 'name-attr', ) ); foreach ( $tags as $tag ) { if ( str_contains( $tag->raw_name, '.' ) ) { return $this->add_error( $section, 'dots_in_names', array( 'message' => __( "Dots are used in form-tag names.", 'contact-form-7' ), ) ); } } return false; } /** * Detects errors of colons in form-tag names. * * @link https://contactform7.com/configuration-errors/colons-in-names/ */ public function detect_colons_in_names( $section, $content ) { $form_tags_manager = WPCF7_FormTagsManager::get_instance(); $tags = $form_tags_manager->filter( $content, array( 'feature' => 'name-attr', ) ); foreach ( $tags as $tag ) { if ( str_contains( $tag->raw_name, ':' ) ) { return $this->add_error( $section, 'colons_in_names', array( 'message' => __( "Colons are used in form-tag names.", 'contact-form-7' ), ) ); } } return false; } /** * Detects errors of uploadable file size overlimit. * * @link https://contactform7.com/configuration-errors/upload-filesize-overlimit */ public function detect_upload_filesize_overlimit( $section, $content ) { $upload_max_filesize = ini_get( 'upload_max_filesize' ); if ( ! $upload_max_filesize ) { return false; } $upload_max_filesize = strtolower( $upload_max_filesize ); $upload_max_filesize = trim( $upload_max_filesize ); if ( ! preg_match( '/^(\d+)([kmg]?)$/', $upload_max_filesize, $matches ) ) { return false; } if ( 'k' === $matches[2] ) { $upload_max_filesize = (int) $matches[1] * KB_IN_BYTES; } elseif ( 'm' === $matches[2] ) { $upload_max_filesize = (int) $matches[1] * MB_IN_BYTES; } elseif ( 'g' === $matches[2] ) { $upload_max_filesize = (int) $matches[1] * GB_IN_BYTES; } else { $upload_max_filesize = (int) $matches[1]; } $form_tags_manager = WPCF7_FormTagsManager::get_instance(); $tags = $form_tags_manager->filter( $content, array( 'basetype' => 'file', ) ); foreach ( $tags as $tag ) { if ( $upload_max_filesize < $tag->get_limit_option() ) { return $this->add_error( $section, 'upload_filesize_overlimit', array( 'message' => __( "Uploadable file size exceeds PHP’s maximum acceptable size.", 'contact-form-7' ), ) ); } } return false; } } includes/config-validator/additional-settings.php000064400000001057150515101440016260 0ustar00contact_form->additional_setting( 'on_sent_ok' ) || $this->contact_form->additional_setting( 'on_submit' ); if ( $deprecated_settings_used ) { return $this->add_error( 'additional_settings.body', 'deprecated_settings', array( 'message' => __( "Deprecated settings are used.", 'contact-form-7' ), ) ); } } } includes/config-validator/validator.php000064400000015403150515101440014277 0ustar00contact_form = $contact_form; } /** * Returns the contact form object that is tied to this validator. */ public function contact_form() { return $this->contact_form; } /** * Returns true if no error has been detected. */ public function is_valid() { return ! $this->count_errors(); } /** * Counts detected errors. */ public function count_errors( $args = '' ) { $args = wp_parse_args( $args, array( 'section' => '', 'code' => '', ) ); $count = 0; foreach ( $this->errors as $key => $errors ) { if ( preg_match( '/^mail_[0-9]+\.(.*)$/', $key, $matches ) ) { $key = sprintf( 'mail.%s', $matches[1] ); } if ( $args['section'] and $key !== $args['section'] and preg_replace( '/\..*$/', '', $key, 1 ) !== $args['section'] ) { continue; } foreach ( $errors as $error ) { if ( empty( $error ) ) { continue; } if ( $args['code'] and $error['code'] !== $args['code'] ) { continue; } $count += 1; } } return $count; } /** * Collects messages for detected errors. */ public function collect_error_messages() { $error_messages = array(); foreach ( $this->errors as $section => $errors ) { $error_messages[$section] = array(); foreach ( $errors as $error ) { if ( empty( $error['args']['message'] ) ) { $message = $this->get_default_message( $error['code'] ); } elseif ( empty( $error['args']['params'] ) ) { $message = $error['args']['message']; } else { $message = $this->build_message( $error['args']['message'], $error['args']['params'] ); } $link = ''; if ( ! empty( $error['args']['link'] ) ) { $link = $error['args']['link']; } $error_messages[$section][] = array( 'message' => $message, 'link' => esc_url( $link ), ); } } return $error_messages; } /** * Builds an error message by replacing placeholders. */ public function build_message( $message, $params = '' ) { $params = wp_parse_args( $params, array() ); foreach ( $params as $key => $val ) { if ( ! preg_match( '/^[0-9A-Za-z_]+$/', $key ) ) { // invalid key continue; } $placeholder = '%' . $key . '%'; if ( false !== stripos( $message, $placeholder ) ) { $message = str_ireplace( $placeholder, $val, $message ); } } return $message; } /** * Returns a default message that is used when the message for the error * is not specified. */ public function get_default_message( $code = '' ) { return __( "Configuration error is detected.", 'contact-form-7' ); } /** * Adds a validation error. * * @param string $section The section where the error detected. * @param string $code The unique code of the error. * @param string|array $args Optional options for the error. */ public function add_error( $section, $code, $args = '' ) { $args = wp_parse_args( $args, array( 'message' => '', 'params' => array(), ) ); $available_error_codes = (array) apply_filters( 'wpcf7_config_validator_available_error_codes', self::error_codes, $this->contact_form ); if ( ! in_array( $code, $available_error_codes, true ) ) { return false; } if ( ! isset( $args['link'] ) ) { $args['link'] = self::get_doc_link( $code ); } if ( ! isset( $this->errors[$section] ) ) { $this->errors[$section] = array(); } $this->errors[$section][] = array( 'code' => $code, 'args' => $args, ); return true; } /** * Removes an error. * * @param string $section The section where the error detected. * @param string $code The unique code of the error. */ public function remove_error( $section, $code ) { if ( empty( $this->errors[$section] ) ) { return; } foreach ( (array) $this->errors[$section] as $key => $error ) { if ( isset( $error['code'] ) and $error['code'] === $code ) { unset( $this->errors[$section][$key] ); } } if ( empty( $this->errors[$section] ) ) { unset( $this->errors[$section] ); } } /** * The main validation runner. * * @return bool True if there is no error detected. */ public function validate() { $this->errors = array(); $this->validate_form(); $this->validate_mail( 'mail' ); $this->validate_mail( 'mail_2' ); $this->validate_messages(); $this->validate_additional_settings(); do_action( 'wpcf7_config_validator_validate', $this ); return $this->is_valid(); } /** * Saves detected errors as a post meta data. */ public function save() { if ( $this->contact_form->initial() ) { return; } delete_post_meta( $this->contact_form->id(), '_config_validation' ); if ( $this->errors ) { update_post_meta( $this->contact_form->id(), '_config_validation', $this->errors ); } } /** * Restore errors from the database. */ public function restore() { $config_errors = get_post_meta( $this->contact_form->id(), '_config_validation', true ); foreach ( (array) $config_errors as $section => $errors ) { if ( empty( $errors ) ) { continue; } foreach ( (array) $errors as $error ) { if ( ! empty( $error['code'] ) ) { $code = $error['code']; $args = isset( $error['args'] ) ? $error['args'] : ''; $this->add_error( $section, $code, $args ); } } } } } includes/config-validator/mail.php000064400000022433150515101440013235 0ustar00field_name(); $example_email = 'example@example.com'; $example_text = 'example'; $example_blank = ''; $form_tags = $this->contact_form->scan_form_tags( array( 'name' => $field_name ) ); if ( $form_tags ) { $form_tag = new WPCF7_FormTag( $form_tags[0] ); $is_required = $form_tag->is_required() || 'radio' === $form_tag->type; if ( ! $is_required ) { return $example_blank; } if ( wpcf7_form_tag_supports( $form_tag->type, 'selectable-values' ) ) { if ( $form_tag->pipes instanceof WPCF7_Pipes ) { if ( $mail_tag->get_option( 'do_not_heat' ) ) { $before_pipes = $form_tag->pipes->collect_befores(); $last_item = array_pop( $before_pipes ); } else { $after_pipes = $form_tag->pipes->collect_afters(); $last_item = array_pop( $after_pipes ); } } else { $last_item = array_pop( $form_tag->values ); } if ( $last_item and wpcf7_is_mailbox_list( $last_item ) ) { return $example_email; } else { return $example_text; } } if ( 'email' === $form_tag->basetype ) { return $example_email; } else { return $example_text; } } else { // maybe special mail tag // for back-compat $field_name = preg_replace( '/^wpcf7\./', '_', $field_name ); if ( '_site_admin_email' === $field_name ) { return get_bloginfo( 'admin_email', 'raw' ); } elseif ( '_user_agent' === $field_name ) { return $example_text; } elseif ( '_user_email' === $field_name ) { return $this->contact_form->is_true( 'subscribers_only' ) ? $example_email : $example_blank; } elseif ( str_starts_with( $field_name, '_user_' ) ) { return $this->contact_form->is_true( 'subscribers_only' ) ? $example_text : $example_blank; } elseif ( str_starts_with( $field_name, '_' ) ) { return str_ends_with( $field_name, '_email' ) ? $example_email : $example_text; } } return $tag; } /** * Runs error detection for the mail sections. */ public function validate_mail( $template = 'mail' ) { if ( $this->contact_form->is_true( 'demo_mode' ) or $this->contact_form->is_true( 'skip_mail' ) ) { return; } $components = (array) $this->contact_form->prop( $template ); if ( ! $components ) { return; } if ( 'mail' !== $template and empty( $components['active'] ) ) { return; } $components = wp_parse_args( $components, array( 'subject' => '', 'sender' => '', 'recipient' => '', 'additional_headers' => '', 'body' => '', 'attachments' => '', ) ); $callback = array( $this, 'replace_mail_tags_with_minimum_input' ); $subject = new WPCF7_MailTaggedText( $components['subject'], array( 'callback' => $callback ) ); $subject = $subject->replace_tags(); $subject = wpcf7_strip_newline( $subject ); $this->detect_maybe_empty( sprintf( '%s.subject', $template ), $subject ); $sender = new WPCF7_MailTaggedText( $components['sender'], array( 'callback' => $callback ) ); $sender = $sender->replace_tags(); $sender = wpcf7_strip_newline( $sender ); $invalid_mailbox = $this->detect_invalid_mailbox_syntax( sprintf( '%s.sender', $template ), $sender ); if ( ! $invalid_mailbox and ! wpcf7_is_email_in_site_domain( $sender ) ) { $this->add_error( sprintf( '%s.sender', $template ), 'email_not_in_site_domain', array( 'message' => __( "Sender email address does not belong to the site domain.", 'contact-form-7' ), ) ); } $recipient = new WPCF7_MailTaggedText( $components['recipient'], array( 'callback' => $callback ) ); $recipient = $recipient->replace_tags(); $recipient = wpcf7_strip_newline( $recipient ); $this->detect_invalid_mailbox_syntax( sprintf( '%s.recipient', $template ), $recipient ); $additional_headers = new WPCF7_MailTaggedText( $components['additional_headers'], array( 'callback' => $callback ) ); $additional_headers = $additional_headers->replace_tags(); $additional_headers = explode( "\n", $additional_headers ); $mailbox_header_types = array( 'reply-to', 'cc', 'bcc' ); $invalid_mail_header_exists = false; foreach ( $additional_headers as $header ) { $header = trim( $header ); if ( '' === $header ) { continue; } if ( ! preg_match( '/^([0-9A-Za-z-]+):(.*)$/', $header, $matches ) ) { $invalid_mail_header_exists = true; } else { $header_name = $matches[1]; $header_value = trim( $matches[2] ); if ( in_array( strtolower( $header_name ), $mailbox_header_types ) and '' !== $header_value ) { $this->detect_invalid_mailbox_syntax( sprintf( '%s.additional_headers', $template ), $header_value, array( 'message' => __( "Invalid mailbox syntax is used in the %name% field.", 'contact-form-7' ), 'params' => array( 'name' => $header_name ) ) ); } } } if ( $invalid_mail_header_exists ) { $this->add_error( sprintf( '%s.additional_headers', $template ), 'invalid_mail_header', array( 'message' => __( "There are invalid mail header fields.", 'contact-form-7' ), ) ); } $body = new WPCF7_MailTaggedText( $components['body'], array( 'callback' => $callback ) ); $body = $body->replace_tags(); $this->detect_maybe_empty( sprintf( '%s.body', $template ), $body ); if ( '' !== $components['attachments'] ) { $attachables = array(); $tags = $this->contact_form->scan_form_tags( array( 'type' => array( 'file', 'file*' ) ) ); foreach ( $tags as $tag ) { $name = $tag->name; if ( ! str_contains( $components['attachments'], "[{$name}]" ) ) { continue; } $limit = (int) $tag->get_limit_option(); if ( empty( $attachables[$name] ) or $attachables[$name] < $limit ) { $attachables[$name] = $limit; } } $total_size = array_sum( $attachables ); $has_file_not_found = false; $has_file_not_in_content_dir = false; foreach ( explode( "\n", $components['attachments'] ) as $line ) { $line = trim( $line ); if ( '' === $line or str_starts_with( $line, '[' ) ) { continue; } $has_file_not_found = $this->detect_file_not_found( sprintf( '%s.attachments', $template ), $line ); if ( ! $has_file_not_found and ! $has_file_not_in_content_dir ) { $has_file_not_in_content_dir = $this->detect_file_not_in_content_dir( sprintf( '%s.attachments', $template ), $line ); } if ( ! $has_file_not_found ) { $path = path_join( WP_CONTENT_DIR, $line ); $total_size += (int) @filesize( $path ); } } $max = 25 * MB_IN_BYTES; // 25 MB if ( $max < $total_size ) { $this->add_error( sprintf( '%s.attachments', $template ), 'attachments_overweight', array( 'message' => __( "The total size of attachment files is too large.", 'contact-form-7' ), ) ); } } } /** * Detects errors of invalid mailbox syntax. * * @link https://contactform7.com/configuration-errors/invalid-mailbox-syntax/ */ public function detect_invalid_mailbox_syntax( $section, $content, $args = '' ) { $args = wp_parse_args( $args, array( 'message' => __( "Invalid mailbox syntax is used.", 'contact-form-7' ), 'params' => array(), ) ); if ( ! wpcf7_is_mailbox_list( $content ) ) { return $this->add_error( $section, 'invalid_mailbox_syntax', $args ); } return false; } /** * Detects errors of empty message fields. * * @link https://contactform7.com/configuration-errors/maybe-empty/ */ public function detect_maybe_empty( $section, $content ) { if ( '' === $content ) { return $this->add_error( $section, 'maybe_empty', array( 'message' => __( "There is a possible empty field.", 'contact-form-7' ), ) ); } return false; } /** * Detects errors of nonexistent attachment files. * * @link https://contactform7.com/configuration-errors/file-not-found/ */ public function detect_file_not_found( $section, $content ) { $path = path_join( WP_CONTENT_DIR, $content ); if ( ! is_readable( $path ) or ! is_file( $path ) ) { return $this->add_error( $section, 'file_not_found', array( 'message' => __( "Attachment file does not exist at %path%.", 'contact-form-7' ), 'params' => array( 'path' => $content ), ) ); } return false; } /** * Detects errors of attachment files out of the content directory. * * @link https://contactform7.com/configuration-errors/file-not-in-content-dir/ */ public function detect_file_not_in_content_dir( $section, $content ) { $path = path_join( WP_CONTENT_DIR, $content ); if ( ! wpcf7_is_file_path_in_content_dir( $path ) ) { return $this->add_error( $section, 'file_not_in_content_dir', array( 'message' => __( "It is not allowed to use files outside the wp-content directory.", 'contact-form-7' ), ) ); } return false; } } includes/contact-form.php000064400000073732150515101440011467 0ustar00 array( 'name' => __( 'Contact Forms', 'contact-form-7' ), 'singular_name' => __( 'Contact Form', 'contact-form-7' ), ), 'rewrite' => false, 'query_var' => false, 'public' => false, 'capability_type' => 'page', 'capabilities' => array( 'edit_post' => 'wpcf7_edit_contact_form', 'read_post' => 'wpcf7_read_contact_form', 'delete_post' => 'wpcf7_delete_contact_form', 'edit_posts' => 'wpcf7_edit_contact_forms', 'edit_others_posts' => 'wpcf7_edit_contact_forms', 'publish_posts' => 'wpcf7_edit_contact_forms', 'read_private_posts' => 'wpcf7_edit_contact_forms', ), ) ); } /** * Retrieves contact form data that match given conditions. * * @param string|array $args Optional. Arguments to be passed to WP_Query. * @return array Array of WPCF7_ContactForm objects. */ public static function find( $args = '' ) { $defaults = array( 'post_status' => 'any', 'posts_per_page' => -1, 'offset' => 0, 'orderby' => 'ID', 'order' => 'ASC', ); $args = wp_parse_args( $args, $defaults ); $args['post_type'] = self::post_type; $q = new WP_Query(); $posts = $q->query( $args ); self::$found_items = $q->found_posts; $objs = array(); foreach ( (array) $posts as $post ) { $objs[] = new self( $post ); } return $objs; } /** * Returns a contact form data filled by default template contents. * * @param string|array $args Optional. Contact form options. * @return WPCF7_ContactForm A new contact form object. */ public static function get_template( $args = '' ) { $args = wp_parse_args( $args, array( 'locale' => null, 'title' => __( 'Untitled', 'contact-form-7' ), ) ); if ( ! isset( $args['locale'] ) ) { $args['locale'] = determine_locale(); } $callback = static function ( $args ) { $contact_form = new self; $contact_form->title = $args['title']; $contact_form->locale = $args['locale']; $properties = $contact_form->get_properties(); foreach ( $properties as $key => $value ) { $default_template = WPCF7_ContactFormTemplate::get_default( $key ); if ( isset( $default_template ) ) { $properties[$key] = $default_template; } } $contact_form->properties = $properties; return $contact_form; }; $contact_form = wpcf7_switch_locale( $args['locale'], $callback, $args ); self::$current = apply_filters( 'wpcf7_contact_form_default_pack', $contact_form, $args ); return self::$current; } /** * Creates a WPCF7_ContactForm object and sets it as the current instance. * * @param WPCF7_ContactForm|WP_Post|int $post Object or post ID. * @return WPCF7_ContactForm|null Contact form object. Null if unset. */ public static function get_instance( $post ) { $contact_form = null; if ( $post instanceof self ) { $contact_form = $post; } elseif ( ! empty( $post ) ) { $post = get_post( $post ); if ( isset( $post ) and self::post_type === get_post_type( $post ) ) { $contact_form = new self( $post ); } } return self::$current = $contact_form; } /** * Generates a "unit-tag" for the given contact form ID. * * @return string Unit-tag. */ private static function generate_unit_tag( $id = 0 ) { static $global_count = 0; $global_count += 1; if ( in_the_loop() ) { $unit_tag = sprintf( 'wpcf7-f%1$d-p%2$d-o%3$d', absint( $id ), get_the_ID(), $global_count ); } else { $unit_tag = sprintf( 'wpcf7-f%1$d-o%2$d', absint( $id ), $global_count ); } return $unit_tag; } /** * Constructor. */ private function __construct( $post = null ) { $post = get_post( $post ); if ( $post and self::post_type === get_post_type( $post ) ) { $this->id = $post->ID; $this->name = $post->post_name; $this->title = $post->post_title; $this->locale = get_post_meta( $post->ID, '_locale', true ); $this->hash = get_post_meta( $post->ID, '_hash', true ); $this->construct_properties( $post ); $this->upgrade(); } else { $this->construct_properties(); } do_action( 'wpcf7_contact_form', $this ); } /** * Magic method for property overloading. */ public function __get( $name ) { $message = __( '%1$s property of a WPCF7_ContactForm object is no longer accessible. Use %2$s method instead.', 'contact-form-7' ); if ( 'id' == $name ) { if ( WP_DEBUG ) { trigger_error( sprintf( $message, 'id', 'id()' ), E_USER_DEPRECATED ); } return $this->id; } elseif ( 'title' == $name ) { if ( WP_DEBUG ) { trigger_error( sprintf( $message, 'title', 'title()' ), E_USER_DEPRECATED ); } return $this->title; } elseif ( $prop = $this->prop( $name ) ) { if ( WP_DEBUG ) { trigger_error( sprintf( $message, $name, 'prop(\'' . $name . '\')' ), E_USER_DEPRECATED ); } return $prop; } } /** * Returns true if this contact form is not yet saved to the database. */ public function initial() { return empty( $this->id ); } /** * Constructs contact form properties. This is called only once * from the constructor. */ private function construct_properties( $post = null ) { $builtin_properties = array( 'form' => '', 'mail' => array(), 'mail_2' => array(), 'messages' => array(), 'additional_settings' => '', ); $properties = apply_filters( 'wpcf7_pre_construct_contact_form_properties', $builtin_properties, $this ); // Filtering out properties with invalid name $properties = array_filter( $properties, static function ( $key ) { $sanitized_key = sanitize_key( $key ); return $key === $sanitized_key; }, ARRAY_FILTER_USE_KEY ); foreach ( $properties as $name => $val ) { $prop = $this->retrieve_property( $name ); if ( isset( $prop ) ) { $properties[$name] = $prop; } } $this->properties = $properties; foreach ( $properties as $name => $val ) { $properties[$name] = apply_filters( "wpcf7_contact_form_property_{$name}", $val, $this ); } $this->properties = $properties; $properties = (array) apply_filters( 'wpcf7_contact_form_properties', $properties, $this ); $this->properties = $properties; } /** * Retrieves contact form property of the specified name from the database. * * @param string $name Property name. * @return array|string|null Property value. Null if property does not exist. */ private function retrieve_property( $name ) { $property = null; if ( ! $this->initial() ) { $post_id = $this->id; if ( metadata_exists( 'post', $post_id, '_' . $name ) ) { $property = get_post_meta( $post_id, '_' . $name, true ); } elseif ( metadata_exists( 'post', $post_id, $name ) ) { $property = get_post_meta( $post_id, $name, true ); } } return $property; } /** * Returns the value for the given property name. * * @param string $name Property name. * @return array|string|null Property value. Null if property does not exist. */ public function prop( $name ) { $props = $this->get_properties(); return isset( $props[$name] ) ? $props[$name] : null; } /** * Returns all the properties. * * @return array This contact form's properties. */ public function get_properties() { return (array) $this->properties; } /** * Updates properties. * * @param array $properties New properties. */ public function set_properties( $properties ) { $defaults = $this->get_properties(); $properties = wp_parse_args( $properties, $defaults ); $properties = array_intersect_key( $properties, $defaults ); $this->properties = $properties; } /** * Returns ID of this contact form. * * @return int The ID. */ public function id() { return $this->id; } /** * Returns unit-tag for this contact form. * * @return string Unit-tag. */ public function unit_tag() { return $this->unit_tag; } /** * Returns name (slug) of this contact form. * * @return string Name. */ public function name() { return $this->name; } /** * Returns title of this contact form. * * @return string Title. */ public function title() { return $this->title; } /** * Set a title for this contact form. * * @param string $title Title. */ public function set_title( $title ) { $title = strip_tags( $title ); $title = trim( $title ); if ( '' === $title ) { $title = __( 'Untitled', 'contact-form-7' ); } $this->title = $title; } /** * Returns the locale code of this contact form. * * @return string Locale code. Empty string if no valid locale is set. */ public function locale() { if ( wpcf7_is_valid_locale( $this->locale ) ) { return $this->locale; } else { return ''; } } /** * Sets a locale for this contact form. * * @param string $locale Locale code. */ public function set_locale( $locale ) { $locale = trim( $locale ); if ( wpcf7_is_valid_locale( $locale ) ) { $this->locale = $locale; } else { $this->locale = 'en_US'; } } /** * Retrieves the random hash string tied to this contact form. * * @param int $length Length of hash string. * @return string Hash string unique to this contact form. */ public function hash( $length = 7 ) { return substr( $this->hash, 0, absint( $length ) ); } /** * Returns the specified shortcode attribute value. * * @param string $name Shortcode attribute name. * @return string|null Attribute value. Null if the attribute does not exist. */ public function shortcode_attr( $name ) { if ( isset( $this->shortcode_atts[$name] ) ) { return (string) $this->shortcode_atts[$name]; } } /** * Returns true if this contact form is identical to the submitted one. */ public function is_posted() { if ( ! WPCF7_Submission::get_instance() ) { return false; } if ( empty( $_POST['_wpcf7_unit_tag'] ) ) { return false; } return $this->unit_tag() === $_POST['_wpcf7_unit_tag']; } /** * Generates HTML that represents a form. * * @param string|array $args Optional. Form options. * @return string HTML output. */ public function form_html( $args = '' ) { $args = wp_parse_args( $args, array( 'html_id' => '', 'html_name' => '', 'html_title' => '', 'html_class' => '', 'output' => 'form', ) ); $this->shortcode_atts = $args; if ( 'raw_form' == $args['output'] ) { return sprintf( '
    %s
    ', esc_html( $this->prop( 'form' ) ) ); } if ( $this->is_true( 'subscribers_only' ) and ! current_user_can( 'wpcf7_submit', $this->id() ) ) { $notice = __( "This contact form is available only for logged in users.", 'contact-form-7' ); $notice = sprintf( '

    %s

    ', esc_html( $notice ) ); return apply_filters( 'wpcf7_subscribers_only_notice', $notice, $this ); } $this->unit_tag = self::generate_unit_tag( $this->id ); $lang_tag = str_replace( '_', '-', $this->locale ); if ( preg_match( '/^([a-z]+-[a-z]+)-/i', $lang_tag, $matches ) ) { $lang_tag = $matches[1]; } $html = "\n" . sprintf( '
    ', wpcf7_format_atts( array( 'class' => 'wpcf7 no-js', 'id' => $this->unit_tag(), ( get_option( 'html_type' ) == 'text/html' ) ? 'lang' : 'xml:lang' => $lang_tag, 'dir' => wpcf7_is_rtl( $this->locale ) ? 'rtl' : 'ltr', ) ) ); $html .= "\n" . $this->screen_reader_response() . "\n"; $url = wpcf7_get_request_uri(); if ( $frag = strstr( $url, '#' ) ) { $url = substr( $url, 0, -strlen( $frag ) ); } $url .= '#' . $this->unit_tag(); $url = apply_filters( 'wpcf7_form_action_url', $url ); $id_attr = apply_filters( 'wpcf7_form_id_attr', preg_replace( '/[^A-Za-z0-9:._-]/', '', $args['html_id'] ) ); $name_attr = apply_filters( 'wpcf7_form_name_attr', preg_replace( '/[^A-Za-z0-9:._-]/', '', $args['html_name'] ) ); $title_attr = apply_filters( 'wpcf7_form_title_attr', $args['html_title'] ); $class = 'wpcf7-form'; if ( $this->is_posted() ) { $submission = WPCF7_Submission::get_instance(); $data_status_attr = $this->form_status_class_name( $submission->get_status() ); $class .= sprintf( ' %s', $data_status_attr ); } else { $data_status_attr = 'init'; $class .= ' init'; } if ( $args['html_class'] ) { $class .= ' ' . $args['html_class']; } if ( $this->in_demo_mode() ) { $class .= ' demo'; } $class = explode( ' ', $class ); $class = array_map( 'sanitize_html_class', $class ); $class = array_filter( $class ); $class = array_unique( $class ); $class = implode( ' ', $class ); $class = apply_filters( 'wpcf7_form_class_attr', $class ); $enctype = wpcf7_enctype_value( apply_filters( 'wpcf7_form_enctype', '' ) ); $autocomplete = apply_filters( 'wpcf7_form_autocomplete', '' ); $atts = array( 'action' => esc_url( $url ), 'method' => 'post', 'class' => ( '' !== $class ) ? $class : null, 'id' => ( '' !== $id_attr ) ? $id_attr : null, 'name' => ( '' !== $name_attr ) ? $name_attr : null, 'aria-label' => ( '' !== $title_attr ) ? $title_attr : __( 'Contact form', 'contact-form-7' ), 'enctype' => ( '' !== $enctype ) ? $enctype : null, 'autocomplete' => ( '' !== $autocomplete ) ? $autocomplete : null, 'novalidate' => true, 'data-status' => $data_status_attr, ); $atts += (array) apply_filters( 'wpcf7_form_additional_atts', array() ); $html .= sprintf( '
    ', wpcf7_format_atts( $atts ) ) . "\n"; $html .= $this->form_hidden_fields(); $html .= $this->form_elements(); if ( ! $this->responses_count ) { $html .= $this->form_response_output(); } $html .= "\n" . '
    '; $html .= "\n" . '
    '; return $html . "\n"; } /** * Returns the class name that matches the given form status. */ private function form_status_class_name( $status ) { switch ( $status ) { case 'init': $class = 'init'; break; case 'validation_failed': $class = 'invalid'; break; case 'acceptance_missing': $class = 'unaccepted'; break; case 'spam': $class = 'spam'; break; case 'aborted': $class = 'aborted'; break; case 'mail_sent': $class = 'sent'; break; case 'mail_failed': $class = 'failed'; break; default: $class = sprintf( 'custom-%s', preg_replace( '/[^0-9a-z]+/i', '-', $status ) ); } return $class; } /** * Returns a set of hidden fields. */ private function form_hidden_fields() { $hidden_fields = array( '_wpcf7' => $this->id(), '_wpcf7_version' => WPCF7_VERSION, '_wpcf7_locale' => $this->locale(), '_wpcf7_unit_tag' => $this->unit_tag(), '_wpcf7_container_post' => 0, '_wpcf7_posted_data_hash' => '', ); if ( in_the_loop() ) { $hidden_fields['_wpcf7_container_post'] = (int) get_the_ID(); } if ( $this->nonce_is_active() and is_user_logged_in() ) { $hidden_fields['_wpnonce'] = wpcf7_create_nonce(); } $hidden_fields += (array) apply_filters( 'wpcf7_form_hidden_fields', array() ); $content = ''; foreach ( $hidden_fields as $name => $value ) { $content .= sprintf( '', esc_attr( $name ), esc_attr( $value ) ) . "\n"; } return '
    ' . "\n" . $content . '
    ' . "\n"; } /** * Returns the visible response output for a form submission. */ public function form_response_output() { $status = 'init'; $class = 'wpcf7-response-output'; $content = ''; if ( $this->is_posted() ) { // Post response output for non-AJAX $submission = WPCF7_Submission::get_instance(); $status = $submission->get_status(); $content = $submission->get_response(); } $atts = array( 'class' => trim( $class ), 'aria-hidden' => 'true', ); $output = sprintf( '
    %2$s
    ', wpcf7_format_atts( $atts ), esc_html( $content ) ); $output = apply_filters( 'wpcf7_form_response_output', $output, $class, $content, $this, $status ); $this->responses_count += 1; return $output; } /** * Returns the response output that is only accessible from screen readers. */ public function screen_reader_response() { $primary_response = ''; $validation_errors = array(); if ( $this->is_posted() ) { // Post response output for non-AJAX $submission = WPCF7_Submission::get_instance(); $primary_response = $submission->get_response(); if ( $invalid_fields = $submission->get_invalid_fields() ) { foreach ( (array) $invalid_fields as $name => $field ) { $list_item = esc_html( $field['reason'] ); if ( $field['idref'] ) { $list_item = sprintf( '%2$s', esc_attr( $field['idref'] ), $list_item ); } $validation_error_id = wpcf7_get_validation_error_reference( $name, $this->unit_tag() ); if ( $validation_error_id ) { $list_item = sprintf( '
  • %2$s
  • ', esc_attr( $validation_error_id ), $list_item ); $validation_errors[] = $list_item; } } } } $primary_response = sprintf( '

    %s

    ', esc_html( $primary_response ) ); $validation_errors = sprintf( '
      %s
    ', implode( "\n", $validation_errors ) ); $output = sprintf( '
    %1$s %2$s
    ', $primary_response, $validation_errors ); return $output; } /** * Returns a validation error for the specified input field. * * @param string $name Input field name. */ public function validation_error( $name ) { $error = ''; if ( $this->is_posted() ) { $submission = WPCF7_Submission::get_instance(); if ( $invalid_field = $submission->get_invalid_field( $name ) ) { $error = trim( $invalid_field['reason'] ); } } if ( ! $error ) { return $error; } $atts = array( 'class' => 'wpcf7-not-valid-tip', 'aria-hidden' => 'true', ); $error = sprintf( '%2$s', wpcf7_format_atts( $atts ), esc_html( $error ) ); return apply_filters( 'wpcf7_validation_error', $error, $name, $this ); } /** * Replaces all form-tags in the form template with corresponding HTML. * * @return string Replaced form content. */ public function replace_all_form_tags() { $manager = WPCF7_FormTagsManager::get_instance(); $form = $this->prop( 'form' ); if ( wpcf7_autop_or_not() ) { $form = $manager->replace_with_placeholders( $form ); $form = wpcf7_autop( $form ); $form = $manager->restore_from_placeholders( $form ); } $form = $manager->replace_all( $form ); $this->scanned_form_tags = $manager->get_scanned_tags(); return $form; } /** * Replaces all form-tags in the form template with corresponding HTML. * * @deprecated 4.6 Use replace_all_form_tags() * * @return string Replaced form content. */ public function form_do_shortcode() { wpcf7_deprecated_function( __METHOD__, '4.6', 'WPCF7_ContactForm::replace_all_form_tags' ); return $this->replace_all_form_tags(); } /** * Scans form-tags from the form template. * * @param string|array|null $cond Optional. Filters. Default null. * @return array Form-tags matching the given filter conditions. */ public function scan_form_tags( $cond = null ) { $manager = WPCF7_FormTagsManager::get_instance(); if ( empty( $this->scanned_form_tags ) ) { $this->scanned_form_tags = $manager->scan( $this->prop( 'form' ) ); } $tags = $this->scanned_form_tags; return $manager->filter( $tags, $cond ); } /** * Scans form-tags from the form template. * * @deprecated 4.6 Use scan_form_tags() * * @param string|array|null $cond Optional. Filters. Default null. * @return array Form-tags matching the given filter conditions. */ public function form_scan_shortcode( $cond = null ) { wpcf7_deprecated_function( __METHOD__, '4.6', 'WPCF7_ContactForm::scan_form_tags' ); return $this->scan_form_tags( $cond ); } /** * Replaces all form-tags in the form template with corresponding HTML. * * @return string Replaced form content. wpcf7_form_elements filters applied. */ public function form_elements() { return apply_filters( 'wpcf7_form_elements', $this->replace_all_form_tags() ); } /** * Collects mail-tags available for this contact form. * * @param string|array $args Optional. Search options. * @return array Mail-tag names. */ public function collect_mail_tags( $args = '' ) { $manager = WPCF7_FormTagsManager::get_instance(); $args = wp_parse_args( $args, array( 'include' => array(), 'exclude' => $manager->collect_tag_types( 'not-for-mail' ), ) ); $tags = $this->scan_form_tags(); $mailtags = array(); foreach ( (array) $tags as $tag ) { $type = $tag->basetype; if ( empty( $type ) ) { continue; } elseif ( ! empty( $args['include'] ) ) { if ( ! in_array( $type, $args['include'] ) ) { continue; } } elseif ( ! empty( $args['exclude'] ) ) { if ( in_array( $type, $args['exclude'] ) ) { continue; } } $mailtags[] = $tag->name; } $mailtags = array_unique( $mailtags ); $mailtags = array_filter( $mailtags ); $mailtags = array_values( $mailtags ); return apply_filters( 'wpcf7_collect_mail_tags', $mailtags, $args, $this ); } /** * Prints a mail-tag suggestion list. * * @param string $template_name Optional. Mail template name. Default 'mail'. */ public function suggest_mail_tags( $template_name = 'mail' ) { $mail = wp_parse_args( $this->prop( $template_name ), array( 'active' => false, 'recipient' => '', 'sender' => '', 'subject' => '', 'body' => '', 'additional_headers' => '', 'attachments' => '', 'use_html' => false, 'exclude_blank' => false, ) ); $mail = array_filter( $mail ); foreach ( (array) $this->collect_mail_tags() as $mail_tag ) { $pattern = sprintf( '/\[(_[a-z]+_)?%s([ \t]+[^]]+)?\]/', preg_quote( $mail_tag, '/' ) ); $used = preg_grep( $pattern, $mail ); echo sprintf( '[%2$s]', 'mailtag code ' . ( $used ? 'used' : 'unused' ), esc_html( $mail_tag ) ); } } /** * Submits this contact form. * * @param string|array $args Optional. Submission options. Default empty. * @return array Result of submission. */ public function submit( $args = '' ) { $args = wp_parse_args( $args, array( 'skip_mail' => ( $this->in_demo_mode() || $this->is_true( 'skip_mail' ) || ! empty( $this->skip_mail ) ), ) ); if ( $this->is_true( 'subscribers_only' ) and ! current_user_can( 'wpcf7_submit', $this->id() ) ) { $result = array( 'contact_form_id' => $this->id(), 'status' => 'error', 'message' => __( "This contact form is available only for logged in users.", 'contact-form-7' ), ); return $result; } $submission = WPCF7_Submission::get_instance( $this, array( 'skip_mail' => $args['skip_mail'], ) ); $result = array( 'contact_form_id' => $this->id(), ); $result += $submission->get_result(); if ( $this->in_demo_mode() ) { $result['demo_mode'] = true; } do_action( 'wpcf7_submit', $this, $result ); return $result; } /** * Returns message used for given status. * * @param string $status Status. * @param bool $filter Optional. Whether filters are applied. Default true. * @return string Message. */ public function message( $status, $filter = true ) { $messages = $this->prop( 'messages' ); $message = isset( $messages[$status] ) ? $messages[$status] : ''; if ( $filter ) { $message = $this->filter_message( $message, $status ); } return $message; } /** * Filters a message. * * @param string $message Message to filter. * @param string $status Optional. Status. Default empty. * @return string Filtered message. */ public function filter_message( $message, $status = '' ) { $message = wpcf7_mail_replace_tags( $message ); $message = apply_filters( 'wpcf7_display_message', $message, $status ); $message = wp_strip_all_tags( $message ); return $message; } /** * Returns the additional setting value searched by name. * * @param string $name Name of setting. * @return string Additional setting value. */ public function pref( $name ) { $settings = $this->additional_setting( $name ); if ( $settings ) { return $settings[0]; } } /** * Returns additional setting values searched by name. * * @param string $name Name of setting. * @param int $max Maximum result item count. * @return array Additional setting values. */ public function additional_setting( $name, $max = 1 ) { $settings = (array) explode( "\n", $this->prop( 'additional_settings' ) ); $pattern = '/^([a-zA-Z0-9_]+)[\t ]*:(.*)$/'; $count = 0; $values = array(); foreach ( $settings as $setting ) { if ( preg_match( $pattern, $setting, $matches ) ) { if ( $matches[1] != $name ) { continue; } if ( ! $max or $count < (int) $max ) { $values[] = trim( $matches[2] ); $count += 1; } } } return $values; } /** * Returns true if the specified setting has a truthy string value. * * @param string $name Name of setting. * @return bool True if the setting value is 'on', 'true', or '1'. */ public function is_true( $name ) { return in_array( $this->pref( $name ), array( 'on', 'true', '1' ), true ); } /** * Returns true if this contact form is in the demo mode. */ public function in_demo_mode() { return $this->is_true( 'demo_mode' ); } /** * Returns true if nonce is active for this contact form. */ public function nonce_is_active() { $is_active = WPCF7_VERIFY_NONCE; if ( $this->is_true( 'subscribers_only' ) ) { $is_active = true; } return (bool) apply_filters( 'wpcf7_verify_nonce', $is_active, $this ); } /** * Returns true if the specified setting has a falsey string value. * * @param string $name Name of setting. * @return bool True if the setting value is 'off', 'false', or '0'. */ public function is_false( $name ) { return in_array( $this->pref( $name ), array( 'off', 'false', '0' ), true ); } /** * Upgrades this contact form properties. */ private function upgrade() { $mail = $this->prop( 'mail' ); if ( is_array( $mail ) and ! isset( $mail['recipient'] ) ) { $mail['recipient'] = get_option( 'admin_email' ); } $this->properties['mail'] = $mail; $messages = $this->prop( 'messages' ); if ( is_array( $messages ) ) { foreach ( wpcf7_messages() as $key => $arr ) { if ( ! isset( $messages[$key] ) ) { $messages[$key] = $arr['default']; } } } $this->properties['messages'] = $messages; } /** * Stores this contact form properties to the database. * * @return int The post ID on success. The value 0 on failure. */ public function save() { $title = wp_slash( $this->title ); $props = wp_slash( $this->get_properties() ); $post_content = implode( "\n", wpcf7_array_flatten( $props ) ); if ( $this->initial() ) { $post_id = wp_insert_post( array( 'post_type' => self::post_type, 'post_status' => 'publish', 'post_title' => $title, 'post_content' => trim( $post_content ), ) ); } else { $post_id = wp_update_post( array( 'ID' => (int) $this->id, 'post_status' => 'publish', 'post_title' => $title, 'post_content' => trim( $post_content ), ) ); } if ( $post_id ) { foreach ( $props as $prop => $value ) { update_post_meta( $post_id, '_' . $prop, wpcf7_normalize_newline_deep( $value ) ); } if ( wpcf7_is_valid_locale( $this->locale ) ) { update_post_meta( $post_id, '_locale', $this->locale ); } add_post_meta( $post_id, '_hash', wpcf7_generate_contact_form_hash( $post_id ), true // Unique ); if ( $this->initial() ) { $this->id = $post_id; do_action( 'wpcf7_after_create', $this ); } else { do_action( 'wpcf7_after_update', $this ); } do_action( 'wpcf7_after_save', $this ); } return $post_id; } /** * Makes a copy of this contact form. * * @return WPCF7_ContactForm New contact form object. */ public function copy() { $new = new self; $new->title = $this->title . '_copy'; $new->locale = $this->locale; $new->properties = $this->properties; return apply_filters( 'wpcf7_copy', $new, $this ); } /** * Deletes this contact form. */ public function delete() { if ( $this->initial() ) { return; } if ( wp_delete_post( $this->id, true ) ) { $this->id = 0; return true; } return false; } /** * Returns a WordPress shortcode for this contact form. */ public function shortcode( $args = '' ) { $args = wp_parse_args( $args, array( 'use_old_format' => false ) ); $title = str_replace( array( '"', '[', ']' ), '', $this->title ); if ( $args['use_old_format'] ) { $old_unit_id = (int) get_post_meta( $this->id, '_old_cf7_unit_id', true ); if ( $old_unit_id ) { $shortcode = sprintf( '[contact-form %1$d "%2$s"]', $old_unit_id, $title ); } else { $shortcode = ''; } } else { $shortcode = sprintf( '[contact-form-7 id="%1$s" title="%2$s"]', $this->hash(), $title ); } return apply_filters( 'wpcf7_contact_form_shortcode', $shortcode, $args, $this ); } } includes/formatting.php000064400000030155150515101440011235 0ustar00/is', static function ( $matches ) use ( &$placeholders ) { $placeholder = sprintf( '<%1$s id="%2$s" />', WPCF7_HTMLFormatter::placeholder_inline, sha1( $matches[0] ) ); list( $placeholder ) = WPCF7_HTMLFormatter::normalize_start_tag( $placeholder ); $placeholders[$placeholder] = $matches[0]; return $placeholder; }, $input ); $formatter = new WPCF7_HTMLFormatter( array( 'auto_br' => $br, ) ); $chunks = $formatter->separate_into_chunks( $input ); $output = $formatter->format( $chunks ); // Restore from placeholders. $output = str_replace( array_keys( $placeholders ), array_values( $placeholders ), $output ); return $output; } /** * Newline preservation help function for wpcf7_autop(). * * @deprecated 5.7 Unnecessary to use any more. * * @param array $matches preg_replace_callback() matches array. * @return string Text including newline placeholders. */ function wpcf7_autop_preserve_newline_callback( $matches ) { return str_replace( "\n", '', $matches[0] ); } /** * Sanitizes the query variables. * * @param string $text Query variable. * @return string Text sanitized. */ function wpcf7_sanitize_query_var( $text ) { $text = wp_unslash( $text ); $text = wp_check_invalid_utf8( $text ); if ( false !== strpos( $text, '<' ) ) { $text = wp_pre_kses_less_than( $text ); $text = wp_strip_all_tags( $text ); } $text = preg_replace( '/%[a-f0-9]{2}/i', '', $text ); $text = preg_replace( '/ +/', ' ', $text ); $text = trim( $text, ' ' ); return $text; } /** * Strips quote characters surrounding the input. * * @param string $text Input text. * @return string Processed output. */ function wpcf7_strip_quote( $text ) { $text = trim( $text ); if ( preg_match( '/^"(.*)"$/s', $text, $matches ) ) { $text = $matches[1]; } elseif ( preg_match( "/^'(.*)'$/s", $text, $matches ) ) { $text = $matches[1]; } return $text; } /** * Navigates through an array, object, or scalar, and * strips quote characters surrounding the each value. * * @param mixed $input The array or string to be processed. * @return mixed Processed value. */ function wpcf7_strip_quote_deep( $input ) { if ( is_string( $input ) ) { return wpcf7_strip_quote( $input ); } if ( is_array( $input ) ) { $result = array(); foreach ( $input as $key => $text ) { $result[$key] = wpcf7_strip_quote_deep( $text ); } return $result; } } /** * Normalizes newline characters. * * @param string $text Input text. * @param string $to Optional. The newline character that is used in the output. * @return string Normalized text. */ function wpcf7_normalize_newline( $text, $to = "\n" ) { if ( ! is_string( $text ) ) { return $text; } $nls = array( "\r\n", "\r", "\n" ); if ( ! in_array( $to, $nls ) ) { return $text; } return str_replace( $nls, $to, $text ); } /** * Navigates through an array, object, or scalar, and * normalizes newline characters in the each value. * * @param mixed $input The array or string to be processed. * @param string $to Optional. The newline character that is used in the output. * @return mixed Processed value. */ function wpcf7_normalize_newline_deep( $input, $to = "\n" ) { if ( is_array( $input ) ) { $result = array(); foreach ( $input as $key => $text ) { $result[$key] = wpcf7_normalize_newline_deep( $text, $to ); } return $result; } return wpcf7_normalize_newline( $input, $to ); } /** * Strips newline characters. * * @param string $text Input text. * @return string Processed one-line text. */ function wpcf7_strip_newline( $text ) { $text = (string) $text; $text = str_replace( array( "\r", "\n" ), '', $text ); return trim( $text ); } /** * Canonicalizes text. * * @param string $text Input text. * @param string|array|object $args Options. * @return string Canonicalized text. */ function wpcf7_canonicalize( $text, $args = '' ) { // for back-compat if ( is_string( $args ) and '' !== $args and false === strpos( $args, '=' ) ) { $args = array( 'strto' => $args, ); } $args = wp_parse_args( $args, array( 'strto' => 'lower', 'strip_separators' => false, ) ); static $charset = null; if ( ! isset( $charset ) ) { $charset = get_option( 'blog_charset' ); $is_utf8 = in_array( $charset, array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ); if ( $is_utf8 ) { $charset = 'UTF-8'; } } $text = html_entity_decode( $text, ENT_QUOTES | ENT_HTML5, $charset ); if ( function_exists( 'mb_convert_kana' ) ) { $text = mb_convert_kana( $text, 'asKV', $charset ); } if ( $args['strip_separators'] ) { $text = preg_replace( '/[\r\n\t ]+/', '', $text ); } else { $text = preg_replace( '/[\r\n\t ]+/', ' ', $text ); } if ( 'lower' == $args['strto'] ) { if ( function_exists( 'mb_strtolower' ) ) { $text = mb_strtolower( $text, $charset ); } else { $text = strtolower( $text ); } } elseif ( 'upper' == $args['strto'] ) { if ( function_exists( 'mb_strtoupper' ) ) { $text = mb_strtoupper( $text, $charset ); } else { $text = strtoupper( $text ); } } $text = trim( $text ); return $text; } /** * Sanitizes Contact Form 7's form unit-tag. * * @param string $tag Unit-tag. * @return string Sanitized unit-tag. */ function wpcf7_sanitize_unit_tag( $tag ) { $tag = preg_replace( '/[^A-Za-z0-9_-]/', '', $tag ); return $tag; } /** * Converts a file name to one that is not executable as a script. * * @param string $filename File name. * @return string Converted file name. */ function wpcf7_antiscript_file_name( $filename ) { $filename = wp_basename( $filename ); $filename = preg_replace( '/[\r\n\t -]+/', '-', $filename ); $filename = preg_replace( '/[\pC\pZ]+/iu', '', $filename ); $parts = explode( '.', $filename ); if ( count( $parts ) < 2 ) { return $filename; } $script_pattern = '/^(php|phtml|pl|py|rb|cgi|asp|aspx)\d?$/i'; $filename = array_shift( $parts ); $extension = array_pop( $parts ); foreach ( (array) $parts as $part ) { if ( preg_match( $script_pattern, $part ) ) { $filename .= '.' . $part . '_'; } else { $filename .= '.' . $part; } } if ( preg_match( $script_pattern, $extension ) ) { $filename .= '.' . $extension . '_.txt'; } else { $filename .= '.' . $extension; } return $filename; } /** * Masks a password with asterisks (*). * * @param int $right Length of right-hand unmasked text. Default 0. * @param int $left Length of left-hand unmasked text. Default 0. * @return string Text of masked password. */ function wpcf7_mask_password( $text, $right = 0, $left = 0 ) { $length = strlen( $text ); $right = absint( $right ); $left = absint( $left ); if ( $length < $right + $left ) { $right = $left = 0; } if ( $length <= 48 ) { $masked = str_repeat( '*', $length - ( $right + $left ) ); } elseif ( $right + $left < 48 ) { $masked = str_repeat( '*', 48 - ( $right + $left ) ); } else { $masked = '****'; } $left_unmasked = $left ? substr( $text, 0, $left ) : ''; $right_unmasked = $right ? substr( $text, -1 * $right ) : ''; $text = $left_unmasked . $masked . $right_unmasked; return $text; } /** * Returns an array of allowed HTML tags and attributes for a given context. * * @param string $context Context used to decide allowed tags and attributes. * @return array Array of allowed HTML tags and their allowed attributes. */ function wpcf7_kses_allowed_html( $context = 'form' ) { static $allowed_tags = array(); if ( isset( $allowed_tags[$context] ) ) { return apply_filters( 'wpcf7_kses_allowed_html', $allowed_tags[$context], $context ); } $allowed_tags[$context] = wp_kses_allowed_html( 'post' ); if ( 'form' === $context ) { $additional_tags_for_form = array( 'button' => array( 'disabled' => true, 'name' => true, 'type' => true, 'value' => true, ), 'datalist' => array(), 'fieldset' => array( 'disabled' => true, 'name' => true, ), 'input' => array( 'accept' => true, 'alt' => true, 'capture' => true, 'checked' => true, 'disabled' => true, 'list' => true, 'max' => true, 'maxlength' => true, 'min' => true, 'minlength' => true, 'multiple' => true, 'name' => true, 'placeholder' => true, 'readonly' => true, 'size' => true, 'step' => true, 'type' => true, 'value' => true, ), 'label' => array( 'for' => true, ), 'legend' => array(), 'meter' => array( 'value' => true, 'min' => true, 'max' => true, 'low' => true, 'high' => true, 'optimum' => true, ), 'optgroup' => array( 'disabled' => true, 'label' => true, ), 'option' => array( 'disabled' => true, 'label' => true, 'selected' => true, 'value' => true, ), 'output' => array( 'for' => true, 'name' => true, ), 'progress' => array( 'max' => true, 'value' => true, ), 'select' => array( 'disabled' => true, 'multiple' => true, 'name' => true, 'size' => true, ), 'textarea' => array( 'cols' => true, 'disabled' => true, 'maxlength' => true, 'minlength' => true, 'name' => true, 'placeholder' => true, 'readonly' => true, 'rows' => true, 'spellcheck' => true, 'wrap' => true, ), ); $additional_tags_for_form = array_map( static function ( $elm ) { $global_attributes = array( 'aria-atomic' => true, 'aria-checked' => true, 'aria-describedby' => true, 'aria-details' => true, 'aria-disabled' => true, 'aria-hidden' => true, 'aria-invalid' => true, 'aria-label' => true, 'aria-labelledby' => true, 'aria-live' => true, 'aria-relevant' => true, 'aria-required' => true, 'aria-selected' => true, 'class' => true, 'data-*' => true, 'id' => true, 'inputmode' => true, 'role' => true, 'style' => true, 'tabindex' => true, 'title' => true, ); return array_merge( $global_attributes, (array) $elm ); }, $additional_tags_for_form ); $allowed_tags[$context] = array_merge( $allowed_tags[$context], $additional_tags_for_form ); } return apply_filters( 'wpcf7_kses_allowed_html', $allowed_tags[$context], $context ); } /** * Sanitizes content for allowed HTML tags for the specified context. * * @param string $input Content to filter. * @param string $context Context used to decide allowed tags and attributes. * @return string Filtered text with allowed HTML tags and attributes intact. */ function wpcf7_kses( $input, $context = 'form' ) { $output = wp_kses( $input, wpcf7_kses_allowed_html( $context ) ); return $output; } /** * Returns a formatted string of HTML attributes. * * @param array $atts Associative array of attribute name and value pairs. * @return string Formatted HTML attributes. */ function wpcf7_format_atts( $atts ) { $atts_filtered = array(); foreach ( $atts as $name => $value ) { $name = strtolower( trim( $name ) ); if ( ! preg_match( '/^[a-z_:][a-z_:.0-9-]*$/', $name ) ) { continue; } static $boolean_attributes = array( 'checked', 'disabled', 'multiple', 'readonly', 'required', 'selected', ); if ( in_array( $name, $boolean_attributes ) and '' === $value ) { $value = false; } if ( is_numeric( $value ) ) { $value = (string) $value; } if ( null === $value or false === $value ) { unset( $atts_filtered[$name] ); } elseif ( true === $value ) { $atts_filtered[$name] = $name; // boolean attribute } elseif ( is_string( $value ) ) { $atts_filtered[$name] = trim( $value ); } } $output = ''; foreach ( $atts_filtered as $name => $value ) { $output .= sprintf( ' %1$s="%2$s"', $name, esc_attr( $value ) ); } return trim( $output ); } includes/html-formatter.php000064400000040503150515101440012026 0ustar00options = wp_parse_args( $args, array( 'auto_br' => true, 'auto_indent' => true, ) ); } /** * Separates the given text into chunks of HTML. Each chunk must be an * associative array that includes 'position', 'type', and 'content' keys. * * @param string $input Text to be separated into chunks. * @return iterable Iterable of chunks. */ public function separate_into_chunks( $input ) { $input_bytelength = strlen( $input ); $position = 0; while ( $position < $input_bytelength ) { $next_tag = preg_match( '/(?:|<(?:\/?)[a-z].*?>)/is', $input, $matches, PREG_OFFSET_CAPTURE, $position ); if ( ! $next_tag ) { yield array( 'position' => $position, 'type' => self::text, 'content' => substr( $input, $position ), ); break; } $next_tag = $matches[0][0]; $next_tag_position = $matches[0][1]; if ( $position < $next_tag_position ) { yield array( 'position' => $position, 'type' => self::text, 'content' => substr( $input, $position, $next_tag_position - $position ), ); } if ( ' $next_tag_position, 'type' => $next_tag_type, 'content' => substr( $input, $next_tag_position, strlen( $next_tag ) ), ); $position = $next_tag_position + strlen( $next_tag ); } } /** * Normalizes content in each chunk. This may change the type and position * of the chunk. * * @param iterable $chunks The original chunks. * @return iterable Normalized chunks. */ public function pre_format( $chunks ) { $position = 0; foreach ( $chunks as $chunk ) { $chunk['position'] = $position; // Standardize newline characters to "\n". $chunk['content'] = str_replace( array( "\r\n", "\r" ), "\n", $chunk['content'] ); if ( $chunk['type'] === self::start_tag ) { list( $chunk['content'] ) = self::normalize_start_tag( $chunk['content'] ); // Replace
    by a line break. if ( $this->options['auto_br'] and preg_match( '/^$/i', $chunk['content'] ) ) { $chunk['type'] = self::text; $chunk['content'] = "\n"; } } yield $chunk; $position = self::calc_next_position( $chunk ); } } /** * Concatenates neighboring text chunks to create a single chunk. * * @param iterable $chunks The original chunks. * @return iterable Processed chunks. */ public function concatenate_texts( $chunks ) { $position = 0; $text_left = null; foreach ( $chunks as $chunk ) { $chunk['position'] = $position; if ( $chunk['type'] === self::text ) { if ( isset( $text_left ) ) { $text_left['content'] .= $chunk['content']; } else { $text_left = $chunk; } continue; } if ( isset( $text_left ) ) { yield $text_left; $chunk['position'] = self::calc_next_position( $text_left ); $text_left = null; } yield $chunk; $position = self::calc_next_position( $chunk ); } if ( isset( $text_left ) ) { yield $text_left; } } /** * Outputs formatted HTML based on the given chunks. * * @param iterable $chunks The original chunks. * @return string Formatted HTML. */ public function format( $chunks ) { $chunks = $this->pre_format( $chunks ); $chunks = $this->concatenate_texts( $chunks ); $this->output = ''; $this->stacked_elements = array(); foreach ( $chunks as $chunk ) { if ( $chunk['type'] === self::text ) { $this->append_text( $chunk['content'] ); } if ( $chunk['type'] === self::start_tag ) { $this->start_tag( $chunk['content'] ); } if ( $chunk['type'] === self::end_tag ) { $this->end_tag( $chunk['content'] ); } if ( $chunk['type'] === self::comment ) { $this->append_comment( $chunk['content'] ); } } // Close all remaining tags. $this->close_all_tags(); return $this->output; } /** * Appends a text node content to the output property. * * @param string $content Text node content. */ public function append_text( $content ) { if ( $this->is_inside( array( 'pre', 'template' ) ) ) { $this->output .= $content; return; } if ( empty( $this->stacked_elements ) or $this->has_parent( 'p' ) or $this->has_parent( self::p_parent_elements ) ) { // Close

    if the content starts with multiple line breaks. if ( preg_match( '/^\s*\n\s*\n\s*/', $content ) ) { $this->end_tag( 'p' ); } // Split up the contents into paragraphs, separated by double line breaks. $paragraphs = preg_split( '/\s*\n\s*\n\s*/', $content ); $paragraphs = array_filter( $paragraphs, static function ( $paragraph ) { return '' !== trim( $paragraph ); } ); $paragraphs = array_values( $paragraphs ); if ( $paragraphs ) { if ( $this->is_inside( 'p' ) ) { $paragraph = array_shift( $paragraphs ); $paragraph = self::normalize_paragraph( $paragraph, $this->options['auto_br'] ); $this->output .= $paragraph; } foreach ( $paragraphs as $paragraph ) { $this->start_tag( 'p' ); $paragraph = ltrim( $paragraph ); $paragraph = self::normalize_paragraph( $paragraph, $this->options['auto_br'] ); $this->output .= $paragraph; } } // Close

    if the content ends with multiple line breaks. if ( preg_match( '/\s*\n\s*\n\s*$/', $content ) ) { $this->end_tag( 'p' ); } // Cases where the content is a single line break. if ( preg_match( '/^\s*\n\s*$/', $content ) ) { $auto_br = $this->options['auto_br'] && $this->is_inside( 'p' ); $content = self::normalize_paragraph( $content, $auto_br ); $this->output .= $content; } } else { $auto_br = $this->options['auto_br'] && $this->has_parent( self::br_parent_elements ); $content = self::normalize_paragraph( $content, $auto_br ); $this->output .= $content; } } /** * Appends a start tag to the output property. * * @param string $tag A start tag. */ public function start_tag( $tag ) { list( $tag, $tag_name ) = self::normalize_start_tag( $tag ); if ( in_array( $tag_name, self::p_child_elements ) ) { if ( ! $this->is_inside( 'p' ) and ! $this->is_inside( self::p_child_elements ) and ! $this->has_parent( self::p_nonparent_elements ) ) { // Open

    if it does not exist. $this->start_tag( 'p' ); } } elseif ( 'p' === $tag_name or in_array( $tag_name, self::p_parent_elements ) or in_array( $tag_name, self::p_nonparent_elements ) ) { // Close

    if it exists. $this->end_tag( 'p' ); } if ( 'dd' === $tag_name or 'dt' === $tag_name ) { // Close

    and
    if closing tag is omitted. $this->end_tag( 'dd' ); $this->end_tag( 'dt' ); } if ( 'li' === $tag_name ) { // Close
  • if closing tag is omitted. $this->end_tag( 'li' ); } if ( 'optgroup' === $tag_name ) { // Close if closing tag is omitted. $this->end_tag( 'option' ); $this->end_tag( 'optgroup' ); } if ( 'option' === $tag_name ) { // Close