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 +134 -53 6.36.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
@@ -11,11 +20,18 @@
11 20
12 21 add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' );
13 22 }
14 23
24 + /**
25 + * Include license box template on demand.
26 + *
27 + * @return void
28 + */
15 29 public static function license_box() {
16 - $a = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' );
17 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' );
30 + if ( ! current_user_can( 'activate_plugins' ) ) {
31 + return;
32 + }
33 + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php';
18 34 }
19 35
20 36 public static function display_form( $errors = array(), $message = '' ) {
21 37 global $frm_vars;
@@ -27,9 +43,13 @@
27 43
28 44 $sections = self::get_settings_tabs();
29 45 $current = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' );
30 46
31 - 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';
32 52 }
33 53
34 54 /**
35 55 * Get sections to use for Global Settings.
@@ -37,27 +57,33 @@
37 57 * @return array<array>
38 58 */
39 59 private static function get_settings_tabs() {
40 60 $sections = array(
41 - 'general' => array(
61 + 'general' => array(
42 62 'class' => __CLASS__,
43 63 'function' => 'general_settings',
44 64 'name' => __( 'General Settings', 'formidable' ),
45 65 'icon' => 'frm_icon_font frm_settings_icon',
46 66 ),
47 - 'messages' => array(
67 + 'messages' => array(
48 68 'class' => __CLASS__,
49 69 'function' => 'message_settings',
50 70 'name' => __( 'Message Defaults', 'formidable' ),
51 71 'icon' => 'frm_icon_font frm_stamp_icon',
52 72 ),
53 - 'permissions' => array(
73 + 'permissions' => array(
54 74 'class' => __CLASS__,
55 75 'function' => 'permission_settings',
56 76 'name' => __( 'Permissions', 'formidable' ),
57 77 'icon' => 'frm_icon_font frm_lock_icon',
58 78 ),
59 - '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(
60 86 'class' => 'FrmStylesController',
61 87 'function' => 'custom_css',
62 88 'name' => __( 'Custom CSS', 'formidable' ),
63 89 'icon' => 'frm_icon_font frm_code_icon',
@@ -67,15 +93,15 @@
67 93 'function' => 'manage',
68 94 'name' => __( 'Manage Styles', 'formidable' ),
69 95 'icon' => 'frm_icon_font frm_pallet_icon',
70 96 ),
71 - 'captcha' => array(
97 + 'captcha' => array(
72 98 'class' => __CLASS__,
73 99 'function' => 'captcha_settings',
74 - 'name' => __( 'Captcha', 'formidable' ),
100 + 'name' => __( 'Captcha/Spam', 'formidable' ),
75 101 'icon' => 'frm_icon_font frm_shield_check_icon',
76 102 ),
77 - 'white_label' => array(
103 + 'white_label' => array(
78 104 'name' => __( 'White Labeling', 'formidable' ),
79 105 'icon' => 'frm_icon_font frm_ghost_icon',
80 106 'html_class' => 'frm_show_upgrade_tab frm_noallow',
81 107 'data' => array(
@@ -83,9 +109,9 @@
83 109 'upgrade' => __( 'White labeling options', 'formidable' ),
84 110 'screenshot' => 'white-label.png',
85 111 ),
86 112 ),
87 - 'inbox' => array(
113 + 'inbox' => array(
88 114 'name' => __( 'Inbox', 'formidable' ),
89 115 'icon' => 'frm_icon_font frm_email_icon',
90 116 'html_class' => 'frm_show_upgrade_tab frm_noallow',
91 117 'data' => array(
@@ -111,18 +137,19 @@
111 137 $sections['licenses'] = array(
112 138 'class' => 'FrmAddonsController',
113 139 'function' => 'license_settings',
114 140 'name' => __( 'Plugin Licenses', 'formidable' ),
115 - 'icon' => 'frm_icon_font frm_keyalt_icon',
141 + 'icon' => 'frmfont frm_key_icon',
116 142 'ajax' => true,
117 143 );
118 144 }
119 - }
145 + }//end if
120 146
121 147 /**
122 148 * @param array<array> $sections
123 149 */
124 150 $sections = apply_filters( 'frm_add_settings_section', $sections );
151 + self::remove_payments_sections( $sections );
125 152
126 153 $sections['misc'] = array(
127 154 'name' => __( 'Miscellaneous', 'formidable' ),
128 155 'icon' => 'frm_icon_font frm_shuffle_icon',
@@ -151,13 +178,54 @@
151 178 $section['function'] = $original;
152 179 }
153 180
154 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 + }
155 204 }
156 205
157 - return $sections;
206 + uksort( self::$removed_payments_sections, array( __CLASS__, 'payment_sections_sort_callback' ) );
158 207 }
159 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 +
160 228 public static function load_settings_tab() {
161 229 FrmAppHelper::permission_check( 'frm_change_settings' );
162 230 check_ajax_referer( 'frm_ajax', 'nonce' );
163 231
@@ -177,17 +245,37 @@
177 245 wp_die();
178 246 }
179 247
180 248 /**
249 + * Render the general global settings section.
250 + *
181 251 * @since 4.0
252 + *
253 + * @return void
182 254 */
183 255 public static function general_settings() {
184 256 $frm_settings = FrmAppHelper::get_settings();
257 + $uploads = wp_upload_dir();
258 + $target_path = $uploads['basedir'] . '/formidable/css';
185 259
186 - $uploads = wp_upload_dir();
187 - $target_path = $uploads['basedir'] . '/formidable/css';
260 + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/general.php';
261 + }
188 262
189 - 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';
190 278 }
191 279
192 280 /**
193 281 * @since 4.0
@@ -194,9 +282,9 @@
194 282 */
195 283 public static function message_settings() {
196 284 $frm_settings = FrmAppHelper::get_settings();
197 285
198 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/messages.php' );
286 + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/messages.php';
199 287 }
200 288
201 289 /**
202 290 * @since 4.0
@@ -204,9 +292,9 @@
204 292 public static function captcha_settings() {
205 293 $frm_settings = FrmAppHelper::get_settings();
206 294 $captcha_lang = FrmAppHelper::locales( 'captcha' );
207 295
208 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/captcha/captcha.php' );
296 + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/captcha/captcha.php';
209 297 }
210 298
211 299 /**
212 300 * @since 4.0
@@ -214,11 +302,24 @@
214 302 public static function permission_settings() {
215 303 $frm_settings = FrmAppHelper::get_settings();
216 304 $frm_roles = FrmAppHelper::frm_capabilities();
217 305
218 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/permissions.php' );
306 + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/permissions.php';
219 307 }
220 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 +
221 322 /**
222 323 * @since 4.0
223 324 */
224 325 public static function misc_settings() {
@@ -223,15 +324,15 @@
223 324 */
224 325 public static function misc_settings() {
225 326 $frm_settings = FrmAppHelper::get_settings();
226 327
227 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/misc.php' );
328 + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/misc.php';
228 329 }
229 330
230 331 /**
231 332 * Save form data submitted from the Global settings page.
232 333 *
233 - * @param string|bool $stop_load
334 + * @param bool|string $stop_load
234 335 *
235 336 * @return void
236 337 */
237 338 public static function process_form( $stop_load = false ) {
@@ -240,9 +341,15 @@
240 341 $frm_settings = FrmAppHelper::get_settings();
241 342 $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' );
242 343
243 344 if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) {
244 - 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;
245 352 }
246 353
247 354 $errors = array();
248 355 $message = '';
@@ -282,9 +389,9 @@
282 389 $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
283 390 $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
284 391 FrmAppHelper::include_svg();
285 392
286 - if ( $action == 'process-form' ) {
393 + if ( $action === 'process-form' ) {
287 394 self::process_form( $stop_load );
288 395 } elseif ( $stop_load != 'stop_load' ) {
289 396 self::display_form();
290 397 }
@@ -295,32 +402,13 @@
295 402 *
296 403 * @since 3.04.02
297 404 */
298 405 public static function settings_cta( $view ) {
299 -
300 406 if ( get_option( 'frm_lite_settings_upgrade', false ) ) {
301 407 return;
302 408 }
303 409
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' );
410 + include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/settings_cta.php';
323 411 }
324 412
325 413 /**
326 414 * Dismiss upgrade notice at the bottom on the plugin settings pages.
@@ -327,8 +415,9 @@
327 415 *
328 416 * @since 3.04.02
329 417 */
330 418 public static function settings_cta_dismiss() {
419 + check_ajax_referer( 'frm_ajax', 'nonce' );
331 420 FrmAppHelper::permission_check( 'frm_change_settings' );
332 421
333 422 update_option( 'frm_lite_settings_upgrade', time(), 'no' );
334 423
@@ -345,9 +434,9 @@
345 434 check_ajax_referer( 'frm_ajax', 'nonce' );
346 435
347 436 global $wpdb;
348 437
349 - $term = FrmAppHelper::get_param( 'term', '', 'get', 'sanitize_text_field' );
438 + $term = FrmAppHelper::get_param( 'term', '', 'get', 'sanitize_text_field' );
350 439 $post_type = FrmAppHelper::get_param( 'post_type', 'page', 'get', 'sanitize_text_field' );
351 440
352 441 $where = array(
353 442 'post_status' => 'publish',
@@ -370,14 +459,6 @@
370 459 );
371 460 }
372 461
373 462 wp_send_json( $results );
374 - }
375 -
376 - /**
377 - * @deprecated 6.0 use FrmSettingsController::captcha_settings().
378 - */
379 - public static function recaptcha_settings() {
380 - _deprecated_function( __FUNCTION__, '6.0', 'FrmSettingsController::captcha_settings()' );
381 - self::captcha_settings();
382 463 }
383 464 }