PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 4.01.02
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v4.01.02
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 +77 -315 6.284.01.02 View file →
@@ -1,150 +1,77 @@
1 1 <?php
2 -if ( ! defined( 'ABSPATH' ) ) {
3 - die( 'You are not allowed to call this page directly.' );
4 -}
5 2
6 3 class FrmSettingsController {
7 4
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 5 public static function menu() {
21 6 // Make sure admins can see the menu items
22 7 FrmAppHelper::force_capability( 'frm_change_settings' );
23 8
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
9 + add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' );
25 10 }
26 11
27 - /**
28 - * Include license box template on demand.
29 - *
30 - * @return void
31 - */
32 12 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';
13 + $a = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' );
14 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' );
37 15 }
38 16
39 - /**
40 - * @param array $errors
41 - * @param string $message
42 - *
43 - * @return void
44 - */
45 17 public static function display_form( $errors = array(), $message = '' ) {
46 18 global $frm_vars;
47 19
48 20 $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 21
54 - if ( in_array( $current, array( 'stripe_settings', 'square_settings', 'authorize_net_settings', 'paypal_settings' ), true ) ) {
55 - $current = 'payments_settings';
56 - }
22 + $uploads = wp_upload_dir();
23 + $target_path = $uploads['basedir'] . '/formidable/css';
57 24
58 - require FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php';
25 + $sections = self::get_settings_tabs();
26 + $current = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' );
27 +
28 + require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' );
59 29 }
60 30
61 - /**
62 - * Get sections to use for Global Settings.
63 - *
64 - * @return array<array>
65 - */
66 31 private static function get_settings_tabs() {
67 32 $sections = array(
68 - 'general' => array(
69 - 'class' => self::class,
33 + 'general' => array(
34 + 'class' => __CLASS__,
70 35 'function' => 'general_settings',
71 36 'name' => __( 'General Settings', 'formidable' ),
72 - 'icon' => 'frmfont frm_settings_icon',
37 + 'icon' => 'frm_icon_font frm_settings_icon',
73 38 ),
74 - 'messages' => array(
75 - 'class' => self::class,
39 + 'messages' => array(
40 + 'class' => __CLASS__,
76 41 'function' => 'message_settings',
77 42 'name' => __( 'Message Defaults', 'formidable' ),
78 - 'icon' => 'frmfont frm_stamp_icon',
43 + 'icon' => 'frm_icon_font frm_stamp_icon',
79 44 ),
80 - 'permissions' => array(
81 - 'class' => self::class,
45 + 'permissions' => array(
46 + 'class' => __CLASS__,
82 47 'function' => 'permission_settings',
83 48 'name' => __( 'Permissions', 'formidable' ),
84 - 'icon' => 'frmfont frm_lock_icon',
49 + 'icon' => 'frm_icon_font frm_lock_icon',
85 50 ),
86 - 'payments' => array(
87 - 'name' => __( 'Payments', 'formidable' ),
88 - 'icon' => 'frmfont frm_simple_cc_icon',
89 - 'class' => self::class,
90 - 'function' => 'payments_settings',
51 + 'recaptcha' => array(
52 + 'class' => __CLASS__,
53 + 'function' => 'recaptcha_settings',
54 + 'name' => __( 'reCaptcha', 'formidable' ),
55 + 'icon' => 'frm_icon_font frm_shield_check_icon',
91 56 ),
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,
106 - 'function' => 'captcha_settings',
107 - 'name' => __( 'Captcha/Spam', 'formidable' ),
108 - 'icon' => 'frmfont frm_shield_check_icon',
109 - ),
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(
57 + 'white_label' => array(
117 58 'name' => __( 'White Labeling', 'formidable' ),
118 - 'icon' => 'frmfont frm_ghost_icon',
119 - 'html_class' => 'frm_show_upgrade_tab frm_noallow',
59 + 'icon' => 'frm_icon_font frm_ghost_icon',
60 + 'html_class' => 'frm_show_upgrade frm_noallow',
120 61 'data' => array(
121 - 'medium' => 'white-label',
122 - 'upgrade' => __( 'White labeling options', 'formidable' ),
123 - 'screenshot' => 'white-label.png',
124 - 'learn-more' => FrmAppHelper::get_doc_url( 'features/white-label-form-builder-wordpress', 'white-labeling-global-settings', false ),
62 + 'medium' => 'white-label',
63 + 'upgrade' => __( 'White labeling options', 'formidable' ),
125 64 ),
126 65 ),
127 - 'inbox' => array(
128 - 'name' => __( 'Inbox', 'formidable' ),
129 - 'icon' => 'frmfont frm_email_icon',
130 - 'html_class' => 'frm_show_upgrade_tab frm_noallow',
131 - 'data' => array(
132 - 'medium' => 'inbox-settings',
133 - 'upgrade' => __( 'Inbox settings', 'formidable' ),
134 - 'screenshot' => 'inbox.png',
135 - 'learn-more' => FrmAppHelper::get_doc_url( 'global-settings-overview/#kb-inbox', 'inbox-global-settings' ),
136 - ),
137 - ),
138 66 );
139 67
140 68 if ( apply_filters( 'frm_include_addon_page', false ) ) {
141 - // If no addons need a license, skip this page
69 + // if no addons need a license, skip this page
142 70 $show_licenses = false;
143 71 $installed_addons = apply_filters( 'frm_installed_addons', array() );
144 -
145 72 foreach ( $installed_addons as $installed_addon ) {
146 - if ( ! $installed_addon->is_parent_licence && $installed_addon->plugin_name !== 'Formidable Pro' && $installed_addon->needs_license ) {
73 + if ( ! $installed_addon->is_parent_licence && $installed_addon->plugin_name != 'Formidable Pro' ) {
147 74 $show_licenses = true;
148 75 break;
149 76 }
150 77 }
@@ -153,24 +80,19 @@
153 80 $sections['licenses'] = array(
154 81 'class' => 'FrmAddonsController',
155 82 'function' => 'license_settings',
156 83 'name' => __( 'Plugin Licenses', 'formidable' ),
157 - 'icon' => 'frmfont frm_key_icon',
84 + 'icon' => 'frm_icon_font frm_keyalt_icon',
158 85 'ajax' => true,
159 86 );
160 87 }
161 - }//end if
162 -
163 - /**
164 - * @param array<array> $sections
165 - */
88 + }
166 89 $sections = apply_filters( 'frm_add_settings_section', $sections );
167 - self::remove_payments_sections( $sections );
168 90
169 91 $sections['misc'] = array(
170 92 'name' => __( 'Miscellaneous', 'formidable' ),
171 - 'icon' => 'frmfont frm_shuffle_icon',
172 - 'class' => self::class,
93 + 'icon' => 'frm_icon_font frm_shuffle_icon',
94 + 'class' => __CLASS__,
173 95 'function' => 'misc_settings',
174 96 );
175 97
176 98 foreach ( $sections as $key => $section ) {
@@ -177,9 +99,9 @@
177 99 $original = $section;
178 100 $defaults = array(
179 101 'html_class' => '',
180 102 'name' => ucfirst( $key ),
181 - 'icon' => 'frmfont frm_settings_icon',
103 + 'icon' => 'frm_icon_font frm_settings_icon',
182 104 'anchor' => $key . '_settings',
183 105 'data' => array(),
184 106 );
185 107
@@ -194,58 +116,13 @@
194 116 $section['function'] = $original;
195 117 }
196 118
197 119 $sections[ $key ] = $section;
198 - }//end foreach
120 + }
199 121
200 122 return $sections;
201 123 }
202 124
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 125 public static function load_settings_tab() {
249 126 FrmAppHelper::permission_check( 'frm_change_settings' );
250 127 check_ajax_referer( 'frm_ajax', 'nonce' );
251 128
@@ -250,9 +127,8 @@
250 127 check_ajax_referer( 'frm_ajax', 'nonce' );
251 128
252 129 $section = FrmAppHelper::get_post_param( 'tab', '', 'sanitize_text_field' );
253 130 $sections = self::get_settings_tabs();
254 -
255 131 if ( ! isset( $sections[ $section ] ) ) {
256 132 wp_die();
257 133 }
258 134
@@ -260,150 +136,82 @@
260 136
261 137 if ( isset( $section['class'] ) ) {
262 138 call_user_func( array( $section['class'], $section['function'] ) );
263 139 } else {
264 - call_user_func( $section['function'] ?? $section );
140 + call_user_func( ( isset( $section['function'] ) ? $section['function'] : $section ) );
265 141 }
266 -
267 142 wp_die();
268 143 }
269 144
270 145 /**
271 - * Render the general global settings section.
272 - *
273 146 * @since 4.0
274 - *
275 - * @return void
276 147 */
277 148 public static function general_settings() {
278 149 $frm_settings = FrmAppHelper::get_settings();
279 - $uploads = wp_upload_dir();
280 - $target_path = $uploads['basedir'] . '/formidable/css';
281 150
282 - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/general.php';
283 - }
151 + $uploads = wp_upload_dir();
152 + $target_path = $uploads['basedir'] . '/formidable/css';
284 153
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';
154 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/general.php' );
300 155 }
301 156
302 157 /**
303 158 * @since 4.0
304 - *
305 - * @return void
306 159 */
307 160 public static function message_settings() {
308 161 $frm_settings = FrmAppHelper::get_settings();
309 - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/messages.php';
162 +
163 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/messages.php' );
310 164 }
311 165
312 166 /**
313 167 * @since 4.0
314 - *
315 - * @return void
316 168 */
317 - public static function captcha_settings() {
169 + public static function recaptcha_settings() {
318 170 $frm_settings = FrmAppHelper::get_settings();
319 171 $captcha_lang = FrmAppHelper::locales( 'captcha' );
320 172
321 - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/captcha/captcha.php';
173 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/recaptcha.php' );
322 174 }
323 175
324 176 /**
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 177 * @since 4.0
338 - *
339 - * @return void
340 178 */
341 179 public static function permission_settings() {
342 180 $frm_settings = FrmAppHelper::get_settings();
343 181 $frm_roles = FrmAppHelper::frm_capabilities();
344 182
345 - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/permissions.php';
183 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/permissions.php' );
346 184 }
347 185
348 186 /**
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 187 * @since 4.0
366 - *
367 - * @return void
368 188 */
369 189 public static function misc_settings() {
370 190 $frm_settings = FrmAppHelper::get_settings();
371 - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/misc.php';
191 +
192 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/misc.php' );
372 193 }
373 194
374 - /**
375 - * Save form data submitted from the Global settings page.
376 - *
377 - * @param bool|string $stop_load
378 - *
379 - * @return void
380 - */
381 195 public static function process_form( $stop_load = false ) {
382 196 global $frm_vars;
383 197
384 198 $frm_settings = FrmAppHelper::get_settings();
199 +
385 200 $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' );
386 -
387 201 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;
202 + wp_die( esc_html( $frm_settings->admin_permission ) );
395 203 }
396 204
397 205 $errors = array();
398 206 $message = '';
399 207
400 - if ( empty( $frm_vars['settings_routed'] ) ) {
208 + if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) {
401 209 $errors = $frm_settings->validate( $_POST, array() );
402 210
403 211 $frm_settings->update( wp_unslash( $_POST ) );
404 212
405 - if ( ! $errors ) {
213 + if ( empty( $errors ) ) {
406 214 $frm_settings->store();
407 215 $message = __( 'Settings Saved', 'formidable' );
408 216 }
409 217 } else {
@@ -409,10 +217,11 @@
409 217 } else {
410 218 $message = __( 'Settings Saved', 'formidable' );
411 219 }
412 220
413 - if ( $stop_load === 'stop_load' ) {
221 + if ( $stop_load == 'stop_load' ) {
414 222 $frm_vars['settings_routed'] = true;
223 +
415 224 return;
416 225 }
417 226
418 227 self::display_form( $errors, $message );
@@ -421,10 +230,8 @@
421 230 /**
422 231 * Include the Update button on the global settings page.
423 232 *
424 233 * @since 4.0.02
425 - *
426 - * @return void
427 234 */
428 235 public static function save_button() {
429 236 echo '<input class="button-primary frm-button-primary" type="submit"
430 237 value="' . esc_attr__( 'Update', 'formidable' ) . '"/>';
@@ -429,21 +236,16 @@
429 236 echo '<input class="button-primary frm-button-primary" type="submit"
430 237 value="' . esc_attr__( 'Update', 'formidable' ) . '"/>';
431 238 }
432 239
433 - /**
434 - * @param bool|string $stop_load
435 - *
436 - * @return void
437 - */
438 240 public static function route( $stop_load = false ) {
439 241 $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
440 242 $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
441 243 FrmAppHelper::include_svg();
442 244
443 - if ( $action === 'process-form' ) {
245 + if ( $action == 'process-form' ) {
444 246 self::process_form( $stop_load );
445 - } elseif ( $stop_load !== 'stop_load' ) {
247 + } elseif ( $stop_load != 'stop_load' ) {
446 248 self::display_form();
447 249 }
448 250 }
449 251
@@ -450,17 +252,34 @@
450 252 /**
451 253 * Add CTA to the bottom on the plugin settings pages.
452 254 *
453 255 * @since 3.04.02
454 - *
455 - * @return void
456 256 */
457 - public static function settings_cta() {
257 + public static function settings_cta( $view ) {
258 +
458 259 if ( get_option( 'frm_lite_settings_upgrade', false ) ) {
459 260 return;
460 261 }
461 262
462 - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/settings_cta.php';
263 + $features = array(
264 + __( 'Extra form features like file uploads, pagination, etc', 'formidable' ),
265 + __( 'Repeaters & cascading fields for advanced forms', 'formidable' ),
266 + __( 'Flexibly view, search, edit, and delete entries anywhere', 'formidable' ),
267 + __( 'Display entries with virtually limitless Formidable views', 'formidable' ),
268 + __( 'Create surveys & polls', 'formidable' ),
269 + __( 'WordPress user registration and login forms', 'formidable' ),
270 + __( 'Create Stripe, PayPal or Authorize.net payment forms', 'formidable' ),
271 + __( 'Powerful conditional logic for smart forms', 'formidable' ),
272 + __( 'Integrations with 1000+ marketing & payment services', 'formidable' ),
273 + __( 'Collect digital signatures', 'formidable' ),
274 + __( 'Accept user-submitted content with Post submissions', 'formidable' ),
275 + __( 'Email routing', 'formidable' ),
276 + __( 'Create calculator forms', 'formidable' ),
277 + __( 'Save draft entries and return later', 'formidable' ),
278 + __( 'Analyze form data with graphs & stats', 'formidable' ),
279 + );
280 +
281 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/settings_cta.php' );
463 282 }
464 283
465 284 /**
466 285 * Dismiss upgrade notice at the bottom on the plugin settings pages.
@@ -467,69 +286,12 @@
467 286 *
468 287 * @since 3.04.02
469 288 */
470 289 public static function settings_cta_dismiss() {
471 - check_ajax_referer( 'frm_ajax', 'nonce' );
472 290 FrmAppHelper::permission_check( 'frm_change_settings' );
473 291
474 - update_option( 'frm_lite_settings_upgrade', time(), false );
292 + update_option( 'frm_lite_settings_upgrade', time(), 'no' );
475 293
476 294 wp_send_json_success();
477 295 }
478 296
479 - /**
480 - * Autocomplete page admin ajax endpoint
481 - *
482 - * @since 4.03.06
483 - */
484 - public static function page_search() {
485 - FrmAppHelper::permission_check( 'frm_edit_forms' );
486 - check_ajax_referer( 'frm_ajax', 'nonce' );
487 -
488 - global $wpdb;
489 -
490 - $term = FrmAppHelper::get_param( 'term', '', 'get', 'sanitize_text_field' );
491 - $post_type = FrmAppHelper::get_param( 'post_type', 'page', 'get', 'sanitize_text_field' );
492 -
493 - $where = array(
494 - 'post_status' => 'publish',
495 - 'post_type' => $post_type,
496 - 'post_title LIKE' => $term,
497 - );
498 -
499 - $atts = array(
500 - 'limit' => 25,
501 - 'order_by' => 'post_title',
502 - );
503 -
504 - $pages = FrmDb::get_results( $wpdb->posts, $where, 'ID, post_title', $atts );
505 - $results = array();
506 -
507 - foreach ( $pages as $page ) {
508 - $results[] = array(
509 - 'value' => $page->ID,
510 - 'label' => $page->post_title,
511 - );
512 - }
513 -
514 - wp_send_json( $results );
515 - }
516 -
517 - /**
518 - * Shows a fake color picker.
519 - *
520 - * @since 6.25
521 - *
522 - * @param string $color Color value.
523 - *
524 - * @return void
525 - */
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
534 - }
535 297 }