PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.8
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.8
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 +53 -177 6.266.8 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
@@ -32,17 +20,11 @@
32 20 public static function license_box() {
33 21 if ( ! current_user_can( 'activate_plugins' ) ) {
34 22 return;
35 23 }
36 - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php';
24 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' );
37 25 }
38 26
39 - /**
40 - * @param array $errors
41 - * @param string $message
42 - *
43 - * @return void
44 - */
45 27 public static function display_form( $errors = array(), $message = '' ) {
46 28 global $frm_vars;
47 29
48 30 $frm_settings = FrmAppHelper::get_settings();
@@ -52,13 +34,9 @@
52 34
53 35 $sections = self::get_settings_tabs();
54 36 $current = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' );
55 37
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';
38 + require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' );
61 39 }
62 40
63 41 /**
64 42 * Get sections to use for Global Settings.
@@ -66,33 +44,27 @@
66 44 * @return array<array>
67 45 */
68 46 private static function get_settings_tabs() {
69 47 $sections = array(
70 - 'general' => array(
71 - 'class' => self::class,
48 + 'general' => array(
49 + 'class' => __CLASS__,
72 50 'function' => 'general_settings',
73 51 'name' => __( 'General Settings', 'formidable' ),
74 52 'icon' => 'frm_icon_font frm_settings_icon',
75 53 ),
76 - 'messages' => array(
77 - 'class' => self::class,
54 + 'messages' => array(
55 + 'class' => __CLASS__,
78 56 'function' => 'message_settings',
79 57 'name' => __( 'Message Defaults', 'formidable' ),
80 58 'icon' => 'frm_icon_font frm_stamp_icon',
81 59 ),
82 - 'permissions' => array(
83 - 'class' => self::class,
60 + 'permissions' => array(
61 + 'class' => __CLASS__,
84 62 'function' => 'permission_settings',
85 63 'name' => __( 'Permissions', 'formidable' ),
86 64 'icon' => 'frm_icon_font frm_lock_icon',
87 65 ),
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(
66 + 'custom_css' => array(
95 67 'class' => 'FrmStylesController',
96 68 'function' => 'custom_css',
97 69 'name' => __( 'Custom CSS', 'formidable' ),
98 70 'icon' => 'frm_icon_font frm_code_icon',
@@ -102,21 +74,15 @@
102 74 'function' => 'manage',
103 75 'name' => __( 'Manage Styles', 'formidable' ),
104 76 'icon' => 'frm_icon_font frm_pallet_icon',
105 77 ),
106 - 'captcha' => array(
107 - 'class' => self::class,
78 + 'captcha' => array(
79 + 'class' => __CLASS__,
108 80 'function' => 'captcha_settings',
109 - 'name' => __( 'Captcha/Spam', 'formidable' ),
81 + 'name' => __( 'Captcha', 'formidable' ),
110 82 'icon' => 'frm_icon_font frm_shield_check_icon',
111 83 ),
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(
84 + 'white_label' => array(
119 85 'name' => __( 'White Labeling', 'formidable' ),
120 86 'icon' => 'frm_icon_font frm_ghost_icon',
121 87 'html_class' => 'frm_show_upgrade_tab frm_noallow',
122 88 'data' => array(
@@ -122,12 +88,11 @@
122 88 'data' => array(
123 89 'medium' => 'white-label',
124 90 'upgrade' => __( 'White labeling options', 'formidable' ),
125 91 'screenshot' => 'white-label.png',
126 - 'learn-more' => FrmAppHelper::get_doc_url( 'features/white-label-form-builder-wordpress', 'white-labeling-global-settings', false ),
127 92 ),
128 93 ),
129 - 'inbox' => array(
94 + 'inbox' => array(
130 95 'name' => __( 'Inbox', 'formidable' ),
131 96 'icon' => 'frm_icon_font frm_email_icon',
132 97 'html_class' => 'frm_show_upgrade_tab frm_noallow',
133 98 'data' => array(
@@ -133,9 +98,8 @@
133 98 'data' => array(
134 99 'medium' => 'inbox-settings',
135 100 'upgrade' => __( 'Inbox settings', 'formidable' ),
136 101 'screenshot' => 'inbox.png',
137 - 'learn-more' => FrmAppHelper::get_doc_url( 'global-settings-overview/#kb-inbox', 'inbox-global-settings' ),
138 102 ),
139 103 ),
140 104 );
141 105
@@ -142,9 +106,8 @@
142 106 if ( apply_filters( 'frm_include_addon_page', false ) ) {
143 107 // If no addons need a license, skip this page
144 108 $show_licenses = false;
145 109 $installed_addons = apply_filters( 'frm_installed_addons', array() );
146 -
147 110 foreach ( $installed_addons as $installed_addon ) {
148 111 if ( ! $installed_addon->is_parent_licence && $installed_addon->plugin_name != 'Formidable Pro' && $installed_addon->needs_license ) {
149 112 $show_licenses = true;
150 113 break;
@@ -165,14 +128,13 @@
165 128 /**
166 129 * @param array<array> $sections
167 130 */
168 131 $sections = apply_filters( 'frm_add_settings_section', $sections );
169 - self::remove_payments_sections( $sections );
170 132
171 133 $sections['misc'] = array(
172 134 'name' => __( 'Miscellaneous', 'formidable' ),
173 135 'icon' => 'frm_icon_font frm_shuffle_icon',
174 - 'class' => self::class,
136 + 'class' => __CLASS__,
175 137 'function' => 'misc_settings',
176 138 );
177 139
178 140 foreach ( $sections as $key => $section ) {
@@ -201,52 +163,8 @@
201 163
202 164 return $sections;
203 165 }
204 166
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 167 public static function load_settings_tab() {
250 168 FrmAppHelper::permission_check( 'frm_change_settings' );
251 169 check_ajax_referer( 'frm_ajax', 'nonce' );
252 170
@@ -251,9 +169,8 @@
251 169 check_ajax_referer( 'frm_ajax', 'nonce' );
252 170
253 171 $section = FrmAppHelper::get_post_param( 'tab', '', 'sanitize_text_field' );
254 172 $sections = self::get_settings_tabs();
255 -
256 173 if ( ! isset( $sections[ $section ] ) ) {
257 174 wp_die();
258 175 }
259 176
@@ -261,9 +178,9 @@
261 178
262 179 if ( isset( $section['class'] ) ) {
263 180 call_user_func( array( $section['class'], $section['function'] ) );
264 181 } else {
265 - call_user_func( ( $section['function'] ?? $section ) );
182 + call_user_func( ( isset( $section['function'] ) ? $section['function'] : $section ) );
266 183 }
267 184 wp_die();
268 185 }
269 186
@@ -286,14 +203,14 @@
286 203 * Render the global currency selector if Pro is up to date.
287 204 *
288 205 * @param FrmSettings $frm_settings
289 206 * @param string $more_html
290 - *
291 207 * @return void
292 208 */
293 209 public static function maybe_render_currency_selector( $frm_settings, $more_html ) {
294 - if ( is_callable( 'FrmProSettingsController::add_currency_settings' ) ) {
295 - FrmProSettingsController::add_currency_settings();
210 + if ( false !== strpos( $more_html, 'id="frm_currency"' ) ) {
211 + // Avoid rendering the Currency setting if it gets rendered from the frm_settings_form hook.
212 + // This is for backward compatibility. If Pro is outdated there won't be two currency dropdowns.
296 213 return;
297 214 }
298 215
299 216 $currencies = FrmCurrencyHelper::get_currencies();
@@ -301,86 +218,48 @@
301 218 }
302 219
303 220 /**
304 221 * @since 4.0
305 - *
306 - * @return void
307 222 */
308 223 public static function message_settings() {
309 224 $frm_settings = FrmAppHelper::get_settings();
310 225
311 - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/messages.php';
226 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/messages.php' );
312 227 }
313 228
314 229 /**
315 230 * @since 4.0
316 - *
317 - * @return void
318 231 */
319 232 public static function captcha_settings() {
320 233 $frm_settings = FrmAppHelper::get_settings();
321 234 $captcha_lang = FrmAppHelper::locales( 'captcha' );
322 235
323 - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/captcha/captcha.php';
236 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/captcha/captcha.php' );
324 237 }
325 238
326 239 /**
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 240 * @since 4.0
341 - *
342 - * @return void
343 241 */
344 242 public static function permission_settings() {
345 243 $frm_settings = FrmAppHelper::get_settings();
346 244 $frm_roles = FrmAppHelper::frm_capabilities();
347 245
348 - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/permissions.php';
246 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/permissions.php' );
349 247 }
350 248
351 249 /**
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 250 * @since 4.0
370 - *
371 - * @return void
372 251 */
373 252 public static function misc_settings() {
374 253 $frm_settings = FrmAppHelper::get_settings();
375 254
376 - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/misc.php';
255 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/misc.php' );
377 256 }
378 257
379 258 /**
380 259 * Save form data submitted from the Global settings page.
381 260 *
382 - * @param bool|string $stop_load
261 + * @param string|bool $stop_load
383 262 *
384 263 * @return void
385 264 */
386 265 public static function process_form( $stop_load = false ) {
@@ -390,10 +269,10 @@
390 269 $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' );
391 270
392 271 if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) {
393 272 $error_args = array(
394 - 'title' => __( 'Verification failed', 'formidable' ),
395 - 'body' => $frm_settings->admin_permission,
273 + 'title' => __( 'Verification failed', 'formidable' ),
274 + 'body' => $frm_settings->admin_permission,
396 275 'cancel_text' => __( 'Cancel', 'formidable' ),
397 276 );
398 277 FrmAppController::show_error_modal( $error_args );
399 278 return;
@@ -426,10 +305,8 @@
426 305 /**
427 306 * Include the Update button on the global settings page.
428 307 *
429 308 * @since 4.0.02
430 - *
431 - * @return void
432 309 */
433 310 public static function save_button() {
434 311 echo '<input class="button-primary frm-button-primary" type="submit"
435 312 value="' . esc_attr__( 'Update', 'formidable' ) . '"/>';
@@ -434,19 +311,14 @@
434 311 echo '<input class="button-primary frm-button-primary" type="submit"
435 312 value="' . esc_attr__( 'Update', 'formidable' ) . '"/>';
436 313 }
437 314
438 - /**
439 - * @param bool|string $stop_load
440 - *
441 - * @return void
442 - */
443 315 public static function route( $stop_load = false ) {
444 316 $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
445 317 $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
446 318 FrmAppHelper::include_svg();
447 319
448 - if ( $action === 'process-form' ) {
320 + if ( $action == 'process-form' ) {
449 321 self::process_form( $stop_load );
450 322 } elseif ( $stop_load != 'stop_load' ) {
451 323 self::display_form();
452 324 }
@@ -455,17 +327,34 @@
455 327 /**
456 328 * Add CTA to the bottom on the plugin settings pages.
457 329 *
458 330 * @since 3.04.02
459 - *
460 - * @return void
461 331 */
462 - public static function settings_cta() {
332 + public static function settings_cta( $view ) {
333 +
463 334 if ( get_option( 'frm_lite_settings_upgrade', false ) ) {
464 335 return;
465 336 }
466 337
467 - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/settings_cta.php';
338 + $features = array(
339 + __( 'Extra form features like file uploads, pagination, etc', 'formidable' ),
340 + __( 'Repeaters & cascading fields for advanced forms', 'formidable' ),
341 + __( 'Flexibly view, search, edit, and delete entries anywhere', 'formidable' ),
342 + __( 'Display entries with virtually limitless Formidable views', 'formidable' ),
343 + __( 'Create surveys & polls', 'formidable' ),
344 + __( 'WordPress user registration and login forms', 'formidable' ),
345 + __( 'Create Stripe, PayPal or Authorize.net payment forms', 'formidable' ),
346 + __( 'Powerful conditional logic for smart forms', 'formidable' ),
347 + __( 'Integrations with 1000+ marketing & payment services', 'formidable' ),
348 + __( 'Collect digital signatures', 'formidable' ),
349 + __( 'Accept user-submitted content with Post submissions', 'formidable' ),
350 + __( 'Email routing', 'formidable' ),
351 + __( 'Create calculator forms', 'formidable' ),
352 + __( 'Save draft entries and return later', 'formidable' ),
353 + __( 'Analyze form data with graphs & stats', 'formidable' ),
354 + );
355 +
356 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/settings_cta.php' );
468 357 }
469 358
470 359 /**
471 360 * Dismiss upgrade notice at the bottom on the plugin settings pages.
@@ -472,9 +361,8 @@
472 361 *
473 362 * @since 3.04.02
474 363 */
475 364 public static function settings_cta_dismiss() {
476 - check_ajax_referer( 'frm_ajax', 'nonce' );
477 365 FrmAppHelper::permission_check( 'frm_change_settings' );
478 366
479 367 update_option( 'frm_lite_settings_upgrade', time(), 'no' );
480 368
@@ -491,9 +379,9 @@
491 379 check_ajax_referer( 'frm_ajax', 'nonce' );
492 380
493 381 global $wpdb;
494 382
495 - $term = FrmAppHelper::get_param( 'term', '', 'get', 'sanitize_text_field' );
383 + $term = FrmAppHelper::get_param( 'term', '', 'get', 'sanitize_text_field' );
496 384 $post_type = FrmAppHelper::get_param( 'post_type', 'page', 'get', 'sanitize_text_field' );
497 385
498 386 $where = array(
499 387 'post_status' => 'publish',
@@ -508,9 +396,8 @@
508 396
509 397 $pages = FrmDb::get_results( $wpdb->posts, $where, 'ID, post_title', $atts );
510 398
511 399 $results = array();
512 -
513 400 foreach ( $pages as $page ) {
514 401 $results[] = array(
515 402 'value' => $page->ID,
516 403 'label' => $page->post_title,
@@ -520,22 +407,11 @@
520 407 wp_send_json( $results );
521 408 }
522 409
523 410 /**
524 - * Shows a fake color picker.
525 - *
526 - * @since 6.25
527 - *
528 - * @param string $color Color value.
529 - *
530 - * @return void
411 + * @deprecated 6.0 use FrmSettingsController::captcha_settings().
531 412 */
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
413 + public static function recaptcha_settings() {
414 + _deprecated_function( __FUNCTION__, '6.0', 'FrmSettingsController::captcha_settings()' );
415 + self::captcha_settings();
540 416 }
541 417 }