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