PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 2.05.09
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v2.05.09
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 2.05.09, at classes/controllers/FrmSettingsController.php

112 lines 3.5 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 $frm_roles = FrmAppHelper::frm_capabilities();
22
23 $uploads = wp_upload_dir();
24 $target_path = $uploads['basedir'] . '/formidable/css';
25
26 $sections = self::get_settings_tabs();
27
28 $captcha_lang = FrmAppHelper::locales( 'captcha' );
29
30 require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' );
31 }
32
33 private static function get_settings_tabs() {
34 $sections = array();
35 if ( apply_filters( 'frm_include_addon_page', false ) ) {
36 $sections['licenses'] = array(
37 'class' => 'FrmAddonsController',
38 'function' => 'license_settings',
39 'name' => __( 'Plugin Licenses', 'formidable' ),
40 'ajax' => true,
41 );
42 }
43 $sections = apply_filters( 'frm_add_settings_section', $sections );
44
45 return $sections;
46 }
47
48 public static function load_settings_tab() {
49 FrmAppHelper::permission_check('frm_change_settings');
50 check_ajax_referer( 'frm_ajax', 'nonce' );
51
52 $section = FrmAppHelper::get_post_param( 'tab', '', 'sanitize_text_field' );
53 $sections = self::get_settings_tabs();
54 if ( ! isset( $sections[ $section ] ) ) {
55 wp_die();
56 }
57
58 $section = $sections[ $section ];
59
60 if ( isset( $section['class'] ) ) {
61 call_user_func( array( $section['class'], $section['function'] ) );
62 } else {
63 call_user_func( ( isset( $section['function'] ) ? $section['function'] : $section ) );
64 }
65 wp_die();
66 }
67
68 public static function process_form( $stop_load = false ) {
69 global $frm_vars;
70
71 $frm_settings = FrmAppHelper::get_settings();
72
73 $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' );
74 if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) {
75 wp_die( $frm_settings->admin_permission );
76 }
77
78 $errors = array();
79 $message = '';
80
81 if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) {
82 $errors = $frm_settings->validate( $_POST, array() );
83
84 $frm_settings->update( stripslashes_deep( $_POST ) );
85
86 if ( empty( $errors ) ) {
87 $frm_settings->store();
88 $message = __( 'Settings Saved', 'formidable' );
89 }
90 } else {
91 $message = __( 'Settings Saved', 'formidable' );
92 }
93
94 if ( $stop_load == 'stop_load' ) {
95 $frm_vars['settings_routed'] = true;
96 return;
97 }
98
99 self::display_form( $errors, $message );
100 }
101
102 public static function route( $stop_load = false ) {
103 $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
104 $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
105 if ( $action == 'process-form' ) {
106 self::process_form( $stop_load );
107 } else if ( $stop_load != 'stop_load' ) {
108 self::display_form();
109 }
110 }
111 }
112