Completed
Push — master ( 9a0984...263488 )
by Stephanie
11:38 queued 05:45
created
classes/models/FrmSettings.php 3 patches
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -48,7 +48,8 @@  discard block
 block discarded – undo
48 48
     }
49 49
 
50 50
 	private function translate_settings( $settings ) {
51
-        if ( $settings ) { //workaround for W3 total cache conflict
51
+        if ( $settings ) {
52
+//workaround for W3 total cache conflict
52 53
             return unserialize(serialize($settings));
53 54
         }
54 55
 
@@ -59,7 +60,8 @@  discard block
 block discarded – undo
59 60
         }
60 61
 
61 62
         // If unserializing didn't work
62
-        if ( $settings ) { //workaround for W3 total cache conflict
63
+        if ( $settings ) {
64
+//workaround for W3 total cache conflict
63 65
             $settings = unserialize(serialize($settings));
64 66
         } else {
65 67
             $settings = $this;
Please login to merge, or discard this patch.
Indentation   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -1,260 +1,260 @@
 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;
34 34
 
35
-    public function __construct() {
36
-        if ( ! defined('ABSPATH') ) {
37
-            die('You are not allowed to call this page directly.');
38
-        }
35
+	public function __construct() {
36
+		if ( ! defined('ABSPATH') ) {
37
+			die('You are not allowed to call this page directly.');
38
+		}
39 39
 
40
-        $settings = get_transient($this->option_name);
40
+		$settings = get_transient($this->option_name);
41 41
 
42
-        if ( ! is_object($settings) ) {
43
-            $settings = $this->translate_settings($settings);
44
-        }
42
+		if ( ! is_object($settings) ) {
43
+			$settings = $this->translate_settings($settings);
44
+		}
45 45
 
46
-        foreach ( $settings as $setting_name => $setting ) {
47
-            $this->{$setting_name} = $setting;
48
-            unset($setting_name, $setting);
49
-        }
46
+		foreach ( $settings as $setting_name => $setting ) {
47
+			$this->{$setting_name} = $setting;
48
+			unset($setting_name, $setting);
49
+		}
50 50
 
51
-        $this->set_default_options();
52
-    }
51
+		$this->set_default_options();
52
+	}
53 53
 
54 54
 	private function translate_settings( $settings ) {
55
-        if ( $settings ) { //workaround for W3 total cache conflict
56
-            return unserialize(serialize($settings));
57
-        }
58
-
59
-        $settings = get_option($this->option_name);
60
-        if ( is_object($settings) ) {
61
-            set_transient($this->option_name, $settings);
62
-            return $settings;
63
-        }
64
-
65
-        // If unserializing didn't work
66
-        if ( $settings ) { //workaround for W3 total cache conflict
67
-            $settings = unserialize(serialize($settings));
68
-        } else {
69
-            $settings = $this;
70
-        }
71
-
72
-        update_option($this->option_name, $settings);
73
-        set_transient($this->option_name, $settings);
74
-
75
-        return $settings;
76
-    }
77
-
78
-    /**
79
-     * @return array
80
-     */
55
+		if ( $settings ) { //workaround for W3 total cache conflict
56
+			return unserialize(serialize($settings));
57
+		}
58
+
59
+		$settings = get_option($this->option_name);
60
+		if ( is_object($settings) ) {
61
+			set_transient($this->option_name, $settings);
62
+			return $settings;
63
+		}
64
+
65
+		// If unserializing didn't work
66
+		if ( $settings ) { //workaround for W3 total cache conflict
67
+			$settings = unserialize(serialize($settings));
68
+		} else {
69
+			$settings = $this;
70
+		}
71
+
72
+		update_option($this->option_name, $settings);
73
+		set_transient($this->option_name, $settings);
74
+
75
+		return $settings;
76
+	}
77
+
78
+	/**
79
+	 * @return array
80
+	 */
81 81
 	public function default_options() {
82
-        return array(
83
-            'menu'      => apply_filters( 'frm_default_menu', 'Formidable' ),
84
-            'mu_menu'   => 0,
85
-            'use_html'  => true,
86
-            'jquery_css' => false,
87
-            'accordion_js' => false,
82
+		return array(
83
+			'menu'      => apply_filters( 'frm_default_menu', 'Formidable' ),
84
+			'mu_menu'   => 0,
85
+			'use_html'  => true,
86
+			'jquery_css' => false,
87
+			'accordion_js' => false,
88 88
 			'fade_form' => false,
89 89
 			'old_css'   => true,
90 90
 
91 91
 			're_multi'  => 0,
92 92
 
93
-            'success_msg' => __( 'Your responses were successfully submitted. Thank you!', 'formidable' ),
94
-            'blank_msg' => __( 'This field cannot be blank.', 'formidable' ),
95
-            'unique_msg' => __( 'This value must be unique.', 'formidable' ),
96
-            'invalid_msg' => __( 'There was a problem with your submission. Errors are marked below.', 'formidable' ),
97
-            'failed_msg' => __( 'We\'re sorry. It looks like you\'ve  already submitted that.', 'formidable' ),
98
-            'submit_value' => __( 'Submit', 'formidable' ),
99
-            'login_msg' => __( 'You do not have permission to view this form.', 'formidable' ),
100
-            'admin_permission' => __( 'You do not have permission to do that', 'formidable' ),
93
+			'success_msg' => __( 'Your responses were successfully submitted. Thank you!', 'formidable' ),
94
+			'blank_msg' => __( 'This field cannot be blank.', 'formidable' ),
95
+			'unique_msg' => __( 'This value must be unique.', 'formidable' ),
96
+			'invalid_msg' => __( 'There was a problem with your submission. Errors are marked below.', 'formidable' ),
97
+			'failed_msg' => __( 'We\'re sorry. It looks like you\'ve  already submitted that.', 'formidable' ),
98
+			'submit_value' => __( 'Submit', 'formidable' ),
99
+			'login_msg' => __( 'You do not have permission to view this form.', 'formidable' ),
100
+			'admin_permission' => __( 'You do not have permission to do that', 'formidable' ),
101 101
 
102
-            'email_to' => '[admin_email]',
102
+			'email_to' => '[admin_email]',
103 103
 			'no_ips'   => 0,
104
-        );
105
-    }
104
+		);
105
+	}
106 106
 
107 107
 	private function set_default_options() {
108
-        $this->fill_recaptcha_settings();
109
-
110
-        if ( ! isset($this->load_style) ) {
111
-            if ( ! isset($this->custom_style) ) {
112
-                $this->custom_style = true;
113
-            }
114
-
115
-            $this->load_style = 'all';
116
-        }
117
-
118
-        $this->fill_with_defaults();
119
-
120
-        if ( is_multisite() && is_admin() ) {
121
-            $mu_menu = get_site_option('frm_admin_menu_name');
122
-            if ( $mu_menu && ! empty($mu_menu) ) {
123
-                $this->menu = $mu_menu;
124
-                $this->mu_menu = 1;
125
-            }
126
-        }
127
-
128
-        $frm_roles = FrmAppHelper::frm_capabilities('pro');
129
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
130
-            if ( ! isset($this->$frm_role) ) {
131
-                $this->$frm_role = 'administrator';
132
-            }
133
-        }
134
-    }
108
+		$this->fill_recaptcha_settings();
109
+
110
+		if ( ! isset($this->load_style) ) {
111
+			if ( ! isset($this->custom_style) ) {
112
+				$this->custom_style = true;
113
+			}
114
+
115
+			$this->load_style = 'all';
116
+		}
117
+
118
+		$this->fill_with_defaults();
119
+
120
+		if ( is_multisite() && is_admin() ) {
121
+			$mu_menu = get_site_option('frm_admin_menu_name');
122
+			if ( $mu_menu && ! empty($mu_menu) ) {
123
+				$this->menu = $mu_menu;
124
+				$this->mu_menu = 1;
125
+			}
126
+		}
127
+
128
+		$frm_roles = FrmAppHelper::frm_capabilities('pro');
129
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
130
+			if ( ! isset($this->$frm_role) ) {
131
+				$this->$frm_role = 'administrator';
132
+			}
133
+		}
134
+	}
135 135
 
136 136
 	public function fill_with_defaults( $params = array() ) {
137
-        $settings = $this->default_options();
137
+		$settings = $this->default_options();
138 138
 
139
-        foreach ( $settings as $setting => $default ) {
139
+		foreach ( $settings as $setting => $default ) {
140 140
 			if ( isset( $params[ 'frm_' . $setting ] ) ) {
141 141
 				$this->{$setting} = $params[ 'frm_' . $setting ];
142
-            } else if ( ! isset($this->{$setting}) ) {
143
-                $this->{$setting} = $default;
144
-            }
142
+			} else if ( ! isset($this->{$setting}) ) {
143
+				$this->{$setting} = $default;
144
+			}
145 145
 
146 146
 			if ( $setting == 'menu' && empty( $this->{$setting} ) ) {
147 147
 				$this->{$setting} = $default;
148 148
 			}
149 149
 
150
-            unset($setting, $default);
151
-        }
152
-    }
150
+			unset($setting, $default);
151
+		}
152
+	}
153 153
 
154
-    private function fill_recaptcha_settings() {
155
-        $privkey = '';
154
+	private function fill_recaptcha_settings() {
155
+		$privkey = '';
156 156
 		$re_lang = '';
157 157
 
158
-        if ( ! isset($this->pubkey) ) {
159
-            // get the options from the database
160
-            $recaptcha_opt = is_multisite() ? get_site_option('recaptcha') : get_option('recaptcha');
161
-            $this->pubkey = isset($recaptcha_opt['pubkey']) ? $recaptcha_opt['pubkey'] : '';
162
-            $privkey = isset($recaptcha_opt['privkey']) ? $recaptcha_opt['privkey'] : $privkey;
163
-            $re_lang = isset($recaptcha_opt['re_lang']) ? $recaptcha_opt['re_lang'] : $re_lang;
164
-        }
158
+		if ( ! isset($this->pubkey) ) {
159
+			// get the options from the database
160
+			$recaptcha_opt = is_multisite() ? get_site_option('recaptcha') : get_option('recaptcha');
161
+			$this->pubkey = isset($recaptcha_opt['pubkey']) ? $recaptcha_opt['pubkey'] : '';
162
+			$privkey = isset($recaptcha_opt['privkey']) ? $recaptcha_opt['privkey'] : $privkey;
163
+			$re_lang = isset($recaptcha_opt['re_lang']) ? $recaptcha_opt['re_lang'] : $re_lang;
164
+		}
165 165
 
166
-        if ( ! isset($this->re_msg) || empty($this->re_msg) ) {
167
-            $this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' );
168
-        }
166
+		if ( ! isset($this->re_msg) || empty($this->re_msg) ) {
167
+			$this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' );
168
+		}
169 169
 
170
-        if ( ! isset($this->privkey) ) {
171
-            $this->privkey = $privkey;
172
-        }
170
+		if ( ! isset($this->privkey) ) {
171
+			$this->privkey = $privkey;
172
+		}
173 173
 
174
-        if ( ! isset($this->re_lang) ) {
175
-            $this->re_lang = $re_lang;
176
-        }
174
+		if ( ! isset($this->re_lang) ) {
175
+			$this->re_lang = $re_lang;
176
+		}
177 177
 
178 178
 		if ( ! isset( $this->re_type ) ) {
179 179
 			$this->re_type = '';
180 180
 		}
181
-    }
181
+	}
182 182
 
183
-    public function validate( $params, $errors ) {
184
-        return apply_filters( 'frm_validate_settings', $errors, $params );
185
-    }
183
+	public function validate( $params, $errors ) {
184
+		return apply_filters( 'frm_validate_settings', $errors, $params );
185
+	}
186 186
 
187 187
 	public function update( $params ) {
188
-        $this->fill_with_defaults($params);
189
-        $this->update_settings($params);
188
+		$this->fill_with_defaults($params);
189
+		$this->update_settings($params);
190 190
 
191
-        if ( $this->mu_menu ) {
192
-            update_site_option('frm_admin_menu_name', $this->menu);
193
-        } else if ( current_user_can('administrator') ) {
194
-            update_site_option('frm_admin_menu_name', false);
195
-        }
191
+		if ( $this->mu_menu ) {
192
+			update_site_option('frm_admin_menu_name', $this->menu);
193
+		} else if ( current_user_can('administrator') ) {
194
+			update_site_option('frm_admin_menu_name', false);
195
+		}
196 196
 
197
-        $this->update_roles($params);
197
+		$this->update_roles($params);
198 198
 
199
-        do_action( 'frm_update_settings', $params );
199
+		do_action( 'frm_update_settings', $params );
200 200
 
201 201
 		if ( function_exists( 'get_filesystem_method' ) ) {
202 202
 			// save styling settings in case fallback setting changes
203 203
 			$frm_style = new FrmStyle();
204 204
 			$frm_style->update( 'default' );
205 205
 		}
206
-    }
206
+	}
207 207
 
208 208
 	private function update_settings( $params ) {
209
-        $this->mu_menu = isset($params['frm_mu_menu']) ? $params['frm_mu_menu'] : 0;
209
+		$this->mu_menu = isset($params['frm_mu_menu']) ? $params['frm_mu_menu'] : 0;
210 210
 
211
-        $this->pubkey = trim($params['frm_pubkey']);
212
-        $this->privkey = $params['frm_privkey'];
211
+		$this->pubkey = trim($params['frm_pubkey']);
212
+		$this->privkey = $params['frm_privkey'];
213 213
 		$this->re_type = $params['frm_re_type'];
214
-        $this->re_lang = $params['frm_re_lang'];
214
+		$this->re_lang = $params['frm_re_lang'];
215 215
 		$this->re_multi = isset( $params['frm_re_multi'] ) ? $params['frm_re_multi'] : 0;
216 216
 
217
-        $this->load_style = $params['frm_load_style'];
217
+		$this->load_style = $params['frm_load_style'];
218 218
 
219
-        $this->use_html = isset($params['frm_use_html']) ? $params['frm_use_html'] : 0;
219
+		$this->use_html = isset($params['frm_use_html']) ? $params['frm_use_html'] : 0;
220 220
 		$this->jquery_css = isset( $params['frm_jquery_css'] ) ? absint( $params['frm_jquery_css'] ) : 0;
221 221
 		$this->accordion_js = isset( $params['frm_accordion_js'] ) ? absint( $params['frm_accordion_js'] ) : 0;
222 222
 		$this->fade_form = isset( $params['frm_fade_form'] ) ? absint( $params['frm_fade_form'] ) : 0;
223 223
 		$this->old_css   = isset( $params['frm_old_css'] ) ? absint( $params['frm_old_css'] ) : 0;
224 224
 		$this->no_ips = isset( $params['frm_no_ips'] ) ? absint( $params['frm_no_ips'] ) : 0;
225
-    }
225
+	}
226 226
 
227 227
 	private function update_roles( $params ) {
228
-        global $wp_roles;
228
+		global $wp_roles;
229 229
 
230
-        $frm_roles = FrmAppHelper::frm_capabilities();
231
-        $roles = get_editable_roles();
232
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
233
-            $this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' );
230
+		$frm_roles = FrmAppHelper::frm_capabilities();
231
+		$roles = get_editable_roles();
232
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
233
+			$this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' );
234 234
 
235
-            // Make sure administrators always have permissions
236
-            if ( ! in_array( 'administrator', $this->$frm_role ) ) {
235
+			// Make sure administrators always have permissions
236
+			if ( ! in_array( 'administrator', $this->$frm_role ) ) {
237 237
 				array_push( $this->$frm_role, 'administrator' );
238
-            }
239
-
240
-            foreach ( $roles as $role => $details ) {
241
-                if ( in_array($role, $this->$frm_role) ) {
242
-    			    $wp_roles->add_cap( $role, $frm_role );
243
-    			} else {
244
-    			    $wp_roles->remove_cap( $role, $frm_role );
245
-    			}
246
-    		}
238
+			}
239
+
240
+			foreach ( $roles as $role => $details ) {
241
+				if ( in_array($role, $this->$frm_role) ) {
242
+					$wp_roles->add_cap( $role, $frm_role );
243
+				} else {
244
+					$wp_roles->remove_cap( $role, $frm_role );
245
+				}
246
+			}
247 247
 		}
248
-    }
248
+	}
249 249
 
250 250
 	public function store() {
251
-        // Save the posted value in the database
251
+		// Save the posted value in the database
252 252
 
253
-        update_option('frm_options', $this);
253
+		update_option('frm_options', $this);
254 254
 
255
-        delete_transient('frm_options');
256
-        set_transient('frm_options', $this);
255
+		delete_transient('frm_options');
256
+		set_transient('frm_options', $this);
257 257
 
258
-        do_action( 'frm_store_settings' );
259
-    }
258
+		do_action( 'frm_store_settings' );
259
+	}
260 260
 }
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -33,19 +33,19 @@  discard block
 block discarded – undo
33 33
 	public $no_ips;
34 34
 
