| @@ -31,131 +31,33 @@ | ||
| 31 | 31 | * @since 1.0.5 |
| 32 | 32 | * @return array<string, string> Associative array of translated validation messages for frontend use. |
| 33 | 33 | */ |
| 34 | 34 | public static function get_frontend_validation_messages() { |
| 35 | - $translatable_array = self::dynamic_validation_messages(); | |
| 35 | + $translatable_array = [ | |
| 36 | + 'valid_phone_number' => __( 'Please enter a valid phone number.', 'sureforms' ), | |
| 37 | + 'valid_url' => __( 'Please enter a valid URL.', 'sureforms' ), | |
| 38 | + 'confirm_email_same' => __( 'Confirmation email does not match.', 'sureforms' ), | |
| 39 | + 'valid_email' => __( 'Please enter a valid email address.', 'sureforms' ), | |
| 40 | + 'confirm_password_same' => __( 'Confirmation password does not match.', 'sureforms' ), | |
| 36 | 41 | |
| 37 | - /** | |
| 38 | - * Filter for frontend validation messages. | |
| 39 | - * | |
| 40 | - * This filter allows developers to add or modify the default validation messages. | |
| 41 | - * Primarily intended for enabling custom validation messages and supporting pro functionality. | |
| 42 | - * | |
| 43 | - * @internal This filter is primarily used for internal purposes and pro functionality. | |
| 44 | - */ | |
| 45 | - return apply_filters( 'srfm_frontend_validation_messages', $translatable_array ); | |
| 46 | - } | |
| 47 | - | |
| 48 | - /** | |
| 49 | - * Retrieve default dynamic validation messages. | |
| 50 | - * | |
| 51 | - * @since 1.2.1 | |
| 52 | - * @return array<string, string> Associative array of translated validation messages for dynamic use. | |
| 53 | - */ | |
| 54 | - public static function dynamic_validation_messages() { | |
| 55 | - $translatable_array = self::dynamic_messages(); | |
| 56 | - | |
| 57 | - /** | |
| 58 | - * Filter for dynamic validation messages. | |
| 59 | - * | |
| 60 | - * The `srfm_dynamic_validation_messages` filter allows developers to add or modify | |
| 61 | - * the default dynamic validation messages. | |
| 62 | - * This is primarily intended for enabling custom validation messages and supporting pro functionality. | |
| 63 | - * | |
| 64 | - * @internal This filter is primarily used for internal purposes and pro functionality. | |
| 65 | - */ | |
| 66 | - $filtered_array = apply_filters( 'srfm_dynamic_validation_messages', $translatable_array ); | |
| 67 | - | |
| 68 | - $dynamic_options = get_option( 'srfm_default_dynamic_block_option', [] ); | |
| 69 | - if ( ! empty( $dynamic_options ) && is_array( $dynamic_options ) ) { | |
| 70 | - foreach ( $dynamic_options as $key => $value ) { | |
| 71 | - if ( isset( $filtered_array[ $key ] ) ) { | |
| 72 | - $filtered_array[ $key ] = $value; | |
| 73 | - } | |
| 74 | - } | |
| 75 | - } | |
| 76 | - | |
| 77 | - return $filtered_array; | |
| 78 | - } | |
| 79 | - | |
| 80 | - /** | |
| 81 | - * Dynamic messages array | |
| 82 | - * | |
| 83 | - * @since 1.2.1 | |
| 84 | - * @return array<string, string> Associative array of translated dynamic messages. | |
| 85 | - */ | |
| 86 | - public static function dynamic_messages() { | |
| 87 | - return [ | |
| 88 | - 'srfm_valid_phone_number' => __( 'Enter a valid phone number.', 'sureforms' ), | |
| 89 | - 'srfm_valid_url' => __( 'Enter a valid URL.', 'sureforms' ), | |
| 90 | - 'srfm_confirm_email_same' => __( 'Confirmation email does not match.', 'sureforms' ), | |
| 91 | - 'srfm_valid_email' => __( 'Enter a valid email address.', 'sureforms' ), | |
| 92 | - | |
| 93 | - /* translators: %s represents the minimum number of characters required */ | |
| 94 | - 'srfm_textarea_min_chars' => __( 'Please enter at least %s characters.', 'sureforms' ), | |
| 95 | - | |
| 96 | - /* translators: %s: maximum characters allowed before the @ symbol. */ | |
| 97 | - 'srfm_email_local_max_length' => __( 'The part before @ may not exceed %s characters.', 'sureforms' ), | |
| 98 | - | |
| 99 | - /* translators: %s: maximum characters allowed after the @ symbol. */ | |
| 100 | - 'srfm_email_domain_max_length' => __( 'The part after @ may not exceed %s characters.', 'sureforms' ), | |
| 101 | - | |
| 102 | 42 | /* translators: %s represents the minimum acceptable value */ |
| 103 | - 'srfm_input_min_value' => __( 'Minimum value is %s.', 'sureforms' ), | |
| 43 | + 'input_min_value' => __( 'Minimum value is %s', 'sureforms' ), | |
| 104 | 44 | |
| 105 | 45 | /* translators: %s represents the maximum acceptable value */ |
| 106 | - 'srfm_input_max_value' => __( 'Maximum value is %s.', 'sureforms' ), | |
| 46 | + 'input_max_value' => __( 'Maximum value is %s', 'sureforms' ), | |
| 107 | 47 | |
| 108 | - /* translators: %s represents the minimum number of options to select */ | |
| 109 | - 'srfm_dropdown_min_selections' => __( 'Select at least %s options.', 'sureforms' ), | |
| 48 | + /* translators: %s represents the minimum number of selections required */ | |
| 49 | + 'dropdown_min_selections' => __( 'Minimum %s selections are required', 'sureforms' ), | |
| 110 | 50 | |
| 111 | - /* translators: %s represents the maximum number of options that can be selected */ | |
| 112 | - 'srfm_dropdown_max_selections' => __( 'You can select up to %s options.', 'sureforms' ), | |
| 51 | + /* translators: %s represents the maximum number of selections allowed */ | |
| 52 | + 'dropdown_max_selections' => __( 'Maximum %s selections are allowed', 'sureforms' ), | |
| 113 | 53 | |
| 114 | - /* translators: %s represents the minimum number of options to select */ | |
| 115 | - 'srfm_multi_choice_min_selections' => __( 'Select at least %s options.', 'sureforms' ), | |
| 54 | + /* translators: %s represents the minimum number of characters required */ | |
| 55 | + 'multi_choice_min_selections' => __( 'Minimum %s selections are required', 'sureforms' ), | |
| 116 | 56 | |
| 117 | - /* translators: %s represents the maximum number of options that can be selected */ | |
| 118 | - 'srfm_multi_choice_max_selections' => __( 'You can select up to %s options.', 'sureforms' ), | |
| 57 | + /* translators: %s represents the maximum number of characters allowed */ | |
| 58 | + 'multi_choice_max_selections' => __( 'Maximum %s selections are allowed', 'sureforms' ), | |
| 119 | 59 | ]; |
| 120 | - } | |
| 121 | 60 | |
| 122 | - /** | |
| 123 | - * Source (untranslated) versions of every dynamic validation message. | |
| 124 | - * | |
| 125 | - * Used by the multilingual integration to register a stable English key with | |
| 126 | - * the active provider (e.g., WPML String Translation) regardless of the | |
| 127 | - * site's current WP locale. The keys match {@see dynamic_messages()}; the | |
| 128 | - * values are the raw English source strings without any `__()` wrapping, | |
| 129 | - * so they don't shift when the site locale changes. | |
| 130 | - * | |
| 131 | - * @since 2.11.0 | |
| 132 | - * @return array<string, string> | |
| 133 | - */ | |
| 134 | - public static function dynamic_messages_source() { | |
| 135 | - return [ | |
| 136 | - 'srfm_valid_phone_number' => 'Enter a valid phone number.', | |
| 137 | - 'srfm_valid_url' => 'Enter a valid URL.', | |
| 138 | - 'srfm_confirm_email_same' => 'Confirmation email does not match.', | |
| 139 | - 'srfm_valid_email' => 'Enter a valid email address.', | |
| 140 | - 'srfm_textarea_min_chars' => 'Please enter at least %s characters.', | |
| 141 | - 'srfm_email_local_max_length' => 'The part before @ may not exceed %s characters.', | |
| 142 | - 'srfm_email_domain_max_length' => 'The part after @ may not exceed %s characters.', | |
| 143 | - 'srfm_input_min_value' => 'Minimum value is %s.', | |
| 144 | - 'srfm_input_max_value' => 'Maximum value is %s.', | |
| 145 | - 'srfm_dropdown_min_selections' => 'Select at least %s options.', | |
| 146 | - 'srfm_dropdown_max_selections' => 'You can select up to %s options.', | |
| 147 | - 'srfm_multi_choice_min_selections' => 'Select at least %s options.', | |
| 148 | - 'srfm_multi_choice_max_selections' => 'You can select up to %s options.', | |
| 149 | - ]; | |
| 150 | - } | |
| 151 | - | |
| 152 | - /** | |
| 153 | - * Get default form restriction message. | |
| 154 | - * | |
| 155 | - * @since 1.10.1 | |
| 156 | - * @return string Translated default form restriction message. | |
| 157 | - */ | |
| 158 | - public static function get_default_form_restriction_message() { | |
| 159 | - return __( 'This form is now closed as we have reached the maximum number of entries.', 'sureforms' ); | |
| 61 | + return apply_filters( 'srfm_frontend_validation_messages', $translatable_array ); | |
| 160 | 62 | } |
| 161 | 63 | } |