PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.23
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.23
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 +126 -52 6.3.26.23 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
@@ -184,17 +245,37 @@
184 245 wp_die();
185 246 }
186 247
187 248 /**
249 + * Render the general global settings section.
250 + *
188 251 * @since 4.0
252 + *
253 + * @return void
189 254 */
190 255 public static function general_settings() {
191 256 $frm_settings = FrmAppHelper::get_settings();
257 + $uploads = wp_upload_dir();
258 + $target_path = $uploads['basedir'] . '/formidable/css';
192 259
193 - $uploads = wp_upload_dir();
194 - $target_path = $uploads['basedir'] . '/formidable/css';
260 + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/general.php';
261 + }
195 262
196 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/general.php' );
263 + /**
264 + * Render the global currency selector if Pro is up to date.
265 + *
266 + * @param FrmSettings $frm_settings
267 + * @param string $more_html
268 + * @return void
269 + */
270 + public static function maybe_render_currency_selector( $frm_settings, $more_html ) {
271 + if ( is_callable( 'FrmProSettingsController::add_currency_settings' ) ) {
272 + FrmProSettingsController::add_currency_settings();
273 + return;
274 + }
275 +
276 + $currencies = FrmCurrencyHelper::get_currencies();
277 + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/_currency.php';
197 278 }
198 279
199 280 /**
200 281 * @since 4.0
@@ -201,9 +282,9 @@
201 282 */
202 283 public static function message_settings() {
203 284 $frm_settings = FrmAppHelper::get_settings();
204 285
205 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/messages.php' );
286 + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/messages.php';
206 287 }
207 288
208 289 /**
209 290 * @since 4.0
@@ -211,9 +292,9 @@
211 292 public static function captcha_settings() {
212 293 $frm_settings = FrmAppHelper::get_settings();
213 294 $captcha_lang = FrmAppHelper::locales( 'captcha' );
214 295
215 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/captcha/captcha.php' );
296 + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/captcha/captcha.php';
216 297 }
217 298
218 299 /**
219 300 * @since 4.0
@@ -221,11 +302,24 @@
221 302 public static function permission_settings() {
222 303 $frm_settings = FrmAppHelper::get_settings();
223 304 $frm_roles = FrmAppHelper::frm_capabilities();
224 305
225 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/permissions.php' );
306 + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/permissions.php';
226 307 }
227 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 +
228 322 /**
229 323 * @since 4.0
230 324 */
231 325 public static function misc_settings() {
@@ -230,15 +324,15 @@
230 324 */
231 325 public static function misc_settings() {
232 326 $frm_settings = FrmAppHelper::get_settings();
233 327
234 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/misc.php' );
328 + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/misc.php';
235 329 }
236 330
237 331 /**
238 332 * Save form data submitted from the Global settings page.
239 333 *
240 - * @param string|bool $stop_load
334 + * @param bool|string $stop_load
241 335 *
242 336 * @return void
243 337 */
244 338 public static function process_form( $stop_load = false ) {
@@ -247,9 +341,15 @@
247 341 $frm_settings = FrmAppHelper::get_settings();
248 342 $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' );
249 343
250 344 if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) {
251 - 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;
252 352 }
253 353
254 354 $errors = array();
255 355 $message = '';
@@ -289,9 +389,9 @@
289 389 $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
290 390 $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
291 391 FrmAppHelper::include_svg();
292 392
293 - if ( $action == 'process-form' ) {
393 + if ( $action === 'process-form' ) {
294 394 self::process_form( $stop_load );
295 395 } elseif ( $stop_load != 'stop_load' ) {
296 396 self::display_form();
297 397 }
@@ -302,32 +402,13 @@
302 402 *
303 403 * @since 3.04.02
304 404 */
305 405 public static function settings_cta( $view ) {
306 -
307 406 if ( get_option( 'frm_lite_settings_upgrade', false ) ) {
308 407 return;
309 408 }
310 409
311 - $features = array(
312 - __( 'Extra form features like file uploads, pagination, etc', 'formidable' ),
313 - __( 'Repeaters & cascading fields for advanced forms', 'formidable' ),
314 - __( 'Flexibly view, search, edit, and delete entries anywhere', 'formidable' ),
315 - __( 'Display entries with virtually limitless Formidable views', 'formidable' ),
316 - __( 'Create surveys & polls', 'formidable' ),
317 - __( 'WordPress user registration and login forms', 'formidable' ),
318 - __( 'Create Stripe, PayPal or Authorize.net payment forms', 'formidable' ),
319 - __( 'Powerful conditional logic for smart forms', 'formidable' ),
320 - __( 'Integrations with 1000+ marketing & payment services', 'formidable' ),
321 - __( 'Collect digital signatures', 'formidable' ),
322 - __( 'Accept user-submitted content with Post submissions', 'formidable' ),
323 - __( 'Email routing', 'formidable' ),
324 - __( 'Create calculator forms', 'formidable' ),
325 - __( 'Save draft entries and return later', 'formidable' ),
326 - __( 'Analyze form data with graphs & stats', 'formidable' ),
327 - );
328 -
329 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/settings_cta.php' );
410 + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/settings_cta.php';
330 411 }
331 412
332 413 /**
333 414 * Dismiss upgrade notice at the bottom on the plugin settings pages.
@@ -334,8 +415,9 @@
334 415 *
335 416 * @since 3.04.02
336 417 */
337 418 public static function settings_cta_dismiss() {
419 + check_ajax_referer( 'frm_ajax', 'nonce' );
338 420 FrmAppHelper::permission_check( 'frm_change_settings' );
339 421
340 422 update_option( 'frm_lite_settings_upgrade', time(), 'no' );
341 423
@@ -352,9 +434,9 @@
352 434 check_ajax_referer( 'frm_ajax', 'nonce' );
353 435
354 436 global $wpdb;
355 437
356 - $term = FrmAppHelper::get_param( 'term', '', 'get', 'sanitize_text_field' );
438 + $term = FrmAppHelper::get_param( 'term', '', 'get', 'sanitize_text_field' );
357 439 $post_type = FrmAppHelper::get_param( 'post_type', 'page', 'get', 'sanitize_text_field' );
358 440
359 441 $where = array(
360 442 'post_status' => 'publish',
@@ -377,14 +459,6 @@
377 459 );
378 460 }
379 461
380 462 wp_send_json( $results );
381 - }
382 -
383 - /**
384 - * @deprecated 6.0 use FrmSettingsController::captcha_settings().
385 - */
386 - public static function recaptcha_settings() {
387 - _deprecated_function( __FUNCTION__, '6.0', 'FrmSettingsController::captcha_settings()' );
388 - self::captcha_settings();
389 463 }
390 464 }