class-evf-settings-email.php
3 years ago
class-evf-settings-general.php
5 years ago
class-evf-settings-integrations.php
6 years ago
class-evf-settings-misc.php
2 years ago
class-evf-settings-page.php
7 years ago
class-evf-settings-recaptcha.php
2 years ago
class-evf-settings-validation.php
6 years ago
class-evf-settings-validation.php
129 lines
| 1 | <?php |
| 2 | /** |
| 3 | * EverestForms Validation Settings |
| 4 | * |
| 5 | * @package EverestForms\Admin |
| 6 | * @version 1.0.0 |
| 7 | */ |
| 8 | |
| 9 | defined( 'ABSPATH' ) || exit; |
| 10 | |
| 11 | if ( class_exists( 'EVF_Settings_Validation', false ) ) { |
| 12 | return new EVF_Settings_Validation(); |
| 13 | } |
| 14 | |
| 15 | /** |
| 16 | * EVF_Settings_Validation. |
| 17 | */ |
| 18 | class EVF_Settings_Validation extends EVF_Settings_Page { |
| 19 | |
| 20 | /** |
| 21 | * Constructor. |
| 22 | */ |
| 23 | public function __construct() { |
| 24 | $this->id = 'validation'; |
| 25 | $this->label = __( 'Validations', 'everest-forms' ); |
| 26 | |
| 27 | parent::__construct(); |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * Get settings array. |
| 32 | * |
| 33 | * @return array |
| 34 | */ |
| 35 | public function get_settings() { |
| 36 | $settings = apply_filters( |
| 37 | 'everest_forms_validation_settings', |
| 38 | array( |
| 39 | array( |
| 40 | 'title' => esc_html__( 'Validation Messages', 'everest-forms' ), |
| 41 | 'type' => 'title', |
| 42 | 'desc' => 'Validation Messages for Form Fields.', |
| 43 | 'id' => 'validation_options', |
| 44 | ), |
| 45 | array( |
| 46 | 'title' => esc_html__( 'Required', 'everest-forms' ), |
| 47 | 'desc' => esc_html__( 'Enter the message for the required form field', 'everest-forms' ), |
| 48 | 'id' => 'everest_forms_required_validation', |
| 49 | 'type' => 'text', |
| 50 | 'desc_tip' => true, |
| 51 | 'css' => 'min-width: 350px;', |
| 52 | 'default' => esc_html__( 'This field is required.', 'everest-forms' ), |
| 53 | ), |
| 54 | array( |
| 55 | 'title' => esc_html__( 'Website URL', 'everest-forms' ), |
| 56 | 'desc' => esc_html__( 'Enter the message for the valid website url', 'everest-forms' ), |
| 57 | 'id' => 'everest_forms_url_validation', |
| 58 | 'type' => 'text', |
| 59 | 'desc_tip' => true, |
| 60 | 'css' => 'min-width: 350px;', |
| 61 | 'default' => esc_html__( 'Please enter a valid URL.', 'everest-forms' ), |
| 62 | ), |
| 63 | array( |
| 64 | 'title' => esc_html__( 'Email', 'everest-forms' ), |
| 65 | 'desc' => esc_html__( 'Enter the message for the valid email', 'everest-forms' ), |
| 66 | 'id' => 'everest_forms_email_validation', |
| 67 | 'type' => 'text', |
| 68 | 'desc_tip' => true, |
| 69 | 'css' => 'min-width: 350px;', |
| 70 | 'default' => esc_html__( 'Please enter a valid email address.', 'everest-forms' ), |
| 71 | ), |
| 72 | array( |
| 73 | 'title' => esc_html__( 'Email Suggestion', 'everest-forms' ), |
| 74 | 'desc' => esc_html__( 'Enter the message for the valid email suggestion', 'everest-forms' ), |
| 75 | 'id' => 'everest_forms_email_suggestion', |
| 76 | 'type' => 'text', |
| 77 | 'desc_tip' => true, |
| 78 | 'css' => 'min-width: 350px;', |
| 79 | 'default' => esc_html__( 'Did you mean {suggestion}?', 'everest-forms' ), |
| 80 | ), |
| 81 | array( |
| 82 | 'title' => esc_html__( 'Confirm Value', 'everest-forms' ), |
| 83 | 'desc' => esc_html__( 'Enter the message for confirm field value.', 'everest-forms' ), |
| 84 | 'id' => 'everest_forms_confirm_validation', |
| 85 | 'type' => 'text', |
| 86 | 'desc_tip' => true, |
| 87 | 'css' => 'min-width: 350px;', |
| 88 | 'default' => esc_html__( 'Field values do not match.', 'everest-forms' ), |
| 89 | ), |
| 90 | array( |
| 91 | 'title' => esc_html__( 'Checkbox Selection Limit', 'everest-forms' ), |
| 92 | 'desc' => esc_html__( 'Enter the message for the checkbox selection limit.', 'everest-forms' ), |
| 93 | 'id' => 'everest_forms_check_limit_validation', |
| 94 | 'type' => 'text', |
| 95 | 'desc_tip' => true, |
| 96 | 'css' => 'min-width: 350px;', |
| 97 | 'default' => esc_html__( 'You have exceeded number of allowed selections: {#}.', 'everest-forms' ), |
| 98 | ), |
| 99 | array( |
| 100 | 'title' => esc_html__( 'Number', 'everest-forms' ), |
| 101 | 'desc' => esc_html__( 'Enter the message for the valid number', 'everest-forms' ), |
| 102 | 'id' => 'everest_forms_number_validation', |
| 103 | 'type' => 'text', |
| 104 | 'desc_tip' => true, |
| 105 | 'css' => 'min-width: 350px;', |
| 106 | 'default' => esc_html__( 'Please enter a valid number.', 'everest-forms' ), |
| 107 | ), |
| 108 | array( |
| 109 | 'type' => 'sectionend', |
| 110 | 'id' => 'validation_options', |
| 111 | ), |
| 112 | ) |
| 113 | ); |
| 114 | |
| 115 | return apply_filters( 'everest_forms_get_settings_' . $this->id, $settings ); |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * Save settings. |
| 120 | */ |
| 121 | public function save() { |
| 122 | $settings = $this->get_settings(); |
| 123 | |
| 124 | EVF_Admin_Settings::save_fields( $settings ); |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | return new EVF_Settings_Validation(); |
| 129 |