35 35
     public function __construct() {
36
-        if ( ! defined('ABSPATH') ) {
37
-            die('You are not allowed to call this page directly.');
36
+        if ( ! defined( 'ABSPATH' ) ) {
37
+            die( 'You are not allowed to call this page directly.' );
38 38
         }
39 39
 
40
-        $settings = get_transient($this->option_name);
40
+        $settings = get_transient( $this->option_name );
41 41
 
42
-        if ( ! is_object($settings) ) {
43
-            $settings = $this->translate_settings($settings);
42
+        if ( ! is_object( $settings ) ) {
43
+            $settings = $this->translate_settings( $settings );
44 44
         }
45 45
 
46 46
         foreach ( $settings as $setting_name => $setting ) {
47 47
             $this->{$setting_name} = $setting;
48
-            unset($setting_name, $setting);
48
+            unset( $setting_name, $setting );
49 49
         }
50 50
 
51 51
         $this->set_default_options();
@@ -53,24 +53,24 @@  discard block
 block discarded – undo
53 53
 
54 54
 	private function translate_settings( $settings ) {
55 55
         if ( $settings ) { //workaround for W3 total cache conflict
56
-            return unserialize(serialize($settings));
56
+            return unserialize( serialize( $settings ) );
57 57
         }
58 58
 
59
-        $settings = get_option($this->option_name);
60
-        if ( is_object($settings) ) {
61
-            set_transient($this->option_name, $settings);
59
+        $settings = get_option( $this->option_name );
60
+        if ( is_object( $settings ) ) {
61
+            set_transient( $this->option_name, $settings );
62 62
             return $settings;
63 63
         }
64 64
 
65 65
         // If unserializing didn't work
66 66
         if ( $settings ) { //workaround for W3 total cache conflict
67
-            $settings = unserialize(serialize($settings));
67
+            $settings = unserialize( serialize( $settings ) );
68 68
         } else {
69 69
             $settings = $this;
70 70
         }
71 71
 
72
-        update_option($this->option_name, $settings);
73
-        set_transient($this->option_name, $settings);
72
+        update_option( $this->option_name, $settings );
73
+        set_transient( $this->option_name, $settings );
74 74
 
75 75
         return $settings;
76 76
     }
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
 	private function set_default_options() {
108 108
         $this->fill_recaptcha_settings();
109 109
 
110
-        if ( ! isset($this->load_style) ) {
111
-            if ( ! isset($this->custom_style) ) {
110
+        if ( ! isset( $this->load_style ) ) {
111
+            if ( ! isset( $this->custom_style ) ) {
112 112
                 $this->custom_style = true;
113 113
             }
114 114
 
@@ -118,16 +118,16 @@  discard block
 block discarded – undo
118 118
         $this->fill_with_defaults();
119 119
 
120 120
         if ( is_multisite() && is_admin() ) {
121
-            $mu_menu = get_site_option('frm_admin_menu_name');
122
-            if ( $mu_menu && ! empty($mu_menu) ) {
121
+            $mu_menu = get_site_option( 'frm_admin_menu_name' );
122
+            if ( $mu_menu && ! empty( $mu_menu ) ) {
123 123
                 $this->menu = $mu_menu;
124 124
                 $this->mu_menu = 1;
125 125
             }
126 126
         }
127 127
 
128
-        $frm_roles = FrmAppHelper::frm_capabilities('pro');
128
+        $frm_roles = FrmAppHelper::frm_capabilities( 'pro' );
129 129
         foreach ( $frm_roles as $frm_role => $frm_role_description ) {
130
-            if ( ! isset($this->$frm_role) ) {
130
+            if ( ! isset( $this->$frm_role ) ) {
131 131
                 $this->$frm_role = 'administrator';
132 132
             }
133 133
         }
@@ -137,9 +137,9 @@  discard block
 block discarded – undo
137 137
         $settings = $this->default_options();
138 138
 
139 139
         foreach ( $settings as $setting => $default ) {
140
-			if ( isset( $params[ 'frm_' . $setting ] ) ) {
141
-				$this->{$setting} = $params[ 'frm_' . $setting ];
142
-            } else if ( ! isset($this->{$setting}) ) {
140
+			if ( isset( $params['frm_' . $setting] ) ) {
141
+				$this->{$setting} = $params['frm_' . $setting];
142
+            } else if ( ! isset( $this->{$setting}) ) {
143 143
                 $this->{$setting} = $default;
144 144
             }
145 145
 
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 				$this->{$setting} = $default;
148 148
 			}
149 149
 
150
-            unset($setting, $default);
150
+            unset( $setting, $default );
151 151
         }
152 152
     }
153 153
 
@@ -155,23 +155,23 @@  discard block
 block discarded – undo
155 155
         $privkey = '';
156 156
 		$re_lang = '';
157 157
 
158
-        if ( ! isset($this->pubkey) ) {
158
+        if ( ! isset( $this->pubkey ) ) {
159 159
             // get the options from the database
160
-            $recaptcha_opt = is_multisite() ? get_site_option('recaptcha') : get_option('recaptcha');
161
-            $this->pubkey = isset($recaptcha_opt['pubkey']) ? $recaptcha_opt['pubkey'] : '';
162
-            $privkey = isset($recaptcha_opt['privkey']) ? $recaptcha_opt['privkey'] : $privkey;
163
-            $re_lang = isset($recaptcha_opt['re_lang']) ? $recaptcha_opt['re_lang'] : $re_lang;
160
+            $recaptcha_opt = is_multisite() ? get_site_option( 'recaptcha' ) : get_option( 'recaptcha' );
161
+            $this->pubkey = isset( $recaptcha_opt['pubkey'] ) ? $recaptcha_opt['pubkey'] : '';
162
+            $privkey = isset( $recaptcha_opt['privkey'] ) ? $recaptcha_opt['privkey'] : $privkey;
163
+            $re_lang = isset( $recaptcha_opt['re_lang'] ) ? $recaptcha_opt['re_lang'] : $re_lang;
164 164
         }
165 165
 
166
-        if ( ! isset($this->re_msg) || empty($this->re_msg) ) {
166
+        if ( ! isset( $this->re_msg ) || empty( $this->re_msg ) ) {
167 167
             $this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' );
168 168
         }
169 169
 
170
-        if ( ! isset($this->privkey) ) {
170
+        if ( ! isset( $this->privkey ) ) {
171 171
             $this->privkey = $privkey;
172 172
         }
173 173
 
174
-        if ( ! isset($this->re_lang) ) {
174
+        if ( ! isset( $this->re_lang ) ) {
175 175
             $this->re_lang = $re_lang;
176 176
         }
177 177
 
@@ -185,16 +185,16 @@  discard block
 block discarded – undo
185 185
     }
186 186
 
187 187
 	public function update( $params ) {
188
-        $this->fill_with_defaults($params);
189
-        $this->update_settings($params);
188
+        $this->fill_with_defaults( $params );
189
+        $this->update_settings( $params );
190 190
 
191 191
         if ( $this->mu_menu ) {
192
-            update_site_option('frm_admin_menu_name', $this->menu);
193
-        } else if ( current_user_can('administrator') ) {
194
-            update_site_option('frm_admin_menu_name', false);
192
+            update_site_option( 'frm_admin_menu_name', $this->menu );
193
+        } else if ( current_user_can( 'administrator' ) ) {
194
+            update_site_option( 'frm_admin_menu_name', false );
195 195
         }
196 196
 
197
-        $this->update_roles($params);
197
+        $this->update_roles( $params );
198 198
 
199 199
         do_action( 'frm_update_settings', $params );
200 200
 
@@ -206,9 +206,9 @@  discard block
 block discarded – undo
206 206
     }
207 207
 
208 208
 	private function update_settings( $params ) {
209
-        $this->mu_menu = isset($params['frm_mu_menu']) ? $params['frm_mu_menu'] : 0;
209
+        $this->mu_menu = isset( $params['frm_mu_menu'] ) ? $params['frm_mu_menu'] : 0;
210 210
 
211
-        $this->pubkey = trim($params['frm_pubkey']);
211
+        $this->pubkey = trim( $params['frm_pubkey'] );
212 212
         $this->privkey = $params['frm_privkey'];
213 213
 		$this->re_type = $params['frm_re_type'];
214 214
         $this->re_lang = $params['frm_re_lang'];
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 
217 217
         $this->load_style = $params['frm_load_style'];
218 218
 
219
-        $this->use_html = isset($params['frm_use_html']) ? $params['frm_use_html'] : 0;
219
+        $this->use_html = isset( $params['frm_use_html'] ) ? $params['frm_use_html'] : 0;
220 220
 		$this->jquery_css = isset( $params['frm_jquery_css'] ) ? absint( $params['frm_jquery_css'] ) : 0;
221 221
 		$this->accordion_js = isset( $params['frm_accordion_js'] ) ? absint( $params['frm_accordion_js'] ) : 0;
222 222
 		$this->fade_form = isset( $params['frm_fade_form'] ) ? absint( $params['frm_fade_form'] ) : 0;
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
         $frm_roles = FrmAppHelper::frm_capabilities();
231 231
         $roles = get_editable_roles();
232 232
         foreach ( $frm_roles as $frm_role => $frm_role_description ) {
233
-            $this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' );
233
+            $this->$frm_role = (array) ( isset( $params[$frm_role] ) ? $params[$frm_role] : 'administrator' );
234 234
 
235 235
             // Make sure administrators always have permissions
236 236
             if ( ! in_array( 'administrator', $this->$frm_role ) ) {
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
             }
239 239
 
240 240
             foreach ( $roles as $role => $details ) {
241
-                if ( in_array($role, $this->$frm_role) ) {
241
+                if ( in_array( $role, $this->$frm_role ) ) {
242 242
     			    $wp_roles->add_cap( $role, $frm_role );
243 243
     			} else {
244 244
     			    $wp_roles->remove_cap( $role, $frm_role );
@@ -250,10 +250,10 @@  discard block
 block discarded – undo
250 250
 	public function store() {
251 251
         // Save the posted value in the database
252 252
 
253
-        update_option('frm_options', $this);
253
+        update_option( 'frm_options', $this );
254 254
 
255
-        delete_transient('frm_options');
256
-        set_transient('frm_options', $this);
255
+        delete_transient( 'frm_options' );
256
+        set_transient( 'frm_options', $this );
257 257
 
258 258
         do_action( 'frm_store_settings' );
259 259
     }
Please login to merge, or discard this patch.
classes/controllers/FrmFormsController.php 4 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1082,7 +1082,8 @@
 block discarded – undo
1082 1082
 	private static function maybe_get_form_to_show( $id ) {
1083 1083
 		$form = false;
1084 1084
 
1085
-		if ( ! empty( $id ) ) { // no form id or key set
1085
+		if ( ! empty( $id ) ) {
1086
+// no form id or key set
1086 1087
 			$form = FrmForm::getOne( $id );
1087 1088
 			if ( ! $form || $form->parent_form_id || $form->status == 'trash' ) {
1088 1089
 				$form = false;
Please login to merge, or discard this patch.
Doc Comments   +11 added lines patch added patch discarded remove patch
@@ -177,6 +177,9 @@  discard block
 block discarded – undo
177 177
 		wp_die();
178 178
 	}
179 179
 
180
+	/**
181
+	 * @param string $field
182
+	 */
180 183
 	private static function edit_in_place_value( $field ) {
181 184
 		_deprecated_function( __METHOD__, '3.0' );
182 185
 		check_ajax_referer( 'frm_ajax', 'nonce' );
@@ -825,6 +828,7 @@  discard block
 block discarded – undo
825 828
 	/**
826 829
 	 * Get an array of the helper shortcodes to display in the customization panel
827 830
 	 * @since 2.0.6
831
+	 * @param boolean $settings_tab
828 832
 	 */
829 833
 	private static function get_shortcode_helpers( $settings_tab ) {
830 834
 		$entry_shortcodes = array(
@@ -900,6 +904,9 @@  discard block
 block discarded – undo
900 904
         return $content;
901 905
     }
902 906
 
907
+	/**
908
+	 * @param boolean $entry
909
+	 */
903 910
 	private static function get_entry_by_param( &$entry ) {
904 911
 		if ( ! $entry || ! is_object( $entry ) ) {
905 912
 			if ( ! $entry || ! is_numeric( $entry ) ) {
@@ -1219,6 +1226,9 @@  discard block
 block discarded – undo
1219 1226
 		return $form;
1220 1227
     }
1221 1228
 
1229
+	/**
1230
+	 * @param string $id
1231
+	 */
1222 1232
 	private static function maybe_get_form_to_show( $id ) {
1223 1233
 		$form = false;
1224 1234
 
@@ -1618,6 +1628,7 @@  discard block
 block discarded – undo
1618 1628
 
1619 1629
 	/**
1620 1630
 	 * @since 2.0.8
1631
+	 * @param string $content
1621 1632
 	 */
1622 1633
 	private static function maybe_minimize_form( $atts, &$content ) {
1623 1634
 		// check if minimizing is turned on
Please login to merge, or discard this patch.
Indentation   +448 added lines, -448 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmFormsController {
4 4
 
5
-    public static function menu() {
5
+	public static function menu() {
6 6
 		$menu_label = __( 'Forms', 'formidable' );
7 7
 		if ( ! FrmAppHelper::pro_is_installed() ) {
8 8
 			$menu_label .= ' (Lite)';
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 		add_submenu_page('formidable', 'Formidable | ' . $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' );
11 11
 
12 12
 		self::maybe_load_listing_hooks();
13
-    }
13
+	}
14 14
 
15 15
 	public static function maybe_load_listing_hooks() {
16 16
 		$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
@@ -24,35 +24,35 @@  discard block
 block discarded – undo
24 24
 		add_filter( 'manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' );
25 25
 	}
26 26
 
27
-    public static function head() {
28
-        wp_enqueue_script('formidable-editinplace');
27
+	public static function head() {
28
+		wp_enqueue_script('formidable-editinplace');
29 29
 
30
-        if ( wp_is_mobile() ) {
31
-    		wp_enqueue_script( 'jquery-touch-punch' );
32
-    	}
33
-    }
30
+		if ( wp_is_mobile() ) {
31
+			wp_enqueue_script( 'jquery-touch-punch' );
32
+		}
33
+	}
34 34
 
35
-    public static function register_widgets() {
36
-        require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php');
37
-        register_widget('FrmShowForm');
38
-    }
35
+	public static function register_widgets() {
36
+		require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php');
37
+		register_widget('FrmShowForm');
38
+	}
39 39
 
40
-    public static function list_form() {
41
-        FrmAppHelper::permission_check('frm_view_forms');
40
+	public static function list_form() {
41
+		FrmAppHelper::permission_check('frm_view_forms');
42 42
 
43 43
 		$params = FrmForm::list_page_params();
44
-        $errors = self::process_bulk_form_actions( array());
45
-        $errors = apply_filters('frm_admin_list_form_action', $errors);
44
+		$errors = self::process_bulk_form_actions( array());
45
+		$errors = apply_filters('frm_admin_list_form_action', $errors);
46 46
 
47 47
 		return self::display_forms_list( $params, '', $errors );
48
-    }
48
+	}
49 49
 
50 50
 	public static function new_form( $values = array() ) {
51
-        FrmAppHelper::permission_check('frm_edit_forms');
51
+		FrmAppHelper::permission_check('frm_edit_forms');
52 52
 
53
-        global $frm_vars;
53
+		global $frm_vars;
54 54
 
55
-        $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
55
+		$action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
56 56
 		$action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ];
57 57
 
58 58
 		if ( $action == 'create' ) {
@@ -60,18 +60,18 @@  discard block
 block discarded – undo
60 60
 			return;
61 61
 		} else if ( $action == 'new' ) {
62 62
 			$frm_field_selection = FrmField::field_selection();
63
-            $values = FrmFormsHelper::setup_new_vars($values);
64
-            $id = FrmForm::create( $values );
65
-            $form = FrmForm::getOne($id);
63
+			$values = FrmFormsHelper::setup_new_vars($values);
64
+			$id = FrmForm::create( $values );
65
+			$form = FrmForm::getOne($id);
66 66
 
67 67
 			self::create_default_email_action( $form );
68 68
 
69 69
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
70 70
 
71
-            $values['id'] = $id;
71
+			$values['id'] = $id;
72 72
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
73
-        }
74
-    }
73
+		}
74
+	}
75 75
 
76 76
 	/**
77 77
 	 * Create the default email action
@@ -80,88 +80,88 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @param object $form
82 82
 	 */
83
-    private static function create_default_email_action( $form ) {
84
-    	$create_email = apply_filters( 'frm_create_default_email_action', true, $form );
83
+	private static function create_default_email_action( $form ) {
84
+		$create_email = apply_filters( 'frm_create_default_email_action', true, $form );
85 85
 
86
-	    if ( $create_email ) {
87
-		    $action_control = FrmFormActionsController::get_form_actions( 'email' );
88
-		    $action_control->create( $form->id );
89
-	    }
90
-    }
86
+		if ( $create_email ) {
87
+			$action_control = FrmFormActionsController::get_form_actions( 'email' );
88
+			$action_control->create( $form->id );
89
+		}
90
+	}
91 91
 
92 92
 	public static function create( $values = array() ) {
93
-        FrmAppHelper::permission_check('frm_edit_forms');
93
+		FrmAppHelper::permission_check('frm_edit_forms');
94 94
 
95
-        global $frm_vars;
96
-        if ( empty( $values ) ) {
97
-            $values = $_POST;
98
-        }
95
+		global $frm_vars;
96
+		if ( empty( $values ) ) {
97
+			$values = $_POST;
98
+		}
99 99
 
100
-        //Set radio button and checkbox meta equal to "other" value
101
-        if ( FrmAppHelper::pro_is_installed() ) {
102
-            $values = FrmProEntry::mod_other_vals( $values, 'back' );
103
-        }
100
+		//Set radio button and checkbox meta equal to "other" value
101
+		if ( FrmAppHelper::pro_is_installed() ) {
102
+			$values = FrmProEntry::mod_other_vals( $values, 'back' );
103
+		}
104 104
 
105 105
 		$id = isset($values['id']) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
106 106
 
107
-        if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
108
-            $frm_settings = FrmAppHelper::get_settings();
109
-            $errors = array( 'form' => $frm_settings->admin_permission );
110
-        } else {
111
-            $errors = FrmForm::validate($values);
112
-        }
107
+		if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
108
+			$frm_settings = FrmAppHelper::get_settings();
109
+			$errors = array( 'form' => $frm_settings->admin_permission );
110
+		} else {
111
+			$errors = FrmForm::validate($values);
112
+		}
113 113
 
114
-        if ( count($errors) > 0 ) {
115
-            $hide_preview = true;
114
+		if ( count($errors) > 0 ) {
115
+			$hide_preview = true;
116 116
 			$frm_field_selection = FrmField::field_selection();
117
-            $form = FrmForm::getOne( $id );
118
-            $fields = FrmField::get_all_for_form($id);
117
+			$form = FrmForm::getOne( $id );
118
+			$fields = FrmField::get_all_for_form($id);
119 119
 
120 120
 			$values = FrmAppHelper::setup_edit_vars($form, 'forms', '', true);
121 121
 			$values['fields'] = $fields;
122 122
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
123 123
 
124 124
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
125
-        } else {
126
-            FrmForm::update( $id, $values, true );
125
+		} else {
126
+			FrmForm::update( $id, $values, true );
127 127
 			$url = admin_url( 'admin.php?page=formidable&frm_action=settings&id=' . $id );
128 128
 			die( FrmAppHelper::js_redirect( $url ) );
129
-        }
130
-    }
129
+		}
130
+	}
131 131
 
132
-    public static function edit( $values = false ) {
133
-        FrmAppHelper::permission_check('frm_edit_forms');
132
+	public static function edit( $values = false ) {
133
+		FrmAppHelper::permission_check('frm_edit_forms');
134 134
 
135 135
 		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
136
-        return self::get_edit_vars($id);
137
-    }
136
+		return self::get_edit_vars($id);
137
+	}
138 138
 
139
-    public static function settings( $id = false, $message = '' ) {
140
-        FrmAppHelper::permission_check('frm_edit_forms');
139
+	public static function settings( $id = false, $message = '' ) {
140
+		FrmAppHelper::permission_check('frm_edit_forms');
141 141
 
142
-        if ( ! $id || ! is_numeric($id) ) {
142
+		if ( ! $id || ! is_numeric($id) ) {
143 143
 			$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
144
-        }
144
+		}
145 145
 		return self::get_settings_vars( $id, array(), $message );
146
-    }
146
+	}
147 147
 
148
-    public static function update_settings() {
149
-        FrmAppHelper::permission_check('frm_edit_forms');
148
+	public static function update_settings() {
149
+		FrmAppHelper::permission_check('frm_edit_forms');
150 150
 
151 151
 		$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
152 152
 
153
-        $errors = FrmForm::validate($_POST);
154
-        if ( count($errors) > 0 ) {
155
-            return self::get_settings_vars($id, $errors);
156
-        }
153
+		$errors = FrmForm::validate($_POST);
154
+		if ( count($errors) > 0 ) {
155
+			return self::get_settings_vars($id, $errors);
156
+		}
157 157
 
158
-        do_action('frm_before_update_form_settings', $id);
158
+		do_action('frm_before_update_form_settings', $id);
159 159
 
160 160
 		FrmForm::update( $id, $_POST );
161 161
 
162
-        $message = __( 'Settings Successfully Updated', 'formidable' );
162
+		$message = __( 'Settings Successfully Updated', 'formidable' );
163 163
 		return self::get_settings_vars( $id, array(), $message );
164
-    }
164
+	}
165 165
 
166 166
 	public static function edit_key() {
167 167
 		_deprecated_function( __METHOD__, '3.0' );
@@ -194,33 +194,33 @@  discard block
 block discarded – undo
194 194
 
195 195
 	public static function update( $values = array() ) {
196 196
 		if ( empty( $values ) ) {
197
-            $values = $_POST;
198
-        }
197
+			$values = $_POST;
198
+		}
199 199
 
200
-        //Set radio button and checkbox meta equal to "other" value
201
-        if ( FrmAppHelper::pro_is_installed() ) {
202
-            $values = FrmProEntry::mod_other_vals( $values, 'back' );
203
-        }
200
+		//Set radio button and checkbox meta equal to "other" value
201
+		if ( FrmAppHelper::pro_is_installed() ) {
202
+			$values = FrmProEntry::mod_other_vals( $values, 'back' );
203
+		}
204 204
 
205
-        $errors = FrmForm::validate( $values );
206
-        $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' );
207
-        if ( $permission_error !== false ) {
208
-            $errors['form'] = $permission_error;
209
-        }
205
+		$errors = FrmForm::validate( $values );
206
+		$permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' );
207
+		if ( $permission_error !== false ) {
208
+			$errors['form'] = $permission_error;
209
+		}
210 210
 
211 211
 		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
212 212
 
213 213
 		if ( count( $errors ) > 0 ) {
214
-            return self::get_edit_vars( $id, $errors );
214
+			return self::get_edit_vars( $id, $errors );
215 215
 		} else {
216
-            FrmForm::update( $id, $values );
217
-            $message = __( 'Form was Successfully Updated', 'formidable' );
218
-            if ( defined( 'DOING_AJAX' ) ) {
216
+			FrmForm::update( $id, $values );
217
+			$message = __( 'Form was Successfully Updated', 'formidable' );
218
+			if ( defined( 'DOING_AJAX' ) ) {
219 219
 				wp_die( $message );
220
-            }
220
+			}
221 221
 			return self::get_edit_vars( $id, array(), $message );
222
-        }
223
-    }
222
+		}
223
+	}
224 224
 
225 225
 	/**
226 226
 	 * Redirect to the url for creating from a template
@@ -242,30 +242,30 @@  discard block
 block discarded – undo
242 242
 		wp_die();
243 243
 	}
244 244
 
245
-    public static function duplicate() {
246
-        FrmAppHelper::permission_check('frm_edit_forms');
245
+	public static function duplicate() {
246
+		FrmAppHelper::permission_check('frm_edit_forms');
247 247
 
248 248
 		$params = FrmForm::list_page_params();
249
-        $form = FrmForm::duplicate( $params['id'], $params['template'], true );
250
-        $message = $params['template'] ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
251
-        if ( $form ) {
249
+		$form = FrmForm::duplicate( $params['id'], $params['template'], true );
250
+		$message = $params['template'] ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
251
+		if ( $form ) {
252 252
 			return self::get_edit_vars( $form, array(), $message, true );
253
-        } else {
254
-            return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' ));
255
-        }
256
-    }
253
+		} else {
254
+			return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' ));
255
+		}
256
+	}
257 257
 
258
-    public static function page_preview() {
258
+	public static function page_preview() {
259 259
 		$params = FrmForm::list_page_params();
260
-        if ( ! $params['form'] ) {
261
-            return;
262
-        }
260
+		if ( ! $params['form'] ) {
261
+			return;
262
+		}
263 263
 
264
-        $form = FrmForm::getOne( $params['form'] );
264
+		$form = FrmForm::getOne( $params['form'] );
265 265
 		if ( $form ) {
266 266
 			return self::show_form( $form->id, '', true, true );
267 267
 		}
268
-    }
268
+	}
269 269
 
270 270
 	/**
271 271
 	 * @since 3.0
@@ -274,11 +274,11 @@  discard block
 block discarded – undo
274 274
 		echo self::page_preview();
275 275
 	}
276 276
 
277
-    public static function preview() {
278
-        do_action( 'frm_wp' );
277
+	public static function preview() {
278
+		do_action( 'frm_wp' );
279 279
 
280
-        global $frm_vars;
281
-        $frm_vars['preview'] = true;
280
+		global $frm_vars;
281
+		$frm_vars['preview'] = true;
282 282
 
283 283
 		self::load_wp();
284 284
 
@@ -395,22 +395,22 @@  discard block
 block discarded – undo
395 395
 		}
396 396
 	}
397 397
 
398
-    public static function untrash() {
398
+	public static function untrash() {
399 399
 		self::change_form_status( 'untrash' );
400
-    }
400
+	}
401 401
 
402 402
 	public static function bulk_untrash( $ids ) {
403
-        FrmAppHelper::permission_check('frm_edit_forms');
403
+		FrmAppHelper::permission_check('frm_edit_forms');
404 404
 
405
-        $count = FrmForm::set_status( $ids, 'published' );
405
+		$count = FrmForm::set_status( $ids, 'published' );
406 406
 
407
-        $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
408
-        return $message;
409
-    }
407
+		$message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
408
+		return $message;
409
+	}
410 410
 
411
-    public static function trash() {
411
+	public static function trash() {
412 412
 		self::change_form_status( 'trash' );
413
-    }
413
+	}
414 414
 
415 415
 	/**
416 416
 	 * @param string $status
@@ -459,14 +459,14 @@  discard block
 block discarded – undo
459 459
 	}
460 460
 
461 461
 	public static function bulk_trash( $ids ) {
462
-        FrmAppHelper::permission_check('frm_delete_forms');
462
+		FrmAppHelper::permission_check('frm_delete_forms');
463 463
 
464
-        $count = 0;
465
-        foreach ( $ids as $id ) {
466
-            if ( FrmForm::trash( $id ) ) {
467
-                $count++;
468
-            }
469
-        }
464
+		$count = 0;
465
+		foreach ( $ids as $id ) {
466
+			if ( FrmForm::trash( $id ) ) {
467
+				$count++;
468
+			}
469
+		}
470 470
 
471 471
 		$current_page = FrmAppHelper::get_simple_request( array(
472 472
 			'param' => 'form_type',
@@ -474,63 +474,63 @@  discard block
 block discarded – undo
474 474
 		) );
475 475
 		$message = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=list&action=bulk_untrash&form_type=' . $current_page . '&item-action=' . implode( ',', $ids ), 'bulk-toplevel_page_formidable' ) ) . '">', '</a>' );
476 476
 
477
-        return $message;
478
-    }
477
+		return $message;
478
+	}
479 479
 
480
-    public static function destroy() {
481
-        FrmAppHelper::permission_check('frm_delete_forms');
480
+	public static function destroy() {
481
+		FrmAppHelper::permission_check('frm_delete_forms');
482 482
 
483 483
 		$params = FrmForm::list_page_params();
484 484
 
485
-        //check nonce url
486
-        check_admin_referer('destroy_form_' . $params['id']);
485
+		//check nonce url
486
+		check_admin_referer('destroy_form_' . $params['id']);
487 487
 
488
-        $count = 0;
489
-        if ( FrmForm::destroy( $params['id'] ) ) {
490
-            $count++;
491
-        }
488
+		$count = 0;
489
+		if ( FrmForm::destroy( $params['id'] ) ) {
490
+			$count++;
491
+		}
492 492
 
493
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
493
+		$message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
494 494
 
495 495
 		self::display_forms_list( $params, $message );
496
-    }
496
+	}
497 497
 
498 498
 	public static function bulk_destroy( $ids ) {
499
-        FrmAppHelper::permission_check('frm_delete_forms');
499
+		FrmAppHelper::permission_check('frm_delete_forms');
500 500
 
501
-        $count = 0;
502
-        foreach ( $ids as $id ) {
503
-            $d = FrmForm::destroy( $id );
504
-            if ( $d ) {
505
-                $count++;
506
-            }
507
-        }
501
+		$count = 0;
502
+		foreach ( $ids as $id ) {
503
+			$d = FrmForm::destroy( $id );
504
+			if ( $d ) {
505
+				$count++;
506
+			}
507
+		}
508 508
 
509
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
509
+		$message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
510 510
 
511
-        return $message;
512
-    }
511
+		return $message;
512
+	}
513 513
 
514
-    private static function delete_all() {
515
-        //check nonce url
516
-        $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable');
517
-        if ( $permission_error !== false ) {
514
+	private static function delete_all() {
515
+		//check nonce url
516
+		$permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable');
517
+		if ( $permission_error !== false ) {
518 518
 			self::display_forms_list( array(), '', array( $permission_error ) );
519
-            return;
520
-        }
519
+			return;
520
+		}
521 521
 
522 522
 		$count = FrmForm::scheduled_delete( time() );
523
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
523
+		$message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
524 524
 
525 525
 		self::display_forms_list( array(), $message );
526
-    }
526
+	}
527 527
 
528 528
 	/**
529
-	* Inserts Formidable button
530
-	* Hook exists since 2.5.0
531
-	*
532
-	* @since 2.0.15
533
-	*/
529
+	 * Inserts Formidable button
530
+	 * Hook exists since 2.5.0
531
+	 *
532
+	 * @since 2.0.15
533
+	 */
534 534
 	public static function insert_form_button() {
535 535
 		if ( current_user_can('frm_view_forms') ) {
536 536
 			$menu_name = FrmAppHelper::get_menu_name();
@@ -541,45 +541,45 @@  discard block
 block discarded – undo
541 541
 		}
542 542
 	}
543 543
 
544
-    public static function insert_form_popup() {
544
+	public static function insert_form_popup() {
545 545
 		$page = basename( FrmAppHelper::get_server_value( 'PHP_SELF' ) );
546 546
 		if ( ! in_array( $page, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php' ) ) ) {
547
-            return;
548
-        }
547
+			return;
548
+		}
549 549
 
550
-        FrmAppHelper::load_admin_wide_js();
550
+		FrmAppHelper::load_admin_wide_js();
551 551
 
552
-        $shortcodes = array(
552
+		$shortcodes = array(
553 553
 			'formidable' => array(
554 554
 				'name'  => __( 'Form', 'formidable' ),
555 555
 				'label' => __( 'Insert a Form', 'formidable' ),
556 556
 			),
557
-        );
557
+		);
558 558
 
559
-        $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes);
559
+		$shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes);
560 560
 
561 561
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' );
562
-    }
562
+	}
563 563
 
564
-    public static function get_shortcode_opts() {
564
+	public static function get_shortcode_opts() {
565 565
 		FrmAppHelper::permission_check('frm_view_forms');
566
-        check_ajax_referer( 'frm_ajax', 'nonce' );
566
+		check_ajax_referer( 'frm_ajax', 'nonce' );
567 567
 
568 568
 		$shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' );
569
-        if ( empty($shortcode) ) {
570
-            wp_die();
571
-        }
569
+		if ( empty($shortcode) ) {
570
+			wp_die();
571
+		}
572 572
 
573 573
 		echo '<div id="sc-opts-' . esc_attr( $shortcode ) . '" class="frm_shortcode_option">';
574 574
 		echo '<input type="radio" name="frmsc" value="' . esc_attr( $shortcode ) . '" id="sc-' . esc_attr( $shortcode ) . '" class="frm_hidden" />';
575 575
 
576
-        $form_id = '';
577
-        $opts = array();
576
+		$form_id = '';
577
+		$opts = array();
578 578
 		switch ( $shortcode ) {
579
-            case 'formidable':
580
-                $opts = array(
579
+			case 'formidable':
580
+				$opts = array(
581 581
 					'form_id'       => 'id',
582
-                    //'key' => ',
582
+					//'key' => ',
583 583
 					'title'         => array(
584 584
 						'val'   => 1,
585 585
 						'label' => __( 'Display form title', 'formidable' ),
@@ -592,8 +592,8 @@  discard block
 block discarded – undo
592 592
 						'val'   => 1,
593 593
 						'label' => __( 'Minimize form HTML', 'formidable' ),
594 594
 					),
595
-                );
596
-        }
595
+				);
596
+		}
597 597
 		$opts = apply_filters( 'frm_sc_popup_opts', $opts, $shortcode );
598 598
 
599 599
 		if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) {
@@ -604,38 +604,38 @@  discard block
 block discarded – undo
604 604
 
605 605
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' );
606 606
 
607
-        echo '</div>';
607
+		echo '</div>';
608 608
 
609
-        wp_die();
610
-    }
609
+		wp_die();
610
+	}
611 611
 
612 612
 	public static function display_forms_list( $params = array(), $message = '', $errors = array() ) {
613
-        FrmAppHelper::permission_check( 'frm_view_forms' );
613
+		FrmAppHelper::permission_check( 'frm_view_forms' );
614 614
 
615
-        global $wpdb, $frm_vars;
615
+		global $wpdb, $frm_vars;
616 616
 
617 617
 		if ( empty( $params ) ) {
618 618
 			$params = FrmForm::list_page_params();
619
-        }
619
+		}
620 620
 
621
-        $wp_list_table = new FrmFormsListHelper( compact( 'params' ) );
621
+		$wp_list_table = new FrmFormsListHelper( compact( 'params' ) );
622 622
 
623
-        $pagenum = $wp_list_table->get_pagenum();
623
+		$pagenum = $wp_list_table->get_pagenum();
624 624
 
625
-        $wp_list_table->prepare_items();
625
+		$wp_list_table->prepare_items();
626 626
 
627
-        $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
628
-        if ( $pagenum > $total_pages && $total_pages > 0 ) {
627
+		$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
628
+		if ( $pagenum > $total_pages && $total_pages > 0 ) {
629 629
 			wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) );
630
-            die();
631
-        }
630
+			die();
631
+		}
632 632
 
633 633
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php' );
634
-    }
634
+	}
635 635
 
636 636
 	public static function get_columns( $columns ) {
637
-	    $columns['cb'] = '<input type="checkbox" />';
638
-	    $columns['id'] = 'ID';
637
+		$columns['cb'] = '<input type="checkbox" />';
638
+		$columns['id'] = 'ID';
639 639
 
640 640
 		$type = FrmAppHelper::get_simple_request( array(
641 641
 			'param'   => 'form_type',
@@ -643,18 +643,18 @@  discard block
 block discarded – undo
643 643
 			'default' => 'published',
644 644
 		) );
645 645
 
646
-        if ( 'template' == $type ) {
647
-            $columns['name']        = __( 'Template Name', 'formidable' );
648
-            $columns['type']        = __( 'Type', 'formidable' );
649
-            $columns['form_key']    = __( 'Key', 'formidable' );
650
-        } else {
651
-            $columns['name']        = __( 'Form Title', 'formidable' );
652
-            $columns['entries']     = __( 'Entries', 'formidable' );
653
-            $columns['form_key']    = __( 'Key', 'formidable' );
654
-            $columns['shortcode']   = __( 'Shortcodes', 'formidable' );
655
-        }
646
+		if ( 'template' == $type ) {
647
+			$columns['name']        = __( 'Template Name', 'formidable' );
648
+			$columns['type']        = __( 'Type', 'formidable' );
649
+			$columns['form_key']    = __( 'Key', 'formidable' );
650
+		} else {
651
+			$columns['name']        = __( 'Form Title', 'formidable' );
652
+			$columns['entries']     = __( 'Entries', 'formidable' );
653
+			$columns['form_key']    = __( 'Key', 'formidable' );
654
+			$columns['shortcode']   = __( 'Shortcodes', 'formidable' );
655
+		}
656 656
 
657
-        $columns['created_at'] = __( 'Date', 'formidable' );
657
+		$columns['created_at'] = __( 'Date', 'formidable' );
658 658
 
659 659
 		add_screen_option( 'per_page', array(
660 660
 			'label'   => __( 'Forms', 'formidable' ),
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
 			'option'  => 'formidable_page_formidable_per_page',
663 663
 		) );
664 664
 
665
-        return $columns;
665
+		return $columns;
666 666
 	}
667 667
 
668 668
 	public static function get_sortable_columns() {
@@ -690,86 +690,86 @@  discard block
 block discarded – undo
690 690
 	}
691 691
 
692 692
 	public static function save_per_page( $save, $option, $value ) {
693
-        if ( $option == 'formidable_page_formidable_per_page' ) {
694
-            $save = (int) $value;
695
-        }
696
-        return $save;
697
-    }
693
+		if ( $option == 'formidable_page_formidable_per_page' ) {
694
+			$save = (int) $value;
695
+		}
696
+		return $save;
697
+	}
698 698
 
699 699
 	private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) {
700
-        global $frm_vars;
700
+		global $frm_vars;
701 701
 
702
-        $form = FrmForm::getOne( $id );
703
-        if ( ! $form ) {
704
-            wp_die( __( 'You are trying to edit a form that does not exist.', 'formidable' ) );
705
-        }
702
+		$form = FrmForm::getOne( $id );
703
+		if ( ! $form ) {
704
+			wp_die( __( 'You are trying to edit a form that does not exist.', 'formidable' ) );
705
+		}
706 706
 
707
-        if ( $form->parent_form_id ) {
707
+		if ( $form->parent_form_id ) {
708 708
 			wp_die( sprintf( __( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form->parent_form_id ) ) . '">', '</a>' ));
709
-        }
709
+		}
710 710
 
711 711
 		$frm_field_selection = FrmField::field_selection();
712
-        $fields = FrmField::get_all_for_form($form->id);
712
+		$fields = FrmField::get_all_for_form($form->id);
713 713
 
714
-        // Automatically add end section fields if they don't exist (2.0 migration)
715
-        $reset_fields = false;
716
-        FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields );
714
+		// Automatically add end section fields if they don't exist (2.0 migration)
715
+		$reset_fields = false;
716
+		FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields );
717 717
 
718
-        if ( $reset_fields ) {
719
-            $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
720
-        }
718
+		if ( $reset_fields ) {
719
+			$fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
720
+		}
721 721
 
722
-        unset($end_section_values, $last_order, $open, $reset_fields);
722
+		unset($end_section_values, $last_order, $open, $reset_fields);
723 723
 
724 724
 		$args = array( 'parent_form_id' => $form->id );
725 725
 		$values = FrmAppHelper::setup_edit_vars( $form, 'forms', '', true, array(), $args );
726 726
 		$values['fields'] = $fields;
727 727
 
728
-        $edit_message = __( 'Form was Successfully Updated', 'formidable' );
729
-        if ( $form->is_template && $message == $edit_message ) {
730
-            $message = __( 'Template was Successfully Updated', 'formidable' );
731
-        }
728
+		$edit_message = __( 'Form was Successfully Updated', 'formidable' );
729
+		if ( $form->is_template && $message == $edit_message ) {
730
+			$message = __( 'Template was Successfully Updated', 'formidable' );
731
+		}
732 732
 
733 733
 		$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
734 734
 
735
-        if ( $form->default_template ) {
736
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
737
-        } else if ( defined('DOING_AJAX') ) {
738
-            wp_die();
739
-        } else if ( $create_link ) {
735
+		if ( $form->default_template ) {
736
+			wp_die(__( 'That template cannot be edited', 'formidable' ));
737
+		} else if ( defined('DOING_AJAX') ) {
738
+			wp_die();
739
+		} else if ( $create_link ) {
740 740
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
741
-        } else {
741
+		} else {
742 742
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' );
743
-        }
744
-    }
743
+		}
744
+	}
745 745
 
746 746
 	public static function get_settings_vars( $id, $errors = array(), $message = '' ) {
747 747
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
748 748
 
749
-        global $frm_vars;
749
+		global $frm_vars;
750 750
 
751
-        $form = FrmForm::getOne( $id );
751
+		$form = FrmForm::getOne( $id );
752 752
 
753
-        $fields = FrmField::get_all_for_form($id);
754
-        $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
753
+		$fields = FrmField::get_all_for_form($id);
754
+		$values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
755 755
 
756
-        if ( isset($values['default_template']) && $values['default_template'] ) {
757
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
758
-        }
756
+		if ( isset($values['default_template']) && $values['default_template'] ) {
757
+			wp_die(__( 'That template cannot be edited', 'formidable' ));
758
+		}
759 759
 
760 760
 		self::clean_submit_html( $values );
761 761
 
762
-        $action_controls = FrmFormActionsController::get_form_actions();
762
+		$action_controls = FrmFormActionsController::get_form_actions();
763 763
 
764
-        $sections = apply_filters('frm_add_form_settings_section', array(), $values);
765
-        $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
764
+		$sections = apply_filters('frm_add_form_settings_section', array(), $values);
765
+		$pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
766 766
 
767
-        $styles = apply_filters('frm_get_style_opts', array());
767
+		$styles = apply_filters('frm_get_style_opts', array());
768 768
 
769 769
 		$first_h3 = 'frm_first_h3';
770 770
 
771 771
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' );
772
-    }
772
+	}
773 773
 
774 774
 	/**
775 775
 	 * Replace old Submit Button href with new href to avoid errors in Chrome
@@ -784,11 +784,11 @@  discard block
 block discarded – undo
784 784
 		}
785 785
 	}
786 786
 
787
-    public static function mb_tags_box( $form_id, $class = '' ) {
788
-        $fields = FrmField::get_all_for_form($form_id, '', 'include');
789
-        $linked_forms = array();
790
-        $col = 'one';
791
-        $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false;
787
+	public static function mb_tags_box( $form_id, $class = '' ) {
788
+		$fields = FrmField::get_all_for_form($form_id, '', 'include');
789
+		$linked_forms = array();
790
+		$col = 'one';
791
+		$settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false;
792 792
 
793 793
 		$cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() );
794 794
 		$adv_shortcodes = self::get_advanced_shortcodes();
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
 		$entry_shortcodes = self::get_shortcode_helpers( $settings_tab );
797 797
 
798 798
 		include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' );
799
-    }
799
+	}
800 800
 
801 801
 	/**
802 802
 	 * Get an array of the options to display in the advanced tab
@@ -837,7 +837,7 @@  discard block
 block discarded – undo
837 837
 			''          => '',
838 838
 			'siteurl'   => __( 'Site URL', 'formidable' ),
839 839
 			'sitename'  => __( 'Site Name', 'formidable' ),
840
-        );
840
+		);
841 841
 
842 842
 		if ( ! FrmAppHelper::pro_is_installed() ) {
843 843
 			unset( $entry_shortcodes['post_id'] );
@@ -884,21 +884,21 @@  discard block
 block discarded – undo
884 884
 		wp_die();
885 885
 	}
886 886
 
887
-    public static function filter_content( $content, $form, $entry = false ) {
887
+	public static function filter_content( $content, $form, $entry = false ) {
888 888
 		self::get_entry_by_param( $entry );
889
-        if ( ! $entry ) {
890
-            return $content;
891
-        }
889
+		if ( ! $entry ) {
890
+			return $content;
891
+		}
892 892
 
893
-        if ( is_object( $form ) ) {
894
-            $form = $form->id;
895
-        }
893
+		if ( is_object( $form ) ) {
894
+			$form = $form->id;
895
+		}
896 896
 
897
-        $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form );
898
-        $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes );
897
+		$shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form );
898
+		$content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes );
899 899
 
900
-        return $content;
901
-    }
900
+		return $content;
901
+	}
902 902
 
903 903
 	private static function get_entry_by_param( &$entry ) {
904 904
 		if ( ! $entry || ! is_object( $entry ) ) {
@@ -910,203 +910,203 @@  discard block
 block discarded – undo
910 910
 		}
911 911
 	}
912 912
 
913
-    public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
914
-        return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
915
-    }
913
+	public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
914
+		return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
915
+	}
916 916
 
917
-    public static function process_bulk_form_actions( $errors ) {
918
-        if ( ! $_REQUEST ) {
919
-            return $errors;
920
-        }
917
+	public static function process_bulk_form_actions( $errors ) {
918
+		if ( ! $_REQUEST ) {
919
+			return $errors;
920
+		}
921 921
 
922 922
 		$bulkaction = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' );
923
-        if ( $bulkaction == -1 ) {
923
+		if ( $bulkaction == -1 ) {
924 924
 			$bulkaction = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
925
-        }
925
+		}
926 926
 
927
-        if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) {
928
-            FrmAppHelper::remove_get_action();
927
+		if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) {
928
+			FrmAppHelper::remove_get_action();
929 929
 
930
-            $bulkaction = str_replace( 'bulk_', '', $bulkaction );
931
-        }
930
+			$bulkaction = str_replace( 'bulk_', '', $bulkaction );
931
+		}
932 932
 
933 933
 		$ids = FrmAppHelper::get_param( 'item-action', '', 'get', 'sanitize_text_field' );
934
-        if ( empty( $ids ) ) {
935
-            $errors[] = __( 'No forms were specified', 'formidable' );
936
-            return $errors;
937
-        }
938
-
939
-        $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' );
940
-        if ( $permission_error !== false ) {
941
-            $errors[] = $permission_error;
942
-            return $errors;
943
-        }
944
-
945
-        if ( ! is_array( $ids ) ) {
946
-            $ids = explode( ',', $ids );
947
-        }
948
-
949
-        switch ( $bulkaction ) {
950
-            case 'delete':
951
-                $message = self::bulk_destroy( $ids );
934
+		if ( empty( $ids ) ) {
935
+			$errors[] = __( 'No forms were specified', 'formidable' );
936
+			return $errors;
937
+		}
938
+
939
+		$permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' );
940
+		if ( $permission_error !== false ) {
941
+			$errors[] = $permission_error;
942
+			return $errors;
943
+		}
944
+
945
+		if ( ! is_array( $ids ) ) {
946
+			$ids = explode( ',', $ids );
947
+		}
948
+
949
+		switch ( $bulkaction ) {
950
+			case 'delete':
951
+				$message = self::bulk_destroy( $ids );
952 952
 				break;
953
-            case 'trash':
954
-                $message = self::bulk_trash( $ids );
953
+			case 'trash':
954
+				$message = self::bulk_trash( $ids );
955 955
 				break;
956
-            case 'untrash':
957
-                $message = self::bulk_untrash( $ids );
958
-        }
956
+			case 'untrash':
957
+				$message = self::bulk_untrash( $ids );
958
+		}
959 959
 
960
-        if ( isset( $message ) && ! empty( $message ) ) {
960
+		if ( isset( $message ) && ! empty( $message ) ) {
961 961
 			echo '<div id="message" class="updated frm_updated_message">' . FrmAppHelper::kses( $message, array( 'a' ) ) . '</div>';
962
-        }
962
+		}
963 963
 
964
-        return $errors;
965
-    }
964
+		return $errors;
965
+	}
966 966
 
967
-    public static function add_default_templates( $path, $default = true, $template = true ) {
968
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' );
967
+	public static function add_default_templates( $path, $default = true, $template = true ) {
968
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' );
969 969
 
970
-        $path = untrailingslashit(trim($path));
970
+		$path = untrailingslashit(trim($path));
971 971
 		$templates = glob( $path . '/*.php' );
972 972
 
973 973
 		for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) {
974 974
 			$filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[ $i ] ) );
975 975
 			$template_query = array( 'form_key' => $filename );
976
-            if ( $template ) {
977
-                $template_query['is_template'] = 1;
978
-            }
979
-            if ( $default ) {
980
-                $template_query['default_template'] = 1;
981
-            }
976
+			if ( $template ) {
977
+				$template_query['is_template'] = 1;
978
+			}
979
+			if ( $default ) {
980
+				$template_query['default_template'] = 1;
981
+			}
982 982
 			$form = FrmForm::getAll( $template_query, '', 1 );
983 983
 
984
-            $values = FrmFormsHelper::setup_new_vars();
985
-            $values['form_key'] = $filename;
986
-            $values['is_template'] = $template;
987
-            $values['status'] = 'published';
988
-            if ( $default ) {
989
-                $values['default_template'] = 1;
990
-            }
991
-
992
-            include( $templates[ $i ] );
993
-
994
-            //get updated form
995
-            if ( isset($form) && ! empty($form) ) {
996
-                $old_id = $form->id;
997
-                $form = FrmForm::getOne($form->id);
998
-            } else {
999
-                $old_id = false;
984
+			$values = FrmFormsHelper::setup_new_vars();
985
+			$values['form_key'] = $filename;
986
+			$values['is_template'] = $template;
987
+			$values['status'] = 'published';
988
+			if ( $default ) {
989
+				$values['default_template'] = 1;
990
+			}
991
+
992
+			include( $templates[ $i ] );
993
+
994
+			//get updated form
995
+			if ( isset($form) && ! empty($form) ) {
996
+				$old_id = $form->id;
997
+				$form = FrmForm::getOne($form->id);
998
+			} else {
999
+				$old_id = false;
1000 1000
 				$form = FrmForm::getAll( $template_query, '', 1 );
1001
-            }
1001
+			}
1002 1002
 
1003
-            if ( $form ) {
1003
+			if ( $form ) {
1004 1004
 				do_action( 'frm_after_duplicate_form', $form->id, (array) $form, array( 'old_id' => $old_id ) );
1005
-            }
1006
-        }
1007
-    }
1005
+			}
1006
+		}
1007
+	}
1008 1008
 
1009
-    public static function route() {
1010
-        $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
1011
-        $vars = array();
1009
+	public static function route() {
1010
+		$action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
1011
+		$vars = array();
1012 1012
 		if ( isset( $_POST['frm_compact_fields'] ) ) {
1013 1013
 			FrmAppHelper::permission_check( 'frm_edit_forms' );
1014 1014
 
1015
-            $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('&quot;', '\\\"', $_POST['frm_compact_fields'] ))));
1016
-            $json_vars = json_decode($json_vars, true);
1017
-            if ( empty($json_vars) ) {
1018
-                // json decoding failed so we should return an error message
1015
+			$json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('&quot;', '\\\"', $_POST['frm_compact_fields'] ))));
1016
+			$json_vars = json_decode($json_vars, true);
1017
+			if ( empty($json_vars) ) {
1018
+				// json decoding failed so we should return an error message
1019 1019
 				$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
1020
-                if ( 'edit' == $action ) {
1021
-                    $action = 'update';
1022
-                }
1023
-
1024
-                add_filter('frm_validate_form', 'FrmFormsController::json_error');
1025
-            } else {
1026
-                $vars = FrmAppHelper::json_to_array($json_vars);
1027
-                $action = $vars[ $action ];
1020
+				if ( 'edit' == $action ) {
1021
+					$action = 'update';
1022
+				}
1023
+
1024
+				add_filter('frm_validate_form', 'FrmFormsController::json_error');
1025
+			} else {
1026
+				$vars = FrmAppHelper::json_to_array($json_vars);
1027
+				$action = $vars[ $action ];
1028 1028
 				unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] );
1029 1029
 				$_REQUEST = array_merge( $_REQUEST, $vars );
1030 1030
 				$_POST = array_merge( $_POST, $_REQUEST );
1031
-            }
1032
-        } else {
1031
+			}
1032
+		} else {
1033 1033
 			$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
1034
-    		if ( isset( $_REQUEST['delete_all'] ) ) {
1035
-                // override the action for this page
1036
-    			$action = 'delete_all';
1037
-            }
1038
-        }
1034
+			if ( isset( $_REQUEST['delete_all'] ) ) {
1035
+				// override the action for this page
1036
+				$action = 'delete_all';
1037
+			}
1038
+		}
1039 1039
 
1040 1040
 		add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
1041
-        FrmAppHelper::trigger_hook_load( 'form' );
1042
-
1043
-        switch ( $action ) {
1044
-            case 'new':
1045
-                return self::new_form($vars);
1046
-            case 'create':
1047
-            case 'edit':
1048
-            case 'update':
1049
-            case 'duplicate':
1050
-            case 'trash':
1051
-            case 'untrash':
1052
-            case 'destroy':
1053
-            case 'delete_all':
1054
-            case 'settings':
1055
-            case 'update_settings':
1041
+		FrmAppHelper::trigger_hook_load( 'form' );
1042
+
1043
+		switch ( $action ) {
1044
+			case 'new':
1045
+				return self::new_form($vars);
1046
+			case 'create':
1047
+			case 'edit':
1048
+			case 'update':
1049
+			case 'duplicate':
1050
+			case 'trash':
1051
+			case 'untrash':
1052
+			case 'destroy':
1053
+			case 'delete_all':
1054
+			case 'settings':
1055
+			case 'update_settings':
1056 1056
 				return self::$action( $vars );
1057
-            default:
1057
+			default:
1058 1058
 				do_action( 'frm_form_action_' . $action );
1059 1059
 				if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) {
1060
-                    return;
1061
-                }
1060
+					return;
1061
+				}
1062 1062
 
1063 1063
 				$action = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' );
1064
-                if ( $action == -1 ) {
1064
+				if ( $action == -1 ) {
1065 1065
 					$action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
1066
-                }
1066
+				}
1067 1067
 
1068
-                if ( strpos($action, 'bulk_') === 0 ) {
1069
-                    FrmAppHelper::remove_get_action();
1070
-                    return self::list_form();
1071
-                }
1068
+				if ( strpos($action, 'bulk_') === 0 ) {
1069
+					FrmAppHelper::remove_get_action();
1070
+					return self::list_form();
1071
+				}
1072 1072
 
1073
-                return self::display_forms_list();
1074
-        }
1075
-    }
1073
+				return self::display_forms_list();
1074
+		}
1075
+	}
1076 1076
 
1077
-    public static function json_error( $errors ) {
1078
-        $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' );
1079
-        return $errors;
1080
-    }
1077
+	public static function json_error( $errors ) {
1078
+		$errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' );
1079
+		return $errors;
1080
+	}
1081 1081
 
1082 1082
 
1083
-    /* FRONT-END FORMS */
1084
-    public static function admin_bar_css() {
1083
+	/* FRONT-END FORMS */
1084
+	public static function admin_bar_css() {
1085 1085
 		if ( is_admin() || ! current_user_can( 'frm_edit_forms' ) ) {
1086
-            return;
1087
-        }
1086
+			return;
1087
+		}
1088 1088
 
1089 1089
 		add_action( 'wp_before_admin_bar_render', 'FrmFormsController::admin_bar_configure' );
1090 1090
 		FrmAppHelper::load_font_style();
1091 1091
 	}
1092 1092
 
1093 1093
 	public static function admin_bar_configure() {
1094
-        global $frm_vars;
1095
-        if ( empty($frm_vars['forms_loaded']) ) {
1096
-            return;
1097
-        }
1098
-
1099
-        $actions = array();
1100
-        foreach ( $frm_vars['forms_loaded'] as $form ) {
1101
-            if ( is_object($form) ) {
1102
-                $actions[ $form->id ] = $form->name;
1103
-            }
1104
-            unset($form);
1105
-        }
1106
-
1107
-        if ( empty($actions) ) {
1108
-            return;
1109
-        }
1094
+		global $frm_vars;
1095
+		if ( empty($frm_vars['forms_loaded']) ) {
1096
+			return;
1097
+		}
1098
+
1099
+		$actions = array();
1100
+		foreach ( $frm_vars['forms_loaded'] as $form ) {
1101
+			if ( is_object($form) ) {
1102
+				$actions[ $form->id ] = $form->name;
1103
+			}
1104
+			unset($form);
1105
+		}
1106
+
1107
+		if ( empty($actions) ) {
1108
+			return;
1109
+		}
1110 1110
 
1111 1111
 		self::add_menu_to_admin_bar();
1112 1112
 		self::add_forms_to_admin_bar( $actions );
@@ -1147,18 +1147,18 @@  discard block
 block discarded – undo
1147 1147
 		}
1148 1148
 	}
1149 1149
 
1150
-    //formidable shortcode
1150
+	//formidable shortcode
1151 1151
 	public static function get_form_shortcode( $atts ) {
1152
-        global $frm_vars;
1153
-        if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) {
1154
-            $sc = '[formidable';
1152
+		global $frm_vars;
1153
+		if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) {
1154
+			$sc = '[formidable';
1155 1155
 			if ( ! empty( $atts ) ) {
1156 1156
 				foreach ( $atts as $k => $v ) {
1157 1157
 					$sc .= ' ' . $k . '="' . esc_attr( $v ) . '"';
1158 1158
 				}
1159 1159
 			}
1160 1160
 			return $sc . ']';
1161
-        }
1161
+		}
1162 1162
 
1163 1163
 		$shortcode_atts = shortcode_atts( array(
1164 1164
 			'id'          => '',
@@ -1173,30 +1173,30 @@  discard block
 block discarded – undo
1173 1173
 		), $atts );
1174 1174
 		do_action( 'formidable_shortcode_atts', $shortcode_atts, $atts );
1175 1175
 
1176
-        return self::show_form(
1177
-            $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'],
1178
-            $shortcode_atts['description'], $atts
1179
-        );
1180
-    }
1176
+		return self::show_form(
1177
+			$shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'],
1178
+			$shortcode_atts['description'], $atts
1179
+		);
1180
+	}
1181 1181
 
1182
-    public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
1183
-        if ( empty( $id ) ) {
1184
-            $id = $key;
1185
-        }
1182
+	public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
1183
+		if ( empty( $id ) ) {
1184
+			$id = $key;
1185
+		}
1186 1186
 
1187
-        $form = self::maybe_get_form_to_show( $id );
1188
-        if ( ! $form ) {
1189
-            return __( 'Please select a valid form', 'formidable' );
1190
-        }
1187
+		$form = self::maybe_get_form_to_show( $id );
1188
+		if ( ! $form ) {
1189
+			return __( 'Please select a valid form', 'formidable' );
1190
+		}
1191 1191
 
1192 1192
 		FrmAppController::maybe_update_styles();
1193 1193
 
1194 1194
 		add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
1195
-        FrmAppHelper::trigger_hook_load( 'form', $form );
1195
+		FrmAppHelper::trigger_hook_load( 'form', $form );
1196 1196
 
1197
-        $form = apply_filters( 'frm_pre_display_form', $form );
1197
+		$form = apply_filters( 'frm_pre_display_form', $form );
1198 1198
 
1199
-        $frm_settings = FrmAppHelper::get_settings();
1199
+		$frm_settings = FrmAppHelper::get_settings();
1200 1200
 
1201 1201
 		if ( self::is_viewable_draft_form( $form ) ) {
1202 1202
 			// don't show a draft form on a page
@@ -1217,7 +1217,7 @@  discard block
 block discarded – undo
1217 1217
 		}
1218 1218
 
1219 1219
 		return $form;
1220
-    }
1220
+	}
1221 1221
 
1222 1222
 	private static function maybe_get_form_to_show( $id ) {
1223 1223
 		$form = false;
@@ -1246,21 +1246,21 @@  discard block
 block discarded – undo
1246 1246
 		return $form->logged_in && get_current_user_id() && isset( $form->options['logged_in_role'] ) && $form->options['logged_in_role'] != '' && ! FrmAppHelper::user_has_permission( $form->options['logged_in_role'] );
1247 1247
 	}
1248 1248
 
1249
-    public static function get_form( $form, $title, $description, $atts = array() ) {
1250
-        ob_start();
1249
+	public static function get_form( $form, $title, $description, $atts = array() ) {
1250
+		ob_start();
1251 1251
 
1252 1252
 		do_action( 'frm_before_get_form', $atts );
1253 1253
 
1254
-        self::get_form_contents( $form, $title, $description, $atts );
1254
+		self::get_form_contents( $form, $title, $description, $atts );
1255 1255
 		self::enqueue_scripts( FrmForm::get_params( $form ) );
1256 1256
 
1257
-        $contents = ob_get_contents();
1258
-        ob_end_clean();
1257
+		$contents = ob_get_contents();
1258
+		ob_end_clean();
1259 1259
 
1260 1260
 		self::maybe_minimize_form( $atts, $contents );
1261 1261
 
1262
-        return $contents;
1263
-    }
1262
+		return $contents;
1263
+	}
1264 1264
 
1265 1265
 	public static function enqueue_scripts( $params ) {
1266 1266
 		do_action( 'frm_enqueue_form_scripts', $params );
@@ -1599,10 +1599,10 @@  discard block
 block discarded – undo
1599 1599
 	}
1600 1600
 
1601 1601
 	public static function defer_script_loading( $tag, $handle ) {
1602
-	    if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) {
1603
-	        $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag );
1602
+		if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) {
1603
+			$tag = str_replace( ' src', ' defer="defer" async="async" src', $tag );
1604 1604
 		}
