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