PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.5.5
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.5.5
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/controllers/FrmSettingsController.php +59 -201 6.255.5.5 View file →
@@ -4,17 +4,8 @@
4 4 }
5 5
6 6 class FrmSettingsController {
7 7
8 - /**
9 - * Payments sections are removed from the top level and added to a payments section.
10 - *
11 - * @since 6.22.1
12 - *
13 - * @var array
14 - */
15 - private static $removed_payments_sections = array();
16 -
17 8 public static function menu() {
18 9 // Make sure admins can see the menu items
19 10 FrmAppHelper::force_capability( 'frm_change_settings' );
20 11
@@ -20,18 +11,11 @@
20 11
21 12 add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' );
22 13 }
23 14
24 - /**
25 - * Include license box template on demand.
26 - *
27 - * @return void
28 - */
29 15 public static function license_box() {
30 - if ( ! current_user_can( 'activate_plugins' ) ) {
31 - return;
32 - }
33 - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php';
16 + $a = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' );
17 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' );
34 18 }
35 19
36 20 public static function display_form( $errors = array(), $message = '' ) {
37 21 global $frm_vars;
@@ -43,71 +27,38 @@
43 27
44 28 $sections = self::get_settings_tabs();
45 29 $current = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' );
46 30
47 - if ( in_array( $current, array( 'stripe_settings', 'square_settings', 'authorize_net_settings', 'paypal_settings' ), true ) ) {
48 - $current = 'payments_settings';
49 - }
50 -
51 - require FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php';
31 + require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' );
52 32 }
53 33
54 - /**
55 - * Get sections to use for Global Settings.
56 - *
57 - * @return array<array>
58 - */
59 34 private static function get_settings_tabs() {
60 35 $sections = array(
61 - 'general' => array(
62 - 'class' => self::class,
36 + 'general' => array(
37 + 'class' => __CLASS__,
63 38 'function' => 'general_settings',
64 39 'name' => __( 'General Settings', 'formidable' ),
65 40 'icon' => 'frm_icon_font frm_settings_icon',
66 41 ),
67 - 'messages' => array(
68 - 'class' => self::class,
42 + 'messages' => array(
43 + 'class' => __CLASS__,
69 44 'function' => 'message_settings',
70 45 'name' => __( 'Message Defaults', 'formidable' ),
71 46 'icon' => 'frm_icon_font frm_stamp_icon',
72 47 ),
73 - 'permissions' => array(
74 - 'class' => self::class,
48 + 'permissions' => array(
49 + 'class' => __CLASS__,
75 50 'function' => 'permission_settings',
76 51 'name' => __( 'Permissions', 'formidable' ),
77 52 'icon' => 'frm_icon_font frm_lock_icon',
78 53 ),
79 - 'payments' => array(
80 - 'name' => __( 'Payments', 'formidable' ),
81 - 'icon' => 'frm_icon_font frm_simple_cc_icon',
82 - 'class' => self::class,
83 - 'function' => 'payments_settings',
84 - ),
85 - 'custom_css' => array(
86 - 'class' => 'FrmStylesController',
87 - 'function' => 'custom_css',
88 - 'name' => __( 'Custom CSS', 'formidable' ),
89 - 'icon' => 'frm_icon_font frm_code_icon',
90 - ),
91 - 'manage_styles' => array(
92 - 'class' => 'FrmStylesController',
93 - 'function' => 'manage',
94 - 'name' => __( 'Manage Styles', 'formidable' ),
95 - 'icon' => 'frm_icon_font frm_pallet_icon',
96 - ),
97 - 'captcha' => array(
98 - 'class' => self::class,
54 + 'captcha' => array(
55 + 'class' => __CLASS__,
99 56 'function' => 'captcha_settings',
100 - 'name' => __( 'Captcha/Spam', 'formidable' ),
57 + 'name' => __( 'CAPTCHA', 'formidable' ),
101 58 'icon' => 'frm_icon_font frm_shield_check_icon',
102 59 ),
103 - 'email' => array(
104 - 'class' => self::class,
105 - 'function' => 'email_settings',
106 - 'name' => __( 'Email', 'formidable' ),
107 - 'icon' => 'frm_icon_font frm_email_icon',
108 - ),
109 - 'white_label' => array(
60 + 'white_label' => array(
110 61 'name' => __( 'White Labeling', 'formidable' ),
111 62 'icon' => 'frm_icon_font frm_ghost_icon',
112 63 'html_class' => 'frm_show_upgrade_tab frm_noallow',
113 64 'data' => array(
@@ -115,9 +66,9 @@
115 66 'upgrade' => __( 'White labeling options', 'formidable' ),
116 67 'screenshot' => 'white-label.png',
117 68 ),
118 69 ),
119 - 'inbox' => array(
70 + 'inbox' => array(
120 71 'name' => __( 'Inbox', 'formidable' ),
121 72 'icon' => 'frm_icon_font frm_email_icon',
122 73 'html_class' => 'frm_show_upgrade_tab frm_noallow',
123 74 'data' => array(
@@ -128,9 +79,9 @@
128 79 ),
129 80 );
130 81
131 82 if ( apply_filters( 'frm_include_addon_page', false ) ) {
132 - // If no addons need a license, skip this page
83 + // if no addons need a license, skip this page
133 84 $show_licenses = false;
134 85 $installed_addons = apply_filters( 'frm_installed_addons', array() );
135 86 foreach ( $installed_addons as $installed_addon ) {
136 87 if ( ! $installed_addon->is_parent_licence && $installed_addon->plugin_name != 'Formidable Pro' && $installed_addon->needs_license ) {
@@ -143,24 +94,19 @@
143 94 $sections['licenses'] = array(
144 95 'class' => 'FrmAddonsController',
145 96 'function' => 'license_settings',
146 97 'name' => __( 'Plugin Licenses', 'formidable' ),
147 - 'icon' => 'frmfont frm_key_icon',
98 + 'icon' => 'frm_icon_font frm_keyalt_icon',
148 99 'ajax' => true,
149 100 );
150 101 }
151 - }//end if
152 -
153 - /**
154 - * @param array<array> $sections
155 - */
102 + }
156 103 $sections = apply_filters( 'frm_add_settings_section', $sections );
157 - self::remove_payments_sections( $sections );
158 104
159 105 $sections['misc'] = array(
160 106 'name' => __( 'Miscellaneous', 'formidable' ),
161 107 'icon' => 'frm_icon_font frm_shuffle_icon',
162 - 'class' => self::class,
108 + 'class' => __CLASS__,
163 109 'function' => 'misc_settings',
164 110 );
165 111
166 112 foreach ( $sections as $key => $section ) {
@@ -184,54 +130,13 @@
184 130 $section['function'] = $original;
185 131 }
186 132
187 133 $sections[ $key ] = $section;
188 - }//end foreach
134 + }
189 135
190 136 return $sections;
191 137 }
192 138
193 - /**
194 - * Remove the payments sections (PayPal, Square, Stripe, Authorize.Net)
195 - * and show them all on the payments section in separate tabs.
196 - *
197 - * @since 6.22.1
198 - *
199 - * @param array $sections
200 - * @return void
201 - */
202 - private static function remove_payments_sections( &$sections ) {
203 - $payment_section_keys = array( 'paypal', 'square', 'stripe', 'authorize_net' );
204 -
205 - foreach ( $sections as $key => $section ) {
206 - if ( in_array( $key, $payment_section_keys, true ) ) {
207 - self::$removed_payments_sections[ $key ] = $section;
208 - unset( $sections[ $key ] );
209 - }
210 - }
211 -
212 - uksort( self::$removed_payments_sections, array( self::class, 'payment_sections_sort_callback' ) );
213 - }
214 -
215 - /**
216 - * Sort the payments sections (PayPal, Square, Stripe, Authorize.Net)
217 - *
218 - * @since 6.22.1
219 - *
220 - * @param string $a
221 - * @param string $b
222 - * @return int
223 - */
224 - private static function payment_sections_sort_callback( $a, $b ) {
225 - $order = array( 'stripe', 'square', 'paypal', 'authorize_net' );
226 - $first_key = array_search( $a, $order );
227 - $second_key = array_search( $b, $order );
228 - if ( false === $first_key || false === $second_key ) {
229 - return 0;
230 - }
231 - return $first_key - $second_key;
232 - }
233 -
234 139 public static function load_settings_tab() {
235 140 FrmAppHelper::permission_check( 'frm_change_settings' );
236 141 check_ajax_referer( 'frm_ajax', 'nonce' );
237 142
@@ -245,43 +150,23 @@
245 150
246 151 if ( isset( $section['class'] ) ) {
247 152 call_user_func( array( $section['class'], $section['function'] ) );
248 153 } else {
249 - call_user_func( ( $section['function'] ?? $section ) );
154 + call_user_func( ( isset( $section['function'] ) ? $section['function'] : $section ) );
250 155 }
251 156 wp_die();
252 157 }
253 158
254 159 /**
255 - * Render the general global settings section.
256 - *
257 160 * @since 4.0
258 - *
259 - * @return void
260 161 */
261 162 public static function general_settings() {
262 163 $frm_settings = FrmAppHelper::get_settings();
263 - $uploads = wp_upload_dir();
264 - $target_path = $uploads['basedir'] . '/formidable/css';
265 164
266 - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/general.php';
267 - }
165 + $uploads = wp_upload_dir();
166 + $target_path = $uploads['basedir'] . '/formidable/css';
268 167
269 - /**
270 - * Render the global currency selector if Pro is up to date.
271 - *
272 - * @param FrmSettings $frm_settings
273 - * @param string $more_html
274 - * @return void
275 - */
276 - public static function maybe_render_currency_selector( $frm_settings, $more_html ) {
277 - if ( is_callable( 'FrmProSettingsController::add_currency_settings' ) ) {
278 - FrmProSettingsController::add_currency_settings();
279 - return;
280 - }
281 -
282 - $currencies = FrmCurrencyHelper::get_currencies();
283 - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/_currency.php';
168 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/general.php' );
284 169 }
285 170
286 171 /**
287 172 * @since 4.0
@@ -288,9 +173,9 @@
288 173 */
289 174 public static function message_settings() {
290 175 $frm_settings = FrmAppHelper::get_settings();
291 176
292 - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/messages.php';
177 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/messages.php' );
293 178 }
294 179
295 180 /**
296 181 * @since 4.0
@@ -298,23 +183,12 @@
298 183 public static function captcha_settings() {
299 184 $frm_settings = FrmAppHelper::get_settings();
300 185 $captcha_lang = FrmAppHelper::locales( 'captcha' );
301 186
302 - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/captcha/captcha.php';
187 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/captcha/captcha.php' );
303 188 }
304 189
305 190 /**
306 - * Shows email settings.
307 - *
308 - * @since 6.25
309 - */
310 - public static function email_settings() {
311 - $frm_settings = FrmAppHelper::get_settings();
312 -
313 - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/email/email-styles.php';
314 - }
315 -
316 - /**
317 191 * @since 4.0
318 192 */
319 193 public static function permission_settings() {
320 194 $frm_settings = FrmAppHelper::get_settings();
@@ -319,24 +193,11 @@
319 193 public static function permission_settings() {
320 194 $frm_settings = FrmAppHelper::get_settings();
321 195 $frm_roles = FrmAppHelper::frm_capabilities();
322 196
323 - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/permissions.php';
197 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/permissions.php' );
324 198 }
325 199
326 - public static function payments_settings() {
327 - $payment_sections = self::$removed_payments_sections;
328 -
329 - $tab = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' );
330 - if ( $tab && in_array( $tab, array( 'stripe_settings', 'square_settings', 'authorize_net_settings', 'paypal_settings' ), true ) ) {
331 - $tab = str_replace( '_settings', '', $tab );
332 - } else {
333 - $tab = 'stripe';
334 - }
335 -
336 - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/payments.php';
337 - }
338 -
339 200 /**
340 201 * @since 4.0
341 202 */
342 203 public static function misc_settings() {
@@ -341,43 +202,30 @@
341 202 */
342 203 public static function misc_settings() {
343 204 $frm_settings = FrmAppHelper::get_settings();
344 205
345 - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/misc.php';
206 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/misc.php' );
346 207 }
347 208
348 - /**
349 - * Save form data submitted from the Global settings page.
350 - *
351 - * @param bool|string $stop_load
352 - *
353 - * @return void
354 - */
355 209 public static function process_form( $stop_load = false ) {
356 210 global $frm_vars;
357 211
358 212 $frm_settings = FrmAppHelper::get_settings();
213 +
359 214 $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' );
360 -
361 215 if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) {
362 - $error_args = array(
363 - 'title' => __( 'Verification failed', 'formidable' ),
364 - 'body' => $frm_settings->admin_permission,
365 - 'cancel_text' => __( 'Cancel', 'formidable' ),
366 - );
367 - FrmAppController::show_error_modal( $error_args );
368 - return;
216 + wp_die( esc_html( $frm_settings->admin_permission ) );
369 217 }
370 218
371 219 $errors = array();
372 220 $message = '';
373 221
374 - if ( empty( $frm_vars['settings_routed'] ) ) {
222 + if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) {
375 223 $errors = $frm_settings->validate( $_POST, array() );
376 224
377 225 $frm_settings->update( wp_unslash( $_POST ) );
378 226
379 - if ( ! $errors ) {
227 + if ( empty( $errors ) ) {
380 228 $frm_settings->store();
381 229 $message = __( 'Settings Saved', 'formidable' );
382 230 }
383 231 } else {
@@ -383,10 +231,11 @@
383 231 } else {
384 232 $message = __( 'Settings Saved', 'formidable' );
385 233 }
386 234
387 - if ( $stop_load === 'stop_load' ) {
235 + if ( $stop_load == 'stop_load' ) {
388 236 $frm_vars['settings_routed'] = true;
237 +
389 238 return;
390 239 }
391 240
392 241 self::display_form( $errors, $message );
@@ -406,9 +255,9 @@
406 255 $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
407 256 $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
408 257 FrmAppHelper::include_svg();
409 258
410 - if ( $action === 'process-form' ) {
259 + if ( $action == 'process-form' ) {
411 260 self::process_form( $stop_load );
412 261 } elseif ( $stop_load != 'stop_load' ) {
413 262 self::display_form();
414 263 }
@@ -419,13 +268,32 @@
419 268 *
420 269 * @since 3.04.02
421 270 */
422 271 public static function settings_cta( $view ) {
272 +
423 273 if ( get_option( 'frm_lite_settings_upgrade', false ) ) {
424 274 return;
425 275 }
426 276
427 - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/settings_cta.php';
277 + $features = array(
278 + __( 'Extra form features like file uploads, pagination, etc', 'formidable' ),
279 + __( 'Repeaters & cascading fields for advanced forms', 'formidable' ),
280 + __( 'Flexibly view, search, edit, and delete entries anywhere', 'formidable' ),
281 + __( 'Display entries with virtually limitless Formidable views', 'formidable' ),
282 + __( 'Create surveys & polls', 'formidable' ),
283 + __( 'WordPress user registration and login forms', 'formidable' ),
284 + __( 'Create Stripe, PayPal or Authorize.net payment forms', 'formidable' ),
285 + __( 'Powerful conditional logic for smart forms', 'formidable' ),
286 + __( 'Integrations with 1000+ marketing & payment services', 'formidable' ),
287 + __( 'Collect digital signatures', 'formidable' ),
288 + __( 'Accept user-submitted content with Post submissions', 'formidable' ),
289 + __( 'Email routing', 'formidable' ),
290 + __( 'Create calculator forms', 'formidable' ),
291 + __( 'Save draft entries and return later', 'formidable' ),
292 + __( 'Analyze form data with graphs & stats', 'formidable' ),
293 + );
294 +
295 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/settings_cta.php' );
428 296 }
429 297
430 298 /**
431 299 * Dismiss upgrade notice at the bottom on the plugin settings pages.
@@ -432,9 +300,8 @@
432 300 *
433 301 * @since 3.04.02
434 302 */
435 303 public static function settings_cta_dismiss() {
436 - check_ajax_referer( 'frm_ajax', 'nonce' );
437 304 FrmAppHelper::permission_check( 'frm_change_settings' );
438 305
439 306 update_option( 'frm_lite_settings_upgrade', time(), 'no' );
440 307
@@ -451,9 +318,9 @@
451 318 check_ajax_referer( 'frm_ajax', 'nonce' );
452 319
453 320 global $wpdb;
454 321
455 - $term = FrmAppHelper::get_param( 'term', '', 'get', 'sanitize_text_field' );
322 + $term = FrmAppHelper::get_param( 'term', '', 'get', 'sanitize_text_field' );
456 323 $post_type = FrmAppHelper::get_param( 'post_type', 'page', 'get', 'sanitize_text_field' );
457 324
458 325 $where = array(
459 326 'post_status' => 'publish',
@@ -479,20 +346,11 @@
479 346 wp_send_json( $results );
480 347 }
481 348
482 349 /**
483 - * Shows a fake color picker.
484 - *
485 - * @since 6.25
486 - *
487 - * @param string $color Color value.
350 + * @deprecated x.x use FrmSettingsController::captcha_settings().
488 351 */
489 - public static function fake_color_picker( $color ) {
490 - ?>
491 - <div class="wp-picker-container">
492 - <button type="button" class="button wp-color-result" aria-expanded="false" aria-disabled="true" tabindex="-1" style="background-color:<?php echo esc_attr( $color ); ?>;">
493 - <span class="wp-color-result-text" style="color:#a7aaad;"><?php esc_html_e( 'Select Color', 'formidable' ); ?></span>
494 - </button>
495 - </div>
496 - <?php
352 + public static function recaptcha_settings() {
353 + _deprecated_function( __FUNCTION__, 'x.x', 'FrmSettingsController::captcha_settings()' );
354 + self::captcha_settings();
497 355 }
498 356 }