Completed
Push — master ( eb3dd9...b3dd2b )
by Stephanie
03:38
created
classes/models/FrmSettings.php 1 patch
Indentation   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -1,33 +1,33 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class FrmSettings {
4
-    public $option_name = 'frm_options';
5
-    public $menu;
6
-    public $mu_menu;
7
-    public $use_html;
8
-    public $jquery_css;
9
-    public $accordion_js;
4
+	public $option_name = 'frm_options';
5
+	public $menu;
6
+	public $mu_menu;
7
+	public $use_html;
8
+	public $jquery_css;
9
+	public $accordion_js;
10 10
 	public $fade_form;
11 11
 	public $old_css;
12 12
 
13
-    public $success_msg;
14
-    public $blank_msg;
15
-    public $unique_msg;
16
-    public $invalid_msg;
17
-    public $failed_msg;
18
-    public $submit_value;
19
-    public $login_msg;
20
-    public $admin_permission;
21
-
22
-    public $email_to;
23
-    public $load_style;
24
-    public $custom_style;
25
-
26
-    public $pubkey;
27
-    public $privkey;
28
-    public $re_lang;
13
+	public $success_msg;
14
+	public $blank_msg;
15
+	public $unique_msg;
16
+	public $invalid_msg;
17
+	public $failed_msg;
18
+	public $submit_value;
19
+	public $login_msg;
20
+	public $admin_permission;
21
+
22
+	public $email_to;
23
+	public $load_style;
24
+	public $custom_style;
25
+
26
+	public $pubkey;
27
+	public $privkey;
28
+	public $re_lang;
29 29
 	public $re_type;
30
-    public $re_msg;
30
+	public $re_msg;
31 31
 	public $re_multi;
32 32
 
33 33
 	public $no_ips;
@@ -45,20 +45,20 @@  discard block
 block discarded – undo
45 45
 			$settings = $this->translate_settings( $settings );
46 46
 		}
47 47
 
48
-        foreach ( $settings as $setting_name => $setting ) {
49
-            $this->{$setting_name} = $setting;
48
+		foreach ( $settings as $setting_name => $setting ) {
49
+			$this->{$setting_name} = $setting;
50 50
 			unset( $setting_name, $setting );
51
-        }
51
+		}
52 52
 
53
-        $this->set_default_options();
53
+		$this->set_default_options();
54 54
 
55 55
 		$this->maybe_filter_for_form( $args );
56
-    }
56
+	}
57 57
 
58 58
 	private function translate_settings( $settings ) {
59
-        if ( $settings ) { //workaround for W3 total cache conflict
59
+		if ( $settings ) { //workaround for W3 total cache conflict
60 60
 			return unserialize( serialize( $settings ) );
61
-        }
61
+		}
62 62
 
63 63
 		$settings = get_option( $this->option_name );
64 64
 		if ( is_object( $settings ) ) {
@@ -66,98 +66,98 @@  discard block
 block discarded – undo
66 66
 			return $settings;
67 67
 		}
68 68
 
69
-        // If unserializing didn't work
70
-        if ( $settings ) { //workaround for W3 total cache conflict
69
+		// If unserializing didn't work
70
+		if ( $settings ) { //workaround for W3 total cache conflict
71 71
 			$settings = unserialize( serialize( $settings ) );
72
-        } else {
73
-            $settings = $this;
74
-        }
72
+		} else {
73
+			$settings = $this;
74
+		}
75 75
 
76 76
 		update_option( $this->option_name, $settings );
77 77
 		set_transient( $this->option_name, $settings );
78 78
 
79
-        return $settings;
80
-    }
79
+		return $settings;
80
+	}
81 81
 
