__('File exceeds maximum allowed size', 'contact-forms'), 'invalidType' => __('File type not allowed', 'contact-forms'), 'fileAdded' => __('File added', 'contact-forms'), 'filesAdded' => __('files added', 'contact-forms'), 'fileRemoved' => __('File removed', 'contact-forms'), 'errors' => __('Errors', 'contact-forms'), 'removeFile' => __('Remove', 'contact-forms'), )); // libphonenumber-js for phone validation (min bundle, ~175KB) wp_enqueue_script( 'libphonenumber', plugins_url('assets/js/frontend/libphonenumber-min.js', ACCUA_FORMS_FILE), array(), // No dependencies '1.12.5', // libphonenumber-js version true // Load in footer ); // Phone validation for telephone fields (WCAG 2.2 AA compliant) // Uses libphonenumber-js for proper international phone validation wp_enqueue_script( 'accua-phone-validation', plugins_url('assets/js/frontend/phone-validation.js', ACCUA_FORMS_FILE), array('jquery', 'libphonenumber'), ACCUA_FORMS_JS_VERSION, true // Load in footer ); // Localized strings for phone validation wp_localize_script('accua-phone-validation', 'accuaPhoneL10n', array( 'phoneError' => __('Please enter a valid phone number (e.g. +39 333 1234567)', 'contact-forms'), )); // Post select - AJAX searchable dropdown for post-select fields (WCAG 2.2 AA compliant) wp_enqueue_script( 'accua-post-select', plugins_url('assets/js/frontend/post-select.js', ACCUA_FORMS_FILE), array(), // No dependencies - vanilla JS ACCUA_FORMS_JS_VERSION, true // Load in footer ); // Localized strings for post select wp_localize_script('accua-post-select', 'accuaPostSelectI18n', array( 'select' => __('Select...', 'contact-forms'), 'search' => __('Search...', 'contact-forms'), 'loading' => __('Loading...', 'contact-forms'), 'noResults' => __('No results found', 'contact-forms'), 'loadMore' => __('Loading more...', 'contact-forms'), )); /** * Action fired after Contact Forms enqueues its scripts and styles. * External plugins can use this to enqueue their own field-specific assets. */ do_action( 'accua_forms_enqueue_scripts' ); $first = FALSE; } } // Runs at init priority 5 so that: // 1. Translations are safe to use (after_setup_theme has fired before init). // 2. SMTP plugins (WP Mail SMTP etc.) have already registered their phpmailer_init hooks // at plugins_loaded priority ≤ 10, so emails sent here still go through SMTP. add_action('init', 'accua_form_init', 5); function accua_form_init(){ if (!defined('DOING_CRON')) { AccuaForm::isValid(); } } add_action('wp_ajax_accua_form_submit', 'accua_form_ajax_submit_handler'); add_action('wp_ajax_nopriv_accua_form_submit', 'accua_form_ajax_submit_handler'); function accua_form_ajax_submit_handler(){ header('Content-Type: text/html; charset='.get_option('blog_charset')); header('Cache-Control: no-transform'); echo '
'; $result = AccuaForm::ajaxSubmit(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- JSON encoded data for JavaScript consumption print _accua_forms_json_encode($result); echo ''; // phpcs:disable PluginCheck.CodeAnalysis.Heredoc.NotAllowed -- Heredoc for inline JavaScript echo <<