class-evf-setting-utilities.php
3 months ago
class-evf-settings-advanced.php
1 month ago
class-evf-settings-email.php
1 month ago
class-evf-settings-general.php
3 months ago
class-evf-settings-integrations.php
3 months ago
class-evf-settings-page.php
3 months ago
class-evf-settings-payments.php
1 month ago
class-evf-settings-reporting.php
2 years ago
class-evf-settings-security.php
3 months ago
class-evf-settings-validation.php
11 months ago
class-evf-settings-general.php
263 lines
| 1 | <?php |
| 2 | /** |
| 3 | * EverestForms General Settings |
| 4 | * |
| 5 | * @package EverestForms\Admin |
| 6 | * @version 1.0.0 |
| 7 | */ |
| 8 | |
| 9 | defined( 'ABSPATH' ) || exit; |
| 10 | |
| 11 | if ( class_exists( 'EVF_Settings_General', false ) ) { |
| 12 | return new EVF_Settings_General(); |
| 13 | } |
| 14 | |
| 15 | /** |
| 16 | * EVF_Settings_General. |
| 17 | */ |
| 18 | class EVF_Settings_General extends EVF_Settings_Page { |
| 19 | |
| 20 | /** |
| 21 | * Constructor. |
| 22 | */ |
| 23 | public function __construct() { |
| 24 | $this->id = 'general'; |
| 25 | $this->label = esc_html__( 'General', 'everest-forms' ); |
| 26 | |
| 27 | parent::__construct(); |
| 28 | |
| 29 | add_action( 'everest_forms_sections_' . $this->id, array( $this, 'output_sections' ) ); |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Get sections for general tab. |
| 34 | * |
| 35 | * @return array |
| 36 | */ |
| 37 | public function get_sections() { |
| 38 | $sections = array( |
| 39 | 'validation_messages' => esc_html__( 'Validation Messages', 'everest-forms' ), |
| 40 | 'miscellaneous' => esc_html__( 'Miscellaneous', 'everest-forms' ), |
| 41 | ); |
| 42 | |
| 43 | return apply_filters( 'everest_forms_get_sections_' . $this->id, $sections ); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Output sections in navigation sidebar. |
| 48 | */ |
| 49 | public function output_sections() { |
| 50 | global $current_section; |
| 51 | |
| 52 | $sections = $this->get_sections(); |
| 53 | |
| 54 | if ( empty( $sections ) || 1 === count( $sections ) ) { |
| 55 | return; |
| 56 | } |
| 57 | |
| 58 | $current_section = isset( $_GET['section'] ) ? sanitize_text_field( wp_unslash( $_GET['section'] ) ) : 'validation_messages'; |
| 59 | |
| 60 | echo '<ul class="evf-subsections">'; |
| 61 | |
| 62 | foreach ( $sections as $id => $label ) { |
| 63 | $url = add_query_arg( |
| 64 | array( |
| 65 | 'page' => 'evf-settings', |
| 66 | 'tab' => $this->id, |
| 67 | 'section' => sanitize_title( $id ), |
| 68 | ), |
| 69 | admin_url( 'admin.php' ) |
| 70 | ); |
| 71 | |
| 72 | echo '<li><a href="' . esc_url( $url ) . '" class="' . ( $current_section === $id ? 'current' : '' ) . '">' . esc_html( $label ) . '</a></li>'; |
| 73 | } |
| 74 | |
| 75 | echo '</ul>'; |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Get settings array based on current section. |
| 80 | * |
| 81 | * @return array |
| 82 | */ |
| 83 | public function get_settings() { |
| 84 | global $current_section; |
| 85 | |
| 86 | $current_section = isset( $_GET['section'] ) ? sanitize_text_field( wp_unslash( $_GET['section'] ) ) : 'validation_messages'; |
| 87 | |
| 88 | switch ( $current_section ) { |
| 89 | case 'miscellaneous': |
| 90 | $settings = $this->get_miscellaneous_settings(); |
| 91 | break; |
| 92 | default: |
| 93 | $settings = $this->get_validation_messages_settings(); |
| 94 | break; |
| 95 | } |
| 96 | |
| 97 | return apply_filters( 'everest_forms_get_settings_' . $this->id, $settings, $current_section ); |
| 98 | } |
| 99 | |
| 100 | |
| 101 | /** |
| 102 | * Get settings array. |
| 103 | * |
| 104 | * @return array |
| 105 | */ |
| 106 | // public function get_settings() { |
| 107 | // $settings = apply_filters( |
| 108 | // 'everest_forms_general_settings', |
| 109 | // array( |
| 110 | // array( |
| 111 | // 'title' => esc_html__( 'General Options', 'everest-forms' ), |
| 112 | // 'type' => 'title', |
| 113 | // 'desc' => '', |
| 114 | // 'id' => 'general_options', |
| 115 | // ), |
| 116 | // array( |
| 117 | // 'title' => esc_html__( 'Disable User Details', 'everest-forms' ), |
| 118 | // 'desc' => esc_html__( 'Disable storing the IP address and User Agent on all forms.', 'everest-forms' ), |
| 119 | // 'id' => 'everest_forms_disable_user_details', |
| 120 | // 'default' => 'no', |
| 121 | // 'type' => 'toggle', |
| 122 | // 'desc_tip' => true, |
| 123 | // ), |
| 124 | // array( |
| 125 | // 'title' => esc_html__( 'Enable Log', 'everest-forms' ), |
| 126 | // 'desc' => esc_html__( 'Enable storing the logs.', 'everest-forms' ), |
| 127 | // 'id' => 'everest_forms_enable_log', |
| 128 | // 'default' => 'no', |
| 129 | // 'type' => 'toggle', |
| 130 | // 'desc_tip' => true, |
| 131 | // ), |
| 132 | // array( |
| 133 | // 'type' => 'sectionend', |
| 134 | // 'id' => 'general_options', |
| 135 | // ), |
| 136 | // ) |
| 137 | // ); |
| 138 | |
| 139 | // return apply_filters( 'everest_forms_get_settings_' . $this->id, $settings ); |
| 140 | // } |
| 141 | |
| 142 | public function get_miscellaneous_settings() { |
| 143 | $settings = apply_filters( |
| 144 | 'everest_forms_general_miscellaneous_settings', |
| 145 | array( |
| 146 | array( |
| 147 | 'title' => esc_html__( 'Miscellaneous Options', 'everest-forms' ), |
| 148 | 'type' => 'title', |
| 149 | 'desc' => '', |
| 150 | 'id' => 'general_miscellaneous_options', |
| 151 | ), |
| 152 | array( |
| 153 | 'title' => esc_html__( 'Disable User Details', 'everest-forms' ), |
| 154 | 'desc' => esc_html__( 'Disable storing the IP address and User Agent on all forms.', 'everest-forms' ), |
| 155 | 'id' => 'everest_forms_disable_user_details', |
| 156 | 'default' => 'no', |
| 157 | 'type' => 'toggle', |
| 158 | 'desc_tip' => true, |
| 159 | ), |
| 160 | array( |
| 161 | 'type' => 'sectionend', |
| 162 | 'id' => 'general_miscellaneous_options', |
| 163 | ), |
| 164 | ) |
| 165 | ); |
| 166 | return apply_filters( 'everest_forms_get_settings_' . $this->id, $settings ); |
| 167 | } |
| 168 | |
| 169 | public function get_validation_messages_settings() { |
| 170 | $settings = apply_filters( |
| 171 | 'everest_forms_validation_settings', |
| 172 | array( |
| 173 | array( |
| 174 | 'title' => esc_html__( 'Validation Messages', 'everest-forms' ), |
| 175 | 'type' => 'title', |
| 176 | 'desc' => '', |
| 177 | 'id' => 'validation_options', |
| 178 | ), |
| 179 | array( |
| 180 | 'title' => esc_html__( 'Required', 'everest-forms' ), |
| 181 | 'desc' => esc_html__( 'Enter the message for the required form field', 'everest-forms' ), |
| 182 | 'id' => 'everest_forms_required_validation', |
| 183 | 'type' => 'text', |
| 184 | 'desc_tip' => true, |
| 185 | 'css' => 'min-width: 350px;', |
| 186 | 'default' => __( 'This field is required.', 'everest-forms' ), |
| 187 | ), |
| 188 | array( |
| 189 | 'title' => esc_html__( 'Website URL', 'everest-forms' ), |
| 190 | 'desc' => esc_html__( 'Enter the message for the valid website url', 'everest-forms' ), |
| 191 | 'id' => 'everest_forms_url_validation', |
| 192 | 'type' => 'text', |
| 193 | 'desc_tip' => true, |
| 194 | 'css' => 'min-width: 350px;', |
| 195 | 'default' => __( 'Please enter a valid URL.', 'everest-forms' ), |
| 196 | ), |
| 197 | array( |
| 198 | 'title' => esc_html__( 'Email', 'everest-forms' ), |
| 199 | 'desc' => esc_html__( 'Enter the message for the valid email', 'everest-forms' ), |
| 200 | 'id' => 'everest_forms_email_validation', |
| 201 | 'type' => 'text', |
| 202 | 'desc_tip' => true, |
| 203 | 'css' => 'min-width: 350px;', |
| 204 | 'default' => __( 'Please enter a valid email address.', 'everest-forms' ), |
| 205 | ), |
| 206 | array( |
| 207 | 'title' => esc_html__( 'Email Suggestion', 'everest-forms' ), |
| 208 | 'desc' => esc_html__( 'Enter the message for the valid email suggestion', 'everest-forms' ), |
| 209 | 'id' => 'everest_forms_email_suggestion', |
| 210 | 'type' => 'text', |
| 211 | 'desc_tip' => true, |
| 212 | 'css' => 'min-width: 350px;', |
| 213 | 'default' => __( 'Did you mean {suggestion}?', 'everest-forms' ), |
| 214 | ), |
| 215 | array( |
| 216 | 'title' => esc_html__( 'Confirm Value', 'everest-forms' ), |
| 217 | 'desc' => esc_html__( 'Enter the message for confirm field value.', 'everest-forms' ), |
| 218 | 'id' => 'everest_forms_confirm_validation', |
| 219 | 'type' => 'text', |
| 220 | 'desc_tip' => true, |
| 221 | 'css' => 'min-width: 350px;', |
| 222 | 'default' => __( 'Field values do not match.', 'everest-forms' ), |
| 223 | ), |
| 224 | array( |
| 225 | 'title' => esc_html__( 'Checkbox Selection Limit', 'everest-forms' ), |
| 226 | 'desc' => esc_html__( 'Enter the message for the checkbox selection limit.', 'everest-forms' ), |
| 227 | 'id' => 'everest_forms_check_limit_validation', |
| 228 | 'type' => 'text', |
| 229 | 'desc_tip' => true, |
| 230 | 'css' => 'min-width: 350px;', |
| 231 | 'default' => __( 'You have exceeded number of allowed selections: {#}.', 'everest-forms' ), |
| 232 | ), |
| 233 | array( |
| 234 | 'title' => esc_html__( 'Number', 'everest-forms' ), |
| 235 | 'desc' => esc_html__( 'Enter the message for the valid number', 'everest-forms' ), |
| 236 | 'id' => 'everest_forms_number_validation', |
| 237 | 'type' => 'text', |
| 238 | 'desc_tip' => true, |
| 239 | 'css' => 'min-width: 350px;', |
| 240 | 'default' => __( 'Please enter a valid number.', 'everest-forms' ), |
| 241 | ), |
| 242 | array( |
| 243 | 'type' => 'sectionend', |
| 244 | 'id' => 'validation_options', |
| 245 | ), |
| 246 | ) |
| 247 | ); |
| 248 | |
| 249 | return apply_filters( 'everest_forms_get_settings_' . $this->id, $settings ); |
| 250 | } |
| 251 | |
| 252 | /** |
| 253 | * Save settings. |
| 254 | */ |
| 255 | public function save() { |
| 256 | $settings = $this->get_settings(); |
| 257 | |
| 258 | EVF_Admin_Settings::save_fields( $settings ); |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | return new EVF_Settings_General(); |
| 263 |