PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.1
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.1
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 +55 -170 6.256.1 View file →
@@ -4,17 +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 8 public static function menu() {
18 9 // Make sure admins can see the menu items
19 10 FrmAppHelper::force_capability( 'frm_change_settings' );
20 11
@@ -20,18 +11,11 @@
20 11
21 12 add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' );
22 13 }
23 14
24 - /**
25 - * Include license box template on demand.
26 - *
27 - * @return void
28 - */
29 15 public static function license_box() {
30 - if ( ! current_user_can( 'activate_plugins' ) ) {
31 - return;
32 - }
33 - 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' );
34 18 }
35 19
36 20 public static function display_form( $errors = array(), $message = '' ) {
37 21 global $frm_vars;
@@ -43,13 +27,9 @@
43 27
44 28 $sections = self::get_settings_tabs();
45 29 $current = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' );
46 30
47 - if ( in_array( $current, array( 'stripe_settings', 'square_settings', 'authorize_net_settings', 'paypal_settings' ), true ) ) {
48 - $current = 'payments_settings';
49 - }
50 -
51 - require FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php';
31 + require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' );
52 32 }
53 33
54 34 /**
55 35 * Get sections to use for Global Settings.
@@ -57,33 +37,27 @@
57 37 * @return array<array>
58 38 */
59 39 private static function get_settings_tabs() {
60 40 $sections = array(
61 - 'general' => array(
62 - 'class' => self::class,
41 + 'general' => array(
42 + 'class' => __CLASS__,
63 43 'function' => 'general_settings',
64 44 'name' => __( 'General Settings', 'formidable' ),
65 45 'icon' => 'frm_icon_font frm_settings_icon',
66 46 ),
67 - 'messages' => array(
68 - 'class' => self::class,
47 + 'messages' => array(
48 + 'class' => __CLASS__,
69 49 'function' => 'message_settings',
70 50 'name' => __( 'Message Defaults', 'formidable' ),
71 51 'icon' => 'frm_icon_font frm_stamp_icon',
72 52 ),
73 - 'permissions' => array(
74 - 'class' => self::class,
53 + 'permissions' => array(
54 + 'class' => __CLASS__,
75 55 'function' => 'permission_settings',
76 56 'name' => __( 'Permissions', 'formidable' ),
77 57 'icon' => 'frm_icon_font frm_lock_icon',
78 58 ),
79 - 'payments' => array(
80 - 'name' => __( 'Payments', 'formidable' ),
81 - 'icon' => 'frm_icon_font frm_simple_cc_icon',
82 - 'class' => self::class,
83 - 'function' => 'payments_settings',
84 - ),
85 - 'custom_css' => array(
59 + 'custom_css' => array(
86 60 'class' => 'FrmStylesController',
87 61 'function' => 'custom_css',
88 62 'name' => __( 'Custom CSS', 'formidable' ),
89 63 'icon' => 'frm_icon_font frm_code_icon',
@@ -93,21 +67,15 @@
93 67 'function' => 'manage',
94 68 'name' => __( 'Manage Styles', 'formidable' ),
95 69 'icon' => 'frm_icon_font frm_pallet_icon',
96 70 ),
97 - 'captcha' => array(
98 - 'class' => self::class,
71 + 'captcha' => array(
72 + 'class' => __CLASS__,
99 73 'function' => 'captcha_settings',
100 - 'name' => __( 'Captcha/Spam', 'formidable' ),
74 + 'name' => __( 'Captcha', 'formidable' ),
101 75 'icon' => 'frm_icon_font frm_shield_check_icon',
102 76 ),
103 - 'email' => array(
104 - 'class' => self::class,
105 - 'function' => 'email_settings',
106 - 'name' => __( 'Email', 'formidable' ),
107 - 'icon' => 'frm_icon_font frm_email_icon',
108 - ),
109 - 'white_label' => array(
77 + 'white_label' => array(
110 78 'name' => __( 'White Labeling', 'formidable' ),
111 79 'icon' => 'frm_icon_font frm_ghost_icon',
112 80 'html_class' => 'frm_show_upgrade_tab frm_noallow',
113 81 'data' => array(
@@ -115,9 +83,9 @@
115 83 'upgrade' => __( 'White labeling options', 'formidable' ),
116 84 'screenshot' => 'white-label.png',
117 85 ),
118 86 ),
119 - 'inbox' => array(
87 + 'inbox' => array(
120 88 'name' => __( 'Inbox', 'formidable' ),
121 89 'icon' => 'frm_icon_font frm_email_icon',
122 90 'html_class' => 'frm_show_upgrade_tab frm_noallow',
123 91 'data' => array(
@@ -143,24 +111,23 @@
143 111 $sections['licenses'] = array(
144 112 'class' => 'FrmAddonsController',
145 113 'function' => 'license_settings',
146 114 'name' => __( 'Plugin Licenses', 'formidable' ),
147 - 'icon' => 'frmfont frm_key_icon',
115 + 'icon' => 'frm_icon_font frm_keyalt_icon',
148 116 'ajax' => true,
149 117 );
150 118 }
151 - }//end if
119 + }
152 120
153 121 /**
154 122 * @param array<array> $sections
155 123 */
156 124 $sections = apply_filters( 'frm_add_settings_section', $sections );
157 - self::remove_payments_sections( $sections );
158 125
159 126 $sections['misc'] = array(
160 127 'name' => __( 'Miscellaneous', 'formidable' ),
161 128 'icon' => 'frm_icon_font frm_shuffle_icon',
162 - 'class' => self::class,
129 + 'class' => __CLASS__,
163 130 'function' => 'misc_settings',
164 131 );
165 132
166 133 foreach ( $sections as $key => $section ) {
@@ -184,54 +151,13 @@
184 151 $section['function'] = $original;
185 152 }
186 153
187 154 $sections[ $key ] = $section;
188 - }//end foreach
155 + }
189 156
190 157 return $sections;
191 158 }
192 159
193 - /**
194 - * Remove the payments sections (PayPal, Square, Stripe, Authorize.Net)
195 - * and show them all on the payments section in separate tabs.
196 - *
197 - * @since 6.22.1
198 - *
199 - * @param array $sections
200 - * @return void
201 - */
202 - private static function remove_payments_sections( &$sections ) {
203 - $payment_section_keys = array( 'paypal', 'square', 'stripe', 'authorize_net' );
204 -
205 - foreach ( $sections as $key => $section ) {
206 - if ( in_array( $key, $payment_section_keys, true ) ) {
207 - self::$removed_payments_sections[ $key ] = $section;
208 - unset( $sections[ $key ] );
209 - }
210 - }
211 -
212 - uksort( self::$removed_payments_sections, array( self::class, 'payment_sections_sort_callback' ) );
213 - }
214 -
215 - /**
216 - * Sort the payments sections (PayPal, Square, Stripe, Authorize.Net)
217 - *
218 - * @since 6.22.1
219 - *
220 - * @param string $a
221 - * @param string $b
222 - * @return int
223 - */
224 - private static function payment_sections_sort_callback( $a, $b ) {
225 - $order = array( 'stripe', 'square', 'paypal', 'authorize_net' );
226 - $first_key = array_search( $a, $order );
227 - $second_key = array_search( $b, $order );
228 - if ( false === $first_key || false === $second_key ) {
229 - return 0;
230 - }
231 - return $first_key - $second_key;
232 - }
233 -
234 160 public static function load_settings_tab() {
235 161 FrmAppHelper::permission_check( 'frm_change_settings' );
236 162 check_ajax_referer( 'frm_ajax', 'nonce' );
237 163
@@ -245,43 +171,23 @@
245 171
246 172 if ( isset( $section['class'] ) ) {
247 173 call_user_func( array( $section['class'], $section['function'] ) );
248 174 } else {
249 - call_user_func( ( $section['function'] ?? $section ) );
175 + call_user_func( ( isset( $section['function'] ) ? $section['function'] : $section ) );
250 176 }
251 177 wp_die();
252 178 }
253 179
254 180 /**
255 - * Render the general global settings section.
256 - *
257 181 * @since 4.0
258 - *
259 - * @return void
260 182 */
261 183 public static function general_settings() {
262 184 $frm_settings = FrmAppHelper::get_settings();
263 - $uploads = wp_upload_dir();
264 - $target_path = $uploads['basedir'] . '/formidable/css';
265 185
266 - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/general.php';
267 - }
186 + $uploads = wp_upload_dir();
187 + $target_path = $uploads['basedir'] . '/formidable/css';
268 188
269 - /**
270 - * Render the global currency selector if Pro is up to date.
271 - *
272 - * @param FrmSettings $frm_settings
273 - * @param string $more_html
274 - * @return void
275 - */
276 - public static function maybe_render_currency_selector( $frm_settings, $more_html ) {
277 - if ( is_callable( 'FrmProSettingsController::add_currency_settings' ) ) {
278 - FrmProSettingsController::add_currency_settings();
279 - return;
280 - }
281 -
282 - $currencies = FrmCurrencyHelper::get_currencies();
283 - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/_currency.php';
189 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/general.php' );
284 190 }
285 191
286 192 /**
287 193 * @since 4.0
@@ -288,9 +194,9 @@
288 194 */
289 195 public static function message_settings() {
290 196 $frm_settings = FrmAppHelper::get_settings();
291 197
292 - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/messages.php';
198 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/messages.php' );
293 199 }
294 200
295 201 /**
296 202 * @since 4.0
@@ -298,23 +204,12 @@
298 204 public static function captcha_settings() {
299 205 $frm_settings = FrmAppHelper::get_settings();
300 206 $captcha_lang = FrmAppHelper::locales( 'captcha' );
301 207
302 - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/captcha/captcha.php';
208 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/captcha/captcha.php' );
303 209 }
304 210
305 211 /**
306 - * Shows email settings.
307 - *
308 - * @since 6.25
309 - */
310 - public static function email_settings() {
311 - $frm_settings = FrmAppHelper::get_settings();
312 -
313 - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/email/email-styles.php';
314 - }
315 -
316 - /**
317 212 * @since 4.0
318 213 */
319 214 public static function permission_settings() {
320 215 $frm_settings = FrmAppHelper::get_settings();
@@ -319,24 +214,11 @@
319 214 public static function permission_settings() {
320 215 $frm_settings = FrmAppHelper::get_settings();
321 216 $frm_roles = FrmAppHelper::frm_capabilities();
322 217
323 - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/permissions.php';
218 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/permissions.php' );
324 219 }
325 220
326 - public static function payments_settings() {
327 - $payment_sections = self::$removed_payments_sections;
328 -
329 - $tab = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' );
330 - if ( $tab && in_array( $tab, array( 'stripe_settings', 'square_settings', 'authorize_net_settings', 'paypal_settings' ), true ) ) {
331 - $tab = str_replace( '_settings', '', $tab );
332 - } else {
333 - $tab = 'stripe';
334 - }
335 -
336 - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/payments.php';
337 - }
338 -
339 221 /**
340 222 * @since 4.0
341 223 */
342 224 public static function misc_settings() {
@@ -341,15 +223,15 @@
341 223 */
342 224 public static function misc_settings() {
343 225 $frm_settings = FrmAppHelper::get_settings();
344 226
345 - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/misc.php';
227 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/misc.php' );
346 228 }
347 229
348 230 /**
349 231 * Save form data submitted from the Global settings page.
350 232 *
351 - * @param bool|string $stop_load
233 + * @param string|bool $stop_load
352 234 *
353 235 * @return void
354 236 */
355 237 public static function process_form( $stop_load = false ) {
@@ -358,15 +240,9 @@
358 240 $frm_settings = FrmAppHelper::get_settings();
359 241 $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' );
360 242
361 243 if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) {
362 - $error_args = array(
363 - 'title' => __( 'Verification failed', 'formidable' ),
364 - 'body' => $frm_settings->admin_permission,
365 - 'cancel_text' => __( 'Cancel', 'formidable' ),
366 - );
367 - FrmAppController::show_error_modal( $error_args );
368 - return;
244 + wp_die( esc_html( $frm_settings->admin_permission ) );
369 245 }
370 246
371 247 $errors = array();
372 248 $message = '';
@@ -406,9 +282,9 @@
406 282 $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
407 283 $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
408 284 FrmAppHelper::include_svg();
409 285
410 - if ( $action === 'process-form' ) {
286 + if ( $action == 'process-form' ) {
411 287 self::process_form( $stop_load );
412 288 } elseif ( $stop_load != 'stop_load' ) {
413 289 self::display_form();
414 290 }
@@ -419,13 +295,32 @@
419 295 *
420 296 * @since 3.04.02
421 297 */
422 298 public static function settings_cta( $view ) {
299 +
423 300 if ( get_option( 'frm_lite_settings_upgrade', false ) ) {
424 301 return;
425 302 }
426 303
427 - 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' );
428 323 }
429 324
430 325 /**
431 326 * Dismiss upgrade notice at the bottom on the plugin settings pages.
@@ -432,9 +327,8 @@
432 327 *
433 328 * @since 3.04.02
434 329 */
435 330 public static function settings_cta_dismiss() {
436 - check_ajax_referer( 'frm_ajax', 'nonce' );
437 331 FrmAppHelper::permission_check( 'frm_change_settings' );
438 332
439 333 update_option( 'frm_lite_settings_upgrade', time(), 'no' );
440 334
@@ -451,9 +345,9 @@
451 345 check_ajax_referer( 'frm_ajax', 'nonce' );
452 346
453 347 global $wpdb;
454 348
455 - $term = FrmAppHelper::get_param( 'term', '', 'get', 'sanitize_text_field' );
349 + $term = FrmAppHelper::get_param( 'term', '', 'get', 'sanitize_text_field' );
456 350 $post_type = FrmAppHelper::get_param( 'post_type', 'page', 'get', 'sanitize_text_field' );
457 351
458 352 $where = array(
459 353 'post_status' => 'publish',
@@ -479,20 +373,11 @@
479 373 wp_send_json( $results );
480 374 }
481 375
482 376 /**
483 - * Shows a fake color picker.
484 - *
485 - * @since 6.25
486 - *
487 - * @param string $color Color value.
377 + * @deprecated x.x use FrmSettingsController::captcha_settings().
488 378 */
489 - public static function fake_color_picker( $color ) {
490 - ?>
491 - <div class="wp-picker-container">
492 - <button type="button" class="button wp-color-result" aria-expanded="false" aria-disabled="true" tabindex="-1" style="background-color:<?php echo esc_attr( $color ); ?>;">
493 - <span class="wp-color-result-text" style="color:#a7aaad;"><?php esc_html_e( 'Select Color', 'formidable' ); ?></span>
494 - </button>
495 - </div>
496 - <?php
379 + public static function recaptcha_settings() {
380 + _deprecated_function( __FUNCTION__, 'x.x', 'FrmSettingsController::captcha_settings()' );
381 + self::captcha_settings();
497 382 }
498 383 }