82
-    /**
83
-     * @return array
84
-     */
82
+	/**
83
+	 * @return array
84
+	 */
85 85
 	public function default_options() {
86
-        return array(
87
-            'menu'      => apply_filters( 'frm_default_menu', 'Formidable' ),
88
-            'mu_menu'   => 0,
89
-            'use_html'  => true,
90
-            'jquery_css' => false,
91
-            'accordion_js' => false,
86
+		return array(
87
+			'menu'      => apply_filters( 'frm_default_menu', 'Formidable' ),
88
+			'mu_menu'   => 0,
89
+			'use_html'  => true,
90
+			'jquery_css' => false,
91
+			'accordion_js' => false,
92 92
 			'fade_form' => false,
93 93
 			'old_css'   => true,
94 94
 
95 95
 			're_multi'  => 1,
96 96
 
97
-            'success_msg' => __( 'Your responses were successfully submitted. Thank you!', 'formidable' ),
98
-            'blank_msg' => __( 'This field cannot be blank.', 'formidable' ),
99
-            'unique_msg' => __( 'This value must be unique.', 'formidable' ),
100
-            'invalid_msg' => __( 'There was a problem with your submission. Errors are marked below.', 'formidable' ),
101
-            'failed_msg' => __( 'We\'re sorry. It looks like you\'ve already submitted that.', 'formidable' ),
102
-            'submit_value' => __( 'Submit', 'formidable' ),
103
-            'login_msg' => __( 'You do not have permission to view this form.', 'formidable' ),
104
-            'admin_permission' => __( 'You do not have permission to do that', 'formidable' ),
97
+			'success_msg' => __( 'Your responses were successfully submitted. Thank you!', 'formidable' ),
98
+			'blank_msg' => __( 'This field cannot be blank.', 'formidable' ),
99
+			'unique_msg' => __( 'This value must be unique.', 'formidable' ),
100
+			'invalid_msg' => __( 'There was a problem with your submission. Errors are marked below.', 'formidable' ),
101
+			'failed_msg' => __( 'We\'re sorry. It looks like you\'ve already submitted that.', 'formidable' ),
102
+			'submit_value' => __( 'Submit', 'formidable' ),
103
+			'login_msg' => __( 'You do not have permission to view this form.', 'formidable' ),
104
+			'admin_permission' => __( 'You do not have permission to do that', 'formidable' ),
105 105
 
106
-            'email_to' => '[admin_email]',
106
+			'email_to' => '[admin_email]',
107 107
 			'no_ips'   => 0,
108 108
 			'tracking' => FrmAppHelper::pro_is_installed(),
109
-        );
110
-    }
109
+		);
110
+	}
111 111
 
112 112
 	private function set_default_options() {
113
-        $this->fill_recaptcha_settings();
113
+		$this->fill_recaptcha_settings();
114 114
 
115 115
 		if ( ! isset( $this->load_style ) ) {
116 116
 			if ( ! isset( $this->custom_style ) ) {
117
-                $this->custom_style = true;
118
-            }
117
+				$this->custom_style = true;
118
+			}
119 119
 
120
-            $this->load_style = 'all';
121
-        }
120
+			$this->load_style = 'all';
121
+		}
122 122
 
123
-        $this->fill_with_defaults();
123
+		$this->fill_with_defaults();
124 124
 
125
-        if ( is_multisite() && is_admin() ) {
125
+		if ( is_multisite() && is_admin() ) {
126 126
 			$mu_menu = get_site_option( 'frm_admin_menu_name' );
127 127
 			if ( $mu_menu && ! empty( $mu_menu ) ) {
128
-                $this->menu = $mu_menu;
129
-                $this->mu_menu = 1;
130
-            }
131
-        }
128
+				$this->menu = $mu_menu;
129
+				$this->mu_menu = 1;
130
+			}
131
+		}
132 132
 
133 133
 		$frm_roles = FrmAppHelper::frm_capabilities( 'pro' );
134 134
 		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
135 135
 			if ( ! isset( $this->$frm_role ) ) {
136
-                $this->$frm_role = 'administrator';
137
-            }
138
-        }
139
-    }
136
+				$this->$frm_role = 'administrator';
137
+			}
138
+		}
139
+	}
140 140
 
141 141
 	public function fill_with_defaults( $params = array() ) {
142
-        $settings = $this->default_options();
142
+		$settings = $this->default_options();
143 143
 
144
-        foreach ( $settings as $setting => $default ) {
144
+		foreach ( $settings as $setting => $default ) {
145 145
 			if ( isset( $params[ 'frm_' . $setting ] ) ) {
146 146
 				$this->{$setting} = $params[ 'frm_' . $setting ];
147 147
 			} elseif ( ! isset( $this->{$setting} ) ) {
148
-                $this->{$setting} = $default;
149
-            }
148
+				$this->{$setting} = $default;
149
+			}
150 150
 
151 151
 			if ( $setting == 'menu' && empty( $this->{$setting} ) ) {
152 152
 				$this->{$setting} = $default;
153 153
 			}
154 154
 
155 155
 			unset( $setting, $default );
156
-        }
157
-    }
156
+		}
157
+	}
158 158
 
