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 +106 -53 6.56.22.2 View file →
@@ -4,8 +4,17 @@
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 +
8 17 public static function menu() {
9 18 // Make sure admins can see the menu items
10 19 FrmAppHelper::force_capability( 'frm_change_settings' );
11 20
@@ -20,9 +29,9 @@
20 29 public static function license_box() {
21 30 if ( ! current_user_can( 'activate_plugins' ) ) {
22 31 return;
23 32 }
24 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' );
33 + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php';
25 34 }
26 35
27 36 public static function display_form( $errors = array(), $message = '' ) {
28 37 global $frm_vars;
@@ -34,9 +43,13 @@
34 43
35 44 $sections = self::get_settings_tabs();
36 45 $current = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' );
37 46
38 - require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' );
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';
39 52 }
40 53
41 54 /**
42 55 * Get sections to use for Global Settings.
@@ -44,27 +57,33 @@
44 57 * @return array<array>
45 58 */
46 59 private static function get_settings_tabs() {
47 60 $sections = array(
48 - 'general' => array(
61 + 'general' => array(
49 62 'class' => __CLASS__,
50 63 'function' => 'general_settings',
51 64 'name' => __( 'General Settings', 'formidable' ),
52 65 'icon' => 'frm_icon_font frm_settings_icon',
53 66 ),
54 - 'messages' => array(
67 + 'messages' => array(
55 68 'class' => __CLASS__,
56 69 'function' => 'message_settings',
57 70 'name' => __( 'Message Defaults', 'formidable' ),
58 71 'icon' => 'frm_icon_font frm_stamp_icon',
59 72 ),
60 - 'permissions' => array(
73 + 'permissions' => array(
61 74 'class' => __CLASS__,
62 75 'function' => 'permission_settings',
63 76 'name' => __( 'Permissions', 'formidable' ),
64 77 'icon' => 'frm_icon_font frm_lock_icon',
65 78 ),
66 - 'custom_css' => array(
79 + 'payments' => array(
80 + 'name' => __( 'Payments', 'formidable' ),
81 + 'icon' => 'frm_icon_font frm_simple_cc_icon',
82 + 'class' => __CLASS__,
83 + 'function' => 'payments_settings',
84 + ),
85 + 'custom_css' => array(
67 86 'class' => 'FrmStylesController',
68 87 'function' => 'custom_css',
69 88 'name' => __( 'Custom CSS', 'formidable' ),
70 89 'icon' => 'frm_icon_font frm_code_icon',
@@ -74,15 +93,15 @@
74 93 'function' => 'manage',
75 94 'name' => __( 'Manage Styles', 'formidable' ),
76 95 'icon' => 'frm_icon_font frm_pallet_icon',
77 96 ),
78 - 'captcha' => array(
97 + 'captcha' => array(
79 98 'class' => __CLASS__,
80 99 'function' => 'captcha_settings',
81 - 'name' => __( 'Captcha', 'formidable' ),
100 + 'name' => __( 'Captcha/Spam', 'formidable' ),
82 101 'icon' => 'frm_icon_font frm_shield_check_icon',
83 102 ),
84 - 'white_label' => array(
103 + 'white_label' => array(
85 104 'name' => __( 'White Labeling', 'formidable' ),
86 105 'icon' => 'frm_icon_font frm_ghost_icon',
87 106 'html_class' => 'frm_show_upgrade_tab frm_noallow',
88 107 'data' => array(
@@ -90,9 +109,9 @@
90 109 'upgrade' => __( 'White labeling options', 'formidable' ),
91 110 'screenshot' => 'white-label.png',
92 111 ),
93 112 ),
94 - 'inbox' => array(
113 + 'inbox' => array(
95 114 'name' => __( 'Inbox', 'formidable' ),
96 115 'icon' => 'frm_icon_font frm_email_icon',
97 116 'html_class' => 'frm_show_upgrade_tab frm_noallow',
98 117 'data' => array(
@@ -118,18 +137,19 @@
118 137 $sections['licenses'] = array(
119 138 'class' => 'FrmAddonsController',
120 139 'function' => 'license_settings',
121 140 'name' => __( 'Plugin Licenses', 'formidable' ),
122 - 'icon' => 'frm_icon_font frm_keyalt_icon',
141 + 'icon' => 'frmfont frm_key_icon',
123 142 'ajax' => true,
124 143 );
125 144 }
126 - }
145 + }//end if
127 146
128 147 /**
129 148 * @param array<array> $sections
130 149 */
131 150 $sections = apply_filters( 'frm_add_settings_section', $sections );
151 + self::remove_payments_sections( $sections );
132 152
133 153 $sections['misc'] = array(
134 154 'name' => __( 'Miscellaneous', 'formidable' ),
135 155 'icon' => 'frm_icon_font frm_shuffle_icon',
@@ -158,13 +178,54 @@
158 178 $section['function'] = $original;
159 179 }
160 180
161 181 $sections[ $key ] = $section;
182 + }//end foreach
183 +
184 + return $sections;
185 + }
186 +
187 + /**
188 + * Remove the payments sections (PayPal, Square, Stripe, Authorize.Net)
189 + * and show them all on the payments section in separate tabs.
190 + *
191 + * @since 6.22.1
192 + *
193 + * @param array $sections
194 + * @return void
195 + */
196 + private static function remove_payments_sections( &$sections ) {
197 + $payment_section_keys = array( 'paypal', 'square', 'stripe', 'authorize_net' );
198 +
199 + foreach ( $sections as $key => $section ) {
200 + if ( in_array( $key, $payment_section_keys, true ) ) {
201 + self::$removed_payments_sections[ $key ] = $section;
202 + unset( $sections[ $key ] );
203 + }
162 204 }
163 205
164 - return $sections;
206 + uksort( self::$removed_payments_sections, array( __CLASS__, 'payment_sections_sort_callback' ) );
165 207 }
166 208
209 + /**
210 + * Sort the payments sections (PayPal, Square, Stripe, Authorize.Net)
211 + *
212 + * @since 6.22.1
213 + *
214 + * @param string $a
215 + * @param string $b
216 + * @return int
217 + */
218 + private static function payment_sections_sort_callback( $a, $b ) {
219 + $order = array( 'stripe', 'square', 'paypal', 'authorize_net' );
220 + $first_key = array_search( $a, $order );
221 + $second_key = array_search( $b, $order );
222 + if ( false === $first_key || false === $second_key ) {
223 + return 0;
224 + }
225 + return $first_key - $second_key;
226 + }
227 +
167 228 public static function load_settings_tab() {
168 229 FrmAppHelper::permission_check( 'frm_change_settings' );
169 230 check_ajax_referer( 'frm_ajax', 'nonce' );
170 231
@@ -202,15 +263,14 @@
202 263 /**
203 264 * Render the global currency selector if Pro is up to date.
204 265 *
205 266 * @param FrmSettings $frm_settings
206 - * @param string $more_html
267 + * @param string $more_html
207 268 * @return void
208 269 */
209 270 public static function maybe_render_currency_selector( $frm_settings, $more_html ) {
210 - if ( false !== strpos( $more_html, 'id="frm_currency"' ) ) {
211 - // Avoid rendering the Currency setting if it gets rendered from the frm_settings_form hook.
212 - // This is for backward compatibility. If Pro is outdated there won't be two currency dropdowns.
271 + if ( is_callable( 'FrmProSettingsController::add_currency_settings' ) ) {
272 + FrmProSettingsController::add_currency_settings();
213 273 return;
214 274 }
215 275
216 276 $currencies = FrmCurrencyHelper::get_currencies();
@@ -222,9 +282,9 @@
222 282 */
223 283 public static function message_settings() {
224 284 $frm_settings = FrmAppHelper::get_settings();
225 285
226 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/messages.php' );
286 + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/messages.php';
227 287 }
228 288
229 289 /**
230 290 * @since 4.0
@@ -232,9 +292,9 @@
232 292 public static function captcha_settings() {
233 293 $frm_settings = FrmAppHelper::get_settings();
234 294 $captcha_lang = FrmAppHelper::locales( 'captcha' );
235 295
236 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/captcha/captcha.php' );
296 + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/captcha/captcha.php';
237 297 }
238 298
239 299 /**
240 300 * @since 4.0
@@ -242,11 +302,24 @@
242 302 public static function permission_settings() {
243 303 $frm_settings = FrmAppHelper::get_settings();
244 304 $frm_roles = FrmAppHelper::frm_capabilities();
245 305
246 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/permissions.php' );
306 + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/permissions.php';
247 307 }
248 308
309 + public static function payments_settings() {
310 + $payment_sections = self::$removed_payments_sections;
311 +
312 + $tab = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' );
313 + if ( $tab && in_array( $tab, array( 'stripe_settings', 'square_settings', 'authorize_net_settings', 'paypal_settings' ), true ) ) {
314 + $tab = str_replace( '_settings', '', $tab );
315 + } else {
316 + $tab = 'stripe';
317 + }
318 +
319 + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/payments.php';
320 + }
321 +
249 322 /**
250 323 * @since 4.0
251 324 */
252 325 public static function misc_settings() {
@@ -251,15 +324,15 @@
251 324 */
252 325 public static function misc_settings() {
253 326 $frm_settings = FrmAppHelper::get_settings();
254 327
255 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/misc.php' );
328 + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/misc.php';
256 329 }
257 330
258 331 /**
259 332 * Save form data submitted from the Global settings page.
260 333 *
261 - * @param string|bool $stop_load
334 + * @param bool|string $stop_load
262 335 *
263 336 * @return void
264 337 */
265 338 public static function process_form( $stop_load = false ) {
@@ -268,9 +341,15 @@
268 341 $frm_settings = FrmAppHelper::get_settings();
269 342 $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' );
270 343
271 344 if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) {
272 - wp_die( esc_html( $frm_settings->admin_permission ) );
345 + $error_args = array(
346 + 'title' => __( 'Verification failed', 'formidable' ),
347 + 'body' => $frm_settings->admin_permission,
348 + 'cancel_text' => __( 'Cancel', 'formidable' ),
349 + );
350 + FrmAppController::show_error_modal( $error_args );
351 + return;
273 352 }
274 353
275 354 $errors = array();
276 355 $message = '';
@@ -310,9 +389,9 @@
310 389 $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
311 390 $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
312 391 FrmAppHelper::include_svg();
313 392
314 - if ( $action == 'process-form' ) {
393 + if ( $action === 'process-form' ) {
315 394 self::process_form( $stop_load );
316 395 } elseif ( $stop_load != 'stop_load' ) {
317 396 self::display_form();
318 397 }
@@ -323,32 +402,13 @@
323 402 *
324 403 * @since 3.04.02
325 404 */
326 405 public static function settings_cta( $view ) {
327 -
328 406 if ( get_option( 'frm_lite_settings_upgrade', false ) ) {
329 407 return;
330 408 }
331 409
332 - $features = array(
333 - __( 'Extra form features like file uploads, pagination, etc', 'formidable' ),
334 - __( 'Repeaters & cascading fields for advanced forms', 'formidable' ),
335 - __( 'Flexibly view, search, edit, and delete entries anywhere', 'formidable' ),
336 - __( 'Display entries with virtually limitless Formidable views', 'formidable' ),
337 - __( 'Create surveys & polls', 'formidable' ),
338 - __( 'WordPress user registration and login forms', 'formidable' ),
339 - __( 'Create Stripe, PayPal or Authorize.net payment forms', 'formidable' ),
340 - __( 'Powerful conditional logic for smart forms', 'formidable' ),
341 - __( 'Integrations with 1000+ marketing & payment services', 'formidable' ),
342 - __( 'Collect digital signatures', 'formidable' ),
343 - __( 'Accept user-submitted content with Post submissions', 'formidable' ),
344 - __( 'Email routing', 'formidable' ),
345 - __( 'Create calculator forms', 'formidable' ),
346 - __( 'Save draft entries and return later', 'formidable' ),
347 - __( 'Analyze form data with graphs & stats', 'formidable' ),
348 - );
349 -
350 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/settings_cta.php' );
410 + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/settings_cta.php';
351 411 }
352 412
353 413 /**
354 414 * Dismiss upgrade notice at the bottom on the plugin settings pages.
@@ -355,8 +415,9 @@
355 415 *
356 416 * @since 3.04.02
357 417 */
358 418 public static function settings_cta_dismiss() {
419 + check_ajax_referer( 'frm_ajax', 'nonce' );
359 420 FrmAppHelper::permission_check( 'frm_change_settings' );
360 421
361 422 update_option( 'frm_lite_settings_upgrade', time(), 'no' );
362 423
@@ -373,9 +434,9 @@
373 434 check_ajax_referer( 'frm_ajax', 'nonce' );
374 435
375 436 global $wpdb;
376 437
377 - $term = FrmAppHelper::get_param( 'term', '', 'get', 'sanitize_text_field' );
438 + $term = FrmAppHelper::get_param( 'term', '', 'get', 'sanitize_text_field' );
378 439 $post_type = FrmAppHelper::get_param( 'post_type', 'page', 'get', 'sanitize_text_field' );
379 440
380 441 $where = array(
381 442 'post_status' => 'publish',
@@ -398,14 +459,6 @@
398 459 );
399 460 }
400 461
401 462 wp_send_json( $results );
402 - }
403 -
404 - /**
405 - * @deprecated 6.0 use FrmSettingsController::captcha_settings().
406 - */
407 - public static function recaptcha_settings() {
408 - _deprecated_function( __FUNCTION__, '6.0', 'FrmSettingsController::captcha_settings()' );
409 - self::captcha_settings();
410 463 }
411 464 }