1605
-	    return $tag;
1605
+		return $tag;
1606 1606
 	}
1607 1607
 
1608 1608
 	public static function footer_js( $location = 'footer' ) {
Please login to merge, or discard this patch.
Spacing   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 		if ( ! FrmAppHelper::pro_is_installed() ) {
8 8
 			$menu_label .= ' (Lite)';
9 9
 		}
10
-		add_submenu_page('formidable', 'Formidable | ' . $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' );
10
+		add_submenu_page( 'formidable', 'Formidable | ' . $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' );
11 11
 
12 12
 		self::maybe_load_listing_hooks();
13 13
     }
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	}
26 26
 
27 27
     public static function head() {
28
-        wp_enqueue_script('formidable-editinplace');
28
+        wp_enqueue_script( 'formidable-editinplace' );
29 29
 
30 30
         if ( wp_is_mobile() ) {
31 31
     		wp_enqueue_script( 'jquery-touch-punch' );
@@ -33,36 +33,36 @@  discard block
 block discarded – undo
33 33
     }
34 34
 
35 35
     public static function register_widgets() {
36
-        require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php');
37
-        register_widget('FrmShowForm');
36
+        require_once( FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php' );
37
+        register_widget( 'FrmShowForm' );
38 38
     }
39 39
 
40 40
     public static function list_form() {
41
-        FrmAppHelper::permission_check('frm_view_forms');
41
+        FrmAppHelper::permission_check( 'frm_view_forms' );
42 42
 
43 43
 		$params = FrmForm::list_page_params();
44
-        $errors = self::process_bulk_form_actions( array());
45
-        $errors = apply_filters('frm_admin_list_form_action', $errors);
44
+        $errors = self::process_bulk_form_actions( array() );
45
+        $errors = apply_filters( 'frm_admin_list_form_action', $errors );
46 46
 
47 47
 		return self::display_forms_list( $params, '', $errors );
48 48
     }
49 49
 
50 50
 	public static function new_form( $values = array() ) {
51
-        FrmAppHelper::permission_check('frm_edit_forms');
51
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
52 52
 
53 53
         global $frm_vars;
54 54
 
55
-        $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
56
-		$action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ];
55
+        $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
56
+		$action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[$action];
57 57
 
58 58
 		if ( $action == 'create' ) {
59
-			self::create($values);
59
+			self::create( $values );
60 60
 			return;
61 61
 		} else if ( $action == 'new' ) {
62 62
 			$frm_field_selection = FrmField::field_selection();
63
-            $values = FrmFormsHelper::setup_new_vars($values);
63
+            $values = FrmFormsHelper::setup_new_vars( $values );
64 64
             $id = FrmForm::create( $values );
65
-            $form = FrmForm::getOne($id);
65
+            $form = FrmForm::getOne( $id );
66 66
 
67 67
 			self::create_default_email_action( $form );
68 68
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
     }
91 91
 
92 92
 	public static function create( $values = array() ) {
93
-        FrmAppHelper::permission_check('frm_edit_forms');
93
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
94 94
 
95 95
         global $frm_vars;
96 96
         if ( empty( $values ) ) {
@@ -102,22 +102,22 @@  discard block
 block discarded – undo
102 102
             $values = FrmProEntry::mod_other_vals( $values, 'back' );
103 103
         }
104 104
 
105
-		$id = isset($values['id']) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
105
+		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
106 106
 
107 107
         if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
108 108
             $frm_settings = FrmAppHelper::get_settings();
109 109
             $errors = array( 'form' => $frm_settings->admin_permission );
110 110
         } else {
111
-            $errors = FrmForm::validate($values);
111
+            $errors = FrmForm::validate( $values );
112 112
         }
113 113
 
114
-        if ( count($errors) > 0 ) {
114
+        if ( count( $errors ) > 0 ) {
115 115
             $hide_preview = true;
116 116
 			$frm_field_selection = FrmField::field_selection();
117 117
             $form = FrmForm::getOne( $id );
118
-            $fields = FrmField::get_all_for_form($id);
118
+            $fields = FrmField::get_all_for_form( $id );
119 119
 
120
-			$values = FrmAppHelper::setup_edit_vars($form, 'forms', '', true);
120
+			$values = FrmAppHelper::setup_edit_vars( $form, 'forms', '', true );
121 121
 			$values['fields'] = $fields;
122 122
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
123 123
 
@@ -130,32 +130,32 @@  discard block
 block discarded – undo
130 130
     }
131 131
 
132 132
     public static function edit( $values = false ) {
133
-        FrmAppHelper::permission_check('frm_edit_forms');
133
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
134 134
 
135 135
 		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
136
-        return self::get_edit_vars($id);
136
+        return self::get_edit_vars( $id );
137 137
     }
138 138
 
139 139
     public static function settings( $id = false, $message = '' ) {
140
-        FrmAppHelper::permission_check('frm_edit_forms');
140
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
141 141
 
142
-        if ( ! $id || ! is_numeric($id) ) {
142
+        if ( ! $id || ! is_numeric( $id ) ) {
143 143
 			$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
144 144
         }
145 145
 		return self::get_settings_vars( $id, array(), $message );
146 146
     }
147 147
 
148 148
     public static function update_settings() {
149
-        FrmAppHelper::permission_check('frm_edit_forms');
149
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
150 150
 
151 151
 		$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
152 152
 
153
-        $errors = FrmForm::validate($_POST);
154
-        if ( count($errors) > 0 ) {
155
-            return self::get_settings_vars($id, $errors);
153
+        $errors = FrmForm::validate( $_POST );
154
+        if ( count( $errors ) > 0 ) {
155
+            return self::get_settings_vars( $id, $errors );
156 156
         }
157 157
 
158
-        do_action('frm_before_update_form_settings', $id);
158
+        do_action( 'frm_before_update_form_settings', $id );
159 159
 
160 160
 		FrmForm::update( $id, $_POST );
161 161
 
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 	private static function edit_in_place_value( $field ) {
181 181
 		_deprecated_function( __METHOD__, '3.0' );
182 182
 		check_ajax_referer( 'frm_ajax', 'nonce' );
183
-		FrmAppHelper::permission_check('frm_edit_forms', 'hide');
183
+		FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
184 184
 
185 185
 		$form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
186 186
 		$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_filter_post_kses' );
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 	 * @since 2.0
229 229
 	 */
230 230
 	public static function _create_from_template() {
231
-		FrmAppHelper::permission_check('frm_edit_forms');
231
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
232 232
 		check_ajax_referer( 'frm_ajax', 'nonce' );
233 233
 
234 234
 		$current_form = FrmAppHelper::get_param( 'this_form', '', 'get', 'absint' );
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	}
244 244
 
245 245
     public static function duplicate() {
246
-        FrmAppHelper::permission_check('frm_edit_forms');
246
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
247 247
 
248 248
 		$params = FrmForm::list_page_params();
249 249
         $form = FrmForm::duplicate( $params['id'], $params['template'], true );
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
         if ( $form ) {
252 252
 			return self::get_edit_vars( $form, array(), $message, true );
253 253
         } else {
254
-            return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' ));
254
+            return self::display_forms_list( $params, __( 'There was a problem creating the new template.', 'formidable' ) );
255 255
         }
256 256
     }
257 257
 
@@ -400,11 +400,11 @@  discard block
 block discarded – undo
400 400
     }
401 401
 
402 402
 	public static function bulk_untrash( $ids ) {
403
-        FrmAppHelper::permission_check('frm_edit_forms');
403
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
404 404
 
405 405
         $count = FrmForm::set_status( $ids, 'published' );
406 406
 
407
-        $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
407
+        $message = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
408 408
         return $message;
409 409
     }
410 410
 
@@ -429,11 +429,11 @@  discard block
 block discarded – undo
429 429
 			),
430 430
 		);
431 431
 
432
-		if ( ! isset( $available_status[ $status ] ) ) {
432
+		if ( ! isset( $available_status[$status] ) ) {
433 433
 			return;
434 434
 		}
435 435
 
436
-		FrmAppHelper::permission_check( $available_status[ $status ]['permission'] );
436
+		FrmAppHelper::permission_check( $available_status[$status]['permission'] );
437 437
 
438 438
 		$params = FrmForm::list_page_params();
439 439
 
@@ -441,8 +441,8 @@  discard block
 block discarded – undo
441 441
 		check_admin_referer( $status . '_form_' . $params['id'] );
442 442
 
443 443
 		$count = 0;
444
-		if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) {
445
-			$count++;
444
+		if ( FrmForm::set_status( $params['id'], $available_status[$status]['new_status'] ) ) {
445
+			$count ++;
446 446
 		}
447 447
 
448 448
 		$form_type = FrmAppHelper::get_simple_request( array(
@@ -450,21 +450,21 @@  discard block
 block discarded – undo
450 450
 			'type' => 'request',
451 451
 		) );
452 452
 
453
-		$available_status['untrash']['message'] = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
453
+		$available_status['untrash']['message'] = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
454 454
 		$available_status['trash']['message'] = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=untrash&form_type=' . $form_type . '&id=' . $params['id'], 'untrash_form_' . $params['id'] ) ) . '">', '</a>' );
455 455
 
456
-		$message = $available_status[ $status ]['message'];
456
+		$message = $available_status[$status]['message'];
457 457
 
458 458
 		self::display_forms_list( $params, $message );
459 459
 	}
460 460
 
461 461
 	public static function bulk_trash( $ids ) {
462
-        FrmAppHelper::permission_check('frm_delete_forms');
462
+        FrmAppHelper::permission_check( 'frm_delete_forms' );
463 463
 
464 464
         $count = 0;
465 465
         foreach ( $ids as $id ) {
466 466
             if ( FrmForm::trash( $id ) ) {
467
-                $count++;
467
+                $count ++;
468 468
             }
469 469
         }
470 470
 
@@ -478,49 +478,49 @@  discard block
 block discarded – undo
478 478
     }
479 479
 
480 480
     public static function destroy() {
481
-        FrmAppHelper::permission_check('frm_delete_forms');
481
+        FrmAppHelper::permission_check( 'frm_delete_forms' );
482 482
 
483 483
 		$params = FrmForm::list_page_params();
484 484
 
485 485
         //check nonce url
486
-        check_admin_referer('destroy_form_' . $params['id']);
486
+        check_admin_referer( 'destroy_form_' . $params['id'] );
487 487
 
488 488
         $count = 0;
489 489
         if ( FrmForm::destroy( $params['id'] ) ) {
490
-            $count++;
490
+            $count ++;
491 491
         }
492 492
 
493
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
493
+        $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
494 494
 
495 495
 		self::display_forms_list( $params, $message );
496 496
     }
497 497
 
498 498
 	public static function bulk_destroy( $ids ) {
499
-        FrmAppHelper::permission_check('frm_delete_forms');
499
+        FrmAppHelper::permission_check( 'frm_delete_forms' );
500 500
 
501 501
         $count = 0;
502 502
         foreach ( $ids as $id ) {
503 503
             $d = FrmForm::destroy( $id );
504 504
             if ( $d ) {
505
-                $count++;
505
+                $count ++;
506 506
             }
507 507
         }
508 508
 
509
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
509
+        $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
510 510
 
511 511
         return $message;
512 512
     }
513 513
 
514 514
     private static function delete_all() {
515 515
         //check nonce url
516
-        $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable');
516
+        $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' );
517 517
         if ( $permission_error !== false ) {
518 518
 			self::display_forms_list( array(), '', array( $permission_error ) );
519 519
             return;
520 520
         }
521 521
 
522 522
 		$count = FrmForm::scheduled_delete( time() );
523
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
523
+        $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
524 524
 
525 525
 		self::display_forms_list( array(), $message );
526 526
     }
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
 	* @since 2.0.15
533 533
 	*/
534 534
 	public static function insert_form_button() {
535
-		if ( current_user_can('frm_view_forms') ) {
535
+		if ( current_user_can( 'frm_view_forms' ) ) {
536 536
 			$menu_name = FrmAppHelper::get_menu_name();
537 537
 			$content = '<a href="#TB_inline?width=50&height=50&inlineId=frm_insert_form" class="thickbox button add_media frm_insert_form" title="' . esc_attr__( 'Add forms and content', 'formidable' ) . '">
538 538
 				<span class="frm-buttons-icon wp-media-buttons-icon"></span> ' .
@@ -556,17 +556,17 @@  discard block
 block discarded – undo
556 556
 			),
557 557
         );
558 558
 
559
-        $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes);
559
+        $shortcodes = apply_filters( 'frm_popup_shortcodes', $shortcodes );
560 560
 
561 561
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' );
562 562
     }
563 563
 
564 564
     public static function get_shortcode_opts() {
565
-		FrmAppHelper::permission_check('frm_view_forms');
565
+		FrmAppHelper::permission_check( 'frm_view_forms' );
566 566
         check_ajax_referer( 'frm_ajax', 'nonce' );
567 567
 
568 568
 		$shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' );
569
-        if ( empty($shortcode) ) {
569
+        if ( empty( $shortcode ) ) {
570 570
             wp_die();
571 571
         }
572 572
 
@@ -705,11 +705,11 @@  discard block
 block discarded – undo
705 705
         }
706 706
 
707 707
         if ( $form->parent_form_id ) {
708
-			wp_die( sprintf( __( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form->parent_form_id ) ) . '">', '</a>' ));
708
+			wp_die( sprintf( __( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form->parent_form_id ) ) . '">', '</a>' ) );
709 709
         }
710 710
 
711 711
 		$frm_field_selection = FrmField::field_selection();
712
-        $fields = FrmField::get_all_for_form($form->id);
712
+        $fields = FrmField::get_all_for_form( $form->id );
713 713
 
714 714
         // Automatically add end section fields if they don't exist (2.0 migration)
715 715
         $reset_fields = false;
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
             $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
720 720
         }
721 721
 
722
-        unset($end_section_values, $last_order, $open, $reset_fields);
722
+        unset( $end_section_values, $last_order, $open, $reset_fields );
723 723
 
724 724
 		$args = array( 'parent_form_id' => $form->id );
725 725
 		$values = FrmAppHelper::setup_edit_vars( $form, 'forms', '', true, array(), $args );
@@ -733,8 +733,8 @@  discard block
 block discarded – undo
733 733
 		$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
734 734
 
735 735
         if ( $form->default_template ) {
736
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
737
-        } else if ( defined('DOING_AJAX') ) {
736
+            wp_die( __( 'That template cannot be edited', 'formidable' ) );
737
+        } else if ( defined( 'DOING_AJAX' ) ) {
738 738
             wp_die();
739 739
         } else if ( $create_link ) {
740 740
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
@@ -750,21 +750,21 @@  discard block
 block discarded – undo
750 750
 
751 751
         $form = FrmForm::getOne( $id );
752 752
 
753
-        $fields = FrmField::get_all_for_form($id);
754
-        $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
753
+        $fields = FrmField::get_all_for_form( $id );
754
+        $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true );
755 755
 
756
-        if ( isset($values['default_template']) && $values['default_template'] ) {
757
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
756
+        if ( isset( $values['default_template'] ) && $values['default_template'] ) {
757
+            wp_die( __( 'That template cannot be edited', 'formidable' ) );
758 758
         }
759 759
 
760 760
 		self::clean_submit_html( $values );
761 761
 
762 762
         $action_controls = FrmFormActionsController::get_form_actions();
763 763
 
764
-        $sections = apply_filters('frm_add_form_settings_section', array(), $values);
764
+        $sections = apply_filters( 'frm_add_form_settings_section', array(), $values );
765 765
         $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
766 766
 
767
-        $styles = apply_filters('frm_get_style_opts', array());
767
+        $styles = apply_filters( 'frm_get_style_opts', array() );
768 768
 
769 769
 		$first_h3 = 'frm_first_h3';
770 770
 
@@ -785,10 +785,10 @@  discard block
 block discarded – undo
785 785
 	}
786 786
 
787 787
     public static function mb_tags_box( $form_id, $class = '' ) {
788
-        $fields = FrmField::get_all_for_form($form_id, '', 'include');
788
+        $fields = FrmField::get_all_for_form( $form_id, '', 'include' );
789 789
         $linked_forms = array();
790 790
         $col = 'one';
791
-        $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false;
791
+        $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false;
792 792
 
793 793
 		$cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() );
794 794
 		$adv_shortcodes = self::get_advanced_shortcodes();
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
 	 * Insert the form class setting into the form
864 864
 	 */
865 865
 	public static function form_classes( $form ) {
866
-		if ( isset($form->options['form_class']) ) {
866
+		if ( isset( $form->options['form_class'] ) ) {
867 867
 			echo esc_attr( sanitize_text_field( $form->options['form_class'] ) );
868 868
 		}
869 869
 
@@ -967,11 +967,11 @@  discard block
 block discarded – undo
967 967
     public static function add_default_templates( $path, $default = true, $template = true ) {
968 968
         _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' );
969 969
 
970
-        $path = untrailingslashit(trim($path));
970
+        $path = untrailingslashit( trim( $path ) );
971 971
 		$templates = glob( $path . '/*.php' );
972 972
 
973
-		for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) {
974
-			$filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[ $i ] ) );
973
+		for ( $i = count( $templates ) - 1; $i >= 0; $i -- ) {
974
+			$filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[$i] ) );
975 975
 			$template_query = array( 'form_key' => $filename );
976 976
             if ( $template ) {
977 977
                 $template_query['is_template'] = 1;
@@ -989,12 +989,12 @@  discard block
 block discarded – undo
989 989
                 $values['default_template'] = 1;
990 990
             }
991 991
 
992
-            include( $templates[ $i ] );
992
+            include( $templates[$i] );
993 993
 
994 994
             //get updated form
995
-            if ( isset($form) && ! empty($form) ) {
995
+            if ( isset( $form ) && ! empty( $form ) ) {
996 996
                 $old_id = $form->id;
997
-                $form = FrmForm::getOne($form->id);
997
+                $form = FrmForm::getOne( $form->id );
998 998
             } else {
999 999
                 $old_id = false;
1000 1000
 				$form = FrmForm::getAll( $template_query, '', 1 );
@@ -1007,24 +1007,24 @@  discard block
 block discarded – undo
1007 1007
     }
1008 1008
 
1009 1009
     public static function route() {
1010
-        $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
1010
+        $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
1011 1011
         $vars = array();
1012 1012
 		if ( isset( $_POST['frm_compact_fields'] ) ) {
1013 1013
 			FrmAppHelper::permission_check( 'frm_edit_forms' );
1014 1014
 
1015
-            $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('&quot;', '\\\"', $_POST['frm_compact_fields'] ))));
1016
-            $json_vars = json_decode($json_vars, true);
1017
-            if ( empty($json_vars) ) {
1015
+            $json_vars = htmlspecialchars_decode( nl2br( stripslashes( str_replace( '&quot;', '\\\"', $_POST['frm_compact_fields'] ) ) ) );
1016
+            $json_vars = json_decode( $json_vars, true );
1017
+            if ( empty( $json_vars ) ) {
1018 1018
                 // json decoding failed so we should return an error message
1019 1019
 				$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
1020 1020
                 if ( 'edit' == $action ) {
1021 1021
                     $action = 'update';
1022 1022
                 }
1023 1023
 
1024
-                add_filter('frm_validate_form', 'FrmFormsController::json_error');
1024
+                add_filter( 'frm_validate_form', 'FrmFormsController::json_error' );
1025 1025
             } else {
1026
-                $vars = FrmAppHelper::json_to_array($json_vars);
1027
-                $action = $vars[ $action ];
1026
+                $vars = FrmAppHelper::json_to_array( $json_vars );
1027
+                $action = $vars[$action];
1028 1028
 				unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] );
1029 1029
 				$_REQUEST = array_merge( $_REQUEST, $vars );
1030 1030
 				$_POST = array_merge( $_POST, $_REQUEST );
@@ -1042,7 +1042,7 @@  discard block
 block discarded – undo
1042 1042
 
1043 1043
         switch ( $action ) {
1044 1044
             case 'new':
1045
-                return self::new_form($vars);
1045
+                return self::new_form( $vars );
1046 1046
             case 'create':
1047 1047
             case 'edit':
1048 1048
             case 'update':
@@ -1065,7 +1065,7 @@  discard block
 block discarded – undo
1065 1065
 					$action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
1066 1066
                 }
1067 1067
 
1068
-                if ( strpos($action, 'bulk_') === 0 ) {
1068
+                if ( strpos( $action, 'bulk_' ) === 0 ) {
1069 1069
                     FrmAppHelper::remove_get_action();
1070 1070
                     return self::list_form();
1071 1071
                 }
@@ -1092,19 +1092,19 @@  discard block
 block discarded – undo
1092 1092
 
1093 1093
 	public static function admin_bar_configure() {
1094 1094
         global $frm_vars;
1095
-        if ( empty($frm_vars['forms_loaded']) ) {
1095
+        if ( empty( $frm_vars['forms_loaded'] ) ) {
1096 1096
             return;
1097 1097
         }
1098 1098
 
1099 1099
         $actions = array();
1100 1100
         foreach ( $frm_vars['forms_loaded'] as $form ) {
1101
-            if ( is_object($form) ) {
1102
-                $actions[ $form->id ] = $form->name;
1101
+            if ( is_object( $form ) ) {
1102
+                $actions[$form->id] = $form->name;
1103 1103
             }
1104
-            unset($form);
1104
+            unset( $form );
1105 1105
         }
1106 1106
 
1107
-        if ( empty($actions) ) {
1107
+        if ( empty( $actions ) ) {
1108 1108
             return;
1109 1109
         }
1110 1110
 
@@ -1150,7 +1150,7 @@  discard block
 block discarded – undo
1150 1150
     //formidable shortcode
1151 1151
 	public static function get_form_shortcode( $atts ) {
1152 1152
         global $frm_vars;
1153
-        if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) {
1153
+        if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) {
1154 1154
             $sc = '[formidable';
1155 1155
 			if ( ! empty( $atts ) ) {
1156 1156
 				foreach ( $atts as $k => $v ) {
@@ -1310,8 +1310,8 @@  discard block
 block discarded – undo
1310 1310
 	private static function get_saved_errors( $form, $params ) {
1311 1311
 		global $frm_vars;
1312 1312
 
1313
-		if ( $params['posted_form_id'] == $form->id && $_POST && isset( $frm_vars['created_entries'][ $form->id ] ) ) {
1314
-			$errors = $frm_vars['created_entries'][ $form->id ]['errors'];
1313
+		if ( $params['posted_form_id'] == $form->id && $_POST && isset( $frm_vars['created_entries'][$form->id] ) ) {
1314
+			$errors = $frm_vars['created_entries'][$form->id]['errors'];
1315 1315
 		} else {
1316 1316
 			$errors = array();
1317 1317
 		}
@@ -1323,7 +1323,7 @@  discard block
 block discarded – undo
1323 1323
 	 */
1324 1324
 	public static function just_created_entry( $form_id ) {
1325 1325
 		global $frm_vars;
1326
-		return ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form_id ] ) && isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) ? $frm_vars['created_entries'][ $form_id ]['entry_id'] : 0;
1326
+		return ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][$form_id] ) && isset( $frm_vars['created_entries'][$form_id]['entry_id'] ) ) ? $frm_vars['created_entries'][$form_id]['entry_id'] : 0;
1327 1327
 	}
1328 1328
 
1329 1329
 	/**
@@ -1331,7 +1331,7 @@  discard block
 block discarded – undo
1331 1331
 	 */
1332 1332
 	private static function get_confirmation_method( $atts ) {
1333 1333
 		$opt = 'success_action';
1334
-		$method = ( isset( $atts['form']->options[ $opt ] ) && ! empty( $atts['form']->options[ $opt ] ) ) ? $atts['form']->options[ $opt ] : 'message';
1334
+		$method = ( isset( $atts['form']->options[$opt] ) && ! empty( $atts['form']->options[$opt] ) ) ? $atts['form']->options[$opt] : 'message';
1335 1335
 		$method = apply_filters( 'frm_success_filter', $method, $atts['form'], 'create' );
1336 1336
 
1337 1337
 		if ( $method != 'message' && ( ! $atts['entry_id'] || ! is_numeric( $atts['entry_id'] ) ) ) {
@@ -1344,7 +1344,7 @@  discard block
 block discarded – undo
1344 1344
 	public static function maybe_trigger_redirect( $form, $params, $args ) {
1345 1345
 		if ( ! isset( $params['id'] ) ) {
1346 1346
 			global $frm_vars;
1347
-			$params['id'] = $frm_vars['created_entries'][ $form->id ]['entry_id'];
1347
+			$params['id'] = $frm_vars['created_entries'][$form->id]['entry_id'];
1348 1348
 		}
1349 1349
 
1350 1350
 		$conf_method = self::get_confirmation_method( array(
@@ -1384,7 +1384,7 @@  discard block
 block discarded – undo
1384 1384
 
1385 1385
 		$opt = ( ! isset( $args['action'] ) || $args['action'] == 'create' ) ? 'success' : 'edit';
1386 1386
 		$args['success_opt'] = $opt;
1387
-		if ( $args['conf_method'] == 'page' && is_numeric( $args['form']->options[ $opt . '_page_id' ] ) ) {
1387
+		if ( $args['conf_method'] == 'page' && is_numeric( $args['form']->options[$opt . '_page_id'] ) ) {
1388 1388
 			self::load_page_after_submit( $args );
1389 1389
 		} elseif ( $args['conf_method'] == 'redirect' ) {
1390 1390
 			self::redirect_after_submit( $args );
@@ -1399,8 +1399,8 @@  discard block
 block discarded – undo
1399 1399
 	private static function load_page_after_submit( $args ) {
1400 1400
 		global $post;
1401 1401
 		$opt = $args['success_opt'];
1402
-		if ( ! $post || $args['form']->options[ $opt . '_page_id' ] != $post->ID ) {
1403
-			$page = get_post( $args['form']->options[ $opt . '_page_id' ] );
1402
+		if ( ! $post || $args['form']->options[$opt . '_page_id'] != $post->ID ) {
1403
+			$page = get_post( $args['form']->options[$opt . '_page_id'] );
1404 1404
 			$old_post = $post;
1405 1405
 			$post = $page;
1406 1406
 			$content = apply_filters( 'frm_content', $page->post_content, $args['form'], $args['entry_id'] );
@@ -1418,10 +1418,10 @@  discard block
 block discarded – undo
1418 1418
 		add_filter( 'frm_use_wpautop', '__return_false' );
1419 1419
 
1420 1420
 		$opt = $args['success_opt'];
1421
-		$success_url = trim( $args['form']->options[ $opt . '_url' ] );
1421
+		$success_url = trim( $args['form']->options[$opt . '_url'] );
1422 1422
 		$success_url = apply_filters( 'frm_content', $success_url, $args['form'], $args['entry_id'] );
1423 1423
 
1424
-		$success_msg = isset( $args['form']->options[ $opt . '_msg' ] ) ? $args['form']->options[ $opt . '_msg' ] : __( 'Please wait while you are redirected.', 'formidable' );
1424
+		$success_msg = isset( $args['form']->options[$opt . '_msg'] ) ? $args['form']->options[$opt . '_msg'] : __( 'Please wait while you are redirected.', 'formidable' );
1425 1425
 
1426 1426
 		$redirect_msg = self::get_redirect_message( $success_url, $success_msg, $args );
1427 1427
 
@@ -1429,7 +1429,7 @@  discard block
 block discarded – undo
1429 1429
 		FrmEntriesController::delete_entry_before_redirect( $success_url, $args['form'], $args );
1430 1430
 
1431 1431
 		add_filter( 'frm_redirect_url', 'FrmEntriesController::prepare_redirect_url' );
1432
-		$success_url = apply_filters( 'frm_redirect_url', $success_url, $args['form'], $args);
1432
+		$success_url = apply_filters( 'frm_redirect_url', $success_url, $args['form'], $args );
1433 1433
 
1434 1434
 		$doing_ajax = FrmAppHelper::doing_ajax();
1435 1435
 
@@ -1455,7 +1455,7 @@  discard block
 block discarded – undo
1455 1455
 	 */
1456 1456
 	private static function get_redirect_message( $success_url, $success_msg, $args ) {
1457 1457
 		$redirect_msg = '<div class="' . esc_attr( FrmFormsHelper::get_form_style_class( $args['form'] ) ) . '"><div class="frm-redirect-msg frm_message">' . $success_msg . '<br/>' .
1458
-			sprintf( __( '%1$sClick here%2$s if you are not automatically redirected.', 'formidable' ), '<a href="' . esc_url( $success_url ) . '">', '</a>') .
1458
+			sprintf( __( '%1$sClick here%2$s if you are not automatically redirected.', 'formidable' ), '<a href="' . esc_url( $success_url ) . '">', '</a>' ) .
1459 1459
 			'</div></div>';
1460 1460
 
1461 1461
 		return apply_filters( 'frm_redirect_msg', $redirect_msg, array(
Please login to merge, or discard this patch.
classes/views/addons/upgrade_to_pro.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -58,9 +58,9 @@
 block discarded – undo
58 58
 			<tr>
59 59
 				<th>Included AddOns</th>
60 60
 				<td>None</td>
61
-				<td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidableforms.com/pricing/#addon-lists') ) ?>" target="_blank">Premium Addons</a></td>
62
-				<td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidableforms.com/pricing/#addon-lists') ) ?>" target="_blank">Advanced Addons</a></td>
63
-				<td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidableforms.com/pricing/#addon-lists') ) ?>" target="_blank">Enterprise Addons</a></td>
61
+				<td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/pricing/#addon-lists' ) ) ?>" target="_blank">Premium Addons</a></td>
62
+				<td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/pricing/#addon-lists' ) ) ?>" target="_blank">Advanced Addons</a></td>
63
+				<td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/pricing/#addon-lists' ) ) ?>" target="_blank">Enterprise Addons</a></td>
64 64
 			</tr>
65 65
 		</tbody>
66 66
 	</table>
Please login to merge, or discard this patch.
classes/models/FrmEmail.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 			'entry'     => $this->entry,
96 96
 			'form'      => $this->form,
97 97
 		);
98
-		$to     = apply_filters( 'frm_to_email', $to, $values, $this->form->id, $args );
98
+		$to = apply_filters( 'frm_to_email', $to, $values, $this->form->id, $args );
99 99
 
100 100
 		$this->to = array_unique( (array) $to );
101 101
 
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 	 * @return array
434 434
 	 */
435 435
 	private function package_header() {
436
-		$header   = array();
436
+		$header = array();
437 437
 
438 438
 		if ( ! empty( $this->cc ) ) {
439 439
 			$header[] = 'CC: ' . implode( ',', $this->cc );
@@ -546,12 +546,12 @@  discard block
 block discarded – undo
546 546
 					$name = trim( str_replace( $email, '', $val ) );
547 547
 				} else {
548 548
 					// If user enters a name without an email
549
-					unset( $recipients[ $key ] );
549
+					unset( $recipients[$key] );
550 550
 					continue;
551 551
 				}
552 552
 			}
553 553
 
554
-			$recipients[ $key ] = $name . ' <' . $email . '>';
554
+			$recipients[$key] = $name . ' <' . $email . '>';
555 555
 		}
556 556
 
557 557
 		return $recipients;
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
 				) );
669 669
 
670 670
 				// Remove phone number from to addresses
671
-				unset( $this->to[ $key ] );
671
+				unset( $this->to[$key] );
672 672
 			}
673 673
 		}
674 674
 	}
Please login to merge, or discard this patch.
classes/models/FrmEntryMeta.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -281,6 +281,7 @@
 block discarded – undo
281 281
      * @param string|array $where
282 282
      * @param string $order_by
283 283
      * @param string $limit
284
+     * @param boolean $unique
284 285
      */
285 286
 	private static function get_ids_query( $where, $order_by, $limit, $unique, $args, array &$query ) {
286 287
         global $wpdb;
Please login to merge, or discard this patch.
Indentation   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -5,26 +5,26 @@  discard block
 block discarded – undo
5 5
 
6 6
 class FrmEntryMeta {
7 7
 
8
-    /**
9
-     * @param string $meta_key
10
-     */
8
+	/**
9
+	 * @param string $meta_key
10
+	 */
11 11
 	public static function add_entry_meta( $entry_id, $field_id, $meta_key = null, $meta_value ) {
12
-        global $wpdb;
12
+		global $wpdb;
13 13
 
14
-        if ( FrmAppHelper::is_empty_value( $meta_value ) ) {
15
-            // don't save blank fields
16
-            return 0;
17
-        }
14
+		if ( FrmAppHelper::is_empty_value( $meta_value ) ) {
15
+			// don't save blank fields
16
+			return 0;
17
+		}
18 18
 
19
-        $new_values = array(
19
+		$new_values = array(
20 20
 			'meta_value'    => is_array( $meta_value ) ? serialize( array_filter( $meta_value, 'FrmAppHelper::is_not_empty_value' ) ) : trim( $meta_value ),
21
-            'item_id'       => $entry_id,
22
-            'field_id'      => $field_id,
23
-            'created_at'    => current_time('mysql', 1),
24
-        );
21
+			'item_id'       => $entry_id,
22
+			'field_id'      => $field_id,
23
+			'created_at'    => current_time('mysql', 1),
24
+		);
25 25
 
26 26
 		self::set_value_before_save( $new_values );
27
-        $new_values = apply_filters('frm_add_entry_meta', $new_values);
27
+		$new_values = apply_filters('frm_add_entry_meta', $new_values);
28 28
 
29 29
 		$query_results = $wpdb->insert( $wpdb->prefix . 'frm_item_metas', $new_values );
30 30
 
@@ -36,8 +36,8 @@  discard block
 block discarded – undo
36 36
 			$id = 0;
37 37
 		}
38 38
 
39
-        return $id;
40
-    }
39
+		return $id;
40
+	}
41 41
 
42 42
 	/**
43 43
 	 * @param int $entry_id
@@ -48,31 +48,31 @@  discard block
 block discarded – undo
48 48
 	 * @return bool|false|int
49 49
 	 */
50 50
 	public static function update_entry_meta( $entry_id, $field_id, $meta_key = null, $meta_value ) {
51
-        if ( ! $field_id ) {
52
-            return false;
53
-        }
51
+		if ( ! $field_id ) {
52
+			return false;
53
+		}
54 54
 
55
-        global $wpdb;
55
+		global $wpdb;
56 56
 
57 57
 		$values = array(
58 58
 			'item_id'  => $entry_id,
59 59
 			'field_id' => $field_id,
60 60
 		);
61 61
 		$where_values = $values;
62
-        $values['meta_value'] = $meta_value;
62
+		$values['meta_value'] = $meta_value;
63 63
 		self::set_value_before_save( $values );
64
-        $values = apply_filters('frm_update_entry_meta', $values);
64
+		$values = apply_filters('frm_update_entry_meta', $values);
65 65
 
66 66
 		if ( is_array($values['meta_value']) ) {
67 67
 			$values['meta_value'] = array_filter( $values['meta_value'], 'FrmAppHelper::is_not_empty_value' );
68 68
 		}
69
-        $meta_value = maybe_serialize($values['meta_value']);
69
+		$meta_value = maybe_serialize($values['meta_value']);
70 70
 
71
-        wp_cache_delete( $entry_id, 'frm_entry');
71
+		wp_cache_delete( $entry_id, 'frm_entry');
72 72
 		self::clear_cache();
73 73
 
74 74
 		return $wpdb->update( $wpdb->prefix . 'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values );
75
-    }
75
+	}
76 76
 
77 77
 	/**
78 78
 	 * @since 3.0
@@ -101,14 +101,14 @@  discard block
 block discarded – undo
101 101
 	}
102 102
 
103 103
 	public static function update_entry_metas( $entry_id, $values ) {
104
-        global $wpdb;
104
+		global $wpdb;
105 105
 
106 106
 		$prev_values = FrmDb::get_col( $wpdb->prefix . 'frm_item_metas', array(
107 107
 			'item_id'    => $entry_id,
108 108
 			'field_id !' => 0,
109 109
 		), 'field_id' );
110 110
 
111
-        foreach ( $values as $field_id => $meta_value ) {
111
+		foreach ( $values as $field_id => $meta_value ) {
112 112
 			$field = false;
113 113
 			if ( ! empty( $field_id ) ) {
114 114
 				$field = FrmField::getOne( $field_id );
@@ -131,15 +131,15 @@  discard block
 block discarded – undo
131 131
 			}
132 132
 		}
133 133
 
134
-        if ( empty($prev_values) ) {
135
-            return;
136
-        }
134
+		if ( empty($prev_values) ) {
135
+			return;
136
+		}
137 137
 
138
-        $prev_values = array_diff($prev_values, array_keys($values));
138
+		$prev_values = array_diff($prev_values, array_keys($values));
139 139
 
140
-        if ( empty($prev_values) ) {
141
-            return;
142
-        }
140
+		if ( empty($prev_values) ) {
141
+			return;
142
+		}
143 143
 
144 144
 		// prepare the query
145 145
 		$where = array(
@@ -148,25 +148,25 @@  discard block
 block discarded – undo
148 148
 		);
149 149
 		FrmDb::get_where_clause_and_values( $where );
150 150
 
151
-        // Delete any leftovers
152
-        $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas ' . $where['where'], $where['values'] ) );
151
+		// Delete any leftovers
152
+		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas ' . $where['where'], $where['values'] ) );
153 153
 		self::clear_cache();
154
-    }
154
+	}
155 155
 
156 156
 	public static function duplicate_entry_metas( $old_id, $new_id ) {
157
-        $metas = self::get_entry_meta_info($old_id);
158
-        foreach ( $metas as $meta ) {
159
-            self::add_entry_meta($new_id, $meta->field_id, null, $meta->meta_value);
160
-            unset($meta);
161
-        }
157
+		$metas = self::get_entry_meta_info($old_id);
158
+		foreach ( $metas as $meta ) {
159
+			self::add_entry_meta($new_id, $meta->field_id, null, $meta->meta_value);
160
+			unset($meta);
161
+		}
162 162
 		self::clear_cache();
163
-    }
163
+	}
164 164
 
165 165
 	public static function delete_entry_meta( $entry_id, $field_id ) {
166
-        global $wpdb;
166
+		global $wpdb;
167 167
 		self::clear_cache();
168
-        return $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id));
169
-    }
168
+		return $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id));
169
+	}
170 170
 
171 171
 	/**
172 172
 	 * Clear entry meta caching
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 	}
192 192
 
193 193
 	public static function get_entry_meta_by_field( $entry_id, $field_id ) {
194
-        global $wpdb;
194
+		global $wpdb;
195 195
 
196 196
 		if ( is_object( $entry_id ) ) {
197 197
 			$entry = $entry_id;
@@ -204,93 +204,93 @@  discard block
 block discarded – undo
204 204
 
205 205
 		if ( $cached && isset( $cached->metas ) && isset( $cached->metas[ $field_id ] ) ) {
206 206
 			$result = $cached->metas[ $field_id ];
207
-            return stripslashes_deep($result);
208
-        }
207
+			return stripslashes_deep($result);
208
+		}
209 209
 
210 210
 		$get_table = $wpdb->prefix . 'frm_item_metas';
211 211
 		$query = array( 'item_id' => $entry_id );
212
-        if ( is_numeric($field_id) ) {
212
+		if ( is_numeric($field_id) ) {
213 213
 			$query['field_id'] = $field_id;
214
-        } else {
214
+		} else {
215 215
 			$get_table .= ' it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id';
216 216
 			$query['fi.field_key'] = $field_id;
217
-        }
217
+		}
218 218
 
219 219
 		$result = FrmDb::get_var( $get_table, $query, 'meta_value' );
220
-        $result = maybe_unserialize($result);
221
-        $result = stripslashes_deep($result);
220
+		$result = maybe_unserialize($result);
221
+		$result = stripslashes_deep($result);
222 222
 
223
-        return $result;
224
-    }
223
+		return $result;
224
+	}
225 225
 
226
-    public static function get_entry_metas_for_field( $field_id, $order = '', $limit = '', $args = array() ) {
226
+	public static function get_entry_metas_for_field( $field_id, $order = '', $limit = '', $args = array() ) {
227 227
 		$defaults = array(
228 228
 			'value'    => false,
229 229
 			'unique'   => false,
230 230
 			'stripslashes' => true,
231 231
 			'is_draft' => false,
232 232
 		);
233
-        $args = wp_parse_args( $args, $defaults );
233
+		$args = wp_parse_args( $args, $defaults );
234 234
 
235
-        $query = array();
236
-        self::meta_field_query($field_id, $order, $limit, $args, $query);
237
-        $query = implode(' ', $query);
235
+		$query = array();
236
+		self::meta_field_query($field_id, $order, $limit, $args, $query);
237
+		$query = implode(' ', $query);
238 238
 
239 239
 		$cache_key = 'entry_metas_for_field_' . $field_id . $order . $limit . maybe_serialize( $args );
240
-        $values = FrmDb::check_cache($cache_key, 'frm_entry', $query, 'get_col');
240
+		$values = FrmDb::check_cache($cache_key, 'frm_entry', $query, 'get_col');
241 241
 
242
-        if ( ! $args['stripslashes'] ) {
243
-            return $values;
244
-        }
242
+		if ( ! $args['stripslashes'] ) {
243
+			return $values;
244
+		}
245 245
 
246 246
 		foreach ( $values as $k => $v ) {
247 247
 			$values[ $k ] = maybe_unserialize( $v );
248
-            unset($k, $v);
249
-        }
248
+			unset($k, $v);
249
+		}
250 250
 
251
-        return stripslashes_deep($values);
252
-    }
251
+		return stripslashes_deep($values);
252
+	}
253 253
 
254
-    /**
255
-     * @param string $order
256
-     * @param string $limit
257
-     */
254
+	/**
255
+	 * @param string $order
256
+	 * @param string $limit
257
+	 */
258 258
 	private static function meta_field_query( $field_id, $order, $limit, $args, array &$query ) {
259
-        global $wpdb;
260
-        $query[] = 'SELECT';
261
-        $query[] = $args['unique'] ? 'DISTINCT(em.meta_value)' : 'em.meta_value';
259
+		global $wpdb;
260
+		$query[] = 'SELECT';
261
+		$query[] = $args['unique'] ? 'DISTINCT(em.meta_value)' : 'em.meta_value';
262 262
 		$query[] = 'FROM ' . $wpdb->prefix . 'frm_item_metas em ';
263 263
 
264
-        if ( ! $args['is_draft'] ) {
264
+		if ( ! $args['is_draft'] ) {
265 265
 			$query[] = 'INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=em.item_id)';
266
-        }
266
+		}
267 267
 
268
-        if ( is_numeric($field_id) ) {
269
-            $query[] = $wpdb->prepare('WHERE em.field_id=%d', $field_id);
270
-        } else {
268
+		if ( is_numeric($field_id) ) {
269
+			$query[] = $wpdb->prepare('WHERE em.field_id=%d', $field_id);
270
+		} else {
271 271
 			$query[] = $wpdb->prepare( 'LEFT JOIN ' . $wpdb->prefix . 'frm_fields fi ON (em.field_id = fi.id) WHERE fi.field_key=%s', $field_id );
272
-        }
272
+		}
273 273
 
274
-        if ( ! $args['is_draft'] ) {
275
-            $query[] = 'AND e.is_draft=0';
276
-        }
274
+		if ( ! $args['is_draft'] ) {
275
+			$query[] = 'AND e.is_draft=0';
276
+		}
277 277
 
278
-        if ( $args['value'] ) {
279
-            $query[] = $wpdb->prepare(' AND meta_value=%s', $args['value']);
280
-        }
281
-        $query[] = $order . $limit;
282
-    }
278
+		if ( $args['value'] ) {
279
+			$query[] = $wpdb->prepare(' AND meta_value=%s', $args['value']);
280
+		}
281
+		$query[] = $order . $limit;
282
+	}
283 283
 
284 284
 	public static function get_entry_meta_info( $entry_id ) {
285 285
 		return FrmDb::get_results( 'frm_item_metas', array( 'item_id' => $entry_id ) );
286
-    }
286
+	}
287 287
 
288 288
 	public static function getAll( $where = array(), $order_by = '', $limit = '', $stripslashes = false ) {
289
-        global $wpdb;
290
-        $query = 'SELECT it.*, fi.type as field_type, fi.field_key as field_key,
289
+		global $wpdb;
290
+		$query = 'SELECT it.*, fi.type as field_type, fi.field_key as field_key,
291 291
             fi.required as required, fi.form_id as field_form_id, fi.name as field_name, fi.options as fi_options
292 292
 			FROM ' . $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id' .
293
-            FrmDb::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
293
+			FrmDb::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
294 294
 
295 295
 		$cache_key = 'all_' . maybe_serialize( $where ) . $order_by . $limit;
296 296
 		$results = FrmDb::check_cache( $cache_key, 'frm_entry', $query, ( $limit == ' LIMIT 1' ? 'get_row' : 'get_results' ) );
@@ -305,32 +305,32 @@  discard block
 block discarded – undo
305 305
 		}
306 306
 
307 307
 		return $results;
308
-    }
308
+	}
309 309
 
310
-    public static function getEntryIds( $where = array(), $order_by = '', $limit = '', $unique = true, $args = array() ) {
310
+	public static function getEntryIds( $where = array(), $order_by = '', $limit = '', $unique = true, $args = array() ) {
311 311
 		$defaults = array(
312 312
 			'is_draft' => false,
313 313
 			'user_id'  => '',
314 314
 			'group_by' => '',
315 315
 		);
316
-        $args = wp_parse_args($args, $defaults);
316
+		$args = wp_parse_args($args, $defaults);
317 317
 
318
-        $query = array();
319
-        self::get_ids_query($where, $order_by, $limit, $unique, $args, $query );
320
-        $query = implode(' ', $query);
318
+		$query = array();
319
+		self::get_ids_query($where, $order_by, $limit, $unique, $args, $query );
320
+		$query = implode(' ', $query);
321 321
 
322 322
 		$cache_key = 'ids_' . maybe_serialize( $where ) . $order_by . 'l' . $limit . 'u' . $unique . maybe_serialize( $args );
323 323
 		return FrmDb::check_cache( $cache_key, 'frm_entry', $query, ( $limit == ' LIMIT 1' ? 'get_var' : 'get_col' ) );
324
-    }
324
+	}
325 325
 
326
-    /**
327
-     * @param string|array $where
328
-     * @param string $order_by
329
-     * @param string $limit
330
-     */
326
+	/**
327
+	 * @param string|array $where
328
+	 * @param string $order_by
329
+	 * @param string $limit
330
+	 */
331 331
 	private static function get_ids_query( $where, $order_by, $limit, $unique, $args, array &$query ) {
332
-        global $wpdb;
333
-        $query[] = 'SELECT';
332
+		global $wpdb;
333
+		$query[] = 'SELECT';
334 334
 
335 335
 		$defaults = array( 'return_parent_id' => false );
336 336
 		$args = array_merge( $defaults, $args );
@@ -344,89 +344,89 @@  discard block
 block discarded – undo
344 344
 		$query[] = 'FROM ' . $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id';
345 345
 
346 346
 		$query[] = 'INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=it.item_id)';
347
-        if ( is_array($where) ) {
348
-            if ( ! $args['is_draft'] ) {
349
-                $where['e.is_draft'] = 0;
350
-            } else if ( $args['is_draft'] == 1 ) {
351
-                $where['e.is_draft'] = 1;
352
-            }
353
-
354
-            if ( ! empty($args['user_id']) ) {
355
-                $where['e.user_id'] = $args['user_id'];
356
-            }
357
-            $query[] = FrmDb::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
347
+		if ( is_array($where) ) {
348
+			if ( ! $args['is_draft'] ) {
349
+				$where['e.is_draft'] = 0;
350
+			} else if ( $args['is_draft'] == 1 ) {
351
+				$where['e.is_draft'] = 1;
352
+			}
353
+
354
+			if ( ! empty($args['user_id']) ) {
355
+				$where['e.user_id'] = $args['user_id'];
356
+			}
357
+			$query[] = FrmDb::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
358 358
 
359 359
 			if ( $args['group_by'] ) {
360 360
 				$query[] = ' GROUP BY ' . sanitize_text_field( $args['group_by'] );
361 361
 			}
362
-            return;
363
-        }
362
+			return;
363
+		}
364 364
 
365 365
 		$draft_where = '';
366 366
 		$user_where = '';
367
-        if ( ! $args['is_draft'] ) {
367
+		if ( ! $args['is_draft'] ) {
368 368
 			$draft_where = $wpdb->prepare( ' AND e.is_draft=%d', 0 );
369
-        } else if ( $args['is_draft'] == 1 ) {
369
+		} else if ( $args['is_draft'] == 1 ) {
370 370
 			$draft_where = $wpdb->prepare( ' AND e.is_draft=%d', 1 );
371
-        }
371
+		}
372 372
 
373
-        if ( ! empty($args['user_id']) ) {
374
-            $user_where = $wpdb->prepare(' AND e.user_id=%d', $args['user_id']);
375
-        }
373
+		if ( ! empty($args['user_id']) ) {
374
+			$user_where = $wpdb->prepare(' AND e.user_id=%d', $args['user_id']);
375
+		}
376 376
 
377
-        if ( strpos($where, ' GROUP BY ') ) {
378
-            // don't inject WHERE filtering after GROUP BY
379
-            $parts = explode(' GROUP BY ', $where);
380
-            $where = $parts[0];
381
-            $where .= $draft_where . $user_where;
377
+		if ( strpos($where, ' GROUP BY ') ) {
378
+			// don't inject WHERE filtering after GROUP BY
379
+			$parts = explode(' GROUP BY ', $where);
380
+			$where = $parts[0];
381
+			$where .= $draft_where . $user_where;
382 382
 			$where .= ' GROUP BY ' . $parts[1];
383
-        } else {
384
-            $where .= $draft_where . $user_where;
385
-        }
383
+		} else {
384
+			$where .= $draft_where . $user_where;
385
+		}
386 386
 
387 387
 		// The query has already been prepared
388 388
 		$query[] = FrmDb::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
389
-    }
389
+	}
390 390
 
391
-    public static function search_entry_metas( $search, $field_id = '', $operator ) {
391
+	public static function search_entry_metas( $search, $field_id = '', $operator ) {
392 392
 		$cache_key = 'search_' . maybe_serialize( $search ) . $field_id . $operator;
393
-        $results = wp_cache_get($cache_key, 'frm_entry');
394
-        if ( false !== $results ) {
395
-            return $results;
396
-        }
393
+		$results = wp_cache_get($cache_key, 'frm_entry');
394
+		if ( false !== $results ) {
395
+			return $results;
396
+		}
397 397
 
398
-        global $wpdb;
398
+		global $wpdb;
399 399
 		if ( is_array( $search ) ) {
400
-            $where = '';
400
+			$where = '';
401 401
 			foreach ( $search as $field => $value ) {
402 402
 				if ( $value <= 0 || ! in_array( $field, array( 'year', 'month', 'day' ) ) ) {
403
-                    continue;
404
-                }
403
+					continue;
404
+				}
405 405
 
406
-                switch ( $field ) {
407
-                    case 'year':
406
+				switch ( $field ) {
407
+					case 'year':
408 408
 						$value = '%' . $value;
409 409
 						break;
410
-                    case 'month':
411
-                        $value .= '%';
410
+					case 'month':
411
+						$value .= '%';
412 412
 						break;
413
-                    case 'day':
413
+					case 'day':
414 414
 						$value = '%' . $value . '%';
415
-                }
415
+				}
416 416
 				$where .= $wpdb->prepare(' meta_value ' . $operator . ' %s and', $value );
417
-            }
418
-            $where .= $wpdb->prepare(' field_id=%d', $field_id);
417
+			}
418
+			$where .= $wpdb->prepare(' field_id=%d', $field_id);
419 419
 			$query = 'SELECT DISTINCT item_id FROM ' . $wpdb->prefix . 'frm_item_metas' . FrmDb::prepend_and_or_where( ' WHERE ', $where );
420
-        } else {
420
+		} else {
421 421
 			if ( $operator == 'LIKE' ) {
422
-                $search = '%' . $search . '%';
422
+				$search = '%' . $search . '%';
423 423
 			}
424
-            $query = $wpdb->prepare("SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id);
425
-        }
424
+			$query = $wpdb->prepare("SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id);
425
+		}
426 426
 
427
-        $results = $wpdb->get_col($query, 0);
427
+		$results = $wpdb->get_col($query, 0);
428 428
 		FrmDb::set_cache( $cache_key, $results, 'frm_entry' );
429 429
 
430
-        return $results;
431
-    }
430
+		return $results;
431
+	}
432 432
 }
Please login to merge, or discard this patch.
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -20,11 +20,11 @@  discard block
 block discarded – undo
20 20
 			'meta_value'    => is_array( $meta_value ) ? serialize( array_filter( $meta_value, 'FrmAppHelper::is_not_empty_value' ) ) : trim( $meta_value ),
21 21
             'item_id'       => $entry_id,
22 22
             'field_id'      => $field_id,
23
-            'created_at'    => current_time('mysql', 1),
23
+            'created_at'    => current_time( 'mysql', 1 ),
24 24
         );
25 25
 
26 26
 		self::set_value_before_save( $new_values );
27
-        $new_values = apply_filters('frm_add_entry_meta', $new_values);
27
+        $new_values = apply_filters( 'frm_add_entry_meta', $new_values );
28 28
 
29 29
 		$query_results = $wpdb->insert( $wpdb->prefix . 'frm_item_metas', $new_values );
30 30
 
@@ -61,14 +61,14 @@  discard block
 block discarded – undo
61 61
 		$where_values = $values;
62 62
         $values['meta_value'] = $meta_value;
63 63
 		self::set_value_before_save( $values );
64
-        $values = apply_filters('frm_update_entry_meta', $values);
64
+        $values = apply_filters( 'frm_update_entry_meta', $values );
65 65
 
66
-		if ( is_array($values['meta_value']) ) {
66
+		if ( is_array( $values['meta_value'] ) ) {
67 67
 			$values['meta_value'] = array_filter( $values['meta_value'], 'FrmAppHelper::is_not_empty_value' );
68 68
 		}
69
-        $meta_value = maybe_serialize($values['meta_value']);
69
+        $meta_value = maybe_serialize( $values['meta_value'] );
70 70
 
71
-        wp_cache_delete( $entry_id, 'frm_entry');
71
+        wp_cache_delete( $entry_id, 'frm_entry' );
72 72
 		self::clear_cache();
73 73
 
74 74
 		return $wpdb->update( $wpdb->prefix . 'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values );
@@ -116,11 +116,11 @@  discard block
 block discarded – undo
116 116
 
117 117
 			self::get_value_to_save( compact( 'field', 'field_id', 'entry_id' ), $meta_value );
118 118
 
119
-			if ( $prev_values && in_array($field_id, $prev_values) ) {
119
+			if ( $prev_values && in_array( $field_id, $prev_values ) ) {
120 120
 
121 121
 				if ( ( is_array( $meta_value ) && empty( $meta_value ) ) || ( ! is_array( $meta_value ) && trim( $meta_value ) == '' ) ) {
122 122
 					// remove blank fields
123
-					unset( $values[ $field_id ] );
123
+					unset( $values[$field_id] );
124 124
 				} else {
125 125
 					// if value exists, then update it
126 126
 					self::update_entry_meta( $entry_id, $field_id, '', $meta_value );
@@ -131,13 +131,13 @@  discard block
 block discarded – undo
131 131
 			}
132 132
 		}
133 133
 
134
-        if ( empty($prev_values) ) {
134
+        if ( empty( $prev_values ) ) {
135 135
             return;
136 136
         }
137 137
 
138
-        $prev_values = array_diff($prev_values, array_keys($values));
138
+        $prev_values = array_diff( $prev_values, array_keys( $values ) );
139 139
 
140
-        if ( empty($prev_values) ) {
140
+        if ( empty( $prev_values ) ) {
141 141
             return;
142 142
         }
143 143
 
@@ -154,10 +154,10 @@  discard block
 block discarded – undo
154 154
     }
155 155
 
156 156
 	public static function duplicate_entry_metas( $old_id, $new_id ) {
157
-        $metas = self::get_entry_meta_info($old_id);
157
+        $metas = self::get_entry_meta_info( $old_id );
158 158
         foreach ( $metas as $meta ) {
159
-            self::add_entry_meta($new_id, $meta->field_id, null, $meta->meta_value);
160
-            unset($meta);
159
+            self::add_entry_meta( $new_id, $meta->field_id, null, $meta->meta_value );
160
+            unset( $meta );
161 161
         }
162 162
 		self::clear_cache();
163 163
     }
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	public static function delete_entry_meta( $entry_id, $field_id ) {
166 166
         global $wpdb;
167 167
 		self::clear_cache();
168
-        return $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id));
168
+        return $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id ) );
169 169
     }
170 170
 
171 171
 	/**
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 	 */
185 185
 	public static function get_meta_value( $entry, $field_id ) {
186 186
 		if ( isset( $entry->metas ) ) {
187
-			return isset( $entry->metas[ $field_id ] ) ? $entry->metas[ $field_id ] : false;
187
+			return isset( $entry->metas[$field_id] ) ? $entry->metas[$field_id] : false;
188 188
 		} else {
189 189
 			return self::get_entry_meta_by_field( $entry->id, $field_id );
190 190
 		}
@@ -202,14 +202,14 @@  discard block
 block discarded – undo
202 202
 			$cached = FrmDb::check_cache( $entry_id, 'frm_entry' );
203 203
 		}
204 204
 
205
-		if ( $cached && isset( $cached->metas ) && isset( $cached->metas[ $field_id ] ) ) {
206
-			$result = $cached->metas[ $field_id ];
207
-            return stripslashes_deep($result);
205
+		if ( $cached && isset( $cached->metas ) && isset( $cached->metas[$field_id] ) ) {
206
+			$result = $cached->metas[$field_id];
207
+            return stripslashes_deep( $result );
208 208
         }
209 209
 
210 210
 		$get_table = $wpdb->prefix . 'frm_item_metas';
211 211
 		$query = array( 'item_id' => $entry_id );
212
-        if ( is_numeric($field_id) ) {
212
+        if ( is_numeric( $field_id ) ) {
213 213
 			$query['field_id'] = $field_id;
214 214
         } else {
215 215
 			$get_table .= ' it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id';
@@ -217,8 +217,8 @@  discard block
 block discarded – undo
217 217
         }
218 218
 
219 219
 		$result = FrmDb::get_var( $get_table, $query, 'meta_value' );
220
-        $result = maybe_unserialize($result);
221
-        $result = stripslashes_deep($result);
220
+        $result = maybe_unserialize( $result );
221
+        $result = stripslashes_deep( $result );
222 222
 
223 223
         return $result;
224 224
     }
@@ -233,22 +233,22 @@  discard block
 block discarded – undo
233 233
         $args = wp_parse_args( $args, $defaults );
234 234
 
235 235
         $query = array();
236
-        self::meta_field_query($field_id, $order, $limit, $args, $query);
237
-        $query = implode(' ', $query);
236
+        self::meta_field_query( $field_id, $order, $limit, $args, $query );
237
+        $query = implode( ' ', $query );
238 238
 
239 239
 		$cache_key = 'entry_metas_for_field_' . $field_id . $order . $limit . maybe_serialize( $args );
240
-        $values = FrmDb::check_cache($cache_key, 'frm_entry', $query, 'get_col');
240
+        $values = FrmDb::check_cache( $cache_key, 'frm_entry', $query, 'get_col' );
241 241
 
242 242
         if ( ! $args['stripslashes'] ) {
243 243
             return $values;
244 244
         }
245 245
 
246 246
 		foreach ( $values as $k => $v ) {
247
-			$values[ $k ] = maybe_unserialize( $v );
248
-            unset($k, $v);
247
+			$values[$k] = maybe_unserialize( $v );
248
+            unset( $k, $v );
249 249
         }
250 250
 
251
-        return stripslashes_deep($values);
251
+        return stripslashes_deep( $values );
252 252
     }
253 253
 
254 254
     /**
@@ -265,8 +265,8 @@  discard block
 block discarded – undo
265 265
 			$query[] = 'INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=em.item_id)';
266 266
         }
267 267
 
268
-        if ( is_numeric($field_id) ) {
269
-            $query[] = $wpdb->prepare('WHERE em.field_id=%d', $field_id);
268
+        if ( is_numeric( $field_id ) ) {
269
+            $query[] = $wpdb->prepare( 'WHERE em.field_id=%d', $field_id );
270 270
         } else {
271 271
 			$query[] = $wpdb->prepare( 'LEFT JOIN ' . $wpdb->prefix . 'frm_fields fi ON (em.field_id = fi.id) WHERE fi.field_key=%s', $field_id );
272 272
         }
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
         }
277 277
 
278 278
         if ( $args['value'] ) {
279
-            $query[] = $wpdb->prepare(' AND meta_value=%s', $args['value']);
279
+            $query[] = $wpdb->prepare( ' AND meta_value=%s', $args['value'] );
280 280
         }
281 281
         $query[] = $order . $limit;
282 282
     }
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
         $query = 'SELECT it.*, fi.type as field_type, fi.field_key as field_key,
291 291
             fi.required as required, fi.form_id as field_form_id, fi.name as field_name, fi.options as fi_options
292 292
 			FROM ' . $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id' .
293
-            FrmDb::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
293
+            FrmDb::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
294 294
 
295 295
 		$cache_key = 'all_' . maybe_serialize( $where ) . $order_by . $limit;
296 296
 		$results = FrmDb::check_cache( $cache_key, 'frm_entry', $query, ( $limit == ' LIMIT 1' ? 'get_row' : 'get_results' ) );
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 		}
301 301
 
302 302
 		foreach ( $results as $k => $result ) {
303
-			$results[ $k ]->meta_value = stripslashes_deep( maybe_unserialize( $result->meta_value ) );
303
+			$results[$k]->meta_value = stripslashes_deep( maybe_unserialize( $result->meta_value ) );
304 304
 			unset( $k, $result );
305 305
 		}
306 306
 
@@ -313,11 +313,11 @@  discard block
 block discarded – undo
313 313
 			'user_id'  => '',
314 314
 			'group_by' => '',
315 315
 		);
316
-        $args = wp_parse_args($args, $defaults);
316
+        $args = wp_parse_args( $args, $defaults );
317 317
 
318 318
         $query = array();
319
-        self::get_ids_query($where, $order_by, $limit, $unique, $args, $query );
320
-        $query = implode(' ', $query);
319
+        self::get_ids_query( $where, $order_by, $limit, $unique, $args, $query );
320
+        $query = implode( ' ', $query );
321 321
 
322 322
 		$cache_key = 'ids_' . maybe_serialize( $where ) . $order_by . 'l' . $limit . 'u' . $unique . maybe_serialize( $args );
323 323
 		return FrmDb::check_cache( $cache_key, 'frm_entry', $query, ( $limit == ' LIMIT 1' ? 'get_var' : 'get_col' ) );
@@ -344,17 +344,17 @@  discard block
 block discarded – undo
344 344
 		$query[] = 'FROM ' . $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id';
345 345
 
346 346
 		$query[] = 'INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=it.item_id)';
347
-        if ( is_array($where) ) {
347
+        if ( is_array( $where ) ) {
348 348
             if ( ! $args['is_draft'] ) {
349 349
                 $where['e.is_draft'] = 0;
350 350
             } else if ( $args['is_draft'] == 1 ) {
351 351
                 $where['e.is_draft'] = 1;
352 352
             }
353 353
 
354
-            if ( ! empty($args['user_id']) ) {
354
+            if ( ! empty( $args['user_id'] ) ) {
355 355
                 $where['e.user_id'] = $args['user_id'];
356 356
             }
357
-            $query[] = FrmDb::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
357
+            $query[] = FrmDb::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
358 358
 
359 359
 			if ( $args['group_by'] ) {
360 360
 				$query[] = ' GROUP BY ' . sanitize_text_field( $args['group_by'] );
@@ -370,13 +370,13 @@  discard block
 block discarded – undo
370 370
 			$draft_where = $wpdb->prepare( ' AND e.is_draft=%d', 1 );
371 371
         }
372 372
 
373
-        if ( ! empty($args['user_id']) ) {
374
-            $user_where = $wpdb->prepare(' AND e.user_id=%d', $args['user_id']);
373
+        if ( ! empty( $args['user_id'] ) ) {
374
+            $user_where = $wpdb->prepare( ' AND e.user_id=%d', $args['user_id'] );
375 375
         }
376 376
 
377
-        if ( strpos($where, ' GROUP BY ') ) {
377
+        if ( strpos( $where, ' GROUP BY ' ) ) {
378 378
             // don't inject WHERE filtering after GROUP BY
379
-            $parts = explode(' GROUP BY ', $where);
379
+            $parts = explode( ' GROUP BY ', $where );
380 380
             $where = $parts[0];
381 381
             $where .= $draft_where . $user_where;
382 382
 			$where .= ' GROUP BY ' . $parts[1];
@@ -385,12 +385,12 @@  discard block
 block discarded – undo
385 385
         }
386 386
 
387 387
 		// The query has already been prepared
388
-		$query[] = FrmDb::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
388
+		$query[] = FrmDb::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
389 389
     }
390 390
 
391 391
     public static function search_entry_metas( $search, $field_id = '', $operator ) {
392 392
 		$cache_key = 'search_' . maybe_serialize( $search ) . $field_id . $operator;
393
-        $results = wp_cache_get($cache_key, 'frm_entry');
393
+        $results = wp_cache_get( $cache_key, 'frm_entry' );
394 394
         if ( false !== $results ) {
395 395
             return $results;
396 396
         }
@@ -413,18 +413,18 @@  discard block
 block discarded – undo
413 413
                     case 'day':
414 414
 						$value = '%' . $value . '%';
415 415
                 }
416
-				$where .= $wpdb->prepare(' meta_value ' . $operator . ' %s and', $value );
416
+				$where .= $wpdb->prepare( ' meta_value ' . $operator . ' %s and', $value );
417 417
             }
418
-            $where .= $wpdb->prepare(' field_id=%d', $field_id);
418
+            $where .= $wpdb->prepare( ' field_id=%d', $field_id );
419 419
 			$query = 'SELECT DISTINCT item_id FROM ' . $wpdb->prefix . 'frm_item_metas' . FrmDb::prepend_and_or_where( ' WHERE ', $where );
420 420
         } else {
421 421
 			if ( $operator == 'LIKE' ) {
422 422
                 $search = '%' . $search . '%';
423 423
 			}
424
-            $query = $wpdb->prepare("SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id);
424
+            $query = $wpdb->prepare( "SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id );
425 425
         }
426 426
 
427
-        $results = $wpdb->get_col($query, 0);
427
+        $results = $wpdb->get_col( $query, 0 );
428 428
 		FrmDb::set_cache( $cache_key, $results, 'frm_entry' );
429 429
 
430 430
         return $results;
Please login to merge, or discard this patch.
classes/models/FrmFieldOption.php 1 patch
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -31,6 +31,10 @@
 block discarded – undo
31 31
 	 */
32 32
 	protected $option_label = '';
33 33
 
34
+	/**
35
+	 * @param string $option_key
36
+	 * @param string $option
37
+	 */
34 38
 	public function __construct( $option_key, $option, $args = array() ) {
35 39
 		$this->option_key = $option_key;
36 40
 		$this->option = $option;
Please login to merge, or discard this patch.
classes/models/FrmFieldValueSelector.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@
 block discarded – undo
75 75
 	/**
76 76
 	 * FrmFieldValueSelector constructor
77 77
 	 *
78
-	 * @param int|string $field_id
78
+	 * @param integer $field_id
79 79
 	 */
80 80
 	public function __construct( $field_id, $args ) {
81 81
 		$this->set_html_name( $args );
Please login to merge, or discard this patch.
classes/models/FrmEntry.php 3 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -180,6 +180,7 @@  discard block
 block discarded – undo
180 180
 	*
181 181
 	* @param int $id
182 182
 	* @param array $values
183
+	* @param string $update_type
183 184
 	* @return boolean|int $query_results
184 185
 	*/
185 186
 	private static function update_entry( $id, $values, $update_type ) {
@@ -563,6 +564,9 @@  discard block
 block discarded – undo
563 564
 		return $new_values;
564 565
 	}
565 566
 
567
+	/**
568
+	 * @param string $name
569
+	 */
566 570
 	private static function get_entry_value( $values, $name, $default ) {
567 571
 		return isset( $values[ $name ] ) ? $values[ $name ] : $default;
568 572
 	}
Please login to merge, or discard this patch.
Indentation   +345 added lines, -345 removed lines patch added patch discarded remove patch
@@ -6,11 +6,11 @@  discard block
 block discarded – undo
6 6
 class FrmEntry {
7 7
 
8 8
 	/**
9
-	* Create a new entry
10
-	*
11
-	* @param array $values
12
-	* @return int | boolean $entry_id
13
-	*/
9
+	 * Create a new entry
10
+	 *
11
+	 * @param array $values
12
+	 * @return int | boolean $entry_id
13
+	 */
14 14
 	public static function create( $values ) {
15 15
 		$entry_id = self::create_entry( $values, 'standard' );
16 16
 
@@ -18,12 +18,12 @@  discard block
 block discarded – undo
18 18
 	}
19 19
 
20 20
 	/**
21
-	* Create a new entry with some differences depending on type
22
-	*
23
-	* @param array $values
24
-	* @param string $type
25
-	* @return int | boolean $entry_id
26
-	*/
21
+	 * Create a new entry with some differences depending on type
22
+	 *
23
+	 * @param array $values
24
+	 * @param string $type
25
+	 * @return int | boolean $entry_id
26
+	 */
27 27
 	private static function create_entry( $values, $type ) {
28 28
 		$new_values = self::before_insert_entry_in_database( $values, $type );
29 29
 
@@ -37,10 +37,10 @@  discard block
 block discarded – undo
37 37
 		return $entry_id;
38 38
 	}
39 39
 
40
-    /**
41
-     * check for duplicate entries created in the last minute
42
-     * @return boolean
43
-     */
40
+	/**
41
+	 * check for duplicate entries created in the last minute
42
+	 * @return boolean
43
+	 */
44 44
 	public static function is_duplicate( $new_values, $values ) {
45 45
 		$duplicate_entry_time = apply_filters( 'frm_time_to_check_duplicates', 60, $new_values );
46 46
 
@@ -48,55 +48,55 @@  discard block
 block discarded – undo
48 48
 			return false;
49 49
 		}
50 50
 
51
-        $check_val = $new_values;
51
+		$check_val = $new_values;
52 52
 		$check_val['created_at >'] = date( 'Y-m-d H:i:s', ( strtotime( $new_values['created_at'] ) - absint( $duplicate_entry_time ) ) );
53 53
 
54 54
 		unset( $check_val['created_at'], $check_val['updated_at'] );
55 55
 		unset( $check_val['is_draft'], $check_val['id'], $check_val['item_key'] );
56 56
 
57
-        if ( $new_values['item_key'] == $new_values['name'] ) {
58
-            unset($check_val['name']);
59
-        }
57
+		if ( $new_values['item_key'] == $new_values['name'] ) {
58
+			unset($check_val['name']);
59
+		}
60 60
 
61
-        global $wpdb;
61
+		global $wpdb;
62 62
 		$entry_exists = FrmDb::get_col( $wpdb->prefix . 'frm_items', $check_val, 'id', array( 'order_by' => 'created_at DESC' ) );
63 63
 
64
-        if ( ! $entry_exists || empty($entry_exists) || ! isset($values['item_meta']) ) {
65
-            return false;
66
-        }
64
+		if ( ! $entry_exists || empty($entry_exists) || ! isset($values['item_meta']) ) {
65
+			return false;
66
+		}
67 67
 
68
-        $is_duplicate = false;
69
-        foreach ( $entry_exists as $entry_exist ) {
70
-            $is_duplicate = true;
68
+		$is_duplicate = false;
69
+		foreach ( $entry_exists as $entry_exist ) {
70
+			$is_duplicate = true;
71 71
 
72
-            //add more checks here to make sure it's a duplicate
73
-            $metas = FrmEntryMeta::get_entry_meta_info($entry_exist);
74
-            $field_metas = array();
75
-            foreach ( $metas as $meta ) {
72
+			//add more checks here to make sure it's a duplicate
73
+			$metas = FrmEntryMeta::get_entry_meta_info($entry_exist);
74
+			$field_metas = array();
75
+			foreach ( $metas as $meta ) {
76 76
 				$field_metas[ $meta->field_id ] = $meta->meta_value;
77
-            }
78
-
79
-            // If prev entry is empty and current entry is not, they are not duplicates
80
-            $filtered_vals = array_filter( $values['item_meta'] );
81
-            if ( empty( $field_metas ) && ! empty( $filtered_vals ) ) {
82
-                return false;
83
-            }
84
-
85
-            $diff = array_diff_assoc($field_metas, array_map('maybe_serialize', $values['item_meta']));
86
-            foreach ( $diff as $field_id => $meta_value ) {
87
-                if ( ! empty($meta_value) ) {
88
-                    $is_duplicate = false;
89
-                    continue;
90
-                }
91
-            }
92
-
93
-            if ( $is_duplicate ) {
77
+			}
78
+
79
+			// If prev entry is empty and current entry is not, they are not duplicates
80
+			$filtered_vals = array_filter( $values['item_meta'] );
81
+			if ( empty( $field_metas ) && ! empty( $filtered_vals ) ) {
82
+				return false;
83
+			}
84
+
85
+			$diff = array_diff_assoc($field_metas, array_map('maybe_serialize', $values['item_meta']));
86
+			foreach ( $diff as $field_id => $meta_value ) {
87
+				if ( ! empty($meta_value) ) {
88
+					$is_duplicate = false;
89
+					continue;
90
+				}
91
+			}
92
+
93
+			if ( $is_duplicate ) {
94 94
 				break;
95
-            }
96
-        }
95
+			}
96
+		}
97 97
 
98
-        return $is_duplicate;
99
-    }
98
+		return $is_duplicate;
99
+	}
100 100
 
101 101
 	/**
102 102
 	 * Determine if an entry needs to be checked as a possible duplicate
@@ -141,32 +141,32 @@  discard block
 block discarded – undo
141 141
 		$new_values['updated_at'] = $new_values['created_at'];
142 142
 
143 143
 		$query_results = $wpdb->insert( $wpdb->prefix . 'frm_items', $new_values );
144
-        if ( ! $query_results ) {
145
-            return false;
146
-        }
144
+		if ( ! $query_results ) {
145
+			return false;
146
+		}
147 147
 
148
-        $entry_id = $wpdb->insert_id;
148
+		$entry_id = $wpdb->insert_id;
149 149
 
150
-        global $frm_vars;
151
-        if ( ! isset($frm_vars['saved_entries']) ) {
152
-            $frm_vars['saved_entries'] = array();
153
-        }
154
-        $frm_vars['saved_entries'][] = (int) $entry_id;
150
+		global $frm_vars;
151
+		if ( ! isset($frm_vars['saved_entries']) ) {
152
+			$frm_vars['saved_entries'] = array();
153
+		}
154
+		$frm_vars['saved_entries'][] = (int) $entry_id;
155 155
 
156
-        FrmEntryMeta::duplicate_entry_metas($id, $entry_id);
156
+		FrmEntryMeta::duplicate_entry_metas($id, $entry_id);
157 157
 		self::clear_cache();
158 158
 
159 159
 		do_action( 'frm_after_duplicate_entry', $entry_id, $new_values['form_id'], array( 'old_id' => $id ) );
160
-        return $entry_id;
161
-    }
160
+		return $entry_id;
161
+	}
162 162
 
163 163
 	/**
164
-	* Update an entry (not via XML)
165
-	*
166
-	* @param int $id
167
-	* @param array $values
168
-	* @return boolean|int $update_results
169
-	*/
164
+	 * Update an entry (not via XML)
165
+	 *
166
+	 * @param int $id
167
+	 * @param array $values
168
+	 * @return boolean|int $update_results
169
+	 */
170 170
 	public static function update( $id, $values ) {
171 171
 		$update_results = self::update_entry( $id, $values, 'standard' );
172 172
 
@@ -174,14 +174,14 @@  discard block
 block discarded – undo
174 174
 	}
175 175
 
176 176
 	/**
177
-	* Update an entry with some differences depending on the update type
178
-	*
179
-	* @since 2.0.16
180
-	*
181
-	* @param int $id
182
-	* @param array $values
183
-	* @return boolean|int $query_results
184
-	*/
177
+	 * Update an entry with some differences depending on the update type
178
+	 *
179
+	 * @since 2.0.16
180
+	 *
181
+	 * @param int $id
182
+	 * @param array $values
183
+	 * @return boolean|int $query_results
184
+	 */
185 185
 	private static function update_entry( $id, $values, $update_type ) {
186 186
 		global $wpdb;
187 187
 
@@ -200,34 +200,34 @@  discard block
 block discarded – undo
200 200
 	}
201 201
 
202 202
 	public static function destroy( $id ) {
203
-        global $wpdb;
204
-        $id = (int) $id;
203
+		global $wpdb;
204
+		$id = (int) $id;
205 205
 
206 206
 		$entry = self::getOne( $id );
207
-        if ( ! $entry ) {
208
-            $result = false;
209
-            return $result;
210
-        }
207
+		if ( ! $entry ) {
208
+			$result = false;
209
+			return $result;
210
+		}
211 211
 
212
-        do_action('frm_before_destroy_entry', $id, $entry);
212
+		do_action('frm_before_destroy_entry', $id, $entry);
213 213
 
214 214
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE item_id=%d', $id ) );
215 215
 		$result = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_items WHERE id=%d', $id ) );
216 216
 
217 217
 		self::clear_cache();
218 218
 
219
-        return $result;
220
-    }
219
+		return $result;
220
+	}
221 221
 
222 222
 	public static function update_form( $id, $value, $form_id ) {
223
-        global $wpdb;
224
-        $form_id = isset($value) ? $form_id : null;
223
+		global $wpdb;
224
+		$form_id = isset($value) ? $form_id : null;
225 225
 		$result = $wpdb->update( $wpdb->prefix . 'frm_items', array( 'form_id' => $form_id ), array( 'id' => $id ) );
226 226
 		if ( $result ) {
227 227
 			self::clear_cache();
228 228
 		}
229
-        return $result;
230
-    }
229
+		return $result;
230
+	}
231 231
 
232 232
 	/**
233 233
 	 * Clear entry caching
@@ -269,161 +269,161 @@  discard block
 block discarded – undo
269 269
 	}
270 270
 
271 271
 	public static function getOne( $id, $meta = false ) {
272
-        global $wpdb;
272
+		global $wpdb;
273 273
 
274
-        $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it
274
+		$query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it
275 275
                   LEFT OUTER JOIN {$wpdb->prefix}frm_forms fr ON it.form_id=fr.id WHERE ";
276 276
 
277
-        $query .= is_numeric($id) ? 'it.id=%d' : 'it.item_key=%s';
278
-        $query_args = array( $id );
279
-        $query = $wpdb->prepare( $query, $query_args );
277
+		$query .= is_numeric($id) ? 'it.id=%d' : 'it.item_key=%s';
278
+		$query_args = array( $id );
279
+		$query = $wpdb->prepare( $query, $query_args );
280 280
 
281
-        if ( ! $meta ) {
281
+		if ( ! $meta ) {
282 282
 			$entry = FrmDb::check_cache( $id . '_nometa', 'frm_entry', $query, 'get_row' );
283
-            return stripslashes_deep($entry);
284
-        }
283
+			return stripslashes_deep($entry);
284
+		}
285 285
 
286
-        $entry = FrmDb::check_cache( $id, 'frm_entry' );
287
-        if ( $entry !== false ) {
288
-            return stripslashes_deep($entry);
289
-        }
286
+		$entry = FrmDb::check_cache( $id, 'frm_entry' );
287
+		if ( $entry !== false ) {
288
+			return stripslashes_deep($entry);
289
+		}
290 290
 
291
-        $entry = $wpdb->get_row( $query );
292
-        $entry = self::get_meta($entry);
291
+		$entry = $wpdb->get_row( $query );
292
+		$entry = self::get_meta($entry);
293 293
 
294
-        return stripslashes_deep($entry);
295
-    }
294
+		return stripslashes_deep($entry);
295
+	}
296 296
 
297 297
 	public static function get_meta( $entry ) {
298
-        if ( ! $entry ) {
299
-            return $entry;
300
-        }
298
+		if ( ! $entry ) {
299
+			return $entry;
300
+		}
301 301
 
302
-        global $wpdb;
302
+		global $wpdb;
303 303
 		$metas = FrmDb::get_results( $wpdb->prefix . 'frm_item_metas m LEFT JOIN ' . $wpdb->prefix . 'frm_fields f ON m.field_id=f.id', array(
304 304
 			'item_id' => $entry->id,
305 305
 			'field_id !' => 0,
306 306
 		), 'field_id, meta_value, field_key, item_id' );
307 307
 
308
-        $entry->metas = array();
308
+		$entry->metas = array();
309 309
 
310 310
 		$include_key = apply_filters( 'frm_include_meta_keys', false, array( 'form_id' => $entry->form_id ) );
311
-        foreach ( $metas as $meta_val ) {
312
-            if ( $meta_val->item_id == $entry->id ) {
311
+		foreach ( $metas as $meta_val ) {
312
+			if ( $meta_val->item_id == $entry->id ) {
313 313
 				$entry->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value );
314 314
 				if ( $include_key ) {
315 315
 					$entry->metas[ $meta_val->field_key ] = $entry->metas[ $meta_val->field_id ];
316 316
 				}
317
-                 continue;
318
-            }
317
+				 continue;
318
+			}
319 319
 
320
-            // include sub entries in an array
320
+			// include sub entries in an array
321 321
 			if ( ! isset( $entry_metas[ $meta_val->field_id ] ) ) {
322 322
 				$entry->metas[ $meta_val->field_id ] = array();
323
-            }
323
+			}
324 324
 
325 325
 			$entry->metas[ $meta_val->field_id ][] = maybe_unserialize( $meta_val->meta_value );
326 326
 
327
-            unset($meta_val);
328
-        }
329
-        unset($metas);
327
+			unset($meta_val);
328
+		}
329
+		unset($metas);
330 330
 
331 331
 		FrmDb::set_cache( $entry->id, $entry, 'frm_entry' );
332 332
 
333
-        return $entry;
334
-    }
333
+		return $entry;
334
+	}
335 335
 
336
-    /**
337
-     * @param string $id
338
-     */
336
+	/**
337
+	 * @param string $id
338
+	 */
339 339
 	public static function exists( $id ) {
340
-        global $wpdb;
341
-
342
-        if ( FrmDb::check_cache( $id, 'frm_entry' ) ) {
343
-            $exists = true;
344
-            return $exists;
345
-        }
346
-
347
-        if ( is_numeric($id) ) {
348
-            $where = array( 'id' => $id );
349
-        } else {
350
-            $where = array( 'item_key' => $id );
351
-        }
340
+		global $wpdb;
341
+
342
+		if ( FrmDb::check_cache( $id, 'frm_entry' ) ) {
343
+			$exists = true;
344
+			return $exists;
345
+		}
346
+
347
+		if ( is_numeric($id) ) {
348
+			$where = array( 'id' => $id );
349
+		} else {
350
+			$where = array( 'item_key' => $id );
351
+		}
352 352
 		$id = FrmDb::get_var( $wpdb->prefix . 'frm_items', $where );
353 353
 
354 354
 		return ( $id && $id > 0 );
355
-    }
355
+	}
356 356
 
357
-    public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) {
357
+	public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) {
358 358
 		global $wpdb;
359 359
 
360
-        $limit = FrmDb::esc_limit($limit);
360
+		$limit = FrmDb::esc_limit($limit);
361 361
 
362
-        $cache_key = maybe_serialize($where) . $order_by . $limit . $inc_form;
363
-        $entries = wp_cache_get($cache_key, 'frm_entry');
362
+		$cache_key = maybe_serialize($where) . $order_by . $limit . $inc_form;
363
+		$entries = wp_cache_get($cache_key, 'frm_entry');
364 364
 
365
-        if ( false === $entries ) {
366
-            $fields = 'it.id, it.item_key, it.name, it.ip, it.form_id, it.post_id, it.user_id, it.parent_item_id, it.updated_by, it.created_at, it.updated_at, it.is_draft';
365
+		if ( false === $entries ) {
366
+			$fields = 'it.id, it.item_key, it.name, it.ip, it.form_id, it.post_id, it.user_id, it.parent_item_id, it.updated_by, it.created_at, it.updated_at, it.is_draft';
367 367
 			$table = $wpdb->prefix . 'frm_items it ';
368 368
 
369
-            if ( $inc_form ) {
370
-                $fields = 'it.*, fr.name as form_name,fr.form_key as form_key';
371
-                $table .= 'LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id ';
372
-            }
369
+			if ( $inc_form ) {
370
+				$fields = 'it.*, fr.name as form_name,fr.form_key as form_key';
371
+				$table .= 'LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id ';
372
+			}
373 373
 
374
-            if ( preg_match( '/ meta_([0-9]+)/', $order_by, $order_matches ) ) {
375
-    		    // sort by a requested field
376
-                $field_id = (int) $order_matches[1];
374
+			if ( preg_match( '/ meta_([0-9]+)/', $order_by, $order_matches ) ) {
375
+				// sort by a requested field
376
+				$field_id = (int) $order_matches[1];
377 377
 				$fields .= ', (SELECT meta_value FROM ' . $wpdb->prefix . 'frm_item_metas WHERE field_id = ' . $field_id . ' AND item_id = it.id) as meta_' . $field_id;
378 378
 				unset( $order_matches, $field_id );
379
-		    }
379
+			}
380 380
 
381 381
 			// prepare the query
382 382
 			$query = 'SELECT ' . $fields . ' FROM ' . $table . FrmDb::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
383 383
 
384
-            $entries = $wpdb->get_results($query, OBJECT_K);
385
-            unset($query);
384
+			$entries = $wpdb->get_results($query, OBJECT_K);
385
+			unset($query);
386 386
 
387 387
 			FrmDb::set_cache( $cache_key, $entries, 'frm_entry' );
388
-        }
388
+		}
389 389
 
390
-        if ( ! $meta || ! $entries ) {
391
-            return stripslashes_deep($entries);
392
-        }
393
-        unset($meta);
390
+		if ( ! $meta || ! $entries ) {
391
+			return stripslashes_deep($entries);
392
+		}
393
+		unset($meta);
394 394
 
395
-        if ( ! is_array( $where ) && preg_match('/^it\.form_id=\d+$/', $where) ) {
395
+		if ( ! is_array( $where ) && preg_match('/^it\.form_id=\d+$/', $where) ) {
396 396
 			$where = array( 'it.form_id' => substr( $where, 11 ) );
397
-        }
397
+		}
398 398
 
399
-        $meta_where = array( 'field_id !' => 0 );
400
-        if ( $limit == '' && is_array($where) && count($where) == 1 && isset($where['it.form_id']) ) {
401
-            $meta_where['fi.form_id'] = $where['it.form_id'];
402
-        } else {
403
-            $meta_where['item_id'] = array_keys( $entries );
404
-        }
399
+		$meta_where = array( 'field_id !' => 0 );
400
+		if ( $limit == '' && is_array($where) && count($where) == 1 && isset($where['it.form_id']) ) {
401
+			$meta_where['fi.form_id'] = $where['it.form_id'];
402
+		} else {
403
+			$meta_where['item_id'] = array_keys( $entries );
404
+		}
405 405
 
406
-        $metas = FrmDb::get_results( $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON (it.field_id = fi.id)', $meta_where, 'item_id, meta_value, field_id, field_key, form_id' );
406
+		$metas = FrmDb::get_results( $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON (it.field_id = fi.id)', $meta_where, 'item_id, meta_value, field_id, field_key, form_id' );
407 407
 
408
-        unset( $meta_where );
408
+		unset( $meta_where );
409 409
 
410
-        if ( ! $metas ) {
411
-            return stripslashes_deep($entries);
412
-        }
410
+		if ( ! $metas ) {
411
+			return stripslashes_deep($entries);
412
+		}
413 413
 
414
-        foreach ( $metas as $m_key => $meta_val ) {
415
-            if ( ! isset( $entries[ $meta_val->item_id ] ) ) {
416
-                continue;
417
-            }
414
+		foreach ( $metas as $m_key => $meta_val ) {
415
+			if ( ! isset( $entries[ $meta_val->item_id ] ) ) {
416
+				continue;
417
+			}
418 418
 
419
-            if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) {
419
+			if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) {
420 420
 				$entries[ $meta_val->item_id ]->metas = array();
421
-            }
421
+			}
422 422
 
423 423
 			$entries[ $meta_val->item_id ]->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value );
424 424
 
425
-            unset($m_key, $meta_val);
426
-        }
425
+			unset($m_key, $meta_val);
426
+		}
427 427
 
428 428
 		if ( ! FrmAppHelper::prevent_caching() ) {
429 429
 			foreach ( $entries as $entry ) {
@@ -432,31 +432,31 @@  discard block
 block discarded – undo
432 432
 			}
433 433
 		}
434 434
 
435
-        return stripslashes_deep($entries);
436
-    }
435
+		return stripslashes_deep($entries);
436
+	}
437 437
 
