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
formidable / classes / controllers / FrmSettingsController.php

FrmSettingsController.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More 4.01.02, at classes/controllers/FrmSettingsController.php

298 lines 8.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class FrmSettingsController {
4
5 public static function menu() {
6 // Make sure admins can see the menu items
7 FrmAppHelper::force_capability( 'frm_change_settings' );
8
9 add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' );
10 }
11
12 public static function license_box() {
13 $a = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' );
14 include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' );
15 }
16
17 public static function display_form( $errors = array(), $message = '' ) {
18 global $frm_vars;
19
20 $frm_settings = FrmAppHelper::get_settings();
21
22 $uploads = wp_upload_dir();
23 $target_path = $uploads['basedir'] . '/formidable/css';
24
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' );
29 }
30
31 private static function get_settings_tabs() {
32 $sections = array(
33 'general' => array(
34 'class' => __CLASS__,
35 'function' => 'general_settings',
36 'name' => __( 'General Settings', 'formidable' ),
37 'icon' => 'frm_icon_font frm_settings_icon',
38 ),
39 'messages' => array(
40 'class' => __CLASS__,
41 'function' => 'message_settings',
42 'name' => __( 'Message Defaults', 'formidable' ),
43 'icon' => 'frm_icon_font frm_stamp_icon',
44 ),
45 'permissions' => array(
46 'class' => __CLASS__,
47 'function' => 'permission_settings',
48 'name' => __( 'Permissions', 'formidable' ),
49 'icon' => 'frm_icon_font frm_lock_icon',
50 ),
51 'recaptcha' => array(
52 'class' => __CLASS__,
53 'function' => 'recaptcha_settings',
54 'name' => __( 'reCaptcha', 'formidable' ),
55 'icon' => 'frm_icon_font frm_shield_check_icon',
56 ),
57 'white_label' => array(
58 'name' => __( 'White Labeling', 'formidable' ),
59 'icon' => 'frm_icon_font frm_ghost_icon',
60 'html_class' => 'frm_show_upgrade frm_noallow',
61 'data' => array(
62 'medium' => 'white-label',
63 'upgrade' => __( 'White labeling options', 'formidable' ),
64 ),
65 ),
66 );
67
68 if ( apply_filters( 'frm_include_addon_page', false ) ) {
69 // if no addons need a license, skip this page
70 $show_licenses = false;
71 $installed_addons = apply_filters( 'frm_installed_addons', array() );
72 foreach ( $installed_addons as $installed_addon ) {
73 if ( ! $installed_addon->is_parent_licence && $installed_addon->plugin_name != 'Formidable Pro' ) {
74 $show_licenses = true;
75 break;
76 }
77 }
78
79 if ( $show_licenses ) {
80 $sections['licenses'] = array(
81 'class' => 'FrmAddonsController',
82 'function' => 'license_settings',
83 'name' => __( 'Plugin Licenses', 'formidable' ),
84 'icon' => 'frm_icon_font frm_keyalt_icon',
85 'ajax' => true,
86 );
87 }
88 }
89 $sections = apply_filters( 'frm_add_settings_section', $sections );
90
91 $sections['misc'] = array(
92 'name' => __( 'Miscellaneous', 'formidable' ),
93 'icon' => 'frm_icon_font frm_shuffle_icon',
94 'class' => __CLASS__,
95 'function' => 'misc_settings',
96 );
97
98 foreach ( $sections as $key => $section ) {
99 $original = $section;
100 $defaults = array(
101 'html_class' => '',
102 'name' => ucfirst( $key ),
103 'icon' => 'frm_icon_font frm_settings_icon',
104 'anchor' => $key . '_settings',
105 'data' => array(),
106 );
107
108 $section = array_merge( $defaults, $section );
109
110 if ( isset( $section['ajax'] ) && ! isset( $section['data']['frmajax'] ) ) {
111 $section['data']['frmajax'] = $section['ajax'];
112 }
113
114 // For reverse compatibility.
115 if ( ! isset( $section['function'] ) && ( ! is_array( $original ) || ! isset( $original['name'] ) ) ) {
116 $section['function'] = $original;
117 }
118
119 $sections[ $key ] = $section;
120 }
121
122 return $sections;
123 }
124
125 public static function load_settings_tab() {
126 FrmAppHelper::permission_check( 'frm_change_settings' );
127 check_ajax_referer( 'frm_ajax', 'nonce' );
128
129 $section = FrmAppHelper::get_post_param( 'tab', '', 'sanitize_text_field' );
130 $sections = self::get_settings_tabs();
131 if ( ! isset( $sections[ $section ] ) ) {
132 wp_die();
133 }
134
135 $section = $sections[ $section ];
136
137 if ( isset( $section['class'] ) ) {
138 call_user_func( array( $section['class'], $section['function'] ) );
139 } else {
140 call_user_func( ( isset( $section['function'] ) ? $section['function'] : $section ) );
141 }
142 wp_die();
143 }
144
145 /**
146 * @since 4.0
147 */
148 public static function general_settings() {
149 $frm_settings = FrmAppHelper::get_settings();
150
151 $uploads = wp_upload_dir();
152 $target_path = $uploads['basedir'] . '/formidable/css';
153
154 include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/general.php' );
155 }
156
157 /**
158 * @since 4.0
159 */
160 public static function message_settings() {
161 $frm_settings = FrmAppHelper::get_settings();
162
163 include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/messages.php' );
164 }
165
166 /**
167 * @since 4.0
168 */
169 public static function recaptcha_settings() {
170 $frm_settings = FrmAppHelper::get_settings();
171 $captcha_lang = FrmAppHelper::locales( 'captcha' );
172
173 include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/recaptcha.php' );
174 }
175
176 /**
177 * @since 4.0
178 */
179 public static function permission_settings() {
180 $frm_settings = FrmAppHelper::get_settings();
181 $frm_roles = FrmAppHelper::frm_capabilities();
182
183 include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/permissions.php' );
184 }
185
186 /**
187 * @since 4.0
188 */
189 public static function misc_settings() {
190 $frm_settings = FrmAppHelper::get_settings();
191
192 include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/misc.php' );
193 }
194
195 public static function process_form( $stop_load = false ) {
196 global $frm_vars;
197
198 $frm_settings = FrmAppHelper::get_settings();
199
200 $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' );
201 if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) {
202 wp_die( esc_html( $frm_settings->admin_permission ) );
203 }
204
205 $errors = array();
206 $message = '';
207
208 if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) {
209 $errors = $frm_settings->validate( $_POST, array() );
210
211 $frm_settings->update( wp_unslash( $_POST ) );
212
213 if ( empty( $errors ) ) {
214 $frm_settings->store();
215 $message = __( 'Settings Saved', 'formidable' );
216 }
217 } else {
218 $message = __( 'Settings Saved', 'formidable' );
219 }
220
221 if ( $stop_load == 'stop_load' ) {
222 $frm_vars['settings_routed'] = true;
223
224 return;
225 }
226
227 self::display_form( $errors, $message );
228 }
229
230 /**
231 * Include the Update button on the global settings page.
232 *
233 * @since 4.0.02
234 */
235 public static function save_button() {
236 echo '<input class="button-primary frm-button-primary" type="submit"
237 value="' . esc_attr__( 'Update', 'formidable' ) . '"/>';
238 }
239
240 public static function route( $stop_load = false ) {
241 $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
242 $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
243 FrmAppHelper::include_svg();
244
245 if ( $action == 'process-form' ) {
246 self::process_form( $stop_load );
247 } elseif ( $stop_load != 'stop_load' ) {
248 self::display_form();
249 }
250 }
251
252 /**
253 * Add CTA to the bottom on the plugin settings pages.
254 *
255 * @since 3.04.02
256 */
257 public static function settings_cta( $view ) {
258
259 if ( get_option( 'frm_lite_settings_upgrade', false ) ) {
260 return;
261 }
262
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' );
282 }
283
284 /**
285 * Dismiss upgrade notice at the bottom on the plugin settings pages.
286 *
287 * @since 3.04.02
288 */
289 public static function settings_cta_dismiss() {
290 FrmAppHelper::permission_check( 'frm_change_settings' );
291
292 update_option( 'frm_lite_settings_upgrade', time(), 'no' );
293
294 wp_send_json_success();
295 }
296
297 }
298