PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.22.2
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.22.2
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 +42 -224 6.356.22.2 View file →
@@ -5,17 +5,8 @@
5 5
6 6 class FrmSettingsController {
7 7
8 8 /**
9 - * Icon for the API section, used whether the add-on is active or only a placeholder.
10 - *
11 - * @since 6.35
12 - *
13 - * @var string
14 - */
15 - private static $api_section_icon = 'frmfont frm_cloud_icon';
16 -
17 - /**
18 9 * Payments sections are removed from the top level and added to a payments section.
19 10 *
20 11 * @since 6.22.1
21 12 *
@@ -22,16 +13,13 @@
22 13 * @var array
23 14 */
24 15 private static $removed_payments_sections = array();
25 16
26 - /**
27 - * @return void
28 - */
29 17 public static function menu() {
30 18 // Make sure admins can see the menu items
31 19 FrmAppHelper::force_capability( 'frm_change_settings' );
32 20
33 - add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
21 + add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' );
34 22 }
35 23
36 24 /**
37 25 * Include license box template on demand.
@@ -44,23 +32,19 @@
44 32 }
45 33 include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php';
46 34 }
47 35
48 - /**
49 - * @param array $errors
50 - * @param string $message
51 - *
52 - * @return void
53 - */
54 36 public static function display_form( $errors = array(), $message = '' ) {
55 37 global $frm_vars;
56 38
57 39 $frm_settings = FrmAppHelper::get_settings();
58 - $uploads = wp_upload_dir();
59 - $target_path = $uploads['basedir'] . '/formidable/css';
60 - $sections = self::get_settings_tabs();
61 - $current = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' );
62 40
41 + $uploads = wp_upload_dir();
42 + $target_path = $uploads['basedir'] . '/formidable/css';
43 +
44 + $sections = self::get_settings_tabs();
45 + $current = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' );
46 +
63 47 if ( in_array( $current, array( 'stripe_settings', 'square_settings', 'authorize_net_settings', 'paypal_settings' ), true ) ) {
64 48 $current = 'payments_settings';
65 49 }
66 50
@@ -74,29 +58,29 @@
74 58 */
75 59 private static function get_settings_tabs() {
76 60 $sections = array(
77 61 'general' => array(
78 - 'class' => self::class,
62 + 'class' => __CLASS__,
79 63 'function' => 'general_settings',
80 64 'name' => __( 'General Settings', 'formidable' ),
81 - 'icon' => 'frmfont frm_settings_icon',
65 + 'icon' => 'frm_icon_font frm_settings_icon',
82 66 ),
83 67 'messages' => array(
84 - 'class' => self::class,
68 + 'class' => __CLASS__,
85 69 'function' => 'message_settings',
86 70 'name' => __( 'Message Defaults', 'formidable' ),
87 - 'icon' => 'frmfont frm_stamp_icon',
71 + 'icon' => 'frm_icon_font frm_stamp_icon',
88 72 ),
89 73 'permissions' => array(
90 - 'class' => self::class,
74 + 'class' => __CLASS__,
91 75 'function' => 'permission_settings',
92 76 'name' => __( 'Permissions', 'formidable' ),
93 - 'icon' => 'frmfont frm_lock_icon',
77 + 'icon' => 'frm_icon_font frm_lock_icon',
94 78 ),
95 79 'payments' => array(
96 80 'name' => __( 'Payments', 'formidable' ),
97 - 'icon' => 'frmfont frm_simple_cc_icon',
98 - 'class' => self::class,
81 + 'icon' => 'frm_icon_font frm_simple_cc_icon',
82 + 'class' => __CLASS__,
99 83 'function' => 'payments_settings',
100 84 ),
101 85 'custom_css' => array(
102 86 'class' => 'FrmStylesController',
@@ -101,48 +85,40 @@
101 85 'custom_css' => array(
102 86 'class' => 'FrmStylesController',
103 87 'function' => 'custom_css',
104 88 'name' => __( 'Custom CSS', 'formidable' ),
105 - 'icon' => 'frmfont frm_code_icon',
89 + 'icon' => 'frm_icon_font frm_code_icon',
106 90 ),
107 91 'manage_styles' => array(
108 92 'class' => 'FrmStylesController',
109 93 'function' => 'manage',
110 94 'name' => __( 'Manage Styles', 'formidable' ),
111 - 'icon' => 'frmfont frm_pallet_icon',
95 + 'icon' => 'frm_icon_font frm_pallet_icon',
112 96 ),
113 97 'captcha' => array(
114 - 'class' => self::class,
98 + 'class' => __CLASS__,
115 99 'function' => 'captcha_settings',
116 100 'name' => __( 'Captcha/Spam', 'formidable' ),
117 - 'icon' => 'frmfont frm_shield_check_icon',
101 + 'icon' => 'frm_icon_font frm_shield_check_icon',
118 102 ),
119 - 'email' => array(
120 - 'class' => self::class,
121 - 'function' => 'email_settings',
122 - 'name' => __( 'Email', 'formidable' ),
123 - 'icon' => 'frmfont frm_email_icon',
124 - ),
125 103 'white_label' => array(
126 104 'name' => __( 'White Labeling', 'formidable' ),
127 - 'icon' => 'frmfont frm_ghost_icon',
105 + 'icon' => 'frm_icon_font frm_ghost_icon',
128 106 'html_class' => 'frm_show_upgrade_tab frm_noallow',
129 107 'data' => array(
130 108 'medium' => 'white-label',
131 109 'upgrade' => __( 'White labeling options', 'formidable' ),
132 110 'screenshot' => 'white-label.png',
133 - 'learn-more' => FrmAppHelper::get_doc_url( 'features/white-label-form-builder-wordpress', 'white-labeling-global-settings', false ),
134 111 ),
135 112 ),
136 113 'inbox' => array(
137 114 'name' => __( 'Inbox', 'formidable' ),
138 - 'icon' => 'frmfont frm_email_icon',
115 + 'icon' => 'frm_icon_font frm_email_icon',
139 116 'html_class' => 'frm_show_upgrade_tab frm_noallow',
140 117 'data' => array(
141 118 'medium' => 'inbox-settings',
142 119 'upgrade' => __( 'Inbox settings', 'formidable' ),
143 120 'screenshot' => 'inbox.png',
144 - 'learn-more' => FrmAppHelper::get_doc_url( 'global-settings-overview/#kb-inbox', 'inbox-global-settings' ),
145 121 ),
146 122 ),
147 123 );
148 124
@@ -149,11 +125,10 @@
149 125 if ( apply_filters( 'frm_include_addon_page', false ) ) {
150 126 // If no addons need a license, skip this page
151 127 $show_licenses = false;
152 128 $installed_addons = apply_filters( 'frm_installed_addons', array() );
153 -
154 129 foreach ( $installed_addons as $installed_addon ) {
155 - if ( ! $installed_addon->is_parent_licence && $installed_addon->plugin_name !== 'Formidable Pro' && $installed_addon->needs_license ) {
130 + if ( ! $installed_addon->is_parent_licence && $installed_addon->plugin_name != 'Formidable Pro' && $installed_addon->needs_license ) {
156 131 $show_licenses = true;
157 132 break;
158 133 }
159 134 }
@@ -172,15 +147,14 @@
172 147 /**
173 148 * @param array<array> $sections
174 149 */
175 150 $sections = apply_filters( 'frm_add_settings_section', $sections );
176 - self::add_inactive_addon_sections( $sections );
177 151 self::remove_payments_sections( $sections );
178 152
179 153 $sections['misc'] = array(
180 154 'name' => __( 'Miscellaneous', 'formidable' ),
181 - 'icon' => 'frmfont frm_shuffle_icon',
182 - 'class' => self::class,
155 + 'icon' => 'frm_icon_font frm_shuffle_icon',
156 + 'class' => __CLASS__,
183 157 'function' => 'misc_settings',
184 158 );
185 159
186 160 foreach ( $sections as $key => $section ) {
@@ -187,9 +161,9 @@
187 161 $original = $section;
188 162 $defaults = array(
189 163 'html_class' => '',
190 164 'name' => ucfirst( $key ),
191 - 'icon' => 'frmfont frm_settings_icon',
165 + 'icon' => 'frm_icon_font frm_settings_icon',
192 166 'anchor' => $key . '_settings',
193 167 'data' => array(),
194 168 );
195 169
@@ -210,107 +184,8 @@
210 184 return $sections;
211 185 }
212 186
213 187 /**
214 - * Add a placeholder section for each add-on that owns a Global Settings
215 - * section but is not active.
216 - *
217 - * A placeholder reads as disabled and opens a page offering to activate the
218 - * add-on or to upgrade, depending on what the license allows. It goes at the
219 - * head of the add-on sections, right after Inbox, so it sits with the rest of
220 - * the add-on settings instead of trailing them. A section already claimed by
221 - * an active plugin is left alone, so nothing stands in for a section that is
222 - * really there.
223 - *
224 - * @since 6.35
225 - *
226 - * @param array<array> $sections Sections registered for the Global Settings page so far.
227 - *
228 - * @return void
229 - */
230 - private static function add_inactive_addon_sections( &$sections ) {
231 - if ( isset( $sections['api'] ) ) {
232 - // The add-on is active, so it owns the section. Only the icon is taken over,
233 - // so the tab looks the same whether or not the add-on is installed.
234 - $sections['api']['icon'] = self::$api_section_icon;
235 - return;
236 - }
237 -
238 - self::insert_section_after( $sections, 'inbox', 'api', self::get_api_placeholder_section() );
239 - }
240 -
241 - /**
242 - * Insert a section directly after another one, leaving the rest of the order alone.
243 - *
244 - * Assigning a new key lands the section at the end of the array, so the array
245 - * is rebuilt to put it where it belongs.
246 - *
247 - * @since 6.35
248 - *
249 - * @param array<array> $sections Sections registered for the Global Settings page so far.
250 - * @param string $after Key of the section the new one follows. The new section goes last when this key is not there.
251 - * @param string $key Key for the new section.
252 - * @param array $section The section to insert.
253 - *
254 - * @return void
255 - */
256 - private static function insert_section_after( &$sections, $after, $key, $section ) {
257 - if ( ! isset( $sections[ $after ] ) ) {
258 - $sections[ $key ] = $section;
259 - return;
260 - }
261 -
262 - $ordered = array();
263 -
264 - foreach ( $sections as $section_key => $existing_section ) {
265 - $ordered[ $section_key ] = $existing_section;
266 -
267 - if ( $section_key === $after ) {
268 - $ordered[ $key ] = $section;
269 - }
270 - }
271 -
272 - $sections = $ordered;
273 - }
274 -
275 - /**
276 - * Get the placeholder that stands in for the API add-on's section.
277 - *
278 - * The upgrade data decides which call to action the page shows. When the
279 - * license covers the add-on, it carries the one click install or activate
280 - * link. Otherwise it carries the plan the add-on needs, and the page asks
281 - * the user to upgrade to it, on a gradient button that sets the upgrade
282 - * apart from a one click install.
283 - *
284 - * @since 6.35
285 - *
286 - * @return array
287 - */
288 - private static function get_api_placeholder_section() {
289 - $data = FrmAppHelper::get_upgrade_data_params(
290 - 'api',
291 - array(
292 - 'medium' => 'api-settings',
293 - 'upgrade' => __( 'API settings', 'formidable' ),
294 - 'message' => __( 'Send entries to any site with a REST API, and let AI assistants build your forms. Upgrade to get the API add-on.', 'formidable' ),
295 - 'learn-more' => FrmAppHelper::get_doc_url( 'formidable-api', 'api-global-settings' ),
296 - 'upsell-images' => 'api-settings-1.png,api-settings-2.png,api-settings-3.png',
297 - )
298 - );
299 -
300 - if ( ! FrmAppHelper::pro_is_installed() ) {
301 - $data['gradient-upgrade'] = 1;
302 - }
303 -
304 - return array(
305 - 'name' => __( 'API', 'formidable' ),
306 - 'icon' => self::$api_section_icon,
307 - 'html_class' => 'frm_show_upgrade_tab frm_noallow',
308 - 'data' => $data,
309 - );
310 - }
311 -
312 - /**
313 188 * Remove the payments sections (PayPal, Square, Stripe, Authorize.Net)
314 189 * and show them all on the payments section in separate tabs.
315 190 *
316 191 * @since 6.22.1
@@ -315,9 +190,8 @@
315 190 *
316 191 * @since 6.22.1
317 192 *
318 193 * @param array $sections
319 - *
320 194 * @return void
321 195 */
322 196 private static function remove_payments_sections( &$sections ) {
323 197 $payment_section_keys = array( 'paypal', 'square', 'stripe', 'authorize_net' );
@@ -322,17 +196,15 @@
322 196 private static function remove_payments_sections( &$sections ) {
323 197 $payment_section_keys = array( 'paypal', 'square', 'stripe', 'authorize_net' );
324 198
325 199 foreach ( $sections as $key => $section ) {
326 - if ( ! in_array( $key, $payment_section_keys, true ) ) {
327 - continue;
200 + if ( in_array( $key, $payment_section_keys, true ) ) {
201 + self::$removed_payments_sections[ $key ] = $section;
202 + unset( $sections[ $key ] );
328 203 }
329 -
330 - self::$removed_payments_sections[ $key ] = $section;
331 - unset( $sections[ $key ] );
332 204 }
333 205
334 - uksort( self::$removed_payments_sections, array( self::class, 'payment_sections_sort_callback' ) );
206 + uksort( self::$removed_payments_sections, array( __CLASS__, 'payment_sections_sort_callback' ) );
335 207 }
336 208
337 209 /**
338 210 * Sort the payments sections (PayPal, Square, Stripe, Authorize.Net)
@@ -340,20 +212,17 @@
340 212 * @since 6.22.1
341 213 *
342 214 * @param string $a
343 215 * @param string $b
344 - *
345 216 * @return int
346 217 */
347 218 private static function payment_sections_sort_callback( $a, $b ) {
348 219 $order = array( 'stripe', 'square', 'paypal', 'authorize_net' );
349 - $first_key = array_search( $a, $order, true );
350 - $second_key = array_search( $b, $order, true );
351 -
220 + $first_key = array_search( $a, $order );
221 + $second_key = array_search( $b, $order );
352 222 if ( false === $first_key || false === $second_key ) {
353 223 return 0;
354 224 }
355 -
356 225 return $first_key - $second_key;
357 226 }
358 227
359 228 public static function load_settings_tab() {
@@ -361,9 +230,8 @@
361 230 check_ajax_referer( 'frm_ajax', 'nonce' );
362 231
363 232 $section = FrmAppHelper::get_post_param( 'tab', '', 'sanitize_text_field' );
364 233 $sections = self::get_settings_tabs();
365 -
366 234 if ( ! isset( $sections[ $section ] ) ) {
367 235 wp_die();
368 236 }
369 237
@@ -371,11 +239,10 @@
371 239
372 240 if ( isset( $section['class'] ) ) {
373 241 call_user_func( array( $section['class'], $section['function'] ) );
374 242 } else {
375 - call_user_func( $section['function'] ?? $section );
243 + call_user_func( ( isset( $section['function'] ) ? $section['function'] : $section ) );
376 244 }
377 -
378 245 wp_die();
379 246 }
380 247
381 248 /**
@@ -396,12 +263,12 @@
396 263 /**
397 264 * Render the global currency selector if Pro is up to date.
398 265 *
399 266 * @param FrmSettings $frm_settings
400 - *
267 + * @param string $more_html
401 268 * @return void
402 269 */
403 - public static function maybe_render_currency_selector( $frm_settings ) {
270 + public static function maybe_render_currency_selector( $frm_settings, $more_html ) {
404 271 if ( is_callable( 'FrmProSettingsController::add_currency_settings' ) ) {
405 272 FrmProSettingsController::add_currency_settings();
406 273 return;
407 274 }
@@ -411,20 +278,17 @@
411 278 }
412 279
413 280 /**
414 281 * @since 4.0
415 - *
416 - * @return void
417 282 */
418 283 public static function message_settings() {
419 284 $frm_settings = FrmAppHelper::get_settings();
285 +
420 286 include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/messages.php';
421 287 }
422 288
423 289 /**
424 290 * @since 4.0
425 - *
426 - * @return void
427 291 */
428 292 public static function captcha_settings() {
429 293 $frm_settings = FrmAppHelper::get_settings();
430 294 $captcha_lang = FrmAppHelper::locales( 'captcha' );
@@ -432,23 +296,9 @@
432 296 include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/captcha/captcha.php';
433 297 }
434 298
435 299 /**
436 - * Shows email settings.
437 - *
438 - * @since 6.25
439 - *
440 - * @return void
441 - */
442 - public static function email_settings() {
443 - $frm_settings = FrmAppHelper::get_settings();
444 - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/email/email-styles.php';
445 - }
446 -
447 - /**
448 300 * @since 4.0
449 - *
450 - * @return void
451 301 */
452 302 public static function permission_settings() {
453 303 $frm_settings = FrmAppHelper::get_settings();
454 304 $frm_roles = FrmAppHelper::frm_capabilities();
@@ -455,15 +305,12 @@
455 305
456 306 include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/permissions.php';
457 307 }
458 308
459 - /**
460 - * @return void
461 - */
462 309 public static function payments_settings() {
463 310 $payment_sections = self::$removed_payments_sections;
464 - $tab = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' );
465 311
312 + $tab = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' );
466 313 if ( $tab && in_array( $tab, array( 'stripe_settings', 'square_settings', 'authorize_net_settings', 'paypal_settings' ), true ) ) {
467 314 $tab = str_replace( '_settings', '', $tab );
468 315 } else {
469 316 $tab = 'stripe';
@@ -473,13 +320,12 @@
473 320 }
474 321
475 322 /**
476 323 * @since 4.0
477 - *
478 - * @return void
479 324 */
480 325 public static function misc_settings() {
481 326 $frm_settings = FrmAppHelper::get_settings();
327 +
482 328 include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/misc.php';
483 329 }
484 330
485 331 /**
@@ -532,10 +378,8 @@
532 378 /**
533 379 * Include the Update button on the global settings page.
534 380 *
535 381 * @since 4.0.02
536 - *
537 - * @return void
538 382 */
539 383 public static function save_button() {
540 384 echo '<input class="button-primary frm-button-primary" type="submit"
541 385 value="' . esc_attr__( 'Update', 'formidable' ) . '"/>';
@@ -540,13 +384,8 @@
540 384 echo '<input class="button-primary frm-button-primary" type="submit"
541 385 value="' . esc_attr__( 'Update', 'formidable' ) . '"/>';
542 386 }
543 387
544 - /**
545 - * @param bool|string $stop_load
546 - *
547 - * @return void
548 - */
549 388 public static function route( $stop_load = false ) {
550 389 $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
551 390 $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
552 391 FrmAppHelper::include_svg();
@@ -552,9 +391,9 @@
552 391 FrmAppHelper::include_svg();
553 392
554 393 if ( $action === 'process-form' ) {
555 394 self::process_form( $stop_load );
556 - } elseif ( $stop_load !== 'stop_load' ) {
395 + } elseif ( $stop_load != 'stop_load' ) {
557 396 self::display_form();
558 397 }
559 398 }
560 399
@@ -561,12 +400,10 @@
561 400 /**
562 401 * Add CTA to the bottom on the plugin settings pages.
563 402 *
564 403 * @since 3.04.02
565 - *
566 - * @return void
567 404 */
568 - public static function settings_cta() {
405 + public static function settings_cta( $view ) {
569 406 if ( get_option( 'frm_lite_settings_upgrade', false ) ) {
570 407 return;
571 408 }
572 409
@@ -581,9 +418,9 @@
581 418 public static function settings_cta_dismiss() {
582 419 check_ajax_referer( 'frm_ajax', 'nonce' );
583 420 FrmAppHelper::permission_check( 'frm_change_settings' );
584 421
585 - update_option( 'frm_lite_settings_upgrade', time(), false );
422 + update_option( 'frm_lite_settings_upgrade', time(), 'no' );
586 423
587 424 wp_send_json_success();
588 425 }
589 426
@@ -611,11 +448,11 @@
611 448 'limit' => 25,
612 449 'order_by' => 'post_title',
613 450 );
614 451
615 - $pages = FrmDb::get_results( $wpdb->posts, $where, 'ID, post_title', $atts );
452 + $pages = FrmDb::get_results( $wpdb->posts, $where, 'ID, post_title', $atts );
453 +
616 454 $results = array();
617 -
618 455 foreach ( $pages as $page ) {
619 456 $results[] = array(
620 457 'value' => $page->ID,
621 458 'label' => $page->post_title,
@@ -622,25 +459,6 @@
622 459 );
623 460 }
624 461
625 462 wp_send_json( $results );
626 - }
627 -
628 - /**
629 - * Shows a fake color picker.
630 - *
631 - * @since 6.25
632 - *
633 - * @param string $color Color value.
634 - *
635 - * @return void
636 - */
637 - public static function fake_color_picker( $color ) {
638 - ?>
639 - <div class="wp-picker-container">
640 - <button type="button" class="button wp-color-result" aria-expanded="false" aria-disabled="true" tabindex="-1" style="background-color:<?php echo esc_attr( $color ); ?>;"><?php // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong ?>
641 - <span class="wp-color-result-text" style="color:#a7aaad;"><?php esc_html_e( 'Select Color', 'formidable' ); ?></span>
642 - </button>
643 - </div>
644 - <?php
645 463 }
646 464 }