438
-    // Pagination Methods
439
-    public static function getRecordCount( $where = '' ) {
440
-        global $wpdb;
438
+	// Pagination Methods
439
+	public static function getRecordCount( $where = '' ) {
440
+		global $wpdb;
441 441
 		$table_join = $wpdb->prefix . 'frm_items it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id';
442 442
 
443
-        if ( is_numeric($where) ) {
444
-            $table_join = 'frm_items';
445
-            $where = array( 'form_id' => $where );
446
-        }
443
+		if ( is_numeric($where) ) {
444
+			$table_join = 'frm_items';
445
+			$where = array( 'form_id' => $where );
446
+		}
447 447
 
448
-        if ( is_array( $where ) ) {
449
-            $count = FrmDb::get_count( $table_join, $where );
450
-        } else {
448
+		if ( is_array( $where ) ) {
449
+			$count = FrmDb::get_count( $table_join, $where );
450
+		} else {
451 451
 			$cache_key = 'count_' . maybe_serialize( $where );
452 452
 			$query = 'SELECT COUNT(*) FROM ' . $table_join . FrmDb::prepend_and_or_where( ' WHERE ', $where );
453 453
 			$count = FrmDb::check_cache( $cache_key, 'frm_entry', $query, 'get_var' );
454
-        }
454
+		}
455 455
 
456
-        return $count;
457
-    }
456
+		return $count;
457
+	}
458 458
 
459
-    public static function getPageCount( $p_size, $where = '' ) {
459
+	public static function getPageCount( $p_size, $where = '' ) {
460 460
 		$p_size = (int) $p_size;
461 461
 		$count = 1;
462 462
 		if ( $p_size ) {
@@ -467,16 +467,16 @@  discard block
 block discarded – undo
467 467
 		}
468 468
 
469 469
 		return $count;
470
-    }
470
+	}
471 471
 
472 472
 	/**
473
-	* Prepare the data before inserting it into the database
474
-	*
475
-	* @since 2.0.16
476
-	* @param array $values
477
-	* @param string $type
478
-	* @return array $new_values
479
-	*/
473
+	 * Prepare the data before inserting it into the database
474
+	 *
475
+	 * @since 2.0.16
476
+	 * @param array $values
477
+	 * @param string $type
478
+	 * @return array $new_values
479
+	 */
480 480
 	private static function before_insert_entry_in_database( &$values, $type ) {
481 481
 
482 482
 		self::sanitize_entry_post( $values );
@@ -491,13 +491,13 @@  discard block
 block discarded – undo
491 491
 	}
492 492
 
493 493
 	/**
494
-	* Create an entry and perform after create actions
495
-	*
496
-	* @since 2.0.16
497
-	* @param array $values
498
-	* @param array $new_values
499
-	* @return boolean|int $entry_id
500
-	*/
494
+	 * Create an entry and perform after create actions
495
+	 *
496
+	 * @since 2.0.16
497
+	 * @param array $values
498
+	 * @param array $new_values
499
+	 * @return boolean|int $entry_id
500
+	 */
501 501
 	private static function continue_to_create_entry( $values, $new_values ) {
502 502
 		$entry_id = self::insert_entry_into_database( $new_values );
503 503
 		if ( ! $entry_id ) {
@@ -509,37 +509,37 @@  discard block
 block discarded – undo
509 509
 		return $entry_id;
510 510
 	}
511 511
 
512
-    /**
513
-     * Sanitize the POST values before we use them
514
-     *
515
-     * @since 2.0
516
-     * @param array $values The POST values by reference
517
-     */
518
-    public static function sanitize_entry_post( &$values ) {
519
-        $sanitize_method = array(
520
-            'form_id'       => 'absint',
521
-            'frm_action'    => 'sanitize_title',
522
-            'form_key'      => 'sanitize_title',
523
-            'item_key'      => 'sanitize_title',
524
-            'item_name'     => 'sanitize_text_field',
525
-            'frm_saving_draft' => 'absint',
526
-            'is_draft'      => 'absint',
527
-            'post_id'       => 'absint',
528
-            'parent_item_id' => 'absint',
529
-            'created_at'    => 'sanitize_text_field',
530
-            'updated_at'    => 'sanitize_text_field',
531
-        );
532
-
533
-        FrmAppHelper::sanitize_request( $sanitize_method, $values );
534
-    }
512
+	/**
513
+	 * Sanitize the POST values before we use them
514
+	 *
515
+	 * @since 2.0
516
+	 * @param array $values The POST values by reference
517
+	 */
518
+	public static function sanitize_entry_post( &$values ) {
519
+		$sanitize_method = array(
520
+			'form_id'       => 'absint',
521
+			'frm_action'    => 'sanitize_title',
522
+			'form_key'      => 'sanitize_title',
523
+			'item_key'      => 'sanitize_title',
524
+			'item_name'     => 'sanitize_text_field',
525
+			'frm_saving_draft' => 'absint',
526
+			'is_draft'      => 'absint',
527
+			'post_id'       => 'absint',
528
+			'parent_item_id' => 'absint',
529
+			'created_at'    => 'sanitize_text_field',
530
+			'updated_at'    => 'sanitize_text_field',
531
+		);
532
+
533
+		FrmAppHelper::sanitize_request( $sanitize_method, $values );
534
+	}
535 535
 
536 536
 	/**
537
-	* Prepare the new values for inserting into the database
538
-	*
539
-	* @since 2.0.16
540
-	* @param array $values
541
-	* @return array $new_values
542
-	*/
537
+	 * Prepare the new values for inserting into the database
538
+	 *
539
+	 * @since 2.0.16
540
+	 * @param array $values
541
+	 * @return array $new_values
542
+	 */
543 543
 	private static function package_entry_data( &$values ) {
544 544
 		global $wpdb;
545 545
 
@@ -592,34 +592,34 @@  discard block
 block discarded – undo
592 592
 	}
593 593
 
594 594
 	/**
595
-	* Get the is_draft value for a new entry
596
-	*
597
-	* @since 2.0.16
598
-	* @param array $values
599
-	* @return int
600
-	*/
595
+	 * Get the is_draft value for a new entry
596
+	 *
597
+	 * @since 2.0.16
598
+	 * @param array $values
599
+	 * @return int
600
+	 */
601 601
 	private static function get_is_draft_value( $values ) {
602 602
 		return ( ( isset( $values['frm_saving_draft'] ) && $values['frm_saving_draft'] == 1 ) || ( isset( $values['is_draft'] ) && $values['is_draft'] == 1 ) ) ? 1 : 0;
603 603
 	}
604 604
 
605 605
 	/**
606
-	* Get the created_at value for a new entry
607
-	*
608
-	* @since 2.0.16
609
-	* @param array $values
610
-	* @return string
611
-	*/
606
+	 * Get the created_at value for a new entry
607
+	 *
608
+	 * @since 2.0.16
609
+	 * @param array $values
610
+	 * @return string
611
+	 */
612 612
 	private static function get_created_at( $values ) {
613 613
 		return self::get_entry_value( $values, 'created_at', current_time( 'mysql', 1 ) );
614 614
 	}
615 615
 
616 616
 	/**
617
-	* Get the updated_at value for a new entry
618
-	*
619
-	* @since 2.0.16
620
-	* @param array $values
621
-	* @return string
622
-	*/
617
+	 * Get the updated_at value for a new entry
618
+	 *
619
+	 * @since 2.0.16
620
+	 * @param array $values
621
+	 * @return string
622
+	 */
623 623
 	private static function get_updated_at( $values ) {
624 624
 		if ( isset( $values['updated_at'] ) ) {
625 625
 			$updated_at = $values['updated_at'];
@@ -631,12 +631,12 @@  discard block
 block discarded – undo
631 631
 	}
632 632
 
633 633
 	/**
634
-	* Get the description value for a new entry
635
-	*
636
-	* @since 2.0.16
637
-	* @param array $values
638
-	* @return string
639
-	*/
634
+	 * Get the description value for a new entry
635
+	 *
636
+	 * @since 2.0.16
637
+	 * @param array $values
638
+	 * @return string
639
+	 */
640 640
 	private static function get_entry_description( $values ) {
641 641
 		if ( isset( $values['description'] ) && ! empty( $values['description'] ) ) {
642 642
 			$description = maybe_serialize( $values['description'] );
@@ -651,12 +651,12 @@  discard block
 block discarded – undo
651 651
 	}
652 652
 
653 653
 	/**
654
-	* Get the user_id value for a new entry
655
-	*
656
-	* @since 2.0.16
657
-	* @param array $values
658
-	* @return int
659
-	*/
654
+	 * Get the user_id value for a new entry
655
+	 *
656
+	 * @since 2.0.16
657
+	 * @param array $values
658
+	 * @return int
659
+	 */
660 660
 	private static function get_entry_user_id( $values ) {
661 661
 		if ( isset( $values['frm_user_id'] ) && ( is_numeric( $values['frm_user_id'] ) || FrmAppHelper::is_admin() ) ) {
662 662
 			$user_id = $values['frm_user_id'];
@@ -669,12 +669,12 @@  discard block
 block discarded – undo
669 669
 	}
670 670
 
671 671
 	/**
672
-	* Insert new entry into the database
673
-	*
674
-	* @since 2.0.16
675
-	* @param array $new_values
676
-	* @return int | boolean $entry_id
677
-	*/
672
+	 * Insert new entry into the database
673
+	 *
674
+	 * @since 2.0.16
675
+	 * @param array $new_values
676
+	 * @return int | boolean $entry_id
677
+	 */
678 678
 	private static function insert_entry_into_database( $new_values ) {
679 679
 		global $wpdb;
680 680
 
@@ -690,11 +690,11 @@  discard block
 block discarded – undo
690 690
 	}
691 691
 
692 692
 	/**
693
-	* Add the new entry to global $frm_vars
694
-	*
695
-	* @since 2.0.16
696
-	* @param int $entry_id
697
-	*/
693
+	 * Add the new entry to global $frm_vars
694
+	 *
695
+	 * @since 2.0.16
696
+	 * @param int $entry_id
697
+	 */
698 698
 	private static function add_new_entry_to_frm_vars( $entry_id ) {
699 699
 		global $frm_vars;
700 700
 
@@ -706,12 +706,12 @@  discard block
 block discarded – undo
706 706
 	}
707 707
 
708 708
 	/**
709
-	* Add entry metas, if there are any
710
-	*
711
-	* @since 2.0.16
712
-	* @param array $values
713
-	* @param int $entry_id
714
-	*/
709
+	 * Add entry metas, if there are any
710
+	 *
711
+	 * @since 2.0.16
712
+	 * @param array $values
713
+	 * @param int $entry_id
714
+	 */
715 715
 	private static function maybe_add_entry_metas( $values, $entry_id ) {
716 716
 		if ( isset($values['item_meta']) ) {
717 717
 			FrmEntryMeta::update_entry_metas( $entry_id, $values['item_meta'] );
@@ -719,12 +719,12 @@  discard block
 block discarded – undo
719 719
 	}
720 720
 
721 721
 	/**
722
-	* Trigger frm_after_create_entry hooks
723
-	*
724
-	* @since 2.0.16
725
-	* @param int $entry_id
726
-	* @param array $new_values
727
-	*/
722
+	 * Trigger frm_after_create_entry hooks
723
+	 *
724
+	 * @since 2.0.16
725
+	 * @param int $entry_id
726
+	 * @param array $new_values
727
+	 */
728 728
 	private static function after_entry_created_actions( $entry_id, $values, $new_values ) {
729 729
 		// this is a child entry
730 730
 		$is_child = isset( $values['parent_form_id'] ) && isset( $values['parent_nonce'] ) && ! empty( $values['parent_form_id'] ) && wp_verify_nonce( $values['parent_nonce'], 'parent' );
@@ -734,13 +734,13 @@  discard block
 block discarded – undo
734 734
 	}
735 735
 
736 736
 	/**
737
-	* Actions to perform immediately after an entry is inserted in the frm_items database
738
-	*
739
-	* @since 2.0.16
740
-	* @param array $values
741
-	* @param array $new_values
742
-	* @param int $entry_id
743
-	*/
737
+	 * Actions to perform immediately after an entry is inserted in the frm_items database
738
+	 *
739
+	 * @since 2.0.16
740
+	 * @param array $values
741
+	 * @param array $new_values
742
+	 * @param int $entry_id
743
+	 */
744 744
 	private static function after_insert_entry_in_database( $values, $new_values, $entry_id ) {
745 745
 
746 746
 		self::add_new_entry_to_frm_vars( $entry_id );
@@ -753,14 +753,14 @@  discard block
 block discarded – undo
753 753
 	}
754 754
 
755 755
 	/**
756
-	* Perform some actions right before updating an entry
757
-	*
758
-	* @since 2.0.16
759
-	* @param int $id
760
-	* @param array $values
761
-	* @param string $update_type
762
-	* @return boolean $update
763
-	*/
756
+	 * Perform some actions right before updating an entry
757
+	 *
758
+	 * @since 2.0.16
759
+	 * @param int $id
760
+	 * @param array $values
761
+	 * @param string $update_type
762
+	 * @return boolean $update
763
+	 */
764 764
 	private static function before_update_entry( $id, &$values, $update_type ) {
765 765
 		$update = true;
766 766
 
@@ -778,13 +778,13 @@  discard block
 block discarded – undo
778 778
 	}
779 779
 
780 780
 	/**
781
-	* Package the entry data for updating
782
-	*
783
-	* @since 2.0.16
784
-	* @param int $id
785
-	* @param array $values
786
-	* @return array $new_values
787
-	*/
781
+	 * Package the entry data for updating
782
+	 *
783
+	 * @since 2.0.16
784
+	 * @param int $id
785
+	 * @param array $values
786
+	 * @return array $new_values
787
+	 */
788 788
 	private static function package_entry_to_update( $id, $values ) {
789 789
 		global $wpdb;
790 790
 
@@ -818,14 +818,14 @@  discard block
 block discarded – undo
818 818
 	}
819 819
 
820 820
 	/**
821
-	* Perform some actions right after updating an entry
822
-	*
823
-	* @since 2.0.16
824
-	* @param boolean|int $query_results
825
-	* @param int $id
826
-	* @param array $values
827
-	* @param array $new_values
828
-	*/
821
+	 * Perform some actions right after updating an entry
822
+	 *
823
+	 * @since 2.0.16
824
+	 * @param boolean|int $query_results
825
+	 * @param int $id
826
+	 * @param array $values
827
+	 * @param array $new_values
828
+	 */
829 829
 	private static function after_update_entry( $query_results, $id, $values, $new_values ) {
830 830
 		if ( $query_results ) {
831 831
 			self::clear_cache();
@@ -847,13 +847,13 @@  discard block
 block discarded – undo
847 847
 	}
848 848
 
849 849
 	/**
850
-	* Create entry from an XML import
851
-	* Certain actions aren't necessary when importing (like saving sub entries, checking for duplicates, etc.)
852
-	*
853
-	* @since 2.0.16
854
-	* @param array $values
855
-	* @return int | boolean $entry_id
856
-	*/
850
+	 * Create entry from an XML import
851
+	 * Certain actions aren't necessary when importing (like saving sub entries, checking for duplicates, etc.)
852
+	 *
853
+	 * @since 2.0.16
854
+	 * @param array $values
855
+	 * @return int | boolean $entry_id
856
+	 */
857 857
 	public static function create_entry_from_xml( $values ) {
858 858
 		$entry_id = self::create_entry( $values, 'xml' );
859 859
 
@@ -861,26 +861,26 @@  discard block
 block discarded – undo
861 861
 	}
862 862
 
863 863
 	/**
864
-	* Update entry from an XML import
865
-	* Certain actions aren't necessary when importing (like saving sub entries and modifying other vals)
866
-	*
867
-	* @since 2.0.16
868
-	* @param int $id
869
-	* @param array $values
870
-	* @return int | boolean $updated
871
-	*/
864
+	 * Update entry from an XML import
865
+	 * Certain actions aren't necessary when importing (like saving sub entries and modifying other vals)
866
+	 *
867
+	 * @since 2.0.16
868
+	 * @param int $id
869
+	 * @param array $values
870
+	 * @return int | boolean $updated
871
+	 */
872 872
 	public static function update_entry_from_xml( $id, $values ) {
873 873
 		$updated = self::update_entry( $id, $values, 'xml' );
874 874
 
875 875
 		return $updated;
876 876
 	}
877 877
 
878
-    /**
879
-     * @param string $key
880
-     * @return int entry_id
881
-     */
878
+	/**
879
+	 * @param string $key
880
+	 * @return int entry_id
881
+	 */
882 882
 	public static function get_id_by_key( $key ) {
883
-        $entry_id = FrmDb::get_var( 'frm_items', array( 'item_key' => sanitize_title( $key ) ) );
884
-        return $entry_id;
885
-    }
883
+		$entry_id = FrmDb::get_var( 'frm_items', array( 'item_key' => sanitize_title( $key ) ) );
884
+		return $entry_id;
885
+	}
886 886
 }
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -55,13 +55,13 @@  discard block
 block discarded – undo
55 55
 		unset( $check_val['is_draft'], $check_val['id'], $check_val['item_key'] );
56 56
 
57 57
         if ( $new_values['item_key'] == $new_values['name'] ) {
58
-            unset($check_val['name']);
58
+            unset( $check_val['name'] );
59 59
         }
60 60
 
61 61
         global $wpdb;
62 62
 		$entry_exists = FrmDb::get_col( $wpdb->prefix . 'frm_items', $check_val, 'id', array( 'order_by' => 'created_at DESC' ) );
63 63
 
64
-        if ( ! $entry_exists || empty($entry_exists) || ! isset($values['item_meta']) ) {
64
+        if ( ! $entry_exists || empty( $entry_exists ) || ! isset( $values['item_meta'] ) ) {
65 65
             return false;
66 66
         }
67 67
 
@@ -70,10 +70,10 @@  discard block
 block discarded – undo
70 70
             $is_duplicate = true;
71 71
 
72 72
             //add more checks here to make sure it's a duplicate
73
-            $metas = FrmEntryMeta::get_entry_meta_info($entry_exist);
73
+            $metas = FrmEntryMeta::get_entry_meta_info( $entry_exist );
74 74
             $field_metas = array();
75 75
             foreach ( $metas as $meta ) {
76
-				$field_metas[ $meta->field_id ] = $meta->meta_value;
76
+				$field_metas[$meta->field_id] = $meta->meta_value;
77 77
             }
78 78
 
79 79
             // If prev entry is empty and current entry is not, they are not duplicates
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
                 return false;
83 83
             }
84 84
 
85
-            $diff = array_diff_assoc($field_metas, array_map('maybe_serialize', $values['item_meta']));
85
+            $diff = array_diff_assoc( $field_metas, array_map( 'maybe_serialize', $values['item_meta'] ) );
86 86
             foreach ( $diff as $field_id => $meta_value ) {
87
-                if ( ! empty($meta_value) ) {
87
+                if ( ! empty( $meta_value ) ) {
88 88
                     $is_duplicate = false;
89 89
                     continue;
90 90
                 }
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 		}
114 114
 
115 115
 		// If CSV is importing, don't check for duplicates
116
-		if ( defined('WP_IMPORTING') && WP_IMPORTING ) {
116
+		if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
117 117
 			return false;
118 118
 		}
119 119
 
@@ -148,12 +148,12 @@  discard block
 block discarded – undo
148 148
         $entry_id = $wpdb->insert_id;
149 149
 
150 150
         global $frm_vars;
151
-        if ( ! isset($frm_vars['saved_entries']) ) {
151
+        if ( ! isset( $frm_vars['saved_entries'] ) ) {
152 152
             $frm_vars['saved_entries'] = array();
153 153
         }
154 154
         $frm_vars['saved_entries'][] = (int) $entry_id;
155 155
 
156
-        FrmEntryMeta::duplicate_entry_metas($id, $entry_id);
156
+        FrmEntryMeta::duplicate_entry_metas( $id, $entry_id );
157 157
 		self::clear_cache();
158 158
 
159 159
 		do_action( 'frm_after_duplicate_entry', $entry_id, $new_values['form_id'], array( 'old_id' => $id ) );
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 
193 193
 		$new_values = self::package_entry_to_update( $id, $values );
194 194
 
195
-		$query_results = $wpdb->update( $wpdb->prefix . 'frm_items', $new_values, compact('id') );
195
+		$query_results = $wpdb->update( $wpdb->prefix . 'frm_items', $new_values, compact( 'id' ) );
196 196
 
197 197
 		self::after_update_entry( $query_results, $id, $values, $new_values );
198 198
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
             return $result;
210 210
         }
211 211
 
212
-        do_action('frm_before_destroy_entry', $id, $entry);
212
+        do_action( 'frm_before_destroy_entry', $id, $entry );
213 213
 
214 214
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE item_id=%d', $id ) );
215 215
 		$result = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_items WHERE id=%d', $id ) );
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 
222 222
 	public static function update_form( $id, $value, $form_id ) {
223 223
         global $wpdb;
224
-        $form_id = isset($value) ? $form_id : null;
224
+        $form_id = isset( $value ) ? $form_id : null;
225 225
 		$result = $wpdb->update( $wpdb->prefix . 'frm_items', array( 'form_id' => $form_id ), array( 'id' => $id ) );
226 226
 		if ( $result ) {
227 227
 			self::clear_cache();
@@ -274,24 +274,24 @@  discard block
 block discarded – undo
274 274
         $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it
275 275
                   LEFT OUTER JOIN {$wpdb->prefix}frm_forms fr ON it.form_id=fr.id WHERE ";
276 276
 
277
-        $query .= is_numeric($id) ? 'it.id=%d' : 'it.item_key=%s';
277
+        $query .= is_numeric( $id ) ? 'it.id=%d' : 'it.item_key=%s';
278 278
         $query_args = array( $id );
279 279
         $query = $wpdb->prepare( $query, $query_args );
280 280
 
281 281
         if ( ! $meta ) {
282 282
 			$entry = FrmDb::check_cache( $id . '_nometa', 'frm_entry', $query, 'get_row' );
283
-            return stripslashes_deep($entry);
283
+            return stripslashes_deep( $entry );
284 284
         }
285 285
 
286 286
         $entry = FrmDb::check_cache( $id, 'frm_entry' );
287 287
         if ( $entry !== false ) {
288
-            return stripslashes_deep($entry);
288
+            return stripslashes_deep( $entry );
289 289
         }
290 290
 
291 291
         $entry = $wpdb->get_row( $query );
292
-        $entry = self::get_meta($entry);
292
+        $entry = self::get_meta( $entry );
293 293
 
294
-        return stripslashes_deep($entry);
294
+        return stripslashes_deep( $entry );
295 295
     }
296 296
 
297 297
 	public static function get_meta( $entry ) {
@@ -310,23 +310,23 @@  discard block
 block discarded – undo
310 310
 		$include_key = apply_filters( 'frm_include_meta_keys', false, array( 'form_id' => $entry->form_id ) );
311 311
         foreach ( $metas as $meta_val ) {
312 312
             if ( $meta_val->item_id == $entry->id ) {
313
-				$entry->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value );
313
+				$entry->metas[$meta_val->field_id] = maybe_unserialize( $meta_val->meta_value );
314 314
 				if ( $include_key ) {
315
-					$entry->metas[ $meta_val->field_key ] = $entry->metas[ $meta_val->field_id ];
315
+					$entry->metas[$meta_val->field_key] = $entry->metas[$meta_val->field_id];
316 316
 				}
317 317
                  continue;
318 318
             }
319 319
 
320 320
             // include sub entries in an array
321
-			if ( ! isset( $entry_metas[ $meta_val->field_id ] ) ) {
322
-				$entry->metas[ $meta_val->field_id ] = array();
321
+			if ( ! isset( $entry_metas[$meta_val->field_id] ) ) {
322
+				$entry->metas[$meta_val->field_id] = array();
323 323
             }
324 324
 
325
-			$entry->metas[ $meta_val->field_id ][] = maybe_unserialize( $meta_val->meta_value );
325
+			$entry->metas[$meta_val->field_id][] = maybe_unserialize( $meta_val->meta_value );
326 326
 
327
-            unset($meta_val);
327
+            unset( $meta_val );
328 328
         }
329
-        unset($metas);
329
+        unset( $metas );
330 330
 
331 331
 		FrmDb::set_cache( $entry->id, $entry, 'frm_entry' );
332 332
 
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
             return $exists;
345 345
         }
346 346
 
347
-        if ( is_numeric($id) ) {
347
+        if ( is_numeric( $id ) ) {
348 348
             $where = array( 'id' => $id );
349 349
         } else {
350 350
             $where = array( 'item_key' => $id );
@@ -357,10 +357,10 @@  discard block
 block discarded – undo
357 357
     public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) {
358 358
 		global $wpdb;
359 359
 
360
-        $limit = FrmDb::esc_limit($limit);
360
+        $limit = FrmDb::esc_limit( $limit );
361 361
 
362
-        $cache_key = maybe_serialize($where) . $order_by . $limit . $inc_form;
363
-        $entries = wp_cache_get($cache_key, 'frm_entry');
362
+        $cache_key = maybe_serialize( $where ) . $order_by . $limit . $inc_form;
363
+        $entries = wp_cache_get( $cache_key, 'frm_entry' );
364 364
 
365 365
         if ( false === $entries ) {
366 366
             $fields = 'it.id, it.item_key, it.name, it.ip, it.form_id, it.post_id, it.user_id, it.parent_item_id, it.updated_by, it.created_at, it.updated_at, it.is_draft';
@@ -379,25 +379,25 @@  discard block
 block discarded – undo
379 379
 		    }
380 380
 
381 381
 			// prepare the query
382
-			$query = 'SELECT ' . $fields . ' FROM ' . $table . FrmDb::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
382
+			$query = 'SELECT ' . $fields . ' FROM ' . $table . FrmDb::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
383 383
 
384
-            $entries = $wpdb->get_results($query, OBJECT_K);
385
-            unset($query);
384
+            $entries = $wpdb->get_results( $query, OBJECT_K );
385
+            unset( $query );
386 386
 
387 387
 			FrmDb::set_cache( $cache_key, $entries, 'frm_entry' );
388 388
         }
389 389
 
390 390
         if ( ! $meta || ! $entries ) {
391
-            return stripslashes_deep($entries);
391
+            return stripslashes_deep( $entries );
392 392
         }
393
-        unset($meta);
393
+        unset( $meta );
394 394
 
395
-        if ( ! is_array( $where ) && preg_match('/^it\.form_id=\d+$/', $where) ) {
395
+        if ( ! is_array( $where ) && preg_match( '/^it\.form_id=\d+$/', $where ) ) {
396 396
 			$where = array( 'it.form_id' => substr( $where, 11 ) );
397 397
         }
398 398
 
399 399
         $meta_where = array( 'field_id !' => 0 );
400
-        if ( $limit == '' && is_array($where) && count($where) == 1 && isset($where['it.form_id']) ) {
400
+        if ( $limit == '' && is_array( $where ) && count( $where ) == 1 && isset( $where['it.form_id'] ) ) {
401 401
             $meta_where['fi.form_id'] = $where['it.form_id'];
402 402
         } else {
403 403
             $meta_where['item_id'] = array_keys( $entries );
@@ -408,21 +408,21 @@  discard block
 block discarded – undo
408 408
         unset( $meta_where );
409 409
 
410 410
         if ( ! $metas ) {
411
-            return stripslashes_deep($entries);
411
+            return stripslashes_deep( $entries );
412 412
         }
413 413
 
414 414
         foreach ( $metas as $m_key => $meta_val ) {
415
-            if ( ! isset( $entries[ $meta_val->item_id ] ) ) {
415
+            if ( ! isset( $entries[$meta_val->item_id] ) ) {
416 416
                 continue;
417 417
             }
418 418
 
419
-            if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) {
420
-				$entries[ $meta_val->item_id ]->metas = array();
419
+            if ( ! isset( $entries[$meta_val->item_id]->metas ) ) {
420
+				$entries[$meta_val->item_id]->metas = array();
421 421
             }
422 422
 
423
-			$entries[ $meta_val->item_id ]->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value );
423
+			$entries[$meta_val->item_id]->metas[$meta_val->field_id] = maybe_unserialize( $meta_val->meta_value );
424 424
 
425
-            unset($m_key, $meta_val);
425
+            unset( $m_key, $meta_val );
426 426
         }
427 427
 
428 428
 		if ( ! FrmAppHelper::prevent_caching() ) {
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 			}
433 433
 		}
434 434
 
435
-        return stripslashes_deep($entries);
435
+        return stripslashes_deep( $entries );
436 436
     }
437 437
 
438 438
     // Pagination Methods
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
         global $wpdb;
441 441
 		$table_join = $wpdb->prefix . 'frm_items it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id';
442 442
 
443
-        if ( is_numeric($where) ) {
443
+        if ( is_numeric( $where ) ) {
444 444
             $table_join = 'frm_items';
445 445
             $where = array( 'form_id' => $where );
446 446
         }
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
 		self::sanitize_entry_post( $values );
483 483
 
484 484
 		if ( $type != 'xml' ) {
485
-			$values = apply_filters('frm_pre_create_entry', $values);
485
+			$values = apply_filters( 'frm_pre_create_entry', $values );
486 486
 		}
487 487
 
488 488
 		$new_values = self::package_entry_data( $values );
@@ -562,13 +562,13 @@  discard block
 block discarded – undo
562 562
 			'user_id' => self::get_entry_user_id( $values ),
563 563
 		);
564 564
 
565
-		$new_values['updated_by'] = isset($values['updated_by']) ? $values['updated_by'] : $new_values['user_id'];
565
+		$new_values['updated_by'] = isset( $values['updated_by'] ) ? $values['updated_by'] : $new_values['user_id'];
566 566
 
567 567
 		return $new_values;
568 568
 	}
569 569
 
570 570
 	private static function get_entry_value( $values, $name, $default ) {
571
-		return isset( $values[ $name ] ) ? $values[ $name ] : $default;
571
+		return isset( $values[$name] ) ? $values[$name] : $default;
572 572
 	}
573 573
 
574 574
 	/**
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
 		}
586 586
 
587 587
 		$ip = FrmAppHelper::get_ip_address();
588
-		if ( defined('WP_IMPORTING') && WP_IMPORTING ) {
588
+		if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
589 589
 			$ip = self::get_entry_value( $values, 'ip', $ip );
590 590
 		}
591 591
 		return $ip;
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
 	private static function add_new_entry_to_frm_vars( $entry_id ) {
699 699
 		global $frm_vars;
700 700
 
701
-		if ( ! isset($frm_vars['saved_entries']) ) {
701
+		if ( ! isset( $frm_vars['saved_entries'] ) ) {
702 702
 			$frm_vars['saved_entries'] = array();
703 703
 		}
704 704
 
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
 	* @param int $entry_id
714 714
 	*/
715 715
 	private static function maybe_add_entry_metas( $values, $entry_id ) {
716
-		if ( isset($values['item_meta']) ) {
716
+		if ( isset( $values['item_meta'] ) ) {
717 717
 			FrmEntryMeta::update_entry_metas( $entry_id, $values['item_meta'] );
718 718
 		}
719 719
 	}
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
 		}
772 772
 
773 773
 		if ( $update && $update_type != 'xml' ) {
774
-			$values = apply_filters('frm_pre_update_entry', $values, $id);
774
+			$values = apply_filters( 'frm_pre_update_entry', $values, $id );
775 775
 		}
776 776
 
777 777
 		return $update;
@@ -792,27 +792,27 @@  discard block
 block discarded – undo
792 792
 			'name'      => self::get_new_entry_name( $values ),
793 793
 			'form_id'   => (int) self::get_entry_value( $values, 'form_id', null ),
794 794
 			'is_draft'  => self::get_is_draft_value( $values ),
795
-			'updated_at' => current_time('mysql', 1),
796
-			'updated_by' => isset($values['updated_by']) ? $values['updated_by'] : get_current_user_id(),
795
+			'updated_at' => current_time( 'mysql', 1 ),
796
+			'updated_by' => isset( $values['updated_by'] ) ? $values['updated_by'] : get_current_user_id(),
797 797
 		);
798 798
 
799
-		if ( isset($values['post_id']) ) {
799
+		if ( isset( $values['post_id'] ) ) {
800 800
 			$new_values['post_id'] = (int) $values['post_id'];
801 801
 		}
802 802
 
803
-		if ( isset($values['item_key']) ) {
803
+		if ( isset( $values['item_key'] ) ) {
804 804
 			$new_values['item_key'] = FrmAppHelper::get_unique_key( $values['item_key'], $wpdb->prefix . 'frm_items', 'item_key', $id );
805 805
 		}
806 806
 
807
-		if ( isset($values['parent_item_id']) ) {
807
+		if ( isset( $values['parent_item_id'] ) ) {
808 808
 			$new_values['parent_item_id'] = (int) $values['parent_item_id'];
809 809
 		}
810 810
 
811
-		if ( isset($values['frm_user_id']) && is_numeric($values['frm_user_id']) ) {
811
+		if ( isset( $values['frm_user_id'] ) && is_numeric( $values['frm_user_id'] ) ) {
812 812
 			$new_values['user_id'] = $values['frm_user_id'];
813 813
 		}
814 814
 
815
-		$new_values = apply_filters('frm_update_entry', $new_values, $id);
815
+		$new_values = apply_filters( 'frm_update_entry', $new_values, $id );
816 816
 
817 817
 		return $new_values;
818 818
 	}
Please login to merge, or discard this patch.
classes/controllers/FrmAddonsController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -194,7 +194,7 @@
 block discarded – undo
194 194
 			}
195 195
 			$addon['link'] = FrmAppHelper::make_affiliate_url( $addon['link'] );
196 196
 
197
-			$addons[ $slug ] = $addon;
197
+			$addons[$slug] = $addon;
198 198
 		}
199 199
 	}
200 200
 
Please login to merge, or discard this patch.