PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 1.07.11
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v1.07.11
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 / models / FrmSettings.php

FrmSettings.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More 1.07.11, at classes/models/FrmSettings.php

159 lines 6.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if(!defined('ABSPATH')) die(__('You are not allowed to call this page directly.', 'formidable'));
3
4 if(class_exists('FrmSettings'))
5 return;
6
7 class FrmSettings{
8
9 function __construct(){
10 $this->set_default_options();
11 }
12
13 function default_options(){
14 return array(
15 'menu' => 'Formidable',
16 'mu_menu' => 0,
17 'preview_page_id' => 0,
18 'lock_keys' => false,
19 'track' => false,
20 'use_html' => true,
21 'jquery_css' => false,
22 'accordion_js' => false,
23
24 'success_msg' => __('Your responses were successfully submitted. Thank you!', 'formidable'),
25 'blank_msg' => __('This field cannot be blank.', 'formidable'),
26 'unique_msg' => __('This value must be unique.', 'formidable'),
27 'invalid_msg' => __('There was a problem with your submission. Errors are marked below.', 'formidable'),
28 'failed_msg' => __('We\'re sorry. It looks like you\'ve already submitted that.', 'formidable'),
29 'submit_value' => __('Submit', 'formidable'),
30 'login_msg' => __('You do not have permission to view this form.', 'formidable'),
31 'admin_permission' => __('You do not have permission to do that', 'formidable'),
32
33 'email_to' => '[admin_email]',
34 );
35 }
36
37 function set_default_options(){
38 if(!isset($this->pubkey)){
39 $recaptcha_opt = is_multisite() ? get_site_option('recaptcha') : get_option('recaptcha'); // get the options from the database
40
41 $this->pubkey = isset($recaptcha_opt['pubkey']) ? $recaptcha_opt['pubkey'] : '';
42 }
43
44 if(!isset($this->privkey))
45 $this->privkey = (isset($recaptcha_opt) and isset($recaptcha_opt['privkey'])) ? $recaptcha_opt['privkey'] : '';
46
47 if(!isset($this->re_theme))
48 $this->re_theme = (isset($recaptcha_opt) and isset($recaptcha_opt['re_theme'])) ? $recaptcha_opt['re_theme'] : 'red';
49
50 if(!isset($this->re_lang))
51 $this->re_lang = (isset($recaptcha_opt) and isset($recaptcha_opt['re_lang'])) ? $recaptcha_opt['re_lang'] : 'en';
52
53 if(!isset($this->re_msg) or empty($this->re_msg))
54 $this->re_msg = __('The reCAPTCHA was not entered correctly', 'formidable');
55
56 if(!isset($this->load_style)){
57 if(!isset($this->custom_style))
58 $this->custom_style = true;
59 if(!isset($this->custom_stylesheet))
60 $this->custom_stylesheet = false;
61
62 $this->load_style = ($this->custom_stylesheet) ? 'none' : 'all';
63 }
64
65 $settings = $this->default_options();
66
67 foreach($settings as $setting => $default){
68 if(!isset($this->{$setting}))
69 $this->{$setting} = $default;
70 unset($setting);
71 unset($default);
72 }
73
74 if(is_multisite() and is_admin()){
75 $mu_menu = get_site_option('frm_admin_menu_name');
76 if($mu_menu and !empty($mu_menu)){
77 $this->menu = $mu_menu;
78 $this->mu_menu = 1;
79 }
80 }
81
82 $frm_roles = FrmAppHelper::frm_capabilities('pro');
83 foreach($frm_roles as $frm_role => $frm_role_description){
84 if(!isset($this->$frm_role))
85 $this->$frm_role = 'administrator';
86 }
87 }
88
89 function validate($params,$errors){
90 $errors = apply_filters( 'frm_validate_settings', $errors, $params );
91 return $errors;
92 }
93
94 function update($params){
95 global $wp_roles;
96
97 $this->mu_menu = isset($params['frm_mu_menu']) ? $params['frm_mu_menu'] : 0;
98 if ( $this->mu_menu ) {
99 update_site_option('frm_admin_menu_name', $this->menu);
100 } else if ( current_user_can('administrator') ) {
101 update_site_option('frm_admin_menu_name', false);
102 }
103
104 $this->pubkey = trim($params['frm_pubkey']);
105 $this->privkey = $params['frm_privkey'];
106 $this->re_theme = $params['frm_re_theme'];
107 $this->re_lang = $params['frm_re_lang'];
108
109 $settings = $this->default_options();
110
111 foreach($settings as $setting => $default){
112 if(isset($params['frm_'. $setting]))
113 $this->{$setting} = $params['frm_'. $setting];
114
115 unset($setting);
116 unset($default);
117 }
118
119 $this->load_style = $params['frm_load_style'];
120 $this->preview_page_id = (int)$params['frm-preview-page-id'];
121 $this->lock_keys = isset($params['frm_lock_keys']) ? $params['frm_lock_keys'] : 0;
122 $this->track = isset($params['frm_track']) ? $params['frm_track'] : 0;
123
124 $this->use_html = isset($params['frm_use_html']) ? $params['frm_use_html'] : 0;
125 //$this->custom_style = isset($params['frm_custom_style']) ? $params['frm_custom_style'] : 0;
126 //$this->custom_stylesheet = isset($params['frm_custom_stylesheet']) ? $params['frm_custom_stylesheet'] : 0;
127 $this->jquery_css = isset($params['frm_jquery_css']) ? $params['frm_jquery_css'] : 0;
128 $this->accordion_js = isset($params['frm_accordion_js']) ? $params['frm_accordion_js'] : 0;
129
130 //update roles
131 $frm_roles = FrmAppHelper::frm_capabilities();
132 $roles = get_editable_roles();
133 foreach($frm_roles as $frm_role => $frm_role_description){
134 $this->$frm_role = isset($params[$frm_role]) ? $params[$frm_role] : 'administrator';
135
136 foreach ($roles as $role => $details){
137 if($this->$frm_role == $role or ($this->$frm_role == 'editor' and $role == 'administrator') or ($this->$frm_role == 'author' and in_array($role, array('administrator', 'editor'))) or ($this->$frm_role == 'contributor' and in_array($role, array('administrator', 'editor', 'author'))) or $this->$frm_role == 'subscriber')
138 $wp_roles->add_cap( $role, $frm_role );
139 else
140 $wp_roles->remove_cap( $role, $frm_role );
141 }
142 }
143
144 do_action( 'frm_update_settings', $params );
145 }
146
147 function store(){
148 // Save the posted value in the database
149
150 update_option('frm_options', $this);
151
152 delete_transient('frm_options');
153 set_transient('frm_options', $this);
154
155 do_action( 'frm_store_settings' );
156 }
157
158 }
159