159
-    private function fill_recaptcha_settings() {
160
-        $privkey = '';
159
+	private function fill_recaptcha_settings() {
160
+		$privkey = '';
161 161
 		$re_lang = '';
162 162
 
163 163
 		if ( ! isset( $this->pubkey ) ) {
@@ -169,21 +169,21 @@  discard block
 block discarded – undo
169 169
 		}
170 170
 
171 171
 		if ( ! isset( $this->re_msg ) || empty( $this->re_msg ) ) {
172
-            $this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' );
173
-        }
172
+			$this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' );
173
+		}
174 174
 
175 175
 		if ( ! isset( $this->privkey ) ) {
176
-            $this->privkey = $privkey;
177
-        }
176
+			$this->privkey = $privkey;
177
+		}
178 178
 
179 179
 		if ( ! isset( $this->re_lang ) ) {
180
-            $this->re_lang = $re_lang;
181
-        }
180
+			$this->re_lang = $re_lang;
181
+		}
182 182
 
183 183
 		if ( ! isset( $this->re_type ) ) {
184 184
 			$this->re_type = '';
185 185
 		}
186
-    }
186
+	}
187 187
 
188 188
 	/**
189 189
 	 * Get values that may be shown on the front-end without an override in the form settings.
@@ -213,9 +213,9 @@  discard block
 block discarded – undo
213 213
 		}
214 214
 	}
215 215
 
216
-    public function validate( $params, $errors ) {
217
-        return apply_filters( 'frm_validate_settings', $errors, $params );
218
-    }
216
+	public function validate( $params, $errors ) {
217
+		return apply_filters( 'frm_validate_settings', $errors, $params );
218
+	}
219 219
 
220 220
 	public function update( $params ) {
221 221
 		$this->fill_with_defaults( $params );
@@ -229,51 +229,51 @@  discard block
 block discarded – undo
229 229
 
230 230
 		$this->update_roles( $params );
231 231
 
232
-        do_action( 'frm_update_settings', $params );
232
+		do_action( 'frm_update_settings', $params );
233 233
 
234 234
 		if ( function_exists( 'get_filesystem_method' ) ) {
235 235
 			// save styling settings in case fallback setting changes
236 236
 			$frm_style = new FrmStyle();
237 237
 			$frm_style->update( 'default' );
238 238
 		}
239
-    }
239
+	}
240 240
 
241 241
 	private function update_settings( $params ) {
242 242
 		$this->pubkey = trim( $params['frm_pubkey'] );
243
-        $this->privkey = $params['frm_privkey'];
243
+		$this->privkey = $params['frm_privkey'];
244 244
 		$this->re_type = $params['frm_re_type'];
245
-        $this->re_lang = $params['frm_re_lang'];
245
+		$this->re_lang = $params['frm_re_lang'];
246 246
 
247
-        $this->load_style = $params['frm_load_style'];
247
+		$this->load_style = $params['frm_load_style'];
248 248
 
249 249
 		$checkboxes = array( 'mu_menu', 're_multi', 'use_html', 'jquery_css', 'accordion_js', 'fade_form', 'old_css', 'no_ips', 'tracking' );
250 250
 		foreach ( $checkboxes as $set ) {
251 251
 			$this->$set = isset( $params[ 'frm_' . $set ] ) ? $params[ 'frm_' . $set ] : 0;
252 252
 		}
253
-    }
253
+	}
254 254
 
255 255
 	private function update_roles( $params ) {
256
-        global $wp_roles;
256
+		global $wp_roles;
257 257
 
258
-        $frm_roles = FrmAppHelper::frm_capabilities();
259
-        $roles = get_editable_roles();
260
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
261
-            $this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' );
258
+		$frm_roles = FrmAppHelper::frm_capabilities();
259
+		$roles = get_editable_roles();
260
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
261
+			$this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' );
262 262
 
263
-            // Make sure administrators always have permissions
264
-            if ( ! in_array( 'administrator', $this->$frm_role ) ) {
263
+			// Make sure administrators always have permissions
264
+			if ( ! in_array( 'administrator', $this->$frm_role ) ) {
265 265
 				array_push( $this->$frm_role, 'administrator' );
266
-            }
266
+			}
267 267
 
268
-            foreach ( $roles as $role => $details ) {
268
+			foreach ( $roles as $role => $details ) {
269 269
 				if ( in_array( $role, $this->$frm_role ) ) {
270
-    			    $wp_roles->add_cap( $role, $frm_role );
271
-    			} else {
272
-    			    $wp_roles->remove_cap( $role, $frm_role );
273
-    			}
274
-    		}
270
+					$wp_roles->add_cap( $role, $frm_role );
271
+				} else {
272
+					$wp_roles->remove_cap( $role, $frm_role );
273
+				}
274
+			}
275 275
 		}
276
-    }
276
+	}
277 277
 
278 278
 	public function store() {
279 279
 		// Save the posted value in the database
Please login to merge, or discard this patch.