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