Completed
Push — master ( 542ae8...a61647 )
by Jamie
03:33
created
classes/controllers/FrmAddonsController.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -3,11 +3,11 @@  discard block
 block discarded – undo
3 3
 class FrmAddonsController {
4 4
 
5 5
 	public static function menu() {
6
-		add_submenu_page( 'formidable', 'Formidable | '. __( 'AddOns', 'formidable' ), __( 'AddOns', 'formidable' ), 'frm_view_forms', 'formidable-addons', 'FrmAddonsController::list_addons' );
6
+		add_submenu_page( 'formidable', 'Formidable | ' . __( 'AddOns', 'formidable' ), __( 'AddOns', 'formidable' ), 'frm_view_forms', 'formidable-addons', 'FrmAddonsController::list_addons' );
7 7
 
8 8
 		$affiliate = FrmAppHelper::get_affiliate();
9 9
 		if ( ! empty( $affiliate ) && ! FrmAppHelper::pro_is_installed() ) {
10
-			add_submenu_page( 'formidable', 'Formidable | '. __( 'Upgrade to Pro', 'formidable' ), __( 'Upgrade to Pro', 'formidable' ), 'frm_view_forms', 'formidable-pro-upgrade', 'FrmAddonsController::upgrade_to_pro' );
10
+			add_submenu_page( 'formidable', 'Formidable | ' . __( 'Upgrade to Pro', 'formidable' ), __( 'Upgrade to Pro', 'formidable' ), 'frm_view_forms', 'formidable-pro-upgrade', 'FrmAddonsController::upgrade_to_pro' );
11 11
 		}
12 12
 	}
13 13
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 
40 40
 		$keyed_addons = array();
41 41
 		foreach ( $addons as $addon ) {
42
-			$keyed_addons[ $addon['info']['slug'] ] = $addon;
42
+			$keyed_addons[$addon['info']['slug']] = $addon;
43 43
 		}
44 44
 
45 45
 		$plugin_order = array(
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
 		);
49 49
 		$ordered_addons = array();
50 50
 		foreach ( $plugin_order as $plugin ) {
51
-			if ( isset( $keyed_addons[ $plugin ] ) ) {
52
-				$ordered_addons[] = $keyed_addons[ $plugin ];
53
-				unset( $keyed_addons[ $plugin ] );
51
+			if ( isset( $keyed_addons[$plugin] ) ) {
52
+				$ordered_addons[] = $keyed_addons[$plugin];
53
+				unset( $keyed_addons[$plugin] );
54 54
 			}
55 55
 		}
56 56
 		$addons = $ordered_addons + $keyed_addons;
@@ -85,12 +85,12 @@  discard block
 block discarded – undo
85 85
 	}
86 86
 
87 87
 	public static function get_licenses() {
88
-		FrmAppHelper::permission_check('frm_change_settings');
88
+		FrmAppHelper::permission_check( 'frm_change_settings' );
89 89
 		check_ajax_referer( 'frm_ajax', 'nonce' );
90 90
 
91
-		$license = get_option('frmpro-credentials');
91
+		$license = get_option( 'frmpro-credentials' );
92 92
 		if ( $license && is_array( $license ) && isset( $license['license'] ) ) {
93
-			$url = 'http://formidablepro.com/frm-edd-api/licenses?l='. urlencode( base64_encode( $license['license'] ) );
93
+			$url = 'http://formidablepro.com/frm-edd-api/licenses?l=' . urlencode( base64_encode( $license['license'] ) );
94 94
 			$licenses = self::send_api_request( $url, array( 'name' => 'frm_api_licence', 'expires' => 60 * 60 * 5 ) );
95 95
 			echo json_encode( $licenses );
96 96
 		}
Please login to merge, or discard this patch.
classes/controllers/FrmFormActionsController.php 2 patches
Indentation   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -1,109 +1,109 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class FrmFormActionsController {
4
-    public static $action_post_type = 'frm_form_actions';
5
-    public static $registered_actions;
6
-
7
-    public static function register_post_types() {
8
-        register_post_type( self::$action_post_type, array(
9
-            'label' => __( 'Form Actions', 'formidable' ),
10
-            'description' => '',
11
-            'public' => false,
12
-            'show_ui' => false,
13
-            'exclude_from_search' => true,
14
-            'show_in_nav_menus' => false,
15
-            'show_in_menu' => true,
16
-            'capability_type' => 'page',
17
-            'supports' => array(
4
+	public static $action_post_type = 'frm_form_actions';
5
+	public static $registered_actions;
6
+
7
+	public static function register_post_types() {
8
+		register_post_type( self::$action_post_type, array(
9
+			'label' => __( 'Form Actions', 'formidable' ),
10
+			'description' => '',
11
+			'public' => false,
12
+			'show_ui' => false,
13
+			'exclude_from_search' => true,
14
+			'show_in_nav_menus' => false,
15
+			'show_in_menu' => true,
16
+			'capability_type' => 'page',
17
+			'supports' => array(
18 18
 				'title', 'editor', 'excerpt', 'custom-fields',
19 19
 				'page-attributes',
20
-            ),
21
-            'has_archive' => false,
22
-        ) );
23
-
24
-        /**
25
-         * post_content: json settings
26
-         * menu_order: form id
27
-         * post_excerpt: action type
28
-         */
29
-
30
-        self::actions_init();
31
-    }
32
-
33
-    public static function actions_init() {
34
-        self::$registered_actions = new Frm_Form_Action_Factory();
35
-        self::register_actions();
36
-        do_action( 'frm_form_actions_init' );
37
-    }
38
-
39
-    public static function register_actions() {
40
-        $action_classes = apply_filters( 'frm_registered_form_actions', array(
41
-            'email'     => 'FrmEmailAction',
42
-            'wppost'    => 'FrmDefPostAction',
43
-            'register'  => 'FrmDefRegAction',
44
-            'paypal'    => 'FrmDefPayPalAction',
45
-            //'aweber'    => 'FrmDefAweberAction',
46
-            'mailchimp' => 'FrmDefMlcmpAction',
47
-            'twilio'    => 'FrmDefTwilioAction',
48
-            'highrise'  => 'FrmDefHrsAction',
49
-        ) );
50
-
51
-        include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php');
52
-        include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php');
53
-
54
-        foreach ( $action_classes as $action_class ) {
55
-            self::$registered_actions->register($action_class);
56
-        }
57
-    }
20
+			),
21
+			'has_archive' => false,
22
+		) );
23
+
24
+		/**
25
+		 * post_content: json settings
26
+		 * menu_order: form id
27
+		 * post_excerpt: action type
28
+		 */
29
+
30
+		self::actions_init();
31
+	}
32
+
33
+	public static function actions_init() {
34
+		self::$registered_actions = new Frm_Form_Action_Factory();
35
+		self::register_actions();
36
+		do_action( 'frm_form_actions_init' );
37
+	}
38
+
39
+	public static function register_actions() {
40
+		$action_classes = apply_filters( 'frm_registered_form_actions', array(
41
+			'email'     => 'FrmEmailAction',
42
+			'wppost'    => 'FrmDefPostAction',
43
+			'register'  => 'FrmDefRegAction',
44
+			'paypal'    => 'FrmDefPayPalAction',
45
+			//'aweber'    => 'FrmDefAweberAction',
46
+			'mailchimp' => 'FrmDefMlcmpAction',
47
+			'twilio'    => 'FrmDefTwilioAction',
48
+			'highrise'  => 'FrmDefHrsAction',
49
+		) );
50
+
51
+		include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php');
52
+		include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php');
53
+
54
+		foreach ( $action_classes as $action_class ) {
55
+			self::$registered_actions->register($action_class);
56
+		}
57
+	}
58 58
 
59 59
 	public static function get_form_actions( $action = 'all' ) {
60
-        $temp_actions = self::$registered_actions;
61
-        if ( empty($temp_actions) ) {
62
-            self::actions_init();
63
-            $temp_actions = self::$registered_actions->actions;
64
-        } else {
65
-            $temp_actions = $temp_actions->actions;
66
-        }
60
+		$temp_actions = self::$registered_actions;
61
+		if ( empty($temp_actions) ) {
62
+			self::actions_init();
63
+			$temp_actions = self::$registered_actions->actions;
64
+		} else {
65
+			$temp_actions = $temp_actions->actions;
66
+		}
67 67
 
68
-        $actions = array();
68
+		$actions = array();
69 69
 
70
-        foreach ( $temp_actions as $a ) {
71
-            if ( 'all' != $action && $a->id_base == $action ) {
72
-                return $a;
73
-            }
70
+		foreach ( $temp_actions as $a ) {
71
+			if ( 'all' != $action && $a->id_base == $action ) {
72
+				return $a;
73
+			}
74 74
 
75 75
 			$actions[ $a->id_base ] = $a;
76
-        }
77
-        unset( $temp_actions, $a );
78
-
79
-        $action_limit = 10;
80
-        if ( count( $actions ) <= $action_limit ) {
81
-            return $actions;
82
-        }
83
-
84
-        // remove the last few inactive icons if there are too many
85
-        $temp_actions = $actions;
86
-        arsort( $temp_actions );
87
-        foreach ( $temp_actions as $type => $a ) {
88
-            if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) {
76
+		}
77
+		unset( $temp_actions, $a );
78
+
79
+		$action_limit = 10;
80
+		if ( count( $actions ) <= $action_limit ) {
81
+			return $actions;
82
+		}
83
+
84
+		// remove the last few inactive icons if there are too many
85
+		$temp_actions = $actions;
86
+		arsort( $temp_actions );
87
+		foreach ( $temp_actions as $type => $a ) {
88
+			if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) {
89 89
 				unset( $actions[ $type ] );
90
-                if ( count( $actions ) <= $action_limit ) {
91
-                    break;
92
-                }
93
-            }
94
-            unset( $type, $a );
95
-        }
90
+				if ( count( $actions ) <= $action_limit ) {
91
+					break;
92
+				}
93
+			}
94
+			unset( $type, $a );
95
+		}
96 96
 
97
-        return $actions;
98
-    }
97
+		return $actions;
98
+	}
99 99
 
100 100
 	/**
101 101
 	 * @since 2.0
102 102
 	 */
103
-    public static function list_actions( $form, $values ) {
104
-        if ( empty( $form ) ) {
105
-            return;
106
-        }
103
+	public static function list_actions( $form, $values ) {
104
+		if ( empty( $form ) ) {
105
+			return;
106
+		}
107 107
 
108 108
 		/**
109 109
 		 * use this hook to migrate old settings into a new action
@@ -113,116 +113,116 @@  discard block
 block discarded – undo
113 113
 
114 114
 		$form_actions = FrmFormAction::get_action_for_form( $form->id );
115 115
 
116
-        $action_controls = self::get_form_actions();
116
+		$action_controls = self::get_form_actions();
117 117
 
118
-        $action_map = array();
118
+		$action_map = array();
119 119
 
120 120
 		foreach ( $action_controls as $key => $control ) {
121
-            $action_map[ $control->id_base ] = $key;
122
-        }
121
+			$action_map[ $control->id_base ] = $key;
122
+		}
123 123
 
124
-    	foreach ( $form_actions as $action ) {
125
-    	    if ( ! isset( $action_map[ $action->post_excerpt ] ) ) {
126
-    	        // don't try and show settings if action no longer exists
127
-    	        continue;
128
-    	    }
124
+		foreach ( $form_actions as $action ) {
125
+			if ( ! isset( $action_map[ $action->post_excerpt ] ) ) {
126
+				// don't try and show settings if action no longer exists
127
+				continue;
128
+			}
129 129
 
130
-    		self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values );
131
-    	}
132
-    }
130
+			self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values );
131
+		}
132
+	}
133 133
 
134 134
 	public static function action_control( $form_action, $form, $action_key, $action_control, $values ) {
135
-        $action_control->_set($action_key);
136
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php');
137
-    }
135
+		$action_control->_set($action_key);
136
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php');
137
+	}
138 138
 
139
-    public static function add_form_action() {
139
+	public static function add_form_action() {
140 140
 		FrmAppHelper::permission_check('frm_edit_forms');
141
-        check_ajax_referer( 'frm_ajax', 'nonce' );
141
+		check_ajax_referer( 'frm_ajax', 'nonce' );
142 142
 
143
-        global $frm_vars;
143
+		global $frm_vars;
144 144
 
145 145
 		$action_key = absint( $_POST['list_id'] );
146
-        $action_type = sanitize_text_field( $_POST['type'] );
146
+		$action_type = sanitize_text_field( $_POST['type'] );
147 147
 
148
-        $action_control = self::get_form_actions( $action_type );
149
-        $action_control->_set($action_key);
148
+		$action_control = self::get_form_actions( $action_type );
149
+		$action_control->_set($action_key);
150 150
 
151
-        $form_id = absint( $_POST['form_id'] );
151
+		$form_id = absint( $_POST['form_id'] );
152 152
 
153
-        $form_action = $action_control->prepare_new($form_id);
153
+		$form_action = $action_control->prepare_new($form_id);
154 154
 
155
-        $values = array();
156
-        $form = self::fields_to_values($form_id, $values);
155
+		$values = array();
156
+		$form = self::fields_to_values($form_id, $values);
157 157
 
158
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php');
159
-        wp_die();
160
-    }
158
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php');
159
+		wp_die();
160
+	}
161 161
 
162
-    public static function fill_action() {
162
+	public static function fill_action() {
163 163
 		FrmAppHelper::permission_check('frm_edit_forms');
164
-        check_ajax_referer( 'frm_ajax', 'nonce' );
164
+		check_ajax_referer( 'frm_ajax', 'nonce' );
165 165
 
166
-        $action_key = absint( $_POST['action_id'] );
167
-        $action_type = sanitize_text_field( $_POST['action_type'] );
166
+		$action_key = absint( $_POST['action_id'] );
167
+		$action_type = sanitize_text_field( $_POST['action_type'] );
168 168
 
169
-        $action_control = self::get_form_actions( $action_type );
170
-        if ( empty($action_control) ) {
171
-            wp_die();
172
-        }
169
+		$action_control = self::get_form_actions( $action_type );
170
+		if ( empty($action_control) ) {
171
+			wp_die();
172
+		}
173 173
 
174
-        $form_action = $action_control->get_single_action( $action_key );
174
+		$form_action = $action_control->get_single_action( $action_key );
175 175
 
176
-        $values = array();
177
-        $form = self::fields_to_values($form_action->menu_order, $values);
176
+		$values = array();
177
+		$form = self::fields_to_values($form_action->menu_order, $values);
178 178
 
179
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/_action_inside.php');
180
-        wp_die();
181
-    }
179
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/_action_inside.php');
180
+		wp_die();
181
+	}
182 182
 
183 183
 	private static function fields_to_values( $form_id, array &$values ) {
184
-        $form = FrmForm::getOne($form_id);
184
+		$form = FrmForm::getOne($form_id);
185 185
 
186 186
 		$values = array( 'fields' => array(), 'id' => $form->id );
187 187
 
188
-        $fields = FrmField::get_all_for_form($form->id);
189
-        foreach ( $fields as $k => $f ) {
190
-            $f = (array) $f;
191
-            $opts = (array) $f['field_options'];
192
-            $f = array_merge($opts, $f);
193
-            if ( ! isset( $f['post_field'] ) ) {
194
-                $f['post_field'] = '';
195
-            }
196
-            $values['fields'][] = $f;
197
-            unset($k, $f);
198
-        }
199
-
200
-        return $form;
201
-    }
188
+		$fields = FrmField::get_all_for_form($form->id);
189
+		foreach ( $fields as $k => $f ) {
190
+			$f = (array) $f;
191
+			$opts = (array) $f['field_options'];
192
+			$f = array_merge($opts, $f);
193
+			if ( ! isset( $f['post_field'] ) ) {
194
+				$f['post_field'] = '';
195
+			}
196
+			$values['fields'][] = $f;
197
+			unset($k, $f);
198
+		}
199
+
200
+		return $form;
201
+	}
202 202
 
203 203
 	public static function update_settings( $form_id ) {
204
-        global $wpdb;
204
+		global $wpdb;
205 205
 
206
-        $registered_actions = self::$registered_actions->actions;
206
+		$registered_actions = self::$registered_actions->actions;
207 207
 
208 208
 		$old_actions = FrmDb::get_col( $wpdb->posts, array( 'post_type' => self::$action_post_type, 'menu_order' => $form_id ), 'ID' );
209
-        $new_actions = array();
209
+		$new_actions = array();
210 210
 
211
-        foreach ( $registered_actions as $registered_action ) {
212
-            $action_ids = $registered_action->update_callback($form_id);
213
-            if ( ! empty( $action_ids ) ) {
214
-                $new_actions[] = $action_ids;
215
-            }
216
-        }
211
+		foreach ( $registered_actions as $registered_action ) {
212
+			$action_ids = $registered_action->update_callback($form_id);
213
+			if ( ! empty( $action_ids ) ) {
214
+				$new_actions[] = $action_ids;
215
+			}
216
+		}
217 217
 
218
-        //Only use array_merge if there are new actions
219
-        if ( ! empty( $new_actions ) ) {
220
-            $new_actions = call_user_func_array( 'array_merge', $new_actions );
221
-        }
222
-        $old_actions = array_diff( $old_actions, $new_actions );
218
+		//Only use array_merge if there are new actions
219
+		if ( ! empty( $new_actions ) ) {
220
+			$new_actions = call_user_func_array( 'array_merge', $new_actions );
221
+		}
222
+		$old_actions = array_diff( $old_actions, $new_actions );
223 223
 
224 224
 		self::delete_missing_actions( $old_actions );
225
-    }
225
+	}
226 226
 
227 227
 	public static function delete_missing_actions( $old_actions ) {
228 228
 		if ( ! empty( $old_actions ) ) {
@@ -237,36 +237,36 @@  discard block
 block discarded – undo
237 237
 		self::trigger_actions( 'create', $form_id, $entry_id, 'all', $args );
238 238
 	}
239 239
 
240
-    /**
241
-     * @param string $event
242
-     */
240
+	/**
241
+	 * @param string $event
242
+	 */
243 243
 	public static function trigger_actions( $event, $form, $entry, $type = 'all', $args = array() ) {
244 244
 		$form_actions = FrmFormAction::get_action_for_form( ( is_object( $form ) ? $form->id : $form ), $type );
245 245
 
246 246
 		if ( empty( $form_actions ) ) {
247
-            return;
248
-        }
247
+			return;
248
+		}
249 249
 
250 250
 		FrmForm::maybe_get_form( $form );
251 251
 
252
-        $link_settings = self::get_form_actions( $type );
253
-        if ( 'all' != $type ) {
254
-            $link_settings = array( $type => $link_settings );
255
-        }
252
+		$link_settings = self::get_form_actions( $type );
253
+		if ( 'all' != $type ) {
254
+			$link_settings = array( $type => $link_settings );
255
+		}
256 256
 
257
-        $stored_actions = $action_priority = array();
257
+		$stored_actions = $action_priority = array();
258 258
 
259 259
 		$importing = in_array( $event, array( 'create', 'update' ) ) && defined( 'WP_IMPORTING' ) && WP_IMPORTING;
260 260
 
261
-        foreach ( $form_actions as $action ) {
261
+		foreach ( $form_actions as $action ) {
262 262
 			$trigger_on_import = $importing && in_array( 'import', $action->post_content['event'] );
263 263
 			if ( ! in_array( $event, $action->post_content['event'] ) && ! $trigger_on_import ) {
264
-                continue;
265
-            }
264
+				continue;
265
+			}
266 266
 
267
-            if ( ! is_object( $entry ) ) {
268
-                $entry = FrmEntry::getOne( $entry, true );
269
-            }
267
+			if ( ! is_object( $entry ) ) {
268
+				$entry = FrmEntry::getOne( $entry, true );
269
+			}
270 270
 
271 271
 			if ( empty( $entry ) || $entry->is_draft ) {
272 272
 				continue;
@@ -275,66 +275,66 @@  discard block
 block discarded – undo
275 275
 			$child_entry = ( ( $form && is_numeric( $form->parent_form_id ) && $form->parent_form_id ) || ( $entry && ( $entry->form_id != $form->id || $entry->parent_item_id ) ) || ( isset( $args['is_child'] ) && $args['is_child'] ) );
276 276
 
277 277
 			if ( $child_entry ) {
278
-                //don't trigger actions for sub forms
279
-                continue;
280
-            }
278
+				//don't trigger actions for sub forms
279
+				continue;
280
+			}
281 281
 
282
-            // check conditional logic
282
+			// check conditional logic
283 283
 			$stop = FrmFormAction::action_conditions_met( $action, $entry );
284
-            if ( $stop ) {
285
-                continue;
286
-            }
284
+			if ( $stop ) {
285
+				continue;
286
+			}
287 287
 
288
-            // store actions so they can be triggered with the correct priority
289
-            $stored_actions[ $action->ID ] = $action;
290
-            $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority'];
288
+			// store actions so they can be triggered with the correct priority
289
+			$stored_actions[ $action->ID ] = $action;
290
+			$action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority'];
291 291
 
292
-            unset($action);
293
-        }
292
+			unset($action);
293
+		}
294 294
 
295
-        if ( ! empty( $stored_actions ) ) {
296
-            asort($action_priority);
295
+		if ( ! empty( $stored_actions ) ) {
296
+			asort($action_priority);
297 297
 
298
-            // make sure hooks are loaded
299
-            new FrmNotification();
298
+			// make sure hooks are loaded
299
+			new FrmNotification();
300 300
 
301
-            foreach ( $action_priority as $action_id => $priority ) {
302
-                $action = $stored_actions[ $action_id ];
303
-                do_action('frm_trigger_'. $action->post_excerpt .'_action', $action, $entry, $form, $event);
304
-                do_action('frm_trigger_'. $action->post_excerpt .'_'. $event .'_action', $action, $entry, $form);
301
+			foreach ( $action_priority as $action_id => $priority ) {
302
+				$action = $stored_actions[ $action_id ];
303
+				do_action('frm_trigger_'. $action->post_excerpt .'_action', $action, $entry, $form, $event);
304
+				do_action('frm_trigger_'. $action->post_excerpt .'_'. $event .'_action', $action, $entry, $form);
305 305
 
306
-                // If post is created, get updated $entry object
307
-                if ( $action->post_excerpt == 'wppost' && $event == 'create' ) {
308
-                    $entry = FrmEntry::getOne($entry->id, true);
309
-                }
310
-            }
311
-        }
312
-    }
306
+				// If post is created, get updated $entry object
307
+				if ( $action->post_excerpt == 'wppost' && $event == 'create' ) {
308
+					$entry = FrmEntry::getOne($entry->id, true);
309
+				}
310
+			}
311
+		}
312
+	}
313 313
 
314 314
 	public static function duplicate_form_actions( $form_id, $values, $args = array() ) {
315
-        if ( ! isset($args['old_id']) || empty($args['old_id']) ) {
316
-            // continue if we know which actions to copy
317
-            return;
318
-        }
315
+		if ( ! isset($args['old_id']) || empty($args['old_id']) ) {
316
+			// continue if we know which actions to copy
317
+			return;
318
+		}
319 319
 
320
-        $action_controls = self::get_form_actions( );
320
+		$action_controls = self::get_form_actions( );
321 321
 
322
-        foreach ( $action_controls as $action_control ) {
323
-            $action_control->duplicate_form_actions( $form_id, $args['old_id'] );
324
-            unset( $action_control );
325
-        }
326
-    }
322
+		foreach ( $action_controls as $action_control ) {
323
+			$action_control->duplicate_form_actions( $form_id, $args['old_id'] );
324
+			unset( $action_control );
325
+		}
326
+	}
327 327
 
328
-    public static function limit_by_type( $where ) {
329
-        global $frm_vars, $wpdb;
328
+	public static function limit_by_type( $where ) {
329
+		global $frm_vars, $wpdb;
330 330
 
331
-        if ( ! isset( $frm_vars['action_type'] ) ) {
332
-            return $where;
333
-        }
331
+		if ( ! isset( $frm_vars['action_type'] ) ) {
332
+			return $where;
333
+		}
334 334
 
335
-        $where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] );
336
-        return $where;
337
-    }
335
+		$where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] );
336
+		return $where;
337
+	}
338 338
 }
339 339
 
340 340
 
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 		foreach ( $keys as $key ) {
362 362
 			// don't register new action if old action with the same id is already registered
363 363
 			if ( ! isset( $this->actions[ $key ] ) ) {
364
-			    $this->actions[ $key ]->_register();
364
+				$this->actions[ $key ]->_register();
365 365
 			}
366 366
 		}
367 367
 	}
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -48,17 +48,17 @@  discard block
 block discarded – undo
48 48
             'highrise'  => 'FrmDefHrsAction',
49 49
         ) );
50 50
 
51
-        include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php');
52
-        include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php');
51
+        include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php' );
52
+        include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php' );
53 53
 
54 54
         foreach ( $action_classes as $action_class ) {
55
-            self::$registered_actions->register($action_class);
55
+            self::$registered_actions->register( $action_class );
56 56
         }
57 57
     }
58 58
 
59 59
 	public static function get_form_actions( $action = 'all' ) {
60 60
         $temp_actions = self::$registered_actions;
61
-        if ( empty($temp_actions) ) {
61
+        if ( empty( $temp_actions ) ) {
62 62
             self::actions_init();
63 63
             $temp_actions = self::$registered_actions->actions;
64 64
         } else {
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
                 return $a;
73 73
             }
74 74
 
75
-			$actions[ $a->id_base ] = $a;
75
+			$actions[$a->id_base] = $a;
76 76
         }
77 77
         unset( $temp_actions, $a );
78 78
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         arsort( $temp_actions );
87 87
         foreach ( $temp_actions as $type => $a ) {
88 88
             if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) {
89
-				unset( $actions[ $type ] );
89
+				unset( $actions[$type] );
90 90
                 if ( count( $actions ) <= $action_limit ) {
91 91
                     break;
92 92
                 }
@@ -118,26 +118,26 @@  discard block
 block discarded – undo
118 118
         $action_map = array();
119 119
 
120 120
 		foreach ( $action_controls as $key => $control ) {
121
-            $action_map[ $control->id_base ] = $key;
121
+            $action_map[$control->id_base] = $key;
122 122
         }
123 123
 
124 124
     	foreach ( $form_actions as $action ) {
125
-    	    if ( ! isset( $action_map[ $action->post_excerpt ] ) ) {
125
+    	    if ( ! isset( $action_map[$action->post_excerpt] ) ) {
126 126
     	        // don't try and show settings if action no longer exists
127 127
     	        continue;
128 128
     	    }
129 129
 
130
-    		self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values );
130
+    		self::action_control( $action, $form, $action->ID, $action_controls[$action_map[$action->post_excerpt]], $values );
131 131
     	}
132 132
     }
133 133
 
134 134
 	public static function action_control( $form_action, $form, $action_key, $action_control, $values ) {
135
-        $action_control->_set($action_key);
136
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php');
135
+        $action_control->_set( $action_key );
136
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' );
137 137
     }
138 138
 
139 139
     public static function add_form_action() {
140
-		FrmAppHelper::permission_check('frm_edit_forms');
140
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
141 141
         check_ajax_referer( 'frm_ajax', 'nonce' );
142 142
 
143 143
         global $frm_vars;
@@ -146,55 +146,55 @@  discard block
 block discarded – undo
146 146
         $action_type = sanitize_text_field( $_POST['type'] );
147 147
 
148 148
         $action_control = self::get_form_actions( $action_type );
149
-        $action_control->_set($action_key);
149
+        $action_control->_set( $action_key );
150 150
 
151 151
         $form_id = absint( $_POST['form_id'] );
152 152
 
153
-        $form_action = $action_control->prepare_new($form_id);
153
+        $form_action = $action_control->prepare_new( $form_id );
154 154
 
155 155
         $values = array();
156
-        $form = self::fields_to_values($form_id, $values);
156
+        $form = self::fields_to_values( $form_id, $values );
157 157
 
158
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php');
158
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' );
159 159
         wp_die();
160 160
     }
161 161
 
162 162
     public static function fill_action() {
163
-		FrmAppHelper::permission_check('frm_edit_forms');
163
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
164 164
         check_ajax_referer( 'frm_ajax', 'nonce' );
165 165
 
166 166
         $action_key = absint( $_POST['action_id'] );
167 167
         $action_type = sanitize_text_field( $_POST['action_type'] );
168 168
 
169 169
         $action_control = self::get_form_actions( $action_type );
170
-        if ( empty($action_control) ) {
170
+        if ( empty( $action_control ) ) {
171 171
             wp_die();
172 172
         }
173 173
 
174 174
         $form_action = $action_control->get_single_action( $action_key );
175 175
 
176 176
         $values = array();
177
-        $form = self::fields_to_values($form_action->menu_order, $values);
177
+        $form = self::fields_to_values( $form_action->menu_order, $values );
178 178
 
179
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/_action_inside.php');
179
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_inside.php' );
180 180
         wp_die();
181 181
     }
182 182
 
183 183
 	private static function fields_to_values( $form_id, array &$values ) {
184
-        $form = FrmForm::getOne($form_id);
184
+        $form = FrmForm::getOne( $form_id );
185 185
 
186 186
 		$values = array( 'fields' => array(), 'id' => $form->id );
187 187
 
188
-        $fields = FrmField::get_all_for_form($form->id);
188
+        $fields = FrmField::get_all_for_form( $form->id );
189 189
         foreach ( $fields as $k => $f ) {
190 190
             $f = (array) $f;
191 191
             $opts = (array) $f['field_options'];
192
-            $f = array_merge($opts, $f);
192
+            $f = array_merge( $opts, $f );
193 193
             if ( ! isset( $f['post_field'] ) ) {
194 194
                 $f['post_field'] = '';
195 195
             }
196 196
             $values['fields'][] = $f;
197
-            unset($k, $f);
197
+            unset( $k, $f );
198 198
         }
199 199
 
200 200
         return $form;
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
         $new_actions = array();
210 210
 
211 211
         foreach ( $registered_actions as $registered_action ) {
212
-            $action_ids = $registered_action->update_callback($form_id);
212
+            $action_ids = $registered_action->update_callback( $form_id );
213 213
             if ( ! empty( $action_ids ) ) {
214 214
                 $new_actions[] = $action_ids;
215 215
             }
@@ -286,33 +286,33 @@  discard block
 block discarded – undo
286 286
             }
287 287
 
288 288
             // store actions so they can be triggered with the correct priority
289
-            $stored_actions[ $action->ID ] = $action;
290
-            $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority'];
289
+            $stored_actions[$action->ID] = $action;
290
+            $action_priority[$action->ID] = $link_settings[$action->post_excerpt]->action_options['priority'];
291 291
 
292
-            unset($action);
292
+            unset( $action );
293 293
         }
294 294
 
295 295
         if ( ! empty( $stored_actions ) ) {
296
-            asort($action_priority);
296
+            asort( $action_priority );
297 297
 
298 298
             // make sure hooks are loaded
299 299
             new FrmNotification();
300 300
 
301 301
             foreach ( $action_priority as $action_id => $priority ) {
302
-                $action = $stored_actions[ $action_id ];
303
-                do_action('frm_trigger_'. $action->post_excerpt .'_action', $action, $entry, $form, $event);
304
-                do_action('frm_trigger_'. $action->post_excerpt .'_'. $event .'_action', $action, $entry, $form);
302
+                $action = $stored_actions[$action_id];
303
+                do_action( 'frm_trigger_' . $action->post_excerpt . '_action', $action, $entry, $form, $event );
304
+                do_action( 'frm_trigger_' . $action->post_excerpt . '_' . $event . '_action', $action, $entry, $form );
305 305
 
306 306
                 // If post is created, get updated $entry object
307 307
                 if ( $action->post_excerpt == 'wppost' && $event == 'create' ) {
308
-                    $entry = FrmEntry::getOne($entry->id, true);
308
+                    $entry = FrmEntry::getOne( $entry->id, true );
309 309
                 }
310 310
             }
311 311
         }
312 312
     }
313 313
 
314 314
 	public static function duplicate_form_actions( $form_id, $values, $args = array() ) {
315
-        if ( ! isset($args['old_id']) || empty($args['old_id']) ) {
315
+        if ( ! isset( $args['old_id'] ) || empty( $args['old_id'] ) ) {
316 316
             // continue if we know which actions to copy
317 317
             return;
318 318
         }
@@ -346,22 +346,22 @@  discard block
 block discarded – undo
346 346
 	}
347 347
 
348 348
 	public function register( $action_class ) {
349
-		$this->actions[ $action_class ] = new $action_class();
349
+		$this->actions[$action_class] = new $action_class();
350 350
 	}
351 351
 
352 352
 	public function unregister( $action_class ) {
353
-		if ( isset( $this->actions[ $action_class ] ) ) {
354
-			unset($this->actions[ $action_class ]);
353
+		if ( isset( $this->actions[$action_class] ) ) {
354
+			unset( $this->actions[$action_class] );
355 355
 		}
356 356
 	}
357 357
 
358 358
 	public function _register_actions() {
359
-		$keys = array_keys($this->actions);
359
+		$keys = array_keys( $this->actions );
360 360
 
361 361
 		foreach ( $keys as $key ) {
362 362
 			// don't register new action if old action with the same id is already registered
363
-			if ( ! isset( $this->actions[ $key ] ) ) {
364
-			    $this->actions[ $key ]->_register();
363
+			if ( ! isset( $this->actions[$key] ) ) {
364
+			    $this->actions[$key]->_register();
365 365
 			}
366 366
 		}
367 367
 	}
Please login to merge, or discard this patch.
classes/controllers/FrmAppController.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 			$tip = FrmTipsHelper::get_banner_tip();
134 134
 ?>
135 135
 <div class="update-nag frm-update-to-pro">
136
-	<?php echo FrmAppHelper::kses( $tip['tip'] ) ?> <span><?php echo FrmAppHelper::kses( $tip['call'] ) ?></span> <a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidablepro.com?banner=1&tip='. absint( $tip['num'] ) ) ) ?>" class="button">Upgrade to Pro</a>
136
+	<?php echo FrmAppHelper::kses( $tip['tip'] ) ?> <span><?php echo FrmAppHelper::kses( $tip['call'] ) ?></span> <a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidablepro.com?banner=1&tip=' . absint( $tip['num'] ) ) ) ?>" class="button">Upgrade to Pro</a>
137 137
 </div>
138 138
 <?php
139 139
 		}
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
     }
382 382
 
383 383
     public static function uninstall() {
384
-		FrmAppHelper::permission_check('administrator');
384
+		FrmAppHelper::permission_check( 'administrator' );
385 385
         check_ajax_referer( 'frm_ajax', 'nonce' );
386 386
 
387 387
 		$frmdb = new FrmDb();
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
     }
417 417
 
418 418
     public static function deauthorize() {
419
-		FrmAppHelper::permission_check('frm_change_settings');
419
+		FrmAppHelper::permission_check( 'frm_change_settings' );
420 420
         check_ajax_referer( 'frm_ajax', 'nonce' );
421 421
 
422 422
         delete_option( 'frmpro-credentials' );
Please login to merge, or discard this patch.
Indentation   +154 added lines, -154 removed lines patch added patch discarded remove patch
@@ -3,14 +3,14 @@  discard block
 block discarded – undo
3 3
 class FrmAppController {
4 4
 
5 5
 	public static function menu() {
6
-        FrmAppHelper::maybe_add_permissions();
7
-        if ( ! current_user_can( 'frm_view_forms' ) ) {
8
-            return;
9
-        }
6
+		FrmAppHelper::maybe_add_permissions();
7
+		if ( ! current_user_can( 'frm_view_forms' ) ) {
8
+			return;
9
+		}
10 10
 
11 11
 		$menu_name = FrmAppHelper::get_menu_name();
12 12
 		add_menu_page( 'Formidable', $menu_name, 'frm_view_forms', 'formidable', 'FrmFormsController::route', FrmAppHelper::plugin_url() . '/images/form_16.png', self::get_menu_position() );
13
-    }
13
+	}
14 14
 
15 15
 	private static function get_menu_position() {
16 16
 		$count = count( get_post_types( array( 'show_ui' => true, '_builtin' => false, 'show_in_menu' => true ) ) );
@@ -19,39 +19,39 @@  discard block
 block discarded – undo
19 19
 		return $pos;
20 20
 	}
21 21
 
22
-    public static function load_wp_admin_style() {
23
-        FrmAppHelper::load_font_style();
24
-    }
22
+	public static function load_wp_admin_style() {
23
+		FrmAppHelper::load_font_style();
24
+	}
25 25
 
26 26
 	public static function get_form_nav( $form, $show_nav = false, $title = 'show' ) {
27
-        global $pagenow, $frm_vars;
27
+		global $pagenow, $frm_vars;
28 28
 
29 29
 		$show_nav = FrmAppHelper::get_param( 'show_nav', $show_nav, 'get', 'absint' );
30
-        if ( empty( $show_nav ) ) {
31
-            return;
32
-        }
30
+		if ( empty( $show_nav ) ) {
31
+			return;
32
+		}
33 33
 
34 34
 		$current_page = isset( $_GET['page'] ) ? FrmAppHelper::simple_get( 'page', 'sanitize_title' ) : FrmAppHelper::simple_get( 'post_type', 'sanitize_title', 'None' );
35 35
 		if ( $pagenow == 'post.php' || $pagenow == 'post-new.php' ) {
36 36
 			$current_page = 'frm_display';
37 37
 		}
38 38
 
39
-        if ( $form ) {
39
+		if ( $form ) {
40 40
 			FrmForm::maybe_get_form( $form );
41 41
 
42
-            if ( is_object( $form ) ) {
43
-                $id = $form->id;
44
-            }
45
-        }
42
+			if ( is_object( $form ) ) {
43
+				$id = $form->id;
44
+			}
45
+		}
46 46
 
47
-        if ( ! isset( $id ) ) {
48
-            $form = $id = false;
49
-        }
47
+		if ( ! isset( $id ) ) {
48
+			$form = $id = false;
49
+		}
50 50
 
51 51
 		$nav_items = self::get_form_nav_items( $id );
52 52
 
53
-        include( FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php' );
54
-    }
53
+		include( FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php' );
54
+	}
55 55
 
56 56
 	private static function get_form_nav_items( $id ) {
57 57
 		$nav_items = array(
@@ -82,28 +82,28 @@  discard block
 block discarded – undo
82 82
 		return $nav_items;
83 83
 	}
84 84
 
85
-    // Adds a settings link to the plugins page
86
-    public static function settings_link( $links ) {
85
+	// Adds a settings link to the plugins page
86
+	public static function settings_link( $links ) {
87 87
 		$settings = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-settings' ) ) . '">' . __( 'Settings', 'formidable' ) . '</a>';
88
-        array_unshift( $links, $settings );
88
+		array_unshift( $links, $settings );
89 89
 
90
-        return $links;
91
-    }
90
+		return $links;
91
+	}
92 92
 
93
-    public static function pro_get_started_headline() {
93
+	public static function pro_get_started_headline() {
94 94
 		self::maybe_show_upgrade_bar();
95 95
 
96
-        // Don't display this error as we're upgrading the thing, or if the user shouldn't see the message
97
-        if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) {
98
-            return;
99
-        }
96
+		// Don't display this error as we're upgrading the thing, or if the user shouldn't see the message
97
+		if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) {
98
+			return;
99
+		}
100 100
 
101 101
 		if ( get_site_option( 'frmpro-authorized' ) && ! file_exists( FrmAppHelper::plugin_path() . '/pro/formidable-pro.php' ) ) {
102
-            FrmAppHelper::load_admin_wide_js();
102
+			FrmAppHelper::load_admin_wide_js();
103 103
 
104
-            // user is authorized, but running free version
105
-            $inst_install_url = 'https://formidablepro.com/knowledgebase/install-formidable-forms/';
106
-        ?>
104
+			// user is authorized, but running free version
105
+			$inst_install_url = 'https://formidablepro.com/knowledgebase/install-formidable-forms/';
106
+		?>
107 107
 <div class="error" class="frm_previous_install">
108 108
 		<?php
109 109
 		echo wp_kses_post( apply_filters( 'frm_pro_update_msg',
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
 		) ); ?>
116 116
 </div>
117 117
 <?php
118
-        }
119
-    }
118
+		}
119
+	}
120 120
 
121 121
 	private static function maybe_show_upgrade_bar() {
122 122
 		$page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 		}
217 217
 	}
218 218
 
219
-    public static function admin_js() {
219
+	public static function admin_js() {
220 220
 		$version = FrmAppHelper::plugin_version();
221 221
 		FrmAppHelper::load_admin_wide_js( false );
222 222
 
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 			'bootstrap_tooltip', 'bootstrap-multiselect',
228 228
 		), $version, true );
229 229
 		wp_register_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css', array(), $version );
230
-        wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' );
230
+		wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' );
231 231
 
232 232
 		// load multselect js
233 233
 		wp_register_script( 'bootstrap-multiselect', FrmAppHelper::plugin_url() . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip' ), '0.9.8', true );
@@ -238,79 +238,79 @@  discard block
 block discarded – undo
238 238
 		global $pagenow;
239 239
 		if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow == 'edit.php' && $post_type == 'frm_display' ) ) {
240 240
 
241
-            wp_enqueue_script( 'admin-widgets' );
242
-            wp_enqueue_style( 'widgets' );
243
-            wp_enqueue_script( 'formidable' );
244
-            wp_enqueue_script( 'formidable_admin' );
241
+			wp_enqueue_script( 'admin-widgets' );
242
+			wp_enqueue_style( 'widgets' );
243
+			wp_enqueue_script( 'formidable' );
244
+			wp_enqueue_script( 'formidable_admin' );
245 245
 			FrmAppHelper::localize_script( 'admin' );
246 246
 
247
-            wp_enqueue_style( 'formidable-admin' );
247
+			wp_enqueue_style( 'formidable-admin' );
248 248
 			FrmStylesController::enqueue_css( 'admin' );
249
-            add_thickbox();
249
+			add_thickbox();
250 250
 
251
-            wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' );
251
+			wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' );
252 252
 
253
-        } else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) {
254
-            if ( isset( $_REQUEST['post_type'] ) ) {
255
-                $post_type = sanitize_title( $_REQUEST['post_type'] );
253
+		} else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) {
254
+			if ( isset( $_REQUEST['post_type'] ) ) {
255
+				$post_type = sanitize_title( $_REQUEST['post_type'] );
256 256
 			} else if ( isset( $_REQUEST['post'] ) && absint( $_REQUEST['post'] ) ) {
257 257
 				$post = get_post( absint( $_REQUEST['post'] ) );
258
-                if ( ! $post ) {
259
-                    return;
260
-                }
261
-                $post_type = $post->post_type;
262
-            } else {
263
-                return;
264
-            }
265
-
266
-            if ( $post_type == 'frm_display' ) {
267
-                wp_enqueue_script( 'jquery-ui-draggable' );
268
-                wp_enqueue_script( 'formidable_admin' );
269
-                wp_enqueue_style( 'formidable-admin' );
258
+				if ( ! $post ) {
259
+					return;
260
+				}
261
+				$post_type = $post->post_type;
262
+			} else {
263
+				return;
264
+			}
265
+
266
+			if ( $post_type == 'frm_display' ) {
267
+				wp_enqueue_script( 'jquery-ui-draggable' );
268
+				wp_enqueue_script( 'formidable_admin' );
269
+				wp_enqueue_style( 'formidable-admin' );
270 270
 				FrmAppHelper::localize_script( 'admin' );
271
-            }
272
-        } else if ( $pagenow == 'widgets.php' ) {
273
-            FrmAppHelper::load_admin_wide_js();
274
-        }
275
-    }
276
-
277
-    public static function wp_admin_body_class( $classes ) {
278
-        global $wp_version;
279
-        //we need this class everywhere in the admin for the menu
280
-        if ( version_compare( $wp_version, '3.7.2', '>' ) ) {
281
-            $classes .= ' frm_38_trigger';
282
-        }
283
-
284
-        return $classes;
285
-    }
286
-
287
-    public static function load_lang() {
288
-        load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' );
289
-    }
290
-
291
-    /**
292
-     * Filter shortcodes in text widgets
293
-     */
294
-    public static function widget_text_filter( $content ) {
295
-    	$regex = '/\[\s*(formidable|display-frm-data|frm-stats|frm-graph|frm-entry-links|formresults|frm-search)\s+.*\]/';
296
-    	return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content );
297
-    }
298
-
299
-    public static function widget_text_filter_callback( $matches ) {
300
-        _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::widget_text_filter_callback' );
301
-        return FrmAppHelper::widget_text_filter_callback( $matches );
302
-    }
303
-
304
-    public static function front_head() {
305
-        if ( is_multisite() ) {
306
-            $old_db_version = get_option( 'frm_db_version' );
307
-            $pro_db_version = FrmAppHelper::pro_is_installed() ? get_option( 'frmpro_db_version' ) : false;
308
-            if ( ( (int) $old_db_version < (int) FrmAppHelper::$db_version ) ||
309
-                ( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) {
310
-                self::install( $old_db_version );
311
-            }
312
-        }
313
-    }
271
+			}
272
+		} else if ( $pagenow == 'widgets.php' ) {
273
+			FrmAppHelper::load_admin_wide_js();
274
+		}
275
+	}
276
+
277
+	public static function wp_admin_body_class( $classes ) {
278
+		global $wp_version;
279
+		//we need this class everywhere in the admin for the menu
280
+		if ( version_compare( $wp_version, '3.7.2', '>' ) ) {
281
+			$classes .= ' frm_38_trigger';
282
+		}
283
+
284
+		return $classes;
285
+	}
286
+
287
+	public static function load_lang() {
288
+		load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' );
289
+	}
290
+
291
+	/**
292
+	 * Filter shortcodes in text widgets
293
+	 */
294
+	public static function widget_text_filter( $content ) {
295
+		$regex = '/\[\s*(formidable|display-frm-data|frm-stats|frm-graph|frm-entry-links|formresults|frm-search)\s+.*\]/';
296
+		return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content );
297
+	}
298
+
299
+	public static function widget_text_filter_callback( $matches ) {
300
+		_deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::widget_text_filter_callback' );
301
+		return FrmAppHelper::widget_text_filter_callback( $matches );
302
+	}
303
+
304
+	public static function front_head() {
305
+		if ( is_multisite() ) {
306
+			$old_db_version = get_option( 'frm_db_version' );
307
+			$pro_db_version = FrmAppHelper::pro_is_installed() ? get_option( 'frmpro_db_version' ) : false;
308
+			if ( ( (int) $old_db_version < (int) FrmAppHelper::$db_version ) ||
309
+				( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) {
310
+				self::install( $old_db_version );
311
+			}
312
+		}
313
+	}
314 314
 
315 315
 	public static function localize_script( $location ) {
316 316
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmAppHelper::localize_script' );
@@ -370,20 +370,20 @@  discard block
 block discarded – undo
370 370
 		wp_die();
371 371
 	}
372 372
 
373
-    public static function activation_install() {
374
-        FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' );
375
-        FrmFormActionsController::actions_init();
376
-        self::install();
377
-    }
373
+	public static function activation_install() {
374
+		FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' );
375
+		FrmFormActionsController::actions_init();
376
+		self::install();
377
+	}
378 378
 
379
-    public static function install( $old_db_version = false ) {
380
-        $frmdb = new FrmDb();
381
-        $frmdb->upgrade( $old_db_version );
382
-    }
379
+	public static function install( $old_db_version = false ) {
380
+		$frmdb = new FrmDb();
381
+		$frmdb->upgrade( $old_db_version );
382
+	}
383 383
 
384
-    public static function uninstall() {
384
+	public static function uninstall() {
385 385
 		FrmAppHelper::permission_check('administrator');
386
-        check_ajax_referer( 'frm_ajax', 'nonce' );
386
+		check_ajax_referer( 'frm_ajax', 'nonce' );
387 387
 
388 388
 		$frmdb = new FrmDb();
389 389
 		$frmdb->uninstall();
@@ -392,48 +392,48 @@  discard block
 block discarded – undo
392 392
 		deactivate_plugins( FrmAppHelper::plugin_folder() . '/formidable.php', false, false );
393 393
 		echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) );
394 394
 
395
-        wp_die();
396
-    }
395
+		wp_die();
396
+	}
397 397
 
398
-    public static function drop_tables( $tables ) {
399
-        global $wpdb;
400
-        $tables[] = $wpdb->prefix . 'frm_fields';
401
-        $tables[] = $wpdb->prefix . 'frm_forms';
402
-        $tables[] = $wpdb->prefix . 'frm_items';
403
-        $tables[] = $wpdb->prefix . 'frm_item_metas';
404
-        return $tables;
405
-    }
398
+	public static function drop_tables( $tables ) {
399
+		global $wpdb;
400
+		$tables[] = $wpdb->prefix . 'frm_fields';
401
+		$tables[] = $wpdb->prefix . 'frm_forms';
402
+		$tables[] = $wpdb->prefix . 'frm_items';
403
+		$tables[] = $wpdb->prefix . 'frm_item_metas';
404
+		return $tables;
405
+	}
406 406
 
407
-    // Routes for wordpress pages -- we're just replacing content here folks.
408
-    public static function page_route( $content ) {
409
-        global $post;
407
+	// Routes for wordpress pages -- we're just replacing content here folks.
408
+	public static function page_route( $content ) {
409
+		global $post;
410 410
 
411
-        $frm_settings = FrmAppHelper::get_settings();
412
-        if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) {
413
-            $content = FrmFormsController::page_preview();
414
-        }
411
+		$frm_settings = FrmAppHelper::get_settings();
412
+		if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) {
413
+			$content = FrmFormsController::page_preview();
414
+		}
415 415
 
416
-        return $content;
417
-    }
416
+		return $content;
417
+	}
418 418
 
419
-    public static function deauthorize() {
419
+	public static function deauthorize() {
420 420
 		FrmAppHelper::permission_check('frm_change_settings');
421
-        check_ajax_referer( 'frm_ajax', 'nonce' );
422
-
423
-        delete_option( 'frmpro-credentials' );
424
-        delete_option( 'frmpro-authorized' );
425
-        delete_site_option( 'frmpro-credentials' );
426
-        delete_site_option( 'frmpro-authorized' );
427
-        wp_die();
428
-    }
429
-
430
-    public static function get_form_shortcode( $atts ) {
431
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' );
432
-        return FrmFormsController::get_form_shortcode( $atts );
433
-    }
434
-
435
-    public static function get_postbox_class() {
436
-        _deprecated_function( __FUNCTION__, '2.0' );
437
-        return 'postbox-container';
438
-    }
421
+		check_ajax_referer( 'frm_ajax', 'nonce' );
422
+
423
+		delete_option( 'frmpro-credentials' );
424
+		delete_option( 'frmpro-authorized' );
425
+		delete_site_option( 'frmpro-credentials' );
426
+		delete_site_option( 'frmpro-authorized' );
427
+		wp_die();
428
+	}
429
+
430
+	public static function get_form_shortcode( $atts ) {
431
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' );
432
+		return FrmFormsController::get_form_shortcode( $atts );
433
+	}
434
+
435
+	public static function get_postbox_class() {
436
+		_deprecated_function( __FUNCTION__, '2.0' );
437
+		return 'postbox-container';
438
+	}
439 439
 }
Please login to merge, or discard this patch.
classes/helpers/FrmTipsHelper.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -181,13 +181,13 @@
 block discarded – undo
181 181
 			),
182 182
 		);
183 183
 		$random = rand( 0, count( $tips ) - 1 );
184
-		$tip = $tips[ $random ];
184
+		$tip = $tips[$random];
185 185
 		$tip['num'] = $random;
186 186
 		return $tip;
187 187
 	}
188 188
 
189 189
 	public static function get_random_tip( $tips ) {
190 190
 		$random = rand( 0, count( $tips ) - 1 );
191
-		return $tips[ $random ];
191
+		return $tips[$random];
192 192
 	}
193 193
 }
Please login to merge, or discard this patch.
classes/controllers/FrmEntriesController.php 2 patches
Indentation   +352 added lines, -352 removed lines patch added patch discarded remove patch
@@ -2,201 +2,201 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmEntriesController {
4 4
 
5
-    public static function menu() {
5
+	public static function menu() {
6 6
 		FrmAppHelper::force_capability( 'frm_view_entries' );
7 7
 
8
-        add_submenu_page('formidable', 'Formidable | '. __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
8
+		add_submenu_page('formidable', 'Formidable | '. __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
9 9
 
10 10
 		if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) {
11 11
 			$menu_name = FrmAppHelper::get_menu_name();
12 12
 			add_filter( 'manage_' . sanitize_title( $menu_name ) . '_page_formidable-entries_columns', 'FrmEntriesController::manage_columns' );
13 13
 			add_filter( 'get_user_option_manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden', 'FrmEntriesController::hidden_columns' );
14 14
 			add_filter( 'manage_' . sanitize_title( $menu_name ) . '_page_formidable-entries_sortable_columns', 'FrmEntriesController::sortable_columns' );
15
-        }
16
-    }
15
+		}
16
+	}
17 17
 
18
-    /* Display in Back End */
19
-    public static function route() {
18
+	/* Display in Back End */
19
+	public static function route() {
20 20
 		$action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' );
21 21
 
22
-        switch ( $action ) {
23
-            case 'show':
24
-            case 'destroy':
25
-            case 'destroy_all':
26
-                return self::$action();
22
+		switch ( $action ) {
23
+			case 'show':
24
+			case 'destroy':
25
+			case 'destroy_all':
26
+				return self::$action();
27 27
 
28
-            default:
29
-                do_action( 'frm_entry_action_route', $action );
30
-                if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) {
31
-                    return;
32
-                }
28
+			default:
29
+				do_action( 'frm_entry_action_route', $action );
30
+				if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) {
31
+					return;
32
+				}
33 33
 
34
-                return self::display_list();
35
-        }
36
-    }
34
+				return self::display_list();
35
+		}
36
+	}
37 37
 
38 38
 	public static function contextual_help( $help, $screen_id, $screen ) {
39
-        // Only add to certain screens. add_help_tab was introduced in WordPress 3.3
40
-        if ( ! method_exists( $screen, 'add_help_tab' ) ) {
41
-            return $help;
42
-        }
39
+		// Only add to certain screens. add_help_tab was introduced in WordPress 3.3
40
+		if ( ! method_exists( $screen, 'add_help_tab' ) ) {
41
+			return $help;
42
+		}
43 43
 
44 44
 		$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
45 45
 		$page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
46 46
 		if ( $page != 'formidable-entries' || ( ! empty( $action ) && $action != 'list' ) ) {
47
-            return $help;
48
-        }
47
+			return $help;
48
+		}
49 49
 
50 50
 		unset( $action, $page );
51 51
 
52
-        $screen->add_help_tab( array(
53
-            'id'      => 'formidable-entries-tab',
54
-            'title'   => __( 'Overview', 'formidable' ),
52
+		$screen->add_help_tab( array(
53
+			'id'      => 'formidable-entries-tab',
54
+			'title'   => __( 'Overview', 'formidable' ),
55 55
 			'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) .'</p> <p>'. esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>',
56
-        ));
56
+		));
57 57
 
58
-        $screen->set_help_sidebar(
58
+		$screen->set_help_sidebar(
59 59
 			'<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' .
60 60
 			'<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'http://formidablepro.com/knowledgebase/manage-entries-from-the-back-end/' ) ) . '" target="_blank">' . esc_html__( 'Documentation on Entries', 'formidable' ) . '</a></p>' .
61 61
 			'<p><a href="'. esc_url( FrmAppHelper::make_affiliate_url( 'http://formidablepro.com/help-desk/' ) ) . '" target="_blank">' . esc_html__( 'Support', 'formidable' ) . '</a></p>'
62
-    	);
62
+		);
63 63
 
64
-        return $help;
65
-    }
64
+		return $help;
65
+	}
66 66
 
67 67
 	public static function manage_columns( $columns ) {
68
-        global $frm_vars, $wpdb;
68
+		global $frm_vars, $wpdb;
69 69
 		$form_id = FrmForm::get_current_form_id();
70 70
 
71
-        $columns[ $form_id .'_id' ] = 'ID';
71
+		$columns[ $form_id .'_id' ] = 'ID';
72 72
 		$columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' );
73 73
 
74
-        if ( ! $form_id ) {
75
-            return $columns;
76
-        }
74
+		if ( ! $form_id ) {
75
+			return $columns;
76
+		}
77 77
 
78
-        $form_cols = FrmField::get_all_for_form($form_id, '', 'include');
78
+		$form_cols = FrmField::get_all_for_form($form_id, '', 'include');
79 79
 
80
-        foreach ( $form_cols as $form_col ) {
80
+		foreach ( $form_cols as $form_col ) {
81 81
 			if ( FrmField::is_no_save_field( $form_col->type ) ) {
82
-                continue;
83
-            }
82
+				continue;
83
+			}
84 84
 
85
-            if ( $form_col->type == 'form' && isset( $form_col->field_options['form_select'] ) && ! empty( $form_col->field_options['form_select'] ) ) {
85
+			if ( $form_col->type == 'form' && isset( $form_col->field_options['form_select'] ) && ! empty( $form_col->field_options['form_select'] ) ) {
86 86
 				$sub_form_cols = FrmField::get_all_for_form( $form_col->field_options['form_select'] );
87 87
 
88
-                if ( $sub_form_cols ) {
89
-                    foreach ( $sub_form_cols as $k => $sub_form_col ) {
88
+				if ( $sub_form_cols ) {
89
+					foreach ( $sub_form_cols as $k => $sub_form_col ) {
90 90
 						if ( FrmField::is_no_save_field( $sub_form_col->type ) ) {
91
-                            unset( $sub_form_cols[ $k ] );
92
-                            continue;
93
-                        }
91
+							unset( $sub_form_cols[ $k ] );
92
+							continue;
93
+						}
94 94
 						$columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
95
-                        unset($sub_form_col);
96
-                    }
97
-                }
98
-                unset($sub_form_cols);
99
-            } else {
100
-                $col_id = $form_col->field_key;
101
-                if ( $form_col->form_id != $form_id ) {
102
-                    $col_id .= '-_-form'. $form_col->form_id;
103
-                }
104
-
105
-                if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) {
106
-                    $columns[ $form_id .'_frmsep_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
107
-                }
108
-                $columns[ $form_id .'_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
109
-            }
110
-        }
111
-
112
-        $columns[ $form_id .'_created_at' ] = __( 'Entry creation date', 'formidable' );
113
-        $columns[ $form_id .'_updated_at' ] = __( 'Entry update date', 'formidable' );
114
-        $columns[ $form_id .'_ip' ] = 'IP';
115
-
116
-        $frm_vars['cols'] = $columns;
95
+						unset($sub_form_col);
96
+					}
97
+				}
98
+				unset($sub_form_cols);
99
+			} else {
100
+				$col_id = $form_col->field_key;
101
+				if ( $form_col->form_id != $form_id ) {
102
+					$col_id .= '-_-form'. $form_col->form_id;
103
+				}
104
+
105
+				if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) {
106
+					$columns[ $form_id .'_frmsep_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
107
+				}
108
+				$columns[ $form_id .'_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
109
+			}
110
+		}
111
+
112
+		$columns[ $form_id .'_created_at' ] = __( 'Entry creation date', 'formidable' );
113
+		$columns[ $form_id .'_updated_at' ] = __( 'Entry update date', 'formidable' );
114
+		$columns[ $form_id .'_ip' ] = 'IP';
115
+
116
+		$frm_vars['cols'] = $columns;
117 117
 
118 118
 		$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
119 119
 		if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ) ) ) {
120 120
 			add_screen_option( 'per_page', array( 'label' => __( 'Entries', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_entries_per_page' ) );
121
-        }
121
+		}
122 122
 
123
-        return $columns;
124
-    }
123
+		return $columns;
124
+	}
125 125
 
126 126
 	public static function check_hidden_cols( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
127 127
 		$menu_name = FrmAppHelper::get_menu_name();
128 128
 		$this_page_name = 'manage' .  sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden';
129 129
 		if ( $meta_key != $this_page_name || $meta_value == $prev_value ) {
130
-            return $check;
131
-        }
130
+			return $check;
131
+		}
132 132
 
133 133
 		if ( empty( $prev_value ) ) {
134 134
 			$prev_value = get_metadata( 'user', $object_id, $meta_key, true );
135 135
 		}
136 136
 
137
-        global $frm_vars;
138
-        //add a check so we don't create a loop
139
-        $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
137
+		global $frm_vars;
138
+		//add a check so we don't create a loop
139
+		$frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
140 140
 
141
-        return $check;
142
-    }
141
+		return $check;
142
+	}
143 143
 
144
-    //add hidden columns back from other forms
144
+	//add hidden columns back from other forms
145 145
 	public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) {
146 146
 		$menu_name = FrmAppHelper::get_menu_name();
147 147
 		$sanitized = sanitize_title( $menu_name );
148 148
 		$this_page_name = 'manage'.  $sanitized .'_page_formidable-entriescolumnshidden';
149 149
 		if ( $meta_key != $this_page_name ) {
150
-            return;
151
-        }
152
-
153
-        global $frm_vars;
154
-        if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
155
-            return; //don't continue if there's no previous value
156
-        }
157
-
158
-        foreach ( $meta_value as $mk => $mv ) {
159
-            //remove blank values
160
-            if ( empty( $mv )  ) {
161
-                unset( $meta_value[ $mk ] );
162
-            }
163
-        }
164
-
165
-        $cur_form_prefix = reset($meta_value);
166
-        $cur_form_prefix = explode('_', $cur_form_prefix);
167
-        $cur_form_prefix = $cur_form_prefix[0];
168
-        $save = false;
169
-
170
-        foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) {
150
+			return;
151
+		}
152
+
153
+		global $frm_vars;
154
+		if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
155
+			return; //don't continue if there's no previous value
156
+		}
157
+
158
+		foreach ( $meta_value as $mk => $mv ) {
159
+			//remove blank values
160
+			if ( empty( $mv )  ) {
161
+				unset( $meta_value[ $mk ] );
162
+			}
163
+		}
164
+
165
+		$cur_form_prefix = reset($meta_value);
166
+		$cur_form_prefix = explode('_', $cur_form_prefix);
167
+		$cur_form_prefix = $cur_form_prefix[0];
168
+		$save = false;
169
+
170
+		foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) {
171 171
 			if ( empty( $prev_hidden ) || in_array( $prev_hidden, $meta_value ) ) {
172
-                //don't add blank cols or process included cols
173
-                continue;
174
-            }
172
+				//don't add blank cols or process included cols
173
+				continue;
174
+			}
175 175
 
176 176
 			$form_prefix = explode( '_', $prev_hidden );
177
-            $form_prefix = $form_prefix[0];
178
-            if ( $form_prefix == $cur_form_prefix ) {
179
-                //don't add back columns that are meant to be hidden
180
-                continue;
181
-            }
177
+			$form_prefix = $form_prefix[0];
178
+			if ( $form_prefix == $cur_form_prefix ) {
179
+				//don't add back columns that are meant to be hidden
180
+				continue;
181
+			}
182 182
 
183
-            $meta_value[] = $prev_hidden;
184
-            $save = true;
185
-            unset($form_prefix);
186
-        }
183
+			$meta_value[] = $prev_hidden;
184
+			$save = true;
185
+			unset($form_prefix);
186
+		}
187 187
 
188 188
 		if ( $save ) {
189
-            $user = wp_get_current_user();
189
+			$user = wp_get_current_user();
190 190
 			update_user_option( $user->ID, $this_page_name, $meta_value, true );
191
-        }
192
-    }
191
+		}
192
+	}
193 193
 
194 194
 	public static function save_per_page( $save, $option, $value ) {
195
-        if ( $option == 'formidable_page_formidable_entries_per_page' ) {
196
-            $save = (int) $value;
197
-        }
198
-        return $save;
199
-    }
195
+		if ( $option == 'formidable_page_formidable_entries_per_page' ) {
196
+			$save = (int) $value;
197
+		}
198
+		return $save;
199
+	}
200 200
 
201 201
 	public static function sortable_columns() {
202 202
 		$form_id = FrmForm::get_current_form_id();
@@ -222,226 +222,226 @@  discard block
 block discarded – undo
222 222
 	}
223 223
 
224 224
 	public static function hidden_columns( $result ) {
225
-        global $frm_vars;
225
+		global $frm_vars;
226 226
 
227 227
 		$form_id = FrmForm::get_current_form_id();
228 228
 
229
-        $return = false;
230
-        foreach ( (array) $result as $r ) {
231
-            if ( ! empty( $r ) ) {
232
-                $form_prefix = explode( '_', $r );
233
-                $form_prefix = $form_prefix[0];
229
+		$return = false;
230
+		foreach ( (array) $result as $r ) {
231
+			if ( ! empty( $r ) ) {
232
+				$form_prefix = explode( '_', $r );
233
+				$form_prefix = $form_prefix[0];
234 234
 
235
-                if ( (int) $form_prefix == (int) $form_id ) {
236
-                    $return = true;
237
-                    break;
238
-                }
235
+				if ( (int) $form_prefix == (int) $form_id ) {
236
+					$return = true;
237
+					break;
238
+				}
239 239
 
240
-                unset($form_prefix);
241
-            }
242
-        }
240
+				unset($form_prefix);
241
+			}
242
+		}
243 243
 
244
-        if ( $return ) {
244
+		if ( $return ) {
245 245
 			return $result;
246 246
 		}
247 247
 
248
-        $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
249
-        $max_columns = 8;
250
-        if ( $i <= $max_columns ) {
248
+		$i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
249
+		$max_columns = 8;
250
+		if ( $i <= $max_columns ) {
251 251
 			return $result;
252 252
 		}
253 253
 
254
-        global $frm_vars;
255
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
256
-            $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
257
-        }
254
+		global $frm_vars;
255
+		if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
256
+			$frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
257
+		}
258 258
 
259
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) {
260
-            $result = $frm_vars['current_form']->options['hidden_cols'];
261
-        } else {
262
-            $cols = $frm_vars['cols'];
263
-            $cols = array_reverse($cols, true);
259
+		if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) {
260
+			$result = $frm_vars['current_form']->options['hidden_cols'];
261
+		} else {
262
+			$cols = $frm_vars['cols'];
263
+			$cols = array_reverse($cols, true);
264 264
 
265
-            $result[] = $form_id .'_id';
266
-            $i--;
265
+			$result[] = $form_id .'_id';
266
+			$i--;
267 267
 
268
-            $result[] = $form_id .'_item_key';
269
-            $i--;
268
+			$result[] = $form_id .'_item_key';
269
+			$i--;
270 270
 
271 271
 			foreach ( $cols as $col_key => $col ) {
272
-                if ( $i > $max_columns ) {
272
+				if ( $i > $max_columns ) {
273 273
 					$result[] = $col_key;
274 274
 				}
275
-                //remove some columns by default
276
-                $i--;
277
-                unset($col_key, $col);
278
-            }
279
-        }
275
+				//remove some columns by default
276
+				$i--;
277
+				unset($col_key, $col);
278
+			}
279
+		}
280 280
 
281
-        return $result;
282
-    }
281
+		return $result;
282
+	}
283 283
 
284 284
 	public static function display_list( $message = '', $errors = array() ) {
285
-        global $wpdb, $frm_vars;
285
+		global $wpdb, $frm_vars;
286 286
 
287 287
 		$form = FrmForm::get_current_form();
288 288
 		$params = FrmForm::get_admin_params( $form );
289 289
 
290
-        if ( $form ) {
291
-            $params['form'] = $form->id;
292
-            $frm_vars['current_form'] = $form;
290
+		if ( $form ) {
291
+			$params['form'] = $form->id;
292
+			$frm_vars['current_form'] = $form;
293 293
 
294
-	        if ( 'trash' == $form->status ) {
295
-	            $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
296
-	            $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) );
297
-	            $errors['trash'] = sprintf( __( 'This form is in the trash and is scheduled to be deleted permanently in %s along with any entries.', 'formidable' ), $time_to_delete );
298
-	            unset( $time_to_delete, $delete_timestamp );
299
-	        }
294
+			if ( 'trash' == $form->status ) {
295
+				$delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
296
+				$time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) );
297
+				$errors['trash'] = sprintf( __( 'This form is in the trash and is scheduled to be deleted permanently in %s along with any entries.', 'formidable' ), $time_to_delete );
298
+				unset( $time_to_delete, $delete_timestamp );
299
+			}
300 300
 		}
301 301
 
302
-        $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
302
+		$table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
303 303
 
304
-        $wp_list_table = new $table_class( array( 'params' => $params ) );
304
+		$wp_list_table = new $table_class( array( 'params' => $params ) );
305 305
 
306
-        $pagenum = $wp_list_table->get_pagenum();
306
+		$pagenum = $wp_list_table->get_pagenum();
307 307
 
308
-        $wp_list_table->prepare_items();
308
+		$wp_list_table->prepare_items();
309 309
 
310
-        $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
311
-        if ( $pagenum > $total_pages && $total_pages > 0 ) {
310
+		$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
311
+		if ( $pagenum > $total_pages && $total_pages > 0 ) {
312 312
 			$url = add_query_arg( 'paged', $total_pages );
313
-            if ( headers_sent() ) {
314
-                echo FrmAppHelper::js_redirect($url);
315
-            } else {
316
-                wp_redirect( esc_url_raw( $url ) );
317
-            }
318
-            die();
319
-        }
320
-
321
-        if ( empty($message) && isset($_GET['import-message']) ) {
322
-            $message = __( 'Your import is complete', 'formidable' );
323
-        }
324
-
325
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/list.php');
326
-    }
327
-
328
-    /* Back End CRUD */
313
+			if ( headers_sent() ) {
314
+				echo FrmAppHelper::js_redirect($url);
315
+			} else {
316
+				wp_redirect( esc_url_raw( $url ) );
317
+			}
318
+			die();
319
+		}
320
+
321
+		if ( empty($message) && isset($_GET['import-message']) ) {
322
+			$message = __( 'Your import is complete', 'formidable' );
323
+		}
324
+
325
+		require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/list.php');
326
+	}
327
+
328
+	/* Back End CRUD */
329 329
 	public static function show( $id = 0 ) {
330
-        FrmAppHelper::permission_check('frm_view_entries');
330
+		FrmAppHelper::permission_check('frm_view_entries');
331 331
 
332
-        if ( ! $id ) {
332
+		if ( ! $id ) {
333 333
 			$id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
334 334
 
335
-            if ( ! $id ) {
335
+			if ( ! $id ) {
336 336
 				$id = FrmAppHelper::get_param( 'item_id', 0, 'get', 'absint' );
337
-            }
338
-        }
337
+			}
338
+		}
339 339
 
340
-        $entry = FrmEntry::getOne($id, true);
340
+		$entry = FrmEntry::getOne($id, true);
341 341
 
342
-        $data = maybe_unserialize($entry->description);
342
+		$data = maybe_unserialize($entry->description);
343 343
 		if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) {
344 344
 			$data = array( 'referrer' => $data );
345 345
 		}
346 346
 
347 347
 		$fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' );
348
-        $to_emails = array();
348
+		$to_emails = array();
349 349
 
350
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/show.php');
351
-    }
350
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/show.php');
351
+	}
352 352
 
353
-    public static function destroy() {
354
-        FrmAppHelper::permission_check('frm_delete_entries');
353
+	public static function destroy() {
354
+		FrmAppHelper::permission_check('frm_delete_entries');
355 355
 
356 356
 		$params = FrmForm::get_admin_params();
357 357
 
358
-        if ( isset($params['keep_post']) && $params['keep_post'] ) {
359
-            //unlink entry from post
360
-            global $wpdb;
358
+		if ( isset($params['keep_post']) && $params['keep_post'] ) {
359
+			//unlink entry from post
360
+			global $wpdb;
361 361
 			$wpdb->update( $wpdb->prefix .'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
362
-        }
362
+		}
363 363
 
364
-        $message = '';
365
-        if ( FrmEntry::destroy( $params['id'] ) ) {
366
-            $message = __( 'Entry was Successfully Destroyed', 'formidable' );
367
-        }
364
+		$message = '';
365
+		if ( FrmEntry::destroy( $params['id'] ) ) {
366
+			$message = __( 'Entry was Successfully Destroyed', 'formidable' );
367
+		}
368 368
 
369
-        self::display_list( $message );
370
-    }
369
+		self::display_list( $message );
370
+	}
371 371
 
372
-    public static function destroy_all() {
373
-        if ( ! current_user_can( 'frm_delete_entries' ) ) {
374
-            $frm_settings = FrmAppHelper::get_settings();
375
-            wp_die( $frm_settings->admin_permission );
376
-        }
372
+	public static function destroy_all() {
373
+		if ( ! current_user_can( 'frm_delete_entries' ) ) {
374
+			$frm_settings = FrmAppHelper::get_settings();
375
+			wp_die( $frm_settings->admin_permission );
376
+		}
377 377
 
378
-        global $wpdb;
378
+		global $wpdb;
379 379
 		$params = FrmForm::get_admin_params();
380
-        $message = '';
381
-        $errors = array();
382
-        $form_id = (int) $params['form'];
380
+		$message = '';
381
+		$errors = array();
382
+		$form_id = (int) $params['form'];
383 383
 
384
-        if ( $form_id ) {
385
-            $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) );
384
+		if ( $form_id ) {
385
+			$entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) );
386 386
 			$action = FrmFormAction::get_action_for_form( $form_id, 'wppost', 1 );
387 387
 
388
-            if ( $action ) {
389
-                // this action takes a while, so only trigger it if there are posts to delete
390
-                foreach ( $entry_ids as $entry_id ) {
391
-                    do_action( 'frm_before_destroy_entry', $entry_id );
392
-                    unset( $entry_id );
393
-                }
394
-            }
395
-
396
-            $wpdb->query( $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) and form_id=%d", $form_id ) );
397
-            $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) );
398
-            if ( $results ) {
399
-                $message = __( 'Entries were Successfully Destroyed', 'formidable' );
400
-            }
401
-        } else {
402
-            $errors = __( 'No entries were specified', 'formidable' );
403
-        }
404
-
405
-        self::display_list( $message, $errors );
406
-    }
407
-
408
-    public static function show_form( $id = '', $key = '', $title = false, $description = false ) {
409
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' );
410
-        return FrmFormsController::show_form( $id, $key, $title, $description );
411
-    }
412
-
413
-    public static function get_form( $filename, $form, $title, $description ) {
414
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' );
415
-        return FrmFormsController::get_form( $form, $title, $description );
416
-    }
417
-
418
-    public static function process_entry( $errors = '', $ajax = false ) {
388
+			if ( $action ) {
389
+				// this action takes a while, so only trigger it if there are posts to delete
390
+				foreach ( $entry_ids as $entry_id ) {
391
+					do_action( 'frm_before_destroy_entry', $entry_id );
392
+					unset( $entry_id );
393
+				}
394
+			}
395
+
396
+			$wpdb->query( $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) and form_id=%d", $form_id ) );
397
+			$results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) );
398
+			if ( $results ) {
399
+				$message = __( 'Entries were Successfully Destroyed', 'formidable' );
400
+			}
401
+		} else {
402
+			$errors = __( 'No entries were specified', 'formidable' );
403
+		}
404
+
405
+		self::display_list( $message, $errors );
406
+	}
407
+
408
+	public static function show_form( $id = '', $key = '', $title = false, $description = false ) {
409
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' );
410
+		return FrmFormsController::show_form( $id, $key, $title, $description );
411
+	}
412
+
413
+	public static function get_form( $filename, $form, $title, $description ) {
414
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' );
415
+		return FrmFormsController::get_form( $form, $title, $description );
416
+	}
417
+
418
+	public static function process_entry( $errors = '', $ajax = false ) {
419 419
 		$form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
420 420
 		if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) {
421
-            return;
422
-        }
421
+			return;
422
+		}
423 423
 
424
-        global $frm_vars;
424
+		global $frm_vars;
425 425
 
426 426
 		$form = FrmForm::getOne( $form_id );
427
-        if ( ! $form ) {
428
-            return;
429
-        }
427
+		if ( ! $form ) {
428
+			return;
429
+		}
430 430
 
431 431
 		$params = FrmForm::get_params( $form );
432 432
 
433
-        if ( ! isset( $frm_vars['form_params'] ) ) {
434
-            $frm_vars['form_params'] = array();
435
-        }
433
+		if ( ! isset( $frm_vars['form_params'] ) ) {
434
+			$frm_vars['form_params'] = array();
435
+		}
436 436
 		$frm_vars['form_params'][ $form->id ] = $params;
437 437
 
438 438
 		if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) {
439
-            return;
440
-        }
439
+			return;
440
+		}
441 441
 
442
-        if ( $errors == '' ) {
442
+		if ( $errors == '' ) {
443 443
 			$errors = FrmEntryValidate::validate( $_POST );
444
-        }
444
+		}
445 445
 
446 446
 		/**
447 447
 		 * Use this filter to add trigger actions and add errors after
@@ -452,102 +452,102 @@  discard block
 block discarded – undo
452 452
 
453 453
 		$frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors );
454 454
 
455
-        if ( empty( $errors ) ) {
455
+		if ( empty( $errors ) ) {
456 456
 			$_POST['frm_skip_cookie'] = 1;
457
-            if ( $params['action'] == 'create' ) {
457
+			if ( $params['action'] == 'create' ) {
458 458
 				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
459 459
 					$frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST );
460
-                }
461
-            }
460
+				}
461
+			}
462 462
 
463
-            do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
463
+			do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
464 464
 			unset( $_POST['frm_skip_cookie'] );
465
-        }
466
-    }
467
-
468
-    public static function delete_entry_before_redirect( $url, $form, $atts ) {
469
-        self::_delete_entry( $atts['id'], $form );
470
-        return $url;
471
-    }
472
-
473
-    //Delete entry if not redirected
474
-    public static function delete_entry_after_save( $atts ) {
475
-        self::_delete_entry( $atts['entry_id'], $atts['form'] );
476
-    }
477
-
478
-    private static function _delete_entry( $entry_id, $form ) {
479
-        if ( ! $form ) {
480
-            return;
481
-        }
482
-
483
-        $form->options = maybe_unserialize( $form->options );
484
-        if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
485
-            FrmEntry::destroy( $entry_id );
486
-        }
487
-    }
465
+		}
466
+	}
467
+
468
+	public static function delete_entry_before_redirect( $url, $form, $atts ) {
469
+		self::_delete_entry( $atts['id'], $form );
470
+		return $url;
471
+	}
472
+
473
+	//Delete entry if not redirected
474
+	public static function delete_entry_after_save( $atts ) {
475
+		self::_delete_entry( $atts['entry_id'], $atts['form'] );
476
+	}
477
+
478
+	private static function _delete_entry( $entry_id, $form ) {
479
+		if ( ! $form ) {
480
+			return;
481
+		}
482
+
483
+		$form->options = maybe_unserialize( $form->options );
484
+		if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
485
+			FrmEntry::destroy( $entry_id );
486
+		}
487
+	}
488 488
 
489 489
 	public static function show_entry_shortcode( $atts ) {
490 490
 		return FrmEntryFormat::show_entry( $atts );
491 491
 	}
492 492
 
493
-    public static function &filter_email_value( $value, $meta, $entry, $atts = array() ) {
494
-        $field = FrmField::getOne($meta->field_id);
495
-        if ( ! $field ) {
496
-            return $value;
497
-        }
493
+	public static function &filter_email_value( $value, $meta, $entry, $atts = array() ) {
494
+		$field = FrmField::getOne($meta->field_id);
495
+		if ( ! $field ) {
496
+			return $value;
497
+		}
498 498
 
499
-        $value = self::filter_display_value($value, $field, $atts);
500
-        return $value;
501
-    }
499
+		$value = self::filter_display_value($value, $field, $atts);
500
+		return $value;
501
+	}
502 502
 
503 503
 	public static function &filter_shortcode_value( $value, $tag, $atts, $field ) {
504
-        $plain_text = add_filter('frm_plain_text_email', true);
504
+		$plain_text = add_filter('frm_plain_text_email', true);
505 505
 		FrmEntryFormat::textarea_display_value( $field->type, $plain_text, $value );
506 506
 
507
-        if ( isset($atts['show']) && $atts['show'] == 'value' ) {
508
-            return $value;
509
-        }
507
+		if ( isset($atts['show']) && $atts['show'] == 'value' ) {
508
+			return $value;
509
+		}
510 510
 
511
-        return self::filter_display_value($value, $field, $atts);
512
-    }
511
+		return self::filter_display_value($value, $field, $atts);
512
+	}
513 513
 
514
-    public static function &filter_display_value( $value, $field, $atts = array() ) {
515
-        $saved_value = ( isset($atts['saved_value']) && $atts['saved_value'] ) ? true : false;
514
+	public static function &filter_display_value( $value, $field, $atts = array() ) {
515
+		$saved_value = ( isset($atts['saved_value']) && $atts['saved_value'] ) ? true : false;
516 516
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'radio', 'select' ) ) || ! FrmField::is_option_true( $field, 'separate_value' ) || $saved_value ) {
517
-            return $value;
518
-        }
519
-
520
-        $f_values = $f_labels = array();
521
-
522
-        foreach ( $field->options as $opt_key => $opt ) {
523
-            if ( ! is_array($opt) ) {
524
-                continue;
525
-            }
526
-
527
-            $f_labels[ $opt_key ] = isset( $opt['label'] ) ? $opt['label'] : reset($opt);
528
-            $f_values[ $opt_key ] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[ $opt_key ];
529
-            if ( $f_labels[ $opt_key ] == $f_values[ $opt_key ] ) {
530
-                unset( $f_values[ $opt_key ], $f_labels[ $opt_key ] );
531
-            }
532
-            unset($opt_key, $opt);
533
-        }
534
-
535
-        if ( ! empty($f_values) ) {
536
-            foreach ( (array) $value as $v_key => $val ) {
537
-                if ( in_array($val, $f_values) ) {
538
-                    $opt = array_search($val, $f_values);
539
-                    if ( is_array($value) ) {
540
-                        $value[ $v_key ] = $f_labels[ $opt ];
541
-                    } else {
542
-                        $value = $f_labels[ $opt ];
543
-                    }
544
-                }
545
-                unset($v_key, $val);
546
-            }
547
-        }
548
-
549
-        return $value;
550
-    }
517
+			return $value;
518
+		}
519
+
520
+		$f_values = $f_labels = array();
521
+
522
+		foreach ( $field->options as $opt_key => $opt ) {
523
+			if ( ! is_array($opt) ) {
524
+				continue;
525
+			}
526
+
527
+			$f_labels[ $opt_key ] = isset( $opt['label'] ) ? $opt['label'] : reset($opt);
528
+			$f_values[ $opt_key ] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[ $opt_key ];
529
+			if ( $f_labels[ $opt_key ] == $f_values[ $opt_key ] ) {
530
+				unset( $f_values[ $opt_key ], $f_labels[ $opt_key ] );
531
+			}
532
+			unset($opt_key, $opt);
533
+		}
534
+
535
+		if ( ! empty($f_values) ) {
536
+			foreach ( (array) $value as $v_key => $val ) {
537
+				if ( in_array($val, $f_values) ) {
538
+					$opt = array_search($val, $f_values);
539
+					if ( is_array($value) ) {
540
+						$value[ $v_key ] = $f_labels[ $opt ];
541
+					} else {
542
+						$value = $f_labels[ $opt ];
543
+					}
544
+				}
545
+				unset($v_key, $val);
546
+			}
547
+		}
548
+
549
+		return $value;
550
+	}
551 551
 
552 552
 	public static function get_params( $form = null ) {
553 553
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_params' );
@@ -555,13 +555,13 @@  discard block
 block discarded – undo
555 555
 	}
556 556
 
557 557
 	public static function entry_sidebar( $entry ) {
558
-        $data = maybe_unserialize($entry->description);
559
-        $date_format = get_option('date_format');
560
-        $time_format = get_option('time_format');
558
+		$data = maybe_unserialize($entry->description);
559
+		$date_format = get_option('date_format');
560
+		$time_format = get_option('time_format');
561 561
 		if ( isset( $data['browser'] ) ) {
562 562
 			$browser = FrmEntryFormat::get_browser( $data['browser'] );
563 563
 		}
564 564
 
565
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/sidebar-shared.php');
566
-    }
565
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/sidebar-shared.php');
566
+	}
567 567
 }
Please login to merge, or discard this patch.
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
     public static function menu() {
6 6
 		FrmAppHelper::force_capability( 'frm_view_entries' );
7 7
 
8
-        add_submenu_page('formidable', 'Formidable | '. __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
8
+        add_submenu_page( 'formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
9 9
 
10 10
 		if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) {
11 11
 			$menu_name = FrmAppHelper::get_menu_name();
@@ -52,13 +52,13 @@  discard block
 block discarded – undo
52 52
         $screen->add_help_tab( array(
53 53
             'id'      => 'formidable-entries-tab',
54 54
             'title'   => __( 'Overview', 'formidable' ),
55
-			'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) .'</p> <p>'. esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>',
56
-        ));
55
+			'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) . '</p> <p>' . esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>',
56
+        ) );
57 57
 
58 58
         $screen->set_help_sidebar(
59 59
 			'<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' .
60 60
 			'<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'http://formidablepro.com/knowledgebase/manage-entries-from-the-back-end/' ) ) . '" target="_blank">' . esc_html__( 'Documentation on Entries', 'formidable' ) . '</a></p>' .
61
-			'<p><a href="'. esc_url( FrmAppHelper::make_affiliate_url( 'http://formidablepro.com/help-desk/' ) ) . '" target="_blank">' . esc_html__( 'Support', 'formidable' ) . '</a></p>'
61
+			'<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'http://formidablepro.com/help-desk/' ) ) . '" target="_blank">' . esc_html__( 'Support', 'formidable' ) . '</a></p>'
62 62
     	);
63 63
 
64 64
         return $help;
@@ -68,14 +68,14 @@  discard block
 block discarded – undo
68 68
         global $frm_vars, $wpdb;
69 69
 		$form_id = FrmForm::get_current_form_id();
70 70
 
71
-        $columns[ $form_id .'_id' ] = 'ID';
72
-		$columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' );
71
+        $columns[$form_id . '_id'] = 'ID';
72
+		$columns[$form_id . '_item_key'] = esc_html__( 'Entry Key', 'formidable' );
73 73
 
74 74
         if ( ! $form_id ) {
75 75
             return $columns;
76 76
         }
77 77
 
78
-        $form_cols = FrmField::get_all_for_form($form_id, '', 'include');
78
+        $form_cols = FrmField::get_all_for_form( $form_id, '', 'include' );
79 79
 
80 80
         foreach ( $form_cols as $form_col ) {
81 81
 			if ( FrmField::is_no_save_field( $form_col->type ) ) {
@@ -88,30 +88,30 @@  discard block
 block discarded – undo
88 88
                 if ( $sub_form_cols ) {
89 89
                     foreach ( $sub_form_cols as $k => $sub_form_col ) {
90 90
 						if ( FrmField::is_no_save_field( $sub_form_col->type ) ) {
91
-                            unset( $sub_form_cols[ $k ] );
91
+                            unset( $sub_form_cols[$k] );
92 92
                             continue;
93 93
                         }
94
-						$columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
95
-                        unset($sub_form_col);
94
+						$columns[$form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
95
+                        unset( $sub_form_col );
96 96
                     }
97 97
                 }
98
-                unset($sub_form_cols);
98
+                unset( $sub_form_cols );
99 99
             } else {
100 100
                 $col_id = $form_col->field_key;
101 101
                 if ( $form_col->form_id != $form_id ) {
102
-                    $col_id .= '-_-form'. $form_col->form_id;
102
+                    $col_id .= '-_-form' . $form_col->form_id;
103 103
                 }
104 104
 
105
-                if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) {
106
-                    $columns[ $form_id .'_frmsep_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
105
+                if ( isset( $form_col->field_options['separate_value'] ) && $form_col->field_options['separate_value'] ) {
106
+                    $columns[$form_id . '_frmsep_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 );
107 107
                 }
108
-                $columns[ $form_id .'_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
108
+                $columns[$form_id . '_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 );
109 109
             }
110 110
         }
111 111
 
112
-        $columns[ $form_id .'_created_at' ] = __( 'Entry creation date', 'formidable' );
113
-        $columns[ $form_id .'_updated_at' ] = __( 'Entry update date', 'formidable' );
114
-        $columns[ $form_id .'_ip' ] = 'IP';
112
+        $columns[$form_id . '_created_at'] = __( 'Entry creation date', 'formidable' );
113
+        $columns[$form_id . '_updated_at'] = __( 'Entry update date', 'formidable' );
114
+        $columns[$form_id . '_ip'] = 'IP';
115 115
 
116 116
         $frm_vars['cols'] = $columns;
117 117
 
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 
126 126
 	public static function check_hidden_cols( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
127 127
 		$menu_name = FrmAppHelper::get_menu_name();
128
-		$this_page_name = 'manage' .  sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden';
128
+		$this_page_name = 'manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden';
129 129
 		if ( $meta_key != $this_page_name || $meta_value == $prev_value ) {
130 130
             return $check;
131 131
         }
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 
137 137
         global $frm_vars;
138 138
         //add a check so we don't create a loop
139
-        $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
139
+        $frm_vars['prev_hidden_cols'] = ( isset( $frm_vars['prev_hidden_cols'] ) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
140 140
 
141 141
         return $check;
142 142
     }
@@ -145,25 +145,25 @@  discard block
 block discarded – undo
145 145
 	public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) {
146 146
 		$menu_name = FrmAppHelper::get_menu_name();
147 147
 		$sanitized = sanitize_title( $menu_name );
148
-		$this_page_name = 'manage'.  $sanitized .'_page_formidable-entriescolumnshidden';
148
+		$this_page_name = 'manage' . $sanitized . '_page_formidable-entriescolumnshidden';
149 149
 		if ( $meta_key != $this_page_name ) {
150 150
             return;
151 151
         }
152 152
 
153 153
         global $frm_vars;
154
-        if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
154
+        if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) {
155 155
             return; //don't continue if there's no previous value
156 156
         }
157 157
 
158 158
         foreach ( $meta_value as $mk => $mv ) {
159 159
             //remove blank values
160
-            if ( empty( $mv )  ) {
161
-                unset( $meta_value[ $mk ] );
160
+            if ( empty( $mv ) ) {
161
+                unset( $meta_value[$mk] );
162 162
             }
163 163
         }
164 164
 
165
-        $cur_form_prefix = reset($meta_value);
166
-        $cur_form_prefix = explode('_', $cur_form_prefix);
165
+        $cur_form_prefix = reset( $meta_value );
166
+        $cur_form_prefix = explode( '_', $cur_form_prefix );
167 167
         $cur_form_prefix = $cur_form_prefix[0];
168 168
         $save = false;
169 169
 
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 
183 183
             $meta_value[] = $prev_hidden;
184 184
             $save = true;
185
-            unset($form_prefix);
185
+            unset( $form_prefix );
186 186
         }
187 187
 
188 188
 		if ( $save ) {
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 		foreach ( $fields as $field ) {
215 215
 			if ( $field->type != 'checkbox' && ( ! isset( $field->field_options['post_field'] ) || $field->field_options['post_field'] == '' ) ) {
216 216
 				// Can't sort on checkboxes because they are stored serialized, or post fields
217
-				$columns[ $form_id . '_' . $field->field_key ] = 'meta_' . $field->id;
217
+				$columns[$form_id . '_' . $field->field_key] = 'meta_' . $field->id;
218 218
 			}
219 219
 		}
220 220
 
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
                     break;
238 238
                 }
239 239
 
240
-                unset($form_prefix);
240
+                unset( $form_prefix );
241 241
             }
242 242
         }
243 243
 
@@ -245,36 +245,36 @@  discard block
 block discarded – undo
245 245
 			return $result;
246 246
 		}
247 247
 
248
-        $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
248
+        $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0;
249 249
         $max_columns = 8;
250 250
         if ( $i <= $max_columns ) {
251 251
 			return $result;
252 252
 		}
253 253
 
254 254
         global $frm_vars;
255
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
256
-            $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
255
+        if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] ) {
256
+            $frm_vars['current_form']->options = maybe_unserialize( $frm_vars['current_form']->options );
257 257
         }
258 258
 
259
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) {
259
+        if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] && isset( $frm_vars['current_form']->options['hidden_cols'] ) && ! empty( $frm_vars['current_form']->options['hidden_cols'] ) ) {
260 260
             $result = $frm_vars['current_form']->options['hidden_cols'];
261 261
         } else {
262 262
             $cols = $frm_vars['cols'];
263
-            $cols = array_reverse($cols, true);
263
+            $cols = array_reverse( $cols, true );
264 264
 
265
-            $result[] = $form_id .'_id';
266
-            $i--;
265
+            $result[] = $form_id . '_id';
266
+            $i --;
267 267
 
268
-            $result[] = $form_id .'_item_key';
269
-            $i--;
268
+            $result[] = $form_id . '_item_key';
269
+            $i --;
270 270
 
271 271
 			foreach ( $cols as $col_key => $col ) {
272 272
                 if ( $i > $max_columns ) {
273 273
 					$result[] = $col_key;
274 274
 				}
275 275
                 //remove some columns by default
276
-                $i--;
277
-                unset($col_key, $col);
276
+                $i --;
277
+                unset( $col_key, $col );
278 278
             }
279 279
         }
280 280
 
@@ -311,23 +311,23 @@  discard block
 block discarded – undo
311 311
         if ( $pagenum > $total_pages && $total_pages > 0 ) {
312 312
 			$url = add_query_arg( 'paged', $total_pages );
313 313
             if ( headers_sent() ) {
314
-                echo FrmAppHelper::js_redirect($url);
314
+                echo FrmAppHelper::js_redirect( $url );
315 315
             } else {
316 316
                 wp_redirect( esc_url_raw( $url ) );
317 317
             }
318 318
             die();
319 319
         }
320 320
 
321
-        if ( empty($message) && isset($_GET['import-message']) ) {
321
+        if ( empty( $message ) && isset( $_GET['import-message'] ) ) {
322 322
             $message = __( 'Your import is complete', 'formidable' );
323 323
         }
324 324
 
325
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/list.php');
325
+        require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php' );
326 326
     }
327 327
 
328 328
     /* Back End CRUD */
329 329
 	public static function show( $id = 0 ) {
330
-        FrmAppHelper::permission_check('frm_view_entries');
330
+        FrmAppHelper::permission_check( 'frm_view_entries' );
331 331
 
332 332
         if ( ! $id ) {
333 333
 			$id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
@@ -337,9 +337,9 @@  discard block
 block discarded – undo
337 337
             }
338 338
         }
339 339
 
340
-        $entry = FrmEntry::getOne($id, true);
340
+        $entry = FrmEntry::getOne( $id, true );
341 341
 
342
-        $data = maybe_unserialize($entry->description);
342
+        $data = maybe_unserialize( $entry->description );
343 343
 		if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) {
344 344
 			$data = array( 'referrer' => $data );
345 345
 		}
@@ -347,18 +347,18 @@  discard block
 block discarded – undo
347 347
 		$fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' );
348 348
         $to_emails = array();
349 349
 
350
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/show.php');
350
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' );
351 351
     }
352 352
 
353 353
     public static function destroy() {
354
-        FrmAppHelper::permission_check('frm_delete_entries');
354
+        FrmAppHelper::permission_check( 'frm_delete_entries' );
355 355
 
356 356
 		$params = FrmForm::get_admin_params();
357 357
 
358
-        if ( isset($params['keep_post']) && $params['keep_post'] ) {
358
+        if ( isset( $params['keep_post'] ) && $params['keep_post'] ) {
359 359
             //unlink entry from post
360 360
             global $wpdb;
361
-			$wpdb->update( $wpdb->prefix .'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
361
+			$wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
362 362
         }
363 363
 
364 364
         $message = '';
@@ -433,9 +433,9 @@  discard block
 block discarded – undo
433 433
         if ( ! isset( $frm_vars['form_params'] ) ) {
434 434
             $frm_vars['form_params'] = array();
435 435
         }
436
-		$frm_vars['form_params'][ $form->id ] = $params;
436
+		$frm_vars['form_params'][$form->id] = $params;
437 437
 
438
-		if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) {
438
+		if ( isset( $frm_vars['created_entries'][$form_id] ) ) {
439 439
             return;
440 440
         }
441 441
 
@@ -450,13 +450,13 @@  discard block
 block discarded – undo
450 450
 		 */
451 451
 		$errors = apply_filters( 'frm_entries_before_create', $errors, $form );
452 452
 
453
-		$frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors );
453
+		$frm_vars['created_entries'][$form_id] = array( 'errors' => $errors );
454 454
 
455 455
         if ( empty( $errors ) ) {
456 456
 			$_POST['frm_skip_cookie'] = 1;
457 457
             if ( $params['action'] == 'create' ) {
458
-				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
459
-					$frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST );
458
+				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][$form_id]['entry_id'] ) ) {
459
+					$frm_vars['created_entries'][$form_id]['entry_id'] = FrmEntry::create( $_POST );
460 460
                 }
461 461
             }
462 462
 
@@ -491,28 +491,28 @@  discard block
 block discarded – undo
491 491
 	}
492 492
 
493 493
     public static function &filter_email_value( $value, $meta, $entry, $atts = array() ) {
494
-        $field = FrmField::getOne($meta->field_id);
494
+        $field = FrmField::getOne( $meta->field_id );
495 495
         if ( ! $field ) {
496 496
             return $value;
497 497
         }
498 498
 
499
-        $value = self::filter_display_value($value, $field, $atts);
499
+        $value = self::filter_display_value( $value, $field, $atts );
500 500
         return $value;
501 501
     }
502 502
 
503 503
 	public static function &filter_shortcode_value( $value, $tag, $atts, $field ) {
504
-        $plain_text = add_filter('frm_plain_text_email', true);
504
+        $plain_text = add_filter( 'frm_plain_text_email', true );
505 505
 		FrmEntryFormat::textarea_display_value( $field->type, $plain_text, $value );
506 506
 
507
-        if ( isset($atts['show']) && $atts['show'] == 'value' ) {
507
+        if ( isset( $atts['show'] ) && $atts['show'] == 'value' ) {
508 508
             return $value;
509 509
         }
510 510
 
511
-        return self::filter_display_value($value, $field, $atts);
511
+        return self::filter_display_value( $value, $field, $atts );
512 512
     }
513 513
 
514 514
     public static function &filter_display_value( $value, $field, $atts = array() ) {
515
-        $saved_value = ( isset($atts['saved_value']) && $atts['saved_value'] ) ? true : false;
515
+        $saved_value = ( isset( $atts['saved_value'] ) && $atts['saved_value'] ) ? true : false;
516 516
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'radio', 'select' ) ) || ! FrmField::is_option_true( $field, 'separate_value' ) || $saved_value ) {
517 517
             return $value;
518 518
         }
@@ -520,29 +520,29 @@  discard block
 block discarded – undo
520 520
         $f_values = $f_labels = array();
521 521
 
522 522
         foreach ( $field->options as $opt_key => $opt ) {
523
-            if ( ! is_array($opt) ) {
523
+            if ( ! is_array( $opt ) ) {
524 524
                 continue;
525 525
             }
526 526
 
527
-            $f_labels[ $opt_key ] = isset( $opt['label'] ) ? $opt['label'] : reset($opt);
528
-            $f_values[ $opt_key ] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[ $opt_key ];
529
-            if ( $f_labels[ $opt_key ] == $f_values[ $opt_key ] ) {
530
-                unset( $f_values[ $opt_key ], $f_labels[ $opt_key ] );
527
+            $f_labels[$opt_key] = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
528
+            $f_values[$opt_key] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[$opt_key];
529
+            if ( $f_labels[$opt_key] == $f_values[$opt_key] ) {
530
+                unset( $f_values[$opt_key], $f_labels[$opt_key] );
531 531
             }
532
-            unset($opt_key, $opt);
532
+            unset( $opt_key, $opt );
533 533
         }
534 534
 
535
-        if ( ! empty($f_values) ) {
535
+        if ( ! empty( $f_values ) ) {
536 536
             foreach ( (array) $value as $v_key => $val ) {
537
-                if ( in_array($val, $f_values) ) {
538
-                    $opt = array_search($val, $f_values);
539
-                    if ( is_array($value) ) {
540
-                        $value[ $v_key ] = $f_labels[ $opt ];
537
+                if ( in_array( $val, $f_values ) ) {
538
+                    $opt = array_search( $val, $f_values );
539
+                    if ( is_array( $value ) ) {
540
+                        $value[$v_key] = $f_labels[$opt];
541 541
                     } else {
542
-                        $value = $f_labels[ $opt ];
542
+                        $value = $f_labels[$opt];
543 543
                     }
544 544
                 }
545
-                unset($v_key, $val);
545
+                unset( $v_key, $val );
546 546
             }
547 547
         }
548 548
 
@@ -555,13 +555,13 @@  discard block
 block discarded – undo
555 555
 	}
556 556
 
557 557
 	public static function entry_sidebar( $entry ) {
558
-        $data = maybe_unserialize($entry->description);
559
-        $date_format = get_option('date_format');
560
-        $time_format = get_option('time_format');
558
+        $data = maybe_unserialize( $entry->description );
559
+        $date_format = get_option( 'date_format' );
560
+        $time_format = get_option( 'time_format' );
561 561
 		if ( isset( $data['browser'] ) ) {
562 562
 			$browser = FrmEntryFormat::get_browser( $data['browser'] );
563 563
 		}
564 564
 
565
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/sidebar-shared.php');
565
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' );
566 566
     }
567 567
 }
Please login to merge, or discard this patch.
classes/controllers/FrmFormsController.php 2 patches
Indentation   +628 added lines, -628 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,127 +24,127 @@  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' ) {
59
-            return self::create($values);
59
+			return self::create($values);
60 60
 		} else if ( $action == 'new' ) {
61 61
 			$frm_field_selection = FrmField::field_selection();
62
-            $values = FrmFormsHelper::setup_new_vars($values);
63
-            $id = FrmForm::create( $values );
64
-            $form = FrmForm::getOne($id);
62
+			$values = FrmFormsHelper::setup_new_vars($values);
63
+			$id = FrmForm::create( $values );
64
+			$form = FrmForm::getOne($id);
65 65
 
66
-            // add default email notification
67
-            $action_control = FrmFormActionsController::get_form_actions( 'email' );
68
-            $action_control->create($form->id);
66
+			// add default email notification
67
+			$action_control = FrmFormActionsController::get_form_actions( 'email' );
68
+			$action_control->create($form->id);
69 69
 
70 70
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
71 71
 
72
-            $values['id'] = $id;
73
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php');
74
-        }
75
-    }
72
+			$values['id'] = $id;
73
+			require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php');
74
+		}
75
+	}
76 76
 
77 77
 	public static function create( $values = array() ) {
78
-        FrmAppHelper::permission_check('frm_edit_forms');
78
+		FrmAppHelper::permission_check('frm_edit_forms');
79 79
 
80
-        global $frm_vars;
81
-        if ( empty( $values ) ) {
82
-            $values = $_POST;
83
-        }
80
+		global $frm_vars;
81
+		if ( empty( $values ) ) {
82
+			$values = $_POST;
83
+		}
84 84
 
85
-        //Set radio button and checkbox meta equal to "other" value
86
-        if ( FrmAppHelper::pro_is_installed() ) {
87
-            $values = FrmProEntry::mod_other_vals( $values, 'back' );
88
-        }
85
+		//Set radio button and checkbox meta equal to "other" value
86
+		if ( FrmAppHelper::pro_is_installed() ) {
87
+			$values = FrmProEntry::mod_other_vals( $values, 'back' );
88
+		}
89 89
 
90 90
 		$id = isset($values['id']) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
91 91
 
92
-        if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
93
-            $frm_settings = FrmAppHelper::get_settings();
94
-            $errors = array( 'form' => $frm_settings->admin_permission );
95
-        } else {
96
-            $errors = FrmForm::validate($values);
97
-        }
92
+		if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
93
+			$frm_settings = FrmAppHelper::get_settings();
94
+			$errors = array( 'form' => $frm_settings->admin_permission );
95
+		} else {
96
+			$errors = FrmForm::validate($values);
97
+		}
98 98
 
99
-        if ( count($errors) > 0 ) {
100
-            $hide_preview = true;
99
+		if ( count($errors) > 0 ) {
100
+			$hide_preview = true;
101 101
 			$frm_field_selection = FrmField::field_selection();
102
-            $form = FrmForm::getOne( $id );
103
-            $fields = FrmField::get_all_for_form($id);
102
+			$form = FrmForm::getOne( $id );
103
+			$fields = FrmField::get_all_for_form($id);
104 104
 
105
-            $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
105
+			$values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
106 106
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
107 107
 
108
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php');
109
-        } else {
110
-            FrmForm::update( $id, $values, true );
111
-            die(FrmAppHelper::js_redirect(admin_url('admin.php?page=formidable&frm_action=settings&id='. $id)));
112
-        }
113
-    }
108
+			require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php');
109
+		} else {
110
+			FrmForm::update( $id, $values, true );
111
+			die(FrmAppHelper::js_redirect(admin_url('admin.php?page=formidable&frm_action=settings&id='. $id)));
112
+		}
113
+	}
114 114
 
115
-    public static function edit( $values = false ) {
116
-        FrmAppHelper::permission_check('frm_edit_forms');
115
+	public static function edit( $values = false ) {
116
+		FrmAppHelper::permission_check('frm_edit_forms');
117 117
 
118 118
 		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
119
-        return self::get_edit_vars($id);
120
-    }
119
+		return self::get_edit_vars($id);
120
+	}
121 121
 
122
-    public static function settings( $id = false, $message = '' ) {
123
-        FrmAppHelper::permission_check('frm_edit_forms');
122
+	public static function settings( $id = false, $message = '' ) {
123
+		FrmAppHelper::permission_check('frm_edit_forms');
124 124
 
125
-        if ( ! $id || ! is_numeric($id) ) {
125
+		if ( ! $id || ! is_numeric($id) ) {
126 126
 			$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
127
-        }
127
+		}
128 128
 		return self::get_settings_vars( $id, array(), $message );
129
-    }
129
+	}
130 130
 
131
-    public static function update_settings() {
132
-        FrmAppHelper::permission_check('frm_edit_forms');
131
+	public static function update_settings() {
132
+		FrmAppHelper::permission_check('frm_edit_forms');
133 133
 
134 134
 		$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
135 135
 
136
-        $errors = FrmForm::validate($_POST);
137
-        if ( count($errors) > 0 ) {
138
-            return self::get_settings_vars($id, $errors);
139
-        }
136
+		$errors = FrmForm::validate($_POST);
137
+		if ( count($errors) > 0 ) {
138
+			return self::get_settings_vars($id, $errors);
139
+		}
140 140
 
141
-        do_action('frm_before_update_form_settings', $id);
141
+		do_action('frm_before_update_form_settings', $id);
142 142
 
143 143
 		FrmForm::update( $id, $_POST );
144 144
 
145
-        $message = __( 'Settings Successfully Updated', 'formidable' );
145
+		$message = __( 'Settings Successfully Updated', 'formidable' );
146 146
 		return self::get_settings_vars( $id, array(), $message );
147
-    }
147
+	}
148 148
 
149 149
 	public static function edit_key() {
150 150
 		$values = self::edit_in_place_value( 'form_key' );
@@ -174,43 +174,43 @@  discard block
 block discarded – undo
174 174
 
175 175
 	public static function update( $values = array() ) {
176 176
 		if ( empty( $values ) ) {
177
-            $values = $_POST;
178
-        }
177
+			$values = $_POST;
178
+		}
179 179
 
180
-        //Set radio button and checkbox meta equal to "other" value
181
-        if ( FrmAppHelper::pro_is_installed() ) {
182
-            $values = FrmProEntry::mod_other_vals( $values, 'back' );
183
-        }
180
+		//Set radio button and checkbox meta equal to "other" value
181
+		if ( FrmAppHelper::pro_is_installed() ) {
182
+			$values = FrmProEntry::mod_other_vals( $values, 'back' );
183
+		}
184 184
 
185
-        $errors = FrmForm::validate( $values );
186
-        $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' );
187
-        if ( $permission_error !== false ) {
188
-            $errors['form'] = $permission_error;
189
-        }
185
+		$errors = FrmForm::validate( $values );
186
+		$permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' );
187
+		if ( $permission_error !== false ) {
188
+			$errors['form'] = $permission_error;
189
+		}
190 190
 
191 191
 		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
192 192
 
193 193
 		if ( count( $errors ) > 0 ) {
194
-            return self::get_edit_vars( $id, $errors );
194
+			return self::get_edit_vars( $id, $errors );
195 195
 		} else {
196
-            FrmForm::update( $id, $values );
197
-            $message = __( 'Form was Successfully Updated', 'formidable' );
198
-            if ( defined( 'DOING_AJAX' ) ) {
196
+			FrmForm::update( $id, $values );
197
+			$message = __( 'Form was Successfully Updated', 'formidable' );
198
+			if ( defined( 'DOING_AJAX' ) ) {
199 199
 				wp_die( $message );
200
-            }
200
+			}
201 201
 			return self::get_edit_vars( $id, array(), $message );
202
-        }
203
-    }
202
+		}
203
+	}
204 204
 
205
-    public static function bulk_create_template( $ids ) {
206
-        FrmAppHelper::permission_check( 'frm_edit_forms' );
205
+	public static function bulk_create_template( $ids ) {
206
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
207 207
 
208
-        foreach ( $ids as $id ) {
209
-            FrmForm::duplicate( $id, true, true );
210
-        }
208
+		foreach ( $ids as $id ) {
209
+			FrmForm::duplicate( $id, true, true );
210
+		}
211 211
 
212
-        return __( 'Form template was Successfully Created', 'formidable' );
213
-    }
212
+		return __( 'Form template was Successfully Created', 'formidable' );
213
+	}
214 214
 
215 215
 	/**
216 216
 	 * Redirect to the url for creating from a template
@@ -232,45 +232,45 @@  discard block
 block discarded – undo
232 232
 		wp_die();
233 233
 	}
234 234
 
235
-    public static function duplicate() {
236
-        FrmAppHelper::permission_check('frm_edit_forms');
235
+	public static function duplicate() {
236
+		FrmAppHelper::permission_check('frm_edit_forms');
237 237
 
238 238
 		$params = FrmForm::list_page_params();
239
-        $form = FrmForm::duplicate( $params['id'], $params['template'], true );
240
-        $message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
241
-        if ( $form ) {
239
+		$form = FrmForm::duplicate( $params['id'], $params['template'], true );
240
+		$message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
241
+		if ( $form ) {
242 242
 			return self::get_edit_vars( $form, array(), $message, true );
243
-        } else {
244
-            return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' ));
245
-        }
246
-    }
243
+		} else {
244
+			return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' ));
245
+		}
246
+	}
247 247
 
248
-    public static function page_preview() {
248
+	public static function page_preview() {
249 249
 		$params = FrmForm::list_page_params();
250
-        if ( ! $params['form'] ) {
251
-            return;
252
-        }
253
-
254
-        $form = FrmForm::getOne( $params['form'] );
255
-        if ( ! $form ) {
256
-            return;
257
-        }
258
-        return self::show_form( $form->id, '', true, true );
259
-    }
260
-
261
-    public static function preview() {
262
-        do_action( 'frm_wp' );
263
-
264
-        global $frm_vars;
265
-        $frm_vars['preview'] = true;
266
-
267
-        if ( ! defined( 'ABSPATH' ) && ! defined( 'XMLRPC_REQUEST' ) ) {
268
-            global $wp;
269
-            $root = dirname( dirname( dirname( dirname( __FILE__ ) ) ) );
270
-            include_once( $root.'/wp-config.php' );
271
-            $wp->init();
272
-            $wp->register_globals();
273
-        }
250
+		if ( ! $params['form'] ) {
251
+			return;
252
+		}
253
+
254
+		$form = FrmForm::getOne( $params['form'] );
255
+		if ( ! $form ) {
256
+			return;
257
+		}
258
+		return self::show_form( $form->id, '', true, true );
259
+	}
260
+
261
+	public static function preview() {
262
+		do_action( 'frm_wp' );
263
+
264
+		global $frm_vars;
265
+		$frm_vars['preview'] = true;
266
+
267
+		if ( ! defined( 'ABSPATH' ) && ! defined( 'XMLRPC_REQUEST' ) ) {
268
+			global $wp;
269
+			$root = dirname( dirname( dirname( dirname( __FILE__ ) ) ) );
270
+			include_once( $root.'/wp-config.php' );
271
+			$wp->init();
272
+			$wp->register_globals();
273
+		}
274 274
 
275 275
 		self::register_pro_scripts();
276 276
 
@@ -284,11 +284,11 @@  discard block
 block discarded – undo
284 284
 		$form = FrmForm::getAll( array( 'form_key' => $key ), '', 1 );
285 285
 		if ( empty( $form ) ) {
286 286
 			$form = FrmForm::getAll( array(), '', 1 );
287
-        }
287
+		}
288 288
 
289
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/direct.php');
290
-        wp_die();
291
-    }
289
+		require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/direct.php');
290
+		wp_die();
291
+	}
292 292
 
293 293
 	public static function register_pro_scripts() {
294 294
 		if ( FrmAppHelper::pro_is_installed() ) {
@@ -298,22 +298,22 @@  discard block
 block discarded – undo
298 298
 		}
299 299
 	}
300 300
 
301
-    public static function untrash() {
301
+	public static function untrash() {
302 302
 		self::change_form_status( 'untrash' );
303
-    }
303
+	}
304 304
 
305 305
 	public static function bulk_untrash( $ids ) {
306
-        FrmAppHelper::permission_check('frm_edit_forms');
306
+		FrmAppHelper::permission_check('frm_edit_forms');
307 307
 
308
-        $count = FrmForm::set_status( $ids, 'published' );
308
+		$count = FrmForm::set_status( $ids, 'published' );
309 309
 
310
-        $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
311
-        return $message;
312
-    }
310
+		$message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
311
+		return $message;
312
+	}
313 313
 
314
-    public static function trash() {
314
+	public static function trash() {
315 315
 		self::change_form_status( 'trash' );
316
-    }
316
+	}
317 317
 
318 318
 	/**
319 319
 	 * @param string $status
@@ -351,68 +351,68 @@  discard block
 block discarded – undo
351 351
 	}
352 352
 
353 353
 	public static function bulk_trash( $ids ) {
354
-        FrmAppHelper::permission_check('frm_delete_forms');
354
+		FrmAppHelper::permission_check('frm_delete_forms');
355 355
 
356
-        $count = 0;
357
-        foreach ( $ids as $id ) {
358
-            if ( FrmForm::trash( $id ) ) {
359
-                $count++;
360
-            }
361
-        }
356
+		$count = 0;
357
+		foreach ( $ids as $id ) {
358
+			if ( FrmForm::trash( $id ) ) {
359
+				$count++;
360
+			}
361
+		}
362 362
 
363
-        $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
364
-        $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('item-action[]=', $ids), 'bulk-toplevel_page_formidable' )) .'">', '</a>' );
363
+		$current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
364
+		$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('item-action[]=', $ids), 'bulk-toplevel_page_formidable' )) .'">', '</a>' );
365 365
 
366
-        return $message;
367
-    }
366
+		return $message;
367
+	}
368 368
 
369
-    public static function destroy() {
370
-        FrmAppHelper::permission_check('frm_delete_forms');
369
+	public static function destroy() {
370
+		FrmAppHelper::permission_check('frm_delete_forms');
371 371
 
372 372
 		$params = FrmForm::list_page_params();
373 373
 
374
-        //check nonce url
375
-        check_admin_referer('destroy_form_' . $params['id']);
374
+		//check nonce url
375
+		check_admin_referer('destroy_form_' . $params['id']);
376 376
 
377
-        $count = 0;
378
-        if ( FrmForm::destroy( $params['id'] ) ) {
379
-            $count++;
380
-        }
377
+		$count = 0;
378
+		if ( FrmForm::destroy( $params['id'] ) ) {
379
+			$count++;
380
+		}
381 381
 
382
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
382
+		$message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
383 383
 
384 384
 		self::display_forms_list( $params, $message );
385
-    }
385
+	}
386 386
 
387 387
 	public static function bulk_destroy( $ids ) {
388
-        FrmAppHelper::permission_check('frm_delete_forms');
388
+		FrmAppHelper::permission_check('frm_delete_forms');
389 389
 
390
-        $count = 0;
391
-        foreach ( $ids as $id ) {
392
-            $d = FrmForm::destroy( $id );
393
-            if ( $d ) {
394
-                $count++;
395
-            }
396
-        }
390
+		$count = 0;
391
+		foreach ( $ids as $id ) {
392
+			$d = FrmForm::destroy( $id );
393
+			if ( $d ) {
394
+				$count++;
395
+			}
396
+		}
397 397
 
398
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
398
+		$message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
399 399
 
400
-        return $message;
401
-    }
400
+		return $message;
401
+	}
402 402
 
403
-    private static function delete_all() {
404
-        //check nonce url
405
-        $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable');
406
-        if ( $permission_error !== false ) {
403
+	private static function delete_all() {
404
+		//check nonce url
405
+		$permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable');
406
+		if ( $permission_error !== false ) {
407 407
 			self::display_forms_list( array(), '', array( $permission_error ) );
408
-            return;
409
-        }
408
+			return;
409
+		}
410 410
 
411 411
 		$count = FrmForm::scheduled_delete( time() );
412
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
412
+		$message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
413 413
 
414 414
 		self::display_forms_list( array(), $message );
415
-    }
415
+	}
416 416
 
417 417
 	public static function scheduled_delete( $delete_timestamp = '' ) {
418 418
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::scheduled_delete' );
@@ -420,11 +420,11 @@  discard block
 block discarded – undo
420 420
 	}
421 421
 
422 422
 	/**
423
-	* Inserts Formidable button
424
-	* Hook exists since 2.5.0
425
-	*
426
-	* @since 2.0.15
427
-	*/
423
+	 * Inserts Formidable button
424
+	 * Hook exists since 2.5.0
425
+	 *
426
+	 * @since 2.0.15
427
+	 */
428 428
 	public static function insert_form_button() {
429 429
 		if ( current_user_can('frm_view_forms') ) {
430 430
 			$menu_name = FrmAppHelper::get_menu_name();
@@ -435,49 +435,49 @@  discard block
 block discarded – undo
435 435
 		}
436 436
 	}
437 437
 
438
-    public static function insert_form_popup() {
438
+	public static function insert_form_popup() {
439 439
 		$page = basename( FrmAppHelper::get_server_value( 'PHP_SELF' ) );
440 440
 		if ( ! in_array( $page, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php' ) ) ) {
441
-            return;
442
-        }
441
+			return;
442
+		}
443 443
 
444
-        FrmAppHelper::load_admin_wide_js();
444
+		FrmAppHelper::load_admin_wide_js();
445 445
 
446
-        $shortcodes = array(
446
+		$shortcodes = array(
447 447
 			'formidable' => array( 'name' => __( 'Form', 'formidable' ), 'label' => __( 'Insert a Form', 'formidable' ) ),
448
-        );
448
+		);
449 449
 
450
-        $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes);
450
+		$shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes);
451 451
 
452
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/insert_form_popup.php');
453
-    }
452
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/insert_form_popup.php');
453
+	}
454 454
 
455
-    public static function get_shortcode_opts() {
455
+	public static function get_shortcode_opts() {
456 456
 		FrmAppHelper::permission_check('frm_view_forms');
457
-        check_ajax_referer( 'frm_ajax', 'nonce' );
457
+		check_ajax_referer( 'frm_ajax', 'nonce' );
458 458
 
459 459
 		$shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' );
460
-        if ( empty($shortcode) ) {
461
-            wp_die();
462
-        }
460
+		if ( empty($shortcode) ) {
461
+			wp_die();
462
+		}
463 463
 
464
-        echo '<div id="sc-opts-'. esc_attr( $shortcode ) .'" class="frm_shortcode_option">';
465
-        echo '<input type="radio" name="frmsc" value="'. esc_attr($shortcode) .'" id="sc-'. esc_attr($shortcode) .'" class="frm_hidden" />';
464
+		echo '<div id="sc-opts-'. esc_attr( $shortcode ) .'" class="frm_shortcode_option">';
465
+		echo '<input type="radio" name="frmsc" value="'. esc_attr($shortcode) .'" id="sc-'. esc_attr($shortcode) .'" class="frm_hidden" />';
466 466
 
467
-        $form_id = '';
468
-        $opts = array();
467
+		$form_id = '';
468
+		$opts = array();
469 469
 		switch ( $shortcode ) {
470
-            case 'formidable':
471
-                $opts = array(
470
+			case 'formidable':
471
+				$opts = array(
472 472
 					'form_id'       => 'id',
473
-                    //'key' => ',
473
+					//'key' => ',
474 474
 					'title'         => array( 'val' => 1, 'label' => __( 'Display form title', 'formidable' ) ),
475 475
 					'description'   => array( 'val' => 1, 'label' => __( 'Display form description', 'formidable' ) ),
476 476
 					'minimize'      => array( 'val' => 1, 'label' => __( 'Minimize form HTML', 'formidable' ) ),
477
-                );
478
-            break;
479
-        }
480
-        $opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode);
477
+				);
478
+			break;
479
+		}
480
+		$opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode);
481 481
 
482 482
 		if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) {
483 483
 			// allow other shortcodes to use the required form id option
@@ -485,63 +485,63 @@  discard block
 block discarded – undo
485 485
 			unset( $opts['form_id'] );
486 486
 		}
487 487
 
488
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/shortcode_opts.php');
488
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/shortcode_opts.php');
489 489
 
490
-        echo '</div>';
490
+		echo '</div>';
491 491
 
492
-        wp_die();
493
-    }
492
+		wp_die();
493
+	}
494 494
 
495 495
 	public static function display_forms_list( $params = array(), $message = '', $errors = array(), $deprecated_errors = array() ) {
496
-        FrmAppHelper::permission_check( 'frm_view_forms' );
496
+		FrmAppHelper::permission_check( 'frm_view_forms' );
497 497
 		if ( ! empty( $deprecated_errors ) ) {
498 498
 			$errors = $deprecated_errors;
499 499
 			_deprecated_argument( 'errors', '2.0.8' );
500 500
 		}
501 501
 
502
-        global $wpdb, $frm_vars;
502
+		global $wpdb, $frm_vars;
503 503
 
504 504
 		if ( empty( $params ) ) {
505 505
 			$params = FrmForm::list_page_params();
506
-        }
506
+		}
507 507
 
508
-        $wp_list_table = new FrmFormsListHelper( compact( 'params' ) );
508
+		$wp_list_table = new FrmFormsListHelper( compact( 'params' ) );
509 509
 
510
-        $pagenum = $wp_list_table->get_pagenum();
510
+		$pagenum = $wp_list_table->get_pagenum();
511 511
 
512
-        $wp_list_table->prepare_items();
512
+		$wp_list_table->prepare_items();
513 513
 
514
-        $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
515
-        if ( $pagenum > $total_pages && $total_pages > 0 ) {
514
+		$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
515
+		if ( $pagenum > $total_pages && $total_pages > 0 ) {
516 516
 			wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) );
517
-            die();
518
-        }
517
+			die();
518
+		}
519 519
 
520
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/list.php');
521
-    }
520
+		require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/list.php');
521
+	}
522 522
 
523 523
 	public static function get_columns( $columns ) {
524
-	    $columns['cb'] = '<input type="checkbox" />';
525
-	    $columns['id'] = 'ID';
524
+		$columns['cb'] = '<input type="checkbox" />';
525
+		$columns['id'] = 'ID';
526 526
 
527
-        $type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : 'published';
527
+		$type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : 'published';
528 528
 
529
-        if ( 'template' == $type ) {
530
-            $columns['name']        = __( 'Template Name', 'formidable' );
531
-            $columns['type']        = __( 'Type', 'formidable' );
532
-            $columns['form_key']    = __( 'Key', 'formidable' );
533
-        } else {
534
-            $columns['name']        = __( 'Form Title', 'formidable' );
535
-            $columns['entries']     = __( 'Entries', 'formidable' );
536
-            $columns['form_key']    = __( 'Key', 'formidable' );
537
-            $columns['shortcode']   = __( 'Shortcodes', 'formidable' );
538
-        }
529
+		if ( 'template' == $type ) {
530
+			$columns['name']        = __( 'Template Name', 'formidable' );
531
+			$columns['type']        = __( 'Type', 'formidable' );
532
+			$columns['form_key']    = __( 'Key', 'formidable' );
533
+		} else {
534
+			$columns['name']        = __( 'Form Title', 'formidable' );
535
+			$columns['entries']     = __( 'Entries', 'formidable' );
536
+			$columns['form_key']    = __( 'Key', 'formidable' );
537
+			$columns['shortcode']   = __( 'Shortcodes', 'formidable' );
538
+		}
539 539
 
540
-        $columns['created_at'] = __( 'Date', 'formidable' );
540
+		$columns['created_at'] = __( 'Date', 'formidable' );
541 541
 
542 542
 		add_screen_option( 'per_page', array( 'label' => __( 'Forms', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_per_page' ) );
543 543
 
544
-        return $columns;
544
+		return $columns;
545 545
 	}
546 546
 
547 547
 	public static function get_sortable_columns() {
@@ -555,110 +555,110 @@  discard block
 block discarded – undo
555 555
 	}
556 556
 
557 557
 	public static function hidden_columns( $result ) {
558
-        $return = false;
559
-        foreach ( (array) $result as $r ) {
560
-            if ( ! empty( $r ) ) {
561
-                $return = true;
562
-                break;
563
-            }
564
-        }
558
+		$return = false;
559
+		foreach ( (array) $result as $r ) {
560
+			if ( ! empty( $r ) ) {
561
+				$return = true;
562
+				break;
563
+			}
564
+		}
565 565
 
566
-        if ( $return ) {
567
-            return $result;
566
+		if ( $return ) {
567
+			return $result;
568 568
 		}
569 569
 
570
-        $type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
570
+		$type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
571 571
 
572
-        $result[] = 'created_at';
573
-        if ( $type == 'template' ) {
574
-            $result[] = 'id';
575
-            $result[] = 'form_key';
576
-        }
572
+		$result[] = 'created_at';
573
+		if ( $type == 'template' ) {
574
+			$result[] = 'id';
575
+			$result[] = 'form_key';
576
+		}
577 577
 
578
-        return $result;
579
-    }
578
+		return $result;
579
+	}
580 580
 
581 581
 	public static function save_per_page( $save, $option, $value ) {
582
-        if ( $option == 'formidable_page_formidable_per_page' ) {
583
-            $save = (int) $value;
584
-        }
585
-        return $save;
586
-    }
582
+		if ( $option == 'formidable_page_formidable_per_page' ) {
583
+			$save = (int) $value;
584
+		}
585
+		return $save;
586
+	}
587 587
 
588 588
 	private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) {
589
-        global $frm_vars;
589
+		global $frm_vars;
590 590
 
591
-        $form = FrmForm::getOne( $id );
592
-        if ( ! $form ) {
593
-            wp_die( __( 'You are trying to edit a form that does not exist.', 'formidable' ) );
594
-        }
591
+		$form = FrmForm::getOne( $id );
592
+		if ( ! $form ) {
593
+			wp_die( __( 'You are trying to edit a form that does not exist.', 'formidable' ) );
594
+		}
595 595
 
596
-        if ( $form->parent_form_id ) {
596
+		if ( $form->parent_form_id ) {
597 597
 			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>' ));
598
-        }
598
+		}
599 599
 
600 600
 		$frm_field_selection = FrmField::field_selection();
601
-        $fields = FrmField::get_all_for_form($form->id);
601
+		$fields = FrmField::get_all_for_form($form->id);
602 602
 
603
-        // Automatically add end section fields if they don't exist (2.0 migration)
604
-        $reset_fields = false;
605
-        FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields );
603
+		// Automatically add end section fields if they don't exist (2.0 migration)
604
+		$reset_fields = false;
605
+		FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields );
606 606
 
607
-        if ( $reset_fields ) {
608
-            $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
609
-        }
607
+		if ( $reset_fields ) {
608
+			$fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
609
+		}
610 610
 
611
-        unset($end_section_values, $last_order, $open, $reset_fields);
611
+		unset($end_section_values, $last_order, $open, $reset_fields);
612 612
 
613
-        $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
613
+		$values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
614 614
 
615
-        $edit_message = __( 'Form was Successfully Updated', 'formidable' );
616
-        if ( $form->is_template && $message == $edit_message ) {
617
-            $message = __( 'Template was Successfully Updated', 'formidable' );
618
-        }
615
+		$edit_message = __( 'Form was Successfully Updated', 'formidable' );
616
+		if ( $form->is_template && $message == $edit_message ) {
617
+			$message = __( 'Template was Successfully Updated', 'formidable' );
618
+		}
619 619
 
620 620
 		$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
621 621
 
622
-        if ( $form->default_template ) {
623
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
624
-        } else if ( defined('DOING_AJAX') ) {
625
-            wp_die();
626
-        } else if ( $create_link ) {
627
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php');
628
-        } else {
629
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/edit.php');
630
-        }
631
-    }
622
+		if ( $form->default_template ) {
623
+			wp_die(__( 'That template cannot be edited', 'formidable' ));
624
+		} else if ( defined('DOING_AJAX') ) {
625
+			wp_die();
626
+		} else if ( $create_link ) {
627
+			require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php');
628
+		} else {
629
+			require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/edit.php');
630
+		}
631
+	}
632 632
 
633 633
 	public static function get_settings_vars( $id, $errors = array(), $message = '' ) {
634 634
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
635 635
 
636
-        global $frm_vars;
636
+		global $frm_vars;
637 637
 
638
-        $form = FrmForm::getOne( $id );
638
+		$form = FrmForm::getOne( $id );
639 639
 
640
-        $fields = FrmField::get_all_for_form($id);
641
-        $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
640
+		$fields = FrmField::get_all_for_form($id);
641
+		$values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
642 642
 
643
-        if ( isset($values['default_template']) && $values['default_template'] ) {
644
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
645
-        }
643
+		if ( isset($values['default_template']) && $values['default_template'] ) {
644
+			wp_die(__( 'That template cannot be edited', 'formidable' ));
645
+		}
646 646
 
647
-        $action_controls = FrmFormActionsController::get_form_actions();
647
+		$action_controls = FrmFormActionsController::get_form_actions();
648 648
 
649
-        $sections = apply_filters('frm_add_form_settings_section', array(), $values);
650
-        $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
649
+		$sections = apply_filters('frm_add_form_settings_section', array(), $values);
650
+		$pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
651 651
 
652
-        $styles = apply_filters('frm_get_style_opts', array());
652
+		$styles = apply_filters('frm_get_style_opts', array());
653 653
 
654
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/settings.php');
655
-    }
654
+		require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/settings.php');
655
+	}
656 656
 
657
-    public static function mb_tags_box( $form_id, $class = '' ) {
658
-        $fields = FrmField::get_all_for_form($form_id, '', 'include');
659
-        $linked_forms = array();
660
-        $col = 'one';
661
-        $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false;
657
+	public static function mb_tags_box( $form_id, $class = '' ) {
658
+		$fields = FrmField::get_all_for_form($form_id, '', 'include');
659
+		$linked_forms = array();
660
+		$col = 'one';
661
+		$settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false;
662 662
 
663 663
 		$cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() );
664 664
 		$adv_shortcodes = self::get_advanced_shortcodes();
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
 		$entry_shortcodes = self::get_shortcode_helpers( $settings_tab );
667 667
 
668 668
 		include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' );
669
-    }
669
+	}
670 670
 
671 671
 	/**
672 672
 	 * Get an array of the options to display in the advanced tab
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
 			''          => '',
708 708
 			'siteurl'   => __( 'Site URL', 'formidable' ),
709 709
 			'sitename'  => __( 'Site Name', 'formidable' ),
710
-        );
710
+		);
711 711
 
712 712
 		if ( ! FrmAppHelper::pro_is_installed() ) {
713 713
 			unset( $entry_shortcodes['post_id'] );
@@ -734,39 +734,39 @@  discard block
 block discarded – undo
734 734
 		return $entry_shortcodes;
735 735
 	}
736 736
 
737
-    // Insert the form class setting into the form
737
+	// Insert the form class setting into the form
738 738
 	public static function form_classes( $form ) {
739
-        if ( isset($form->options['form_class']) ) {
739
+		if ( isset($form->options['form_class']) ) {
740 740
 			echo esc_attr( sanitize_text_field( $form->options['form_class'] ) );
741
-        }
742
-    }
741
+		}
742
+	}
743 743
 
744
-    public static function get_email_html() {
744
+	public static function get_email_html() {
745 745
 		FrmAppHelper::permission_check('frm_view_forms');
746
-        check_ajax_referer( 'frm_ajax', 'nonce' );
746
+		check_ajax_referer( 'frm_ajax', 'nonce' );
747 747
 		echo FrmEntryFormat::show_entry( array(
748 748
 			'form_id'       => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ),
749
-	        'default_email' => true,
749
+			'default_email' => true,
750 750
 			'plain_text'    => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ),
751
-	    ) );
752
-	    wp_die();
751
+		) );
752
+		wp_die();
753 753
 	}
754 754
 
755
-    public static function filter_content( $content, $form, $entry = false ) {
755
+	public static function filter_content( $content, $form, $entry = false ) {
756 756
 		self::get_entry_by_param( $entry );
757
-        if ( ! $entry ) {
758
-            return $content;
759
-        }
757
+		if ( ! $entry ) {
758
+			return $content;
759
+		}
760 760
 
761
-        if ( is_object( $form ) ) {
762
-            $form = $form->id;
763
-        }
761
+		if ( is_object( $form ) ) {
762
+			$form = $form->id;
763
+		}
764 764
 
765
-        $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form );
766
-        $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes );
765
+		$shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form );
766
+		$content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes );
767 767
 
768
-        return $content;
769
-    }
768
+		return $content;
769
+	}
770 770
 
771 771
 	private static function get_entry_by_param( &$entry ) {
772 772
 		if ( ! $entry || ! is_object( $entry ) ) {
@@ -778,287 +778,287 @@  discard block
 block discarded – undo
778 778
 		}
779 779
 	}
780 780
 
781
-    public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
782
-        return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
783
-    }
781
+	public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
782
+		return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
783
+	}
784 784
 
785
-    public static function process_bulk_form_actions( $errors ) {
786
-        if ( ! $_REQUEST ) {
787
-            return $errors;
788
-        }
785
+	public static function process_bulk_form_actions( $errors ) {
786
+		if ( ! $_REQUEST ) {
787
+			return $errors;
788
+		}
789 789
 
790 790
 		$bulkaction = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' );
791
-        if ( $bulkaction == -1 ) {
791
+		if ( $bulkaction == -1 ) {
792 792
 			$bulkaction = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
793
-        }
794
-
795
-        if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) {
796
-            FrmAppHelper::remove_get_action();
797
-
798
-            $bulkaction = str_replace( 'bulk_', '', $bulkaction );
799
-        }
800
-
801
-        $ids = FrmAppHelper::get_param( 'item-action', '' );
802
-        if ( empty( $ids ) ) {
803
-            $errors[] = __( 'No forms were specified', 'formidable' );
804
-            return $errors;
805
-        }
806
-
807
-        $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' );
808
-        if ( $permission_error !== false ) {
809
-            $errors[] = $permission_error;
810
-            return $errors;
811
-        }
812
-
813
-        if ( ! is_array( $ids ) ) {
814
-            $ids = explode( ',', $ids );
815
-        }
816
-
817
-        switch ( $bulkaction ) {
818
-            case 'delete':
819
-                $message = self::bulk_destroy( $ids );
820
-            break;
821
-            case 'trash':
822
-                $message = self::bulk_trash( $ids );
823
-            break;
824
-            case 'untrash':
825
-                $message = self::bulk_untrash( $ids );
826
-            break;
827
-            case 'create_template':
828
-                $message = self::bulk_create_template( $ids );
829
-            break;
830
-        }
831
-
832
-        if ( isset( $message ) && ! empty( $message ) ) {
793
+		}
794
+
795
+		if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) {
796
+			FrmAppHelper::remove_get_action();
797
+
798
+			$bulkaction = str_replace( 'bulk_', '', $bulkaction );
799
+		}
800
+
801
+		$ids = FrmAppHelper::get_param( 'item-action', '' );
802
+		if ( empty( $ids ) ) {
803
+			$errors[] = __( 'No forms were specified', 'formidable' );
804
+			return $errors;
805
+		}
806
+
807
+		$permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' );
808
+		if ( $permission_error !== false ) {
809
+			$errors[] = $permission_error;
810
+			return $errors;
811
+		}
812
+
813
+		if ( ! is_array( $ids ) ) {
814
+			$ids = explode( ',', $ids );
815
+		}
816
+
817
+		switch ( $bulkaction ) {
818
+			case 'delete':
819
+				$message = self::bulk_destroy( $ids );
820
+			break;
821
+			case 'trash':
822
+				$message = self::bulk_trash( $ids );
823
+			break;
824
+			case 'untrash':
825
+				$message = self::bulk_untrash( $ids );
826
+			break;
827
+			case 'create_template':
828
+				$message = self::bulk_create_template( $ids );
829
+			break;
830
+		}
831
+
832
+		if ( isset( $message ) && ! empty( $message ) ) {
833 833
 			echo '<div id="message" class="updated frm_msg_padding">' . FrmAppHelper::kses( $message ) . '</div>';
834
-        }
834
+		}
835 835
 
836
-        return $errors;
837
-    }
836
+		return $errors;
837
+	}
838 838
 
839
-    public static function add_default_templates( $path, $default = true, $template = true ) {
840
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' );
839
+	public static function add_default_templates( $path, $default = true, $template = true ) {
840
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' );
841 841
 
842
-        $path = untrailingslashit(trim($path));
843
-        $templates = glob( $path .'/*.php' );
842
+		$path = untrailingslashit(trim($path));
843
+		$templates = glob( $path .'/*.php' );
844 844
 
845 845
 		for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) {
846
-            $filename = str_replace( '.php', '', str_replace( $path.'/', '', $templates[ $i ] ) );
846
+			$filename = str_replace( '.php', '', str_replace( $path.'/', '', $templates[ $i ] ) );
847 847
 			$template_query = array( 'form_key' => $filename );
848
-            if ( $template ) {
849
-                $template_query['is_template'] = 1;
850
-            }
851
-            if ( $default ) {
852
-                $template_query['default_template'] = 1;
853
-            }
848
+			if ( $template ) {
849
+				$template_query['is_template'] = 1;
850
+			}
851
+			if ( $default ) {
852
+				$template_query['default_template'] = 1;
853
+			}
854 854
 			$form = FrmForm::getAll( $template_query, '', 1 );
855 855
 
856
-            $values = FrmFormsHelper::setup_new_vars();
857
-            $values['form_key'] = $filename;
858
-            $values['is_template'] = $template;
859
-            $values['status'] = 'published';
860
-            if ( $default ) {
861
-                $values['default_template'] = 1;
862
-            }
863
-
864
-            include( $templates[ $i ] );
865
-
866
-            //get updated form
867
-            if ( isset($form) && ! empty($form) ) {
868
-                $old_id = $form->id;
869
-                $form = FrmForm::getOne($form->id);
870
-            } else {
871
-                $old_id = false;
856
+			$values = FrmFormsHelper::setup_new_vars();
857
+			$values['form_key'] = $filename;
858
+			$values['is_template'] = $template;
859
+			$values['status'] = 'published';
860
+			if ( $default ) {
861
+				$values['default_template'] = 1;
862
+			}
863
+
864
+			include( $templates[ $i ] );
865
+
866
+			//get updated form
867
+			if ( isset($form) && ! empty($form) ) {
868
+				$old_id = $form->id;
869
+				$form = FrmForm::getOne($form->id);
870
+			} else {
871
+				$old_id = false;
872 872
 				$form = FrmForm::getAll( $template_query, '', 1 );
873
-            }
873
+			}
874 874
 
875
-            if ( $form ) {
875
+			if ( $form ) {
876 876
 				do_action( 'frm_after_duplicate_form', $form->id, (array) $form, array( 'old_id' => $old_id ) );
877
-            }
878
-        }
879
-    }
877
+			}
878
+		}
879
+	}
880 880
 
881
-    public static function route() {
882
-        $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
883
-        $vars = array();
881
+	public static function route() {
882
+		$action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
883
+		$vars = array();
884 884
 		if ( isset( $_POST['frm_compact_fields'] ) ) {
885 885
 			FrmAppHelper::permission_check( 'frm_edit_forms' );
886 886
 
887
-            $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('&quot;', '\\\"', $_POST['frm_compact_fields'] ))));
888
-            $json_vars = json_decode($json_vars, true);
889
-            if ( empty($json_vars) ) {
890
-                // json decoding failed so we should return an error message
887
+			$json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('&quot;', '\\\"', $_POST['frm_compact_fields'] ))));
888
+			$json_vars = json_decode($json_vars, true);
889
+			if ( empty($json_vars) ) {
890
+				// json decoding failed so we should return an error message
891 891
 				$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
892
-                if ( 'edit' == $action ) {
893
-                    $action = 'update';
894
-                }
895
-
896
-                add_filter('frm_validate_form', 'FrmFormsController::json_error');
897
-            } else {
898
-                $vars = FrmAppHelper::json_to_array($json_vars);
899
-                $action = $vars[ $action ];
892
+				if ( 'edit' == $action ) {
893
+					$action = 'update';
894
+				}
895
+
896
+				add_filter('frm_validate_form', 'FrmFormsController::json_error');
897
+			} else {
898
+				$vars = FrmAppHelper::json_to_array($json_vars);
899
+				$action = $vars[ $action ];
900 900
 				unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] );
901 901
 				$_REQUEST = array_merge( $_REQUEST, $vars );
902 902
 				$_POST = array_merge( $_POST, $_REQUEST );
903
-            }
904
-        } else {
903
+			}
904
+		} else {
905 905
 			$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
906
-    		if ( isset( $_REQUEST['delete_all'] ) ) {
907
-                // override the action for this page
908
-    			$action = 'delete_all';
909
-            }
910
-        }
906
+			if ( isset( $_REQUEST['delete_all'] ) ) {
907
+				// override the action for this page
908
+				$action = 'delete_all';
909
+			}
910
+		}
911 911
 
912 912
 		add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
913
-        FrmAppHelper::trigger_hook_load( 'form' );
914
-
915
-        switch ( $action ) {
916
-            case 'new':
917
-                return self::new_form($vars);
918
-            case 'create':
919
-            case 'edit':
920
-            case 'update':
921
-            case 'duplicate':
922
-            case 'trash':
923
-            case 'untrash':
924
-            case 'destroy':
925
-            case 'delete_all':
926
-            case 'settings':
927
-            case 'update_settings':
913
+		FrmAppHelper::trigger_hook_load( 'form' );
914
+
915
+		switch ( $action ) {
916
+			case 'new':
917
+				return self::new_form($vars);
918
+			case 'create':
919
+			case 'edit':
920
+			case 'update':
921
+			case 'duplicate':
922
+			case 'trash':
923
+			case 'untrash':
924
+			case 'destroy':
925
+			case 'delete_all':
926
+			case 'settings':
927
+			case 'update_settings':
928 928
 				return self::$action( $vars );
929
-            default:
930
-                do_action('frm_form_action_'. $action);
931
-                if ( apply_filters('frm_form_stop_action_'. $action, false) ) {
932
-                    return;
933
-                }
929
+			default:
930
+				do_action('frm_form_action_'. $action);
931
+				if ( apply_filters('frm_form_stop_action_'. $action, false) ) {
932
+					return;
933
+				}
934 934
 
935 935
 				$action = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' );
936
-                if ( $action == -1 ) {
936
+				if ( $action == -1 ) {
937 937
 					$action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
938
-                }
938
+				}
939 939
 
940
-                if ( strpos($action, 'bulk_') === 0 ) {
941
-                    FrmAppHelper::remove_get_action();
942
-                    return self::list_form();
943
-                }
940
+				if ( strpos($action, 'bulk_') === 0 ) {
941
+					FrmAppHelper::remove_get_action();
942
+					return self::list_form();
943
+				}
944 944
 
945
-                return self::display_forms_list();
946
-        }
947
-    }
945
+				return self::display_forms_list();
946
+		}
947
+	}
948 948
 
949
-    public static function json_error( $errors ) {
950
-        $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' );
951
-        return $errors;
952
-    }
949
+	public static function json_error( $errors ) {
950
+		$errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' );
951
+		return $errors;
952
+	}
953 953
 
954 954
 
955
-    /* FRONT-END FORMS */
956
-    public static function admin_bar_css() {
955
+	/* FRONT-END FORMS */
956
+	public static function admin_bar_css() {
957 957
 		if ( is_admin() || ! current_user_can( 'frm_edit_forms' ) ) {
958
-            return;
959
-        }
958
+			return;
959
+		}
960 960
 
961 961
 		add_action( 'wp_before_admin_bar_render', 'FrmFormsController::admin_bar_configure' );
962 962
 		FrmAppHelper::load_font_style();
963 963
 	}
964 964
 
965 965
 	public static function admin_bar_configure() {
966
-        global $frm_vars;
967
-        if ( empty($frm_vars['forms_loaded']) ) {
968
-            return;
969
-        }
970
-
971
-        $actions = array();
972
-        foreach ( $frm_vars['forms_loaded'] as $form ) {
973
-            if ( is_object($form) ) {
974
-                $actions[ $form->id ] = $form->name;
975
-            }
976
-            unset($form);
977
-        }
978
-
979
-        if ( empty($actions) ) {
980
-            return;
981
-        }
982
-
983
-        asort($actions);
984
-
985
-        global $wp_admin_bar;
986
-
987
-        if ( count($actions) == 1 ) {
988
-            $wp_admin_bar->add_menu( array(
989
-                'title' => 'Edit Form',
990
-                'href'  => admin_url('admin.php?page=formidable&frm_action=edit&id='. current( array_keys( $actions ) )),
991
-                'id'    => 'frm-forms',
992
-            ) );
993
-        } else {
994
-            $wp_admin_bar->add_menu( array(
995
-        		'id'    => 'frm-forms',
996
-        		'title' => '<span class="ab-icon"></span><span class="ab-label">' . __( 'Edit Forms', 'formidable' ) . '</span>',
997
-        		'href'  => admin_url( 'admin.php?page=formidable&frm_action=edit&id='. current( array_keys( $actions ) ) ),
998
-        		'meta'  => array(
966
+		global $frm_vars;
967
+		if ( empty($frm_vars['forms_loaded']) ) {
968
+			return;
969
+		}
970
+
971
+		$actions = array();
972
+		foreach ( $frm_vars['forms_loaded'] as $form ) {
973
+			if ( is_object($form) ) {
974
+				$actions[ $form->id ] = $form->name;
975
+			}
976
+			unset($form);
977
+		}
978
+
979
+		if ( empty($actions) ) {
980
+			return;
981
+		}
982
+
983
+		asort($actions);
984
+
985
+		global $wp_admin_bar;
986
+
987
+		if ( count($actions) == 1 ) {
988
+			$wp_admin_bar->add_menu( array(
989
+				'title' => 'Edit Form',
990
+				'href'  => admin_url('admin.php?page=formidable&frm_action=edit&id='. current( array_keys( $actions ) )),
991
+				'id'    => 'frm-forms',
992
+			) );
993
+		} else {
994
+			$wp_admin_bar->add_menu( array(
995
+				'id'    => 'frm-forms',
996
+				'title' => '<span class="ab-icon"></span><span class="ab-label">' . __( 'Edit Forms', 'formidable' ) . '</span>',
997
+				'href'  => admin_url( 'admin.php?page=formidable&frm_action=edit&id='. current( array_keys( $actions ) ) ),
998
+				'meta'  => array(
999 999
 					'title' => __( 'Edit Forms', 'formidable' ),
1000
-        		),
1001
-        	) );
1000
+				),
1001
+			) );
1002 1002
 
1003
-        	foreach ( $actions as $form_id => $name ) {
1003
+			foreach ( $actions as $form_id => $name ) {
1004 1004
 
1005
-        		$wp_admin_bar->add_menu( array(
1006
-        			'parent'    => 'frm-forms',
1007
-        			'id'        => 'edit_form_'. $form_id,
1008
-        			'title'     => empty($name) ? __( '(no title)') : $name,
1005
+				$wp_admin_bar->add_menu( array(
1006
+					'parent'    => 'frm-forms',
1007
+					'id'        => 'edit_form_'. $form_id,
1008
+					'title'     => empty($name) ? __( '(no title)') : $name,
1009 1009
 					'href'      => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ),
1010
-        		) );
1011
-        	}
1012
-        }
1013
-    }
1010
+				) );
1011
+			}
1012
+		}
1013
+	}
1014 1014
 
1015
-    //formidable shortcode
1015
+	//formidable shortcode
1016 1016
 	public static function get_form_shortcode( $atts ) {
1017
-        global $frm_vars;
1018
-        if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) {
1019
-            $sc = '[formidable';
1017
+		global $frm_vars;
1018
+		if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) {
1019
+			$sc = '[formidable';
1020 1020
 			if ( ! empty( $atts ) ) {
1021 1021
 				foreach ( $atts as $k => $v ) {
1022 1022
 					$sc .= ' ' . $k . '="' . esc_attr( $v ) . '"';
1023 1023
 				}
1024 1024
 			}
1025
-            return $sc .']';
1026
-        }
1027
-
1028
-        $shortcode_atts = shortcode_atts( array(
1029
-            'id' => '', 'key' => '', 'title' => false, 'description' => false,
1030
-            'readonly' => false, 'entry_id' => false, 'fields' => array(),
1031
-            'exclude_fields' => array(), 'minimize' => false,
1032
-        ), $atts);
1033
-        do_action('formidable_shortcode_atts', $shortcode_atts, $atts);
1034
-
1035
-        return self::show_form(
1036
-            $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'],
1037
-            $shortcode_atts['description'], $atts
1038
-        );
1039
-    }
1040
-
1041
-    public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
1042
-        if ( empty( $id ) ) {
1043
-            $id = $key;
1044
-        }
1045
-
1046
-        // no form id or key set
1047
-        if ( empty( $id ) ) {
1048
-            return __( 'Please select a valid form', 'formidable' );
1049
-        }
1050
-
1051
-        $form = FrmForm::getOne( $id );
1052
-        if ( ! $form || $form->parent_form_id ) {
1053
-            return __( 'Please select a valid form', 'formidable' );
1054
-        }
1025
+			return $sc .']';
1026
+		}
1027
+
1028
+		$shortcode_atts = shortcode_atts( array(
1029
+			'id' => '', 'key' => '', 'title' => false, 'description' => false,
1030
+			'readonly' => false, 'entry_id' => false, 'fields' => array(),
1031
+			'exclude_fields' => array(), 'minimize' => false,
1032
+		), $atts);
1033
+		do_action('formidable_shortcode_atts', $shortcode_atts, $atts);
1034
+
1035
+		return self::show_form(
1036
+			$shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'],
1037
+			$shortcode_atts['description'], $atts
1038
+		);
1039
+	}
1040
+
1041
+	public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
1042
+		if ( empty( $id ) ) {
1043
+			$id = $key;
1044
+		}
1045
+
1046
+		// no form id or key set
1047
+		if ( empty( $id ) ) {
1048
+			return __( 'Please select a valid form', 'formidable' );
1049
+		}
1050
+
1051
+		$form = FrmForm::getOne( $id );
1052
+		if ( ! $form || $form->parent_form_id ) {
1053
+			return __( 'Please select a valid form', 'formidable' );
1054
+		}
1055 1055
 
1056 1056
 		add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
1057
-        FrmAppHelper::trigger_hook_load( 'form', $form );
1057
+		FrmAppHelper::trigger_hook_load( 'form', $form );
1058 1058
 
1059
-        $form = apply_filters( 'frm_pre_display_form', $form );
1059
+		$form = apply_filters( 'frm_pre_display_form', $form );
1060 1060
 
1061
-        $frm_settings = FrmAppHelper::get_settings();
1061
+		$frm_settings = FrmAppHelper::get_settings();
1062 1062
 
1063 1063
 		if ( self::is_viewable_draft_form( $form ) ) {
1064 1064
 			// don't show a draft form on a page
@@ -1079,7 +1079,7 @@  discard block
 block discarded – undo
1079 1079
 		}
1080 1080
 
1081 1081
 		return $form;
1082
-    }
1082
+	}
1083 1083
 
1084 1084
 	private static function is_viewable_draft_form( $form ) {
1085 1085
 		global $post;
@@ -1095,98 +1095,98 @@  discard block
 block discarded – undo
1095 1095
 		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'] );
1096 1096
 	}
1097 1097
 
1098
-    public static function get_form( $form, $title, $description, $atts = array() ) {
1099
-        ob_start();
1098
+	public static function get_form( $form, $title, $description, $atts = array() ) {
1099
+		ob_start();
1100 1100
 
1101
-        self::get_form_contents( $form, $title, $description, $atts );
1101
+		self::get_form_contents( $form, $title, $description, $atts );
1102 1102
 		self::enqueue_scripts( FrmForm::get_params( $form ) );
1103 1103
 
1104
-        $contents = ob_get_contents();
1105
-        ob_end_clean();
1104
+		$contents = ob_get_contents();
1105
+		ob_end_clean();
1106 1106
 
1107 1107
 		self::maybe_minimize_form( $atts, $contents );
1108 1108
 
1109
-        return $contents;
1110
-    }
1109
+		return $contents;
1110
+	}
1111 1111
 
1112 1112
 	public static function enqueue_scripts( $params ) {
1113 1113
 		do_action( 'frm_enqueue_form_scripts', $params );
1114 1114
 	}
1115 1115
 
1116 1116
 	public static function get_form_contents( $form, $title, $description, $atts ) {
1117
-        global $frm_vars;
1117
+		global $frm_vars;
1118 1118
 
1119
-        $frm_settings = FrmAppHelper::get_settings();
1119
+		$frm_settings = FrmAppHelper::get_settings();
1120 1120
 
1121
-        $submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value;
1121
+		$submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value;
1122 1122
 
1123
-        $user_ID = get_current_user_id();
1123
+		$user_ID = get_current_user_id();
1124 1124
 		$params = FrmForm::get_params( $form );
1125
-        $message = $errors = '';
1125
+		$message = $errors = '';
1126 1126
 
1127
-        if ( $params['posted_form_id'] == $form->id && $_POST ) {
1128
-            $errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array();
1129
-        }
1127
+		if ( $params['posted_form_id'] == $form->id && $_POST ) {
1128
+			$errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array();
1129
+		}
1130 1130
 
1131 1131
 		$include_form_tag = apply_filters( 'frm_include_form_tag', true, $form );
1132
-        $fields = FrmFieldsHelper::get_form_fields( $form->id, ( isset( $errors ) && ! empty( $errors ) ) );
1133
-
1134
-        if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) {
1135
-            do_action('frm_display_form_action', $params, $fields, $form, $title, $description);
1136
-            if ( apply_filters('frm_continue_to_new', true, $form->id, $params['action']) ) {
1137
-                $values = FrmEntriesHelper::setup_new_vars($fields, $form);
1138
-                include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
1139
-            }
1140
-            return;
1141
-        }
1142
-
1143
-        if ( ! empty($errors) ) {
1144
-            $values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array();
1145
-            include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
1146
-            return;
1147
-        }
1148
-
1149
-        do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description);
1150
-        if ( ! apply_filters('frm_continue_to_create', true, $form->id) ) {
1151
-            return;
1152
-        }
1153
-
1154
-        $values = FrmEntriesHelper::setup_new_vars($fields, $form, true);
1155
-        $created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form->id ] ) ) ? $frm_vars['created_entries'][ $form->id ]['entry_id'] : 0;
1156
-        $conf_method = apply_filters('frm_success_filter', 'message', $form, $form->options, 'create');
1157
-
1158
-        if ( $created && is_numeric($created) && $conf_method != 'message' ) {
1159
-            do_action('frm_success_action', $conf_method, $form, $form->options, $created);
1132
+		$fields = FrmFieldsHelper::get_form_fields( $form->id, ( isset( $errors ) && ! empty( $errors ) ) );
1133
+
1134
+		if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) {
1135
+			do_action('frm_display_form_action', $params, $fields, $form, $title, $description);
1136
+			if ( apply_filters('frm_continue_to_new', true, $form->id, $params['action']) ) {
1137
+				$values = FrmEntriesHelper::setup_new_vars($fields, $form);
1138
+				include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
1139
+			}
1140
+			return;
1141
+		}
1142
+
1143
+		if ( ! empty($errors) ) {
1144
+			$values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array();
1145
+			include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
1146
+			return;
1147
+		}
1148
+
1149
+		do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description);
1150
+		if ( ! apply_filters('frm_continue_to_create', true, $form->id) ) {
1151
+			return;
1152
+		}
1153
+
1154
+		$values = FrmEntriesHelper::setup_new_vars($fields, $form, true);
1155
+		$created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form->id ] ) ) ? $frm_vars['created_entries'][ $form->id ]['entry_id'] : 0;
1156
+		$conf_method = apply_filters('frm_success_filter', 'message', $form, $form->options, 'create');
1157
+
1158
+		if ( $created && is_numeric($created) && $conf_method != 'message' ) {
1159
+			do_action('frm_success_action', $conf_method, $form, $form->options, $created);
1160 1160
 			do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) );
1161
-            return;
1162
-        }
1161
+			return;
1162
+		}
1163 1163
 
1164
-        if ( $created && is_numeric($created) ) {
1165
-            $message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg;
1166
-            $class = 'frm_message';
1167
-        } else {
1168
-            $message = $frm_settings->failed_msg;
1169
-            $class = 'frm_error_style';
1170
-        }
1164
+		if ( $created && is_numeric($created) ) {
1165
+			$message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg;
1166
+			$class = 'frm_message';
1167
+		} else {
1168
+			$message = $frm_settings->failed_msg;
1169
+			$class = 'frm_error_style';
1170
+		}
1171 1171
 
1172 1172
 		$message = FrmFormsHelper::get_success_message( array(
1173 1173
 			'message' => $message, 'form' => $form,
1174 1174
 			'entry_id' => $created, 'class' => $class,
1175 1175
 		) );
1176
-        $message = apply_filters('frm_main_feedback', $message, $form, $created);
1176
+		$message = apply_filters('frm_main_feedback', $message, $form, $created);
1177 1177
 
1178
-        if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) {
1179
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
1180
-        } else {
1181
-            global $frm_vars;
1178
+		if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) {
1179
+			require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
1180
+		} else {
1181
+			global $frm_vars;
1182 1182
 			self::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] );
1183 1183
 
1184
-            $include_extra_container = 'frm_forms'. FrmFormsHelper::get_form_style_class($values);
1185
-            include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/errors.php');
1186
-        }
1184
+			$include_extra_container = 'frm_forms'. FrmFormsHelper::get_form_style_class($values);
1185
+			include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/errors.php');
1186
+		}
1187 1187
 
1188 1188
 		do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) );
1189
-    }
1189
+	}
1190 1190
 
1191 1191
 	public static function front_head() {
1192 1192
 		$version = FrmAppHelper::plugin_version();
@@ -1215,10 +1215,10 @@  discard block
 block discarded – undo
1215 1215
 	}
1216 1216
 
1217 1217
 	public static function defer_script_loading( $tag, $handle ) {
1218
-	    if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) {
1219
-	        $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag );
1218
+		if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) {
1219
+			$tag = str_replace( ' src', ' defer="defer" async="async" src', $tag );
1220 1220
 		}
1221
-	    return $tag;
1221
+		return $tag;
1222 1222
 	}
1223 1223
 
1224 1224
 	public static function footer_js( $location = 'footer' ) {
Please login to merge, or discard this patch.
Spacing   +152 added lines, -152 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
     }
@@ -18,14 +18,14 @@  discard block
 block discarded – undo
18 18
 			return;
19 19
 		}
20 20
 
21
-		add_filter('get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns' );
21
+		add_filter( 'get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns' );
22 22
 
23
-		add_filter('manage_toplevel_page_formidable_columns', 'FrmFormsController::get_columns', 0 );
24
-		add_filter('manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' );
23
+		add_filter( 'manage_toplevel_page_formidable_columns', 'FrmFormsController::get_columns', 0 );
24
+		add_filter( 'manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' );
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,49 +33,49 @@  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
-            return self::create($values);
59
+            return self::create( $values );
60 60
 		} else if ( $action == 'new' ) {
61 61
 			$frm_field_selection = FrmField::field_selection();
62
-            $values = FrmFormsHelper::setup_new_vars($values);
62
+            $values = FrmFormsHelper::setup_new_vars( $values );
63 63
             $id = FrmForm::create( $values );
64
-            $form = FrmForm::getOne($id);
64
+            $form = FrmForm::getOne( $id );
65 65
 
66 66
             // add default email notification
67 67
             $action_control = FrmFormActionsController::get_form_actions( 'email' );
68
-            $action_control->create($form->id);
68
+            $action_control->create( $form->id );
69 69
 
70 70
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
71 71
 
72 72
             $values['id'] = $id;
73
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php');
73
+            require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
74 74
         }
75 75
     }
76 76
 
77 77
 	public static function create( $values = array() ) {
78
-        FrmAppHelper::permission_check('frm_edit_forms');
78
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
79 79
 
80 80
         global $frm_vars;
81 81
         if ( empty( $values ) ) {
@@ -87,58 +87,58 @@  discard block
 block discarded – undo
87 87
             $values = FrmProEntry::mod_other_vals( $values, 'back' );
88 88
         }
89 89
 
90
-		$id = isset($values['id']) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
90
+		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
91 91
 
92 92
         if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
93 93
             $frm_settings = FrmAppHelper::get_settings();
94 94
             $errors = array( 'form' => $frm_settings->admin_permission );
95 95
         } else {
96
-            $errors = FrmForm::validate($values);
96
+            $errors = FrmForm::validate( $values );
97 97
         }
98 98
 
99
-        if ( count($errors) > 0 ) {
99
+        if ( count( $errors ) > 0 ) {
100 100
             $hide_preview = true;
101 101
 			$frm_field_selection = FrmField::field_selection();
102 102
             $form = FrmForm::getOne( $id );
103
-            $fields = FrmField::get_all_for_form($id);
103
+            $fields = FrmField::get_all_for_form( $id );
104 104
 
105
-            $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
105
+            $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true );
106 106
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
107 107
 
108
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php');
108
+            require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
109 109
         } else {
110 110
             FrmForm::update( $id, $values, true );
111
-            die(FrmAppHelper::js_redirect(admin_url('admin.php?page=formidable&frm_action=settings&id='. $id)));
111
+            die( FrmAppHelper::js_redirect( admin_url( 'admin.php?page=formidable&frm_action=settings&id=' . $id ) ) );
112 112
         }
113 113
     }
114 114
 
115 115
     public static function edit( $values = false ) {
116
-        FrmAppHelper::permission_check('frm_edit_forms');
116
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
117 117
 
118 118
 		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
119
-        return self::get_edit_vars($id);
119
+        return self::get_edit_vars( $id );
120 120
     }
121 121
 
122 122
     public static function settings( $id = false, $message = '' ) {
123
-        FrmAppHelper::permission_check('frm_edit_forms');
123
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
124 124
 
125
-        if ( ! $id || ! is_numeric($id) ) {
125
+        if ( ! $id || ! is_numeric( $id ) ) {
126 126
 			$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
127 127
         }
128 128
 		return self::get_settings_vars( $id, array(), $message );
129 129
     }
130 130
 
131 131
     public static function update_settings() {
132
-        FrmAppHelper::permission_check('frm_edit_forms');
132
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
133 133
 
134 134
 		$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
135 135
 
136
-        $errors = FrmForm::validate($_POST);
137
-        if ( count($errors) > 0 ) {
138
-            return self::get_settings_vars($id, $errors);
136
+        $errors = FrmForm::validate( $_POST );
137
+        if ( count( $errors ) > 0 ) {
138
+            return self::get_settings_vars( $id, $errors );
139 139
         }
140 140
 
141
-        do_action('frm_before_update_form_settings', $id);
141
+        do_action( 'frm_before_update_form_settings', $id );
142 142
 
143 143
 		FrmForm::update( $id, $_POST );
144 144
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 
161 161
 	private static function edit_in_place_value( $field ) {
162 162
 		check_ajax_referer( 'frm_ajax', 'nonce' );
163
-		FrmAppHelper::permission_check('frm_edit_forms', 'hide');
163
+		FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
164 164
 
165 165
 		$form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
166 166
 		$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_filter_post_kses' );
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 	 * @since 2.0
219 219
 	 */
220 220
 	public static function _create_from_template() {
221
-		FrmAppHelper::permission_check('frm_edit_forms');
221
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
222 222
 		check_ajax_referer( 'frm_ajax', 'nonce' );
223 223
 
224 224
 		$current_form = FrmAppHelper::get_param( 'this_form', '', 'get', 'absint' );
@@ -233,15 +233,15 @@  discard block
 block discarded – undo
233 233
 	}
234 234
 
235 235
     public static function duplicate() {
236
-        FrmAppHelper::permission_check('frm_edit_forms');
236
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
237 237
 
238 238
 		$params = FrmForm::list_page_params();
239 239
         $form = FrmForm::duplicate( $params['id'], $params['template'], true );
240
-        $message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
240
+        $message = ( $params['template'] ) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
241 241
         if ( $form ) {
242 242
 			return self::get_edit_vars( $form, array(), $message, true );
243 243
         } else {
244
-            return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' ));
244
+            return self::display_forms_list( $params, __( 'There was a problem creating the new template.', 'formidable' ) );
245 245
         }
246 246
     }
247 247
 
@@ -267,14 +267,14 @@  discard block
 block discarded – undo
267 267
         if ( ! defined( 'ABSPATH' ) && ! defined( 'XMLRPC_REQUEST' ) ) {
268 268
             global $wp;
269 269
             $root = dirname( dirname( dirname( dirname( __FILE__ ) ) ) );
270
-            include_once( $root.'/wp-config.php' );
270
+            include_once( $root . '/wp-config.php' );
271 271
             $wp->init();
272 272
             $wp->register_globals();
273 273
         }
274 274
 
275 275
 		self::register_pro_scripts();
276 276
 
277
-		header( 'Content-Type: text/html; charset='. get_option( 'blog_charset' ) );
277
+		header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
278 278
 
279 279
 		$key = FrmAppHelper::simple_get( 'form', 'sanitize_title' );
280 280
 		if ( $key == '' ) {
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 			$form = FrmForm::getAll( array(), '', 1 );
287 287
         }
288 288
 
289
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/direct.php');
289
+        require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php' );
290 290
         wp_die();
291 291
     }
292 292
 
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 		if ( FrmAppHelper::pro_is_installed() ) {
295 295
 			wp_register_script( 'jquery-frm-rating', FrmAppHelper::plugin_url() . '/pro/js/jquery.rating.min.js', array( 'jquery' ), '4.11', true );
296 296
 			wp_register_script( 'jquery-maskedinput', FrmAppHelper::plugin_url() . '/pro/js/jquery.maskedinput.min.js', array( 'jquery' ), '1.4', true );
297
-			wp_register_script( 'jquery-chosen', FrmAppHelper::plugin_url() .'/pro/js/chosen.jquery.min.js', array( 'jquery' ), '1.5.1', true );
297
+			wp_register_script( 'jquery-chosen', FrmAppHelper::plugin_url() . '/pro/js/chosen.jquery.min.js', array( 'jquery' ), '1.5.1', true );
298 298
 		}
299 299
 	}
300 300
 
@@ -303,11 +303,11 @@  discard block
 block discarded – undo
303 303
     }
304 304
 
305 305
 	public static function bulk_untrash( $ids ) {
306
-        FrmAppHelper::permission_check('frm_edit_forms');
306
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
307 307
 
308 308
         $count = FrmForm::set_status( $ids, 'published' );
309 309
 
310
-        $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
310
+        $message = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
311 311
         return $message;
312 312
     }
313 313
 
@@ -326,90 +326,90 @@  discard block
 block discarded – undo
326 326
 			'trash'   => array( 'permission' => 'frm_delete_forms', 'new_status' => 'trash' ),
327 327
 		);
328 328
 
329
-		if ( ! isset( $available_status[ $status ] ) ) {
329
+		if ( ! isset( $available_status[$status] ) ) {
330 330
 			return;
331 331
 		}
332 332
 
333
-		FrmAppHelper::permission_check( $available_status[ $status ]['permission'] );
333
+		FrmAppHelper::permission_check( $available_status[$status]['permission'] );
334 334
 
335 335
 		$params = FrmForm::list_page_params();
336 336
 
337 337
 		//check nonce url
338
-		check_admin_referer($status .'_form_' . $params['id']);
338
+		check_admin_referer( $status . '_form_' . $params['id'] );
339 339
 
340 340
 		$count = 0;
341
-		if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) {
342
-			$count++;
341
+		if ( FrmForm::set_status( $params['id'], $available_status[$status]['new_status'] ) ) {
342
+			$count ++;
343 343
 		}
344 344
 
345
-		$available_status['untrash']['message'] = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
346
-		$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='. ( isset( $_REQUEST['form_type'] ) ? sanitize_title( $_REQUEST['form_type'] ) : '' ) . '&id=' . $params['id'], 'untrash_form_' . $params['id'] ) ) . '">', '</a>' );
345
+		$available_status['untrash']['message'] = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
346
+		$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=' . ( isset( $_REQUEST['form_type'] ) ? sanitize_title( $_REQUEST['form_type'] ) : '' ) . '&id=' . $params['id'], 'untrash_form_' . $params['id'] ) ) . '">', '</a>' );
347 347
 
348
-		$message = $available_status[ $status ]['message'];
348
+		$message = $available_status[$status]['message'];
349 349
 
350 350
 		self::display_forms_list( $params, $message );
351 351
 	}
352 352
 
353 353
 	public static function bulk_trash( $ids ) {
354
-        FrmAppHelper::permission_check('frm_delete_forms');
354
+        FrmAppHelper::permission_check( 'frm_delete_forms' );
355 355
 
356 356
         $count = 0;
357 357
         foreach ( $ids as $id ) {
358 358
             if ( FrmForm::trash( $id ) ) {
359
-                $count++;
359
+                $count ++;
360 360
             }
361 361
         }
362 362
 
363 363
         $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
364
-        $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('item-action[]=', $ids), 'bulk-toplevel_page_formidable' )) .'">', '</a>' );
364
+        $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( 'item-action[]=', $ids ), 'bulk-toplevel_page_formidable' ) ) . '">', '</a>' );
365 365
 
366 366
         return $message;
367 367
     }
368 368
 
369 369
     public static function destroy() {
370
-        FrmAppHelper::permission_check('frm_delete_forms');
370
+        FrmAppHelper::permission_check( 'frm_delete_forms' );
371 371
 
372 372
 		$params = FrmForm::list_page_params();
373 373
 
374 374
         //check nonce url
375
-        check_admin_referer('destroy_form_' . $params['id']);
375
+        check_admin_referer( 'destroy_form_' . $params['id'] );
376 376
 
377 377
         $count = 0;
378 378
         if ( FrmForm::destroy( $params['id'] ) ) {
379
-            $count++;
379
+            $count ++;
380 380
         }
381 381
 
382
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
382
+        $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
383 383
 
384 384
 		self::display_forms_list( $params, $message );
385 385
     }
386 386
 
387 387
 	public static function bulk_destroy( $ids ) {
388
-        FrmAppHelper::permission_check('frm_delete_forms');
388
+        FrmAppHelper::permission_check( 'frm_delete_forms' );
389 389
 
390 390
         $count = 0;
391 391
         foreach ( $ids as $id ) {
392 392
             $d = FrmForm::destroy( $id );
393 393
             if ( $d ) {
394
-                $count++;
394
+                $count ++;
395 395
             }
396 396
         }
397 397
 
398
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
398
+        $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
399 399
 
400 400
         return $message;
401 401
     }
402 402
 
403 403
     private static function delete_all() {
404 404
         //check nonce url
405
-        $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable');
405
+        $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' );
406 406
         if ( $permission_error !== false ) {
407 407
 			self::display_forms_list( array(), '', array( $permission_error ) );
408 408
             return;
409 409
         }
410 410
 
411 411
 		$count = FrmForm::scheduled_delete( time() );
412
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
412
+        $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
413 413
 
414 414
 		self::display_forms_list( array(), $message );
415 415
     }
@@ -426,11 +426,11 @@  discard block
 block discarded – undo
426 426
 	* @since 2.0.15
427 427
 	*/
428 428
 	public static function insert_form_button() {
429
-		if ( current_user_can('frm_view_forms') ) {
429
+		if ( current_user_can( 'frm_view_forms' ) ) {
430 430
 			$menu_name = FrmAppHelper::get_menu_name();
431 431
 			$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' ) . '">
432 432
 				<span class="frm-buttons-icon wp-media-buttons-icon"></span> '.
433
-				$menu_name .'</a>';
433
+				$menu_name . '</a>';
434 434
 			echo wp_kses_post( $content );
435 435
 		}
436 436
 	}
@@ -447,22 +447,22 @@  discard block
 block discarded – undo
447 447
 			'formidable' => array( 'name' => __( 'Form', 'formidable' ), 'label' => __( 'Insert a Form', 'formidable' ) ),
448 448
         );
449 449
 
450
-        $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes);
450
+        $shortcodes = apply_filters( 'frm_popup_shortcodes', $shortcodes );
451 451
 
452
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/insert_form_popup.php');
452
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' );
453 453
     }
454 454
 
455 455
     public static function get_shortcode_opts() {
456
-		FrmAppHelper::permission_check('frm_view_forms');
456
+		FrmAppHelper::permission_check( 'frm_view_forms' );
457 457
         check_ajax_referer( 'frm_ajax', 'nonce' );
458 458
 
459 459
 		$shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' );
460
-        if ( empty($shortcode) ) {
460
+        if ( empty( $shortcode ) ) {
461 461
             wp_die();
462 462
         }
463 463
 
464
-        echo '<div id="sc-opts-'. esc_attr( $shortcode ) .'" class="frm_shortcode_option">';
465
-        echo '<input type="radio" name="frmsc" value="'. esc_attr($shortcode) .'" id="sc-'. esc_attr($shortcode) .'" class="frm_hidden" />';
464
+        echo '<div id="sc-opts-' . esc_attr( $shortcode ) . '" class="frm_shortcode_option">';
465
+        echo '<input type="radio" name="frmsc" value="' . esc_attr( $shortcode ) . '" id="sc-' . esc_attr( $shortcode ) . '" class="frm_hidden" />';
466 466
 
467 467
         $form_id = '';
468 468
         $opts = array();
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
                 );
478 478
             break;
479 479
         }
480
-        $opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode);
480
+        $opts = apply_filters( 'frm_sc_popup_opts', $opts, $shortcode );
481 481
 
482 482
 		if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) {
483 483
 			// allow other shortcodes to use the required form id option
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 			unset( $opts['form_id'] );
486 486
 		}
487 487
 
488
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/shortcode_opts.php');
488
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' );
489 489
 
490 490
         echo '</div>';
491 491
 
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
             die();
518 518
         }
519 519
 
520
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/list.php');
520
+        require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php' );
521 521
     }
522 522
 
523 523
 	public static function get_columns( $columns ) {
@@ -594,11 +594,11 @@  discard block
 block discarded – undo
594 594
         }
595 595
 
596 596
         if ( $form->parent_form_id ) {
597
-			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>' ));
597
+			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>' ) );
598 598
         }
599 599
 
600 600
 		$frm_field_selection = FrmField::field_selection();
601
-        $fields = FrmField::get_all_for_form($form->id);
601
+        $fields = FrmField::get_all_for_form( $form->id );
602 602
 
603 603
         // Automatically add end section fields if they don't exist (2.0 migration)
604 604
         $reset_fields = false;
@@ -608,9 +608,9 @@  discard block
 block discarded – undo
608 608
             $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
609 609
         }
610 610
 
611
-        unset($end_section_values, $last_order, $open, $reset_fields);
611
+        unset( $end_section_values, $last_order, $open, $reset_fields );
612 612
 
613
-        $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
613
+        $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true );
614 614
 
615 615
         $edit_message = __( 'Form was Successfully Updated', 'formidable' );
616 616
         if ( $form->is_template && $message == $edit_message ) {
@@ -620,13 +620,13 @@  discard block
 block discarded – undo
620 620
 		$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
621 621
 
622 622
         if ( $form->default_template ) {
623
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
624
-        } else if ( defined('DOING_AJAX') ) {
623
+            wp_die( __( 'That template cannot be edited', 'formidable' ) );
624
+        } else if ( defined( 'DOING_AJAX' ) ) {
625 625
             wp_die();
626 626
         } else if ( $create_link ) {
627
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php');
627
+            require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
628 628
         } else {
629
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/edit.php');
629
+            require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' );
630 630
         }
631 631
     }
632 632
 
@@ -637,28 +637,28 @@  discard block
 block discarded – undo
637 637
 
638 638
         $form = FrmForm::getOne( $id );
639 639
 
640
-        $fields = FrmField::get_all_for_form($id);
641
-        $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
640
+        $fields = FrmField::get_all_for_form( $id );
641
+        $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true );
642 642
 
643
-        if ( isset($values['default_template']) && $values['default_template'] ) {
644
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
643
+        if ( isset( $values['default_template'] ) && $values['default_template'] ) {
644
+            wp_die( __( 'That template cannot be edited', 'formidable' ) );
645 645
         }
646 646
 
647 647
         $action_controls = FrmFormActionsController::get_form_actions();
648 648
 
649
-        $sections = apply_filters('frm_add_form_settings_section', array(), $values);
649
+        $sections = apply_filters( 'frm_add_form_settings_section', array(), $values );
650 650
         $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
651 651
 
652
-        $styles = apply_filters('frm_get_style_opts', array());
652
+        $styles = apply_filters( 'frm_get_style_opts', array() );
653 653
 
654
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/settings.php');
654
+        require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' );
655 655
     }
656 656
 
657 657
     public static function mb_tags_box( $form_id, $class = '' ) {
658
-        $fields = FrmField::get_all_for_form($form_id, '', 'include');
658
+        $fields = FrmField::get_all_for_form( $form_id, '', 'include' );
659 659
         $linked_forms = array();
660 660
         $col = 'one';
661
-        $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false;
661
+        $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false;
662 662
 
663 663
 		$cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() );
664 664
 		$adv_shortcodes = self::get_advanced_shortcodes();
@@ -736,13 +736,13 @@  discard block
 block discarded – undo
736 736
 
737 737
     // Insert the form class setting into the form
738 738
 	public static function form_classes( $form ) {
739
-        if ( isset($form->options['form_class']) ) {
739
+        if ( isset( $form->options['form_class'] ) ) {
740 740
 			echo esc_attr( sanitize_text_field( $form->options['form_class'] ) );
741 741
         }
742 742
     }
743 743
 
744 744
     public static function get_email_html() {
745
-		FrmAppHelper::permission_check('frm_view_forms');
745
+		FrmAppHelper::permission_check( 'frm_view_forms' );
746 746
         check_ajax_referer( 'frm_ajax', 'nonce' );
747 747
 		echo FrmEntryFormat::show_entry( array(
748 748
 			'form_id'       => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ),
@@ -839,11 +839,11 @@  discard block
 block discarded – undo
839 839
     public static function add_default_templates( $path, $default = true, $template = true ) {
840 840
         _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' );
841 841
 
842
-        $path = untrailingslashit(trim($path));
843
-        $templates = glob( $path .'/*.php' );
842
+        $path = untrailingslashit( trim( $path ) );
843
+        $templates = glob( $path . '/*.php' );
844 844
 
845
-		for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) {
846
-            $filename = str_replace( '.php', '', str_replace( $path.'/', '', $templates[ $i ] ) );
845
+		for ( $i = count( $templates ) - 1; $i >= 0; $i -- ) {
846
+            $filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[$i] ) );
847 847
 			$template_query = array( 'form_key' => $filename );
848 848
             if ( $template ) {
849 849
                 $template_query['is_template'] = 1;
@@ -861,12 +861,12 @@  discard block
 block discarded – undo
861 861
                 $values['default_template'] = 1;
862 862
             }
863 863
 
864
-            include( $templates[ $i ] );
864
+            include( $templates[$i] );
865 865
 
866 866
             //get updated form
867
-            if ( isset($form) && ! empty($form) ) {
867
+            if ( isset( $form ) && ! empty( $form ) ) {
868 868
                 $old_id = $form->id;
869
-                $form = FrmForm::getOne($form->id);
869
+                $form = FrmForm::getOne( $form->id );
870 870
             } else {
871 871
                 $old_id = false;
872 872
 				$form = FrmForm::getAll( $template_query, '', 1 );
@@ -879,24 +879,24 @@  discard block
 block discarded – undo
879 879
     }
880 880
 
881 881
     public static function route() {
882
-        $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
882
+        $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
883 883
         $vars = array();
884 884
 		if ( isset( $_POST['frm_compact_fields'] ) ) {
885 885
 			FrmAppHelper::permission_check( 'frm_edit_forms' );
886 886
 
887
-            $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('&quot;', '\\\"', $_POST['frm_compact_fields'] ))));
888
-            $json_vars = json_decode($json_vars, true);
889
-            if ( empty($json_vars) ) {
887
+            $json_vars = htmlspecialchars_decode( nl2br( stripslashes( str_replace( '&quot;', '\\\"', $_POST['frm_compact_fields'] ) ) ) );
888
+            $json_vars = json_decode( $json_vars, true );
889
+            if ( empty( $json_vars ) ) {
890 890
                 // json decoding failed so we should return an error message
891 891
 				$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
892 892
                 if ( 'edit' == $action ) {
893 893
                     $action = 'update';
894 894
                 }
895 895
 
896
-                add_filter('frm_validate_form', 'FrmFormsController::json_error');
896
+                add_filter( 'frm_validate_form', 'FrmFormsController::json_error' );
897 897
             } else {
898
-                $vars = FrmAppHelper::json_to_array($json_vars);
899
-                $action = $vars[ $action ];
898
+                $vars = FrmAppHelper::json_to_array( $json_vars );
899
+                $action = $vars[$action];
900 900
 				unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] );
901 901
 				$_REQUEST = array_merge( $_REQUEST, $vars );
902 902
 				$_POST = array_merge( $_POST, $_REQUEST );
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
 
915 915
         switch ( $action ) {
916 916
             case 'new':
917
-                return self::new_form($vars);
917
+                return self::new_form( $vars );
918 918
             case 'create':
919 919
             case 'edit':
920 920
             case 'update':
@@ -927,8 +927,8 @@  discard block
 block discarded – undo
927 927
             case 'update_settings':
928 928
 				return self::$action( $vars );
929 929
             default:
930
-                do_action('frm_form_action_'. $action);
931
-                if ( apply_filters('frm_form_stop_action_'. $action, false) ) {
930
+                do_action( 'frm_form_action_' . $action );
931
+                if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) {
932 932
                     return;
933 933
                 }
934 934
 
@@ -937,7 +937,7 @@  discard block
 block discarded – undo
937 937
 					$action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
938 938
                 }
939 939
 
940
-                if ( strpos($action, 'bulk_') === 0 ) {
940
+                if ( strpos( $action, 'bulk_' ) === 0 ) {
941 941
                     FrmAppHelper::remove_get_action();
942 942
                     return self::list_form();
943 943
                 }
@@ -964,37 +964,37 @@  discard block
 block discarded – undo
964 964
 
965 965
 	public static function admin_bar_configure() {
966 966
         global $frm_vars;
967
-        if ( empty($frm_vars['forms_loaded']) ) {
967
+        if ( empty( $frm_vars['forms_loaded'] ) ) {
968 968
             return;
969 969
         }
970 970
 
971 971
         $actions = array();
972 972
         foreach ( $frm_vars['forms_loaded'] as $form ) {
973
-            if ( is_object($form) ) {
974
-                $actions[ $form->id ] = $form->name;
973
+            if ( is_object( $form ) ) {
974
+                $actions[$form->id] = $form->name;
975 975
             }
976
-            unset($form);
976
+            unset( $form );
977 977
         }
978 978
 
979
-        if ( empty($actions) ) {
979
+        if ( empty( $actions ) ) {
980 980
             return;
981 981
         }
982 982
 
983
-        asort($actions);
983
+        asort( $actions );
984 984
 
985 985
         global $wp_admin_bar;
986 986
 
987
-        if ( count($actions) == 1 ) {
987
+        if ( count( $actions ) == 1 ) {
988 988
             $wp_admin_bar->add_menu( array(
989 989
                 'title' => 'Edit Form',
990
-                'href'  => admin_url('admin.php?page=formidable&frm_action=edit&id='. current( array_keys( $actions ) )),
990
+                'href'  => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . current( array_keys( $actions ) ) ),
991 991
                 'id'    => 'frm-forms',
992 992
             ) );
993 993
         } else {
994 994
             $wp_admin_bar->add_menu( array(
995 995
         		'id'    => 'frm-forms',
996 996
         		'title' => '<span class="ab-icon"></span><span class="ab-label">' . __( 'Edit Forms', 'formidable' ) . '</span>',
997
-        		'href'  => admin_url( 'admin.php?page=formidable&frm_action=edit&id='. current( array_keys( $actions ) ) ),
997
+        		'href'  => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . current( array_keys( $actions ) ) ),
998 998
         		'meta'  => array(
999 999
 					'title' => __( 'Edit Forms', 'formidable' ),
1000 1000
         		),
@@ -1004,8 +1004,8 @@  discard block
 block discarded – undo
1004 1004
 
1005 1005
         		$wp_admin_bar->add_menu( array(
1006 1006
         			'parent'    => 'frm-forms',
1007
-        			'id'        => 'edit_form_'. $form_id,
1008
-        			'title'     => empty($name) ? __( '(no title)') : $name,
1007
+        			'id'        => 'edit_form_' . $form_id,
1008
+        			'title'     => empty( $name ) ? __( '(no title)' ) : $name,
1009 1009
 					'href'      => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ),
1010 1010
         		) );
1011 1011
         	}
@@ -1015,22 +1015,22 @@  discard block
 block discarded – undo
1015 1015
     //formidable shortcode
1016 1016
 	public static function get_form_shortcode( $atts ) {
1017 1017
         global $frm_vars;
1018
-        if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) {
1018
+        if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) {
1019 1019
             $sc = '[formidable';
1020 1020
 			if ( ! empty( $atts ) ) {
1021 1021
 				foreach ( $atts as $k => $v ) {
1022 1022
 					$sc .= ' ' . $k . '="' . esc_attr( $v ) . '"';
1023 1023
 				}
1024 1024
 			}
1025
-            return $sc .']';
1025
+            return $sc . ']';
1026 1026
         }
1027 1027
 
1028 1028
         $shortcode_atts = shortcode_atts( array(
1029 1029
             'id' => '', 'key' => '', 'title' => false, 'description' => false,
1030 1030
             'readonly' => false, 'entry_id' => false, 'fields' => array(),
1031 1031
             'exclude_fields' => array(), 'minimize' => false,
1032
-        ), $atts);
1033
-        do_action('formidable_shortcode_atts', $shortcode_atts, $atts);
1032
+        ), $atts );
1033
+        do_action( 'formidable_shortcode_atts', $shortcode_atts, $atts );
1034 1034
 
1035 1035
         return self::show_form(
1036 1036
             $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'],
@@ -1118,51 +1118,51 @@  discard block
 block discarded – undo
1118 1118
 
1119 1119
         $frm_settings = FrmAppHelper::get_settings();
1120 1120
 
1121
-        $submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value;
1121
+        $submit = isset( $form->options['submit_value'] ) ? $form->options['submit_value'] : $frm_settings->submit_value;
1122 1122
 
1123 1123
         $user_ID = get_current_user_id();
1124 1124
 		$params = FrmForm::get_params( $form );
1125 1125
         $message = $errors = '';
1126 1126
 
1127 1127
         if ( $params['posted_form_id'] == $form->id && $_POST ) {
1128
-            $errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array();
1128
+            $errors = isset( $frm_vars['created_entries'][$form->id] ) ? $frm_vars['created_entries'][$form->id]['errors'] : array();
1129 1129
         }
1130 1130
 
1131 1131
 		$include_form_tag = apply_filters( 'frm_include_form_tag', true, $form );
1132 1132
         $fields = FrmFieldsHelper::get_form_fields( $form->id, ( isset( $errors ) && ! empty( $errors ) ) );
1133 1133
 
1134 1134
         if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) {
1135
-            do_action('frm_display_form_action', $params, $fields, $form, $title, $description);
1136
-            if ( apply_filters('frm_continue_to_new', true, $form->id, $params['action']) ) {
1137
-                $values = FrmEntriesHelper::setup_new_vars($fields, $form);
1138
-                include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
1135
+            do_action( 'frm_display_form_action', $params, $fields, $form, $title, $description );
1136
+            if ( apply_filters( 'frm_continue_to_new', true, $form->id, $params['action'] ) ) {
1137
+                $values = FrmEntriesHelper::setup_new_vars( $fields, $form );
1138
+                include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' );
1139 1139
             }
1140 1140
             return;
1141 1141
         }
1142 1142
 
1143
-        if ( ! empty($errors) ) {
1144
-            $values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array();
1145
-            include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
1143
+        if ( ! empty( $errors ) ) {
1144
+            $values = $fields ? FrmEntriesHelper::setup_new_vars( $fields, $form ) : array();
1145
+            include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' );
1146 1146
             return;
1147 1147
         }
1148 1148
 
1149
-        do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description);
1150
-        if ( ! apply_filters('frm_continue_to_create', true, $form->id) ) {
1149
+        do_action( 'frm_validate_form_creation', $params, $fields, $form, $title, $description );
1150
+        if ( ! apply_filters( 'frm_continue_to_create', true, $form->id ) ) {
1151 1151
             return;
1152 1152
         }
1153 1153
 
1154
-        $values = FrmEntriesHelper::setup_new_vars($fields, $form, true);
1155
-        $created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form->id ] ) ) ? $frm_vars['created_entries'][ $form->id ]['entry_id'] : 0;
1156
-        $conf_method = apply_filters('frm_success_filter', 'message', $form, $form->options, 'create');
1154
+        $values = FrmEntriesHelper::setup_new_vars( $fields, $form, true );
1155
+        $created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][$form->id] ) ) ? $frm_vars['created_entries'][$form->id]['entry_id'] : 0;
1156
+        $conf_method = apply_filters( 'frm_success_filter', 'message', $form, $form->options, 'create' );
1157 1157
 
1158
-        if ( $created && is_numeric($created) && $conf_method != 'message' ) {
1159
-            do_action('frm_success_action', $conf_method, $form, $form->options, $created);
1158
+        if ( $created && is_numeric( $created ) && $conf_method != 'message' ) {
1159
+            do_action( 'frm_success_action', $conf_method, $form, $form->options, $created );
1160 1160
 			do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) );
1161 1161
             return;
1162 1162
         }
1163 1163
 
1164
-        if ( $created && is_numeric($created) ) {
1165
-            $message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg;
1164
+        if ( $created && is_numeric( $created ) ) {
1165
+            $message = isset( $form->options['success_msg'] ) ? $form->options['success_msg'] : $frm_settings->success_msg;
1166 1166
             $class = 'frm_message';
1167 1167
         } else {
1168 1168
             $message = $frm_settings->failed_msg;
@@ -1173,16 +1173,16 @@  discard block
 block discarded – undo
1173 1173
 			'message' => $message, 'form' => $form,
1174 1174
 			'entry_id' => $created, 'class' => $class,
1175 1175
 		) );
1176
-        $message = apply_filters('frm_main_feedback', $message, $form, $created);
1176
+        $message = apply_filters( 'frm_main_feedback', $message, $form, $created );
1177 1177
 
1178
-        if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) {
1179
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
1178
+        if ( ! isset( $form->options['show_form'] ) || $form->options['show_form'] ) {
1179
+            require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' );
1180 1180
         } else {
1181 1181
             global $frm_vars;
1182 1182
 			self::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] );
1183 1183
 
1184
-            $include_extra_container = 'frm_forms'. FrmFormsHelper::get_form_style_class($values);
1185
-            include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/errors.php');
1184
+            $include_extra_container = 'frm_forms' . FrmFormsHelper::get_form_style_class( $values );
1185
+            include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php' );
1186 1186
         }
1187 1187
 
1188 1188
 		do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) );
Please login to merge, or discard this patch.
classes/models/FrmEntry.php 3 patches
Indentation   +398 added lines, -398 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 = 60;
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
@@ -127,46 +127,46 @@  discard block
 block discarded – undo
127 127
 		return true;
128 128
 	}
129 129
 
130
-    public static function duplicate( $id ) {
131
-        global $wpdb;
130
+	public static function duplicate( $id ) {
131
+		global $wpdb;
132 132
 
133
-        $values = self::getOne( $id );
133
+		$values = self::getOne( $id );
134 134
 
135
-        $new_values = array();
136
-        $new_values['item_key'] = FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_items', 'item_key');
137
-        $new_values['name'] = $values->name;
138
-        $new_values['is_draft'] = $values->is_draft;
139
-        $new_values['user_id'] = $new_values['updated_by'] = (int) $values->user_id;
140
-        $new_values['form_id'] = $values->form_id ? (int) $values->form_id: null;
141
-        $new_values['created_at'] = $new_values['updated_at'] = current_time('mysql', 1);
135
+		$new_values = array();
136
+		$new_values['item_key'] = FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_items', 'item_key');
137
+		$new_values['name'] = $values->name;
138
+		$new_values['is_draft'] = $values->is_draft;
139
+		$new_values['user_id'] = $new_values['updated_by'] = (int) $values->user_id;
140
+		$new_values['form_id'] = $values->form_id ? (int) $values->form_id: null;
141
+		$new_values['created_at'] = $new_values['updated_at'] = current_time('mysql', 1);
142 142
 
143
-        $query_results = $wpdb->insert( $wpdb->prefix .'frm_items', $new_values );
144
-        if ( ! $query_results ) {
145
-            return false;
146
-        }
143
+		$query_results = $wpdb->insert( $wpdb->prefix .'frm_items', $new_values );
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
-        $wpdb->query( $wpdb->prepare('DELETE FROM ' . $wpdb->prefix .'frm_item_metas WHERE item_id=%d', $id) );
215
-        $result = $wpdb->query( $wpdb->prepare('DELETE FROM ' . $wpdb->prefix .'frm_items WHERE id=%d', $id) );
214
+		$wpdb->query( $wpdb->prepare('DELETE FROM ' . $wpdb->prefix .'frm_item_metas WHERE item_id=%d', $id) );
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
@@ -263,161 +263,161 @@  discard block
 block discarded – undo
263 263
 	}
264 264
 
265 265
 	public static function getOne( $id, $meta = false ) {
266
-        global $wpdb;
266
+		global $wpdb;
267 267
 
268
-        $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it
268
+		$query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it
269 269
                   LEFT OUTER JOIN {$wpdb->prefix}frm_forms fr ON it.form_id=fr.id WHERE ";
270 270
 
271
-        $query .= is_numeric($id) ? 'it.id=%d' : 'it.item_key=%s';
272
-        $query_args = array( $id );
273
-        $query = $wpdb->prepare( $query, $query_args );
271
+		$query .= is_numeric($id) ? 'it.id=%d' : 'it.item_key=%s';
272
+		$query_args = array( $id );
273
+		$query = $wpdb->prepare( $query, $query_args );
274 274
 
275
-        if ( ! $meta ) {
276
-            $entry = FrmAppHelper::check_cache( $id .'_nometa', 'frm_entry', $query, 'get_row' );
277
-            return stripslashes_deep($entry);
278
-        }
275
+		if ( ! $meta ) {
276
+			$entry = FrmAppHelper::check_cache( $id .'_nometa', 'frm_entry', $query, 'get_row' );
277
+			return stripslashes_deep($entry);
278
+		}
279 279
 
280
-        $entry = FrmAppHelper::check_cache( $id, 'frm_entry' );
281
-        if ( $entry !== false ) {
282
-            return stripslashes_deep($entry);
283
-        }
280
+		$entry = FrmAppHelper::check_cache( $id, 'frm_entry' );
281
+		if ( $entry !== false ) {
282
+			return stripslashes_deep($entry);
283
+		}
284 284
 
285
-        $entry = $wpdb->get_row( $query );
286
-        $entry = self::get_meta($entry);
285
+		$entry = $wpdb->get_row( $query );
286
+		$entry = self::get_meta($entry);
287 287
 
288
-        return stripslashes_deep($entry);
289
-    }
288
+		return stripslashes_deep($entry);
289
+	}
290 290
 
291 291
 	public static function get_meta( $entry ) {
292
-        if ( ! $entry ) {
293
-            return $entry;
294
-        }
292
+		if ( ! $entry ) {
293
+			return $entry;
294
+		}
295 295
 
296
-        global $wpdb;
296
+		global $wpdb;
297 297
 		$metas = FrmDb::get_results( $wpdb->prefix . 'frm_item_metas m LEFT JOIN ' . $wpdb->prefix . 'frm_fields f ON m.field_id=f.id', array( 'item_id' => $entry->id, 'field_id !' => 0 ), 'field_id, meta_value, field_key, item_id' );
298 298
 
299
-        $entry->metas = array();
299
+		$entry->metas = array();
300 300
 
301 301
 		$include_key = apply_filters( 'frm_include_meta_keys', false );
302
-        foreach ( $metas as $meta_val ) {
303
-            if ( $meta_val->item_id == $entry->id ) {
302
+		foreach ( $metas as $meta_val ) {
303
+			if ( $meta_val->item_id == $entry->id ) {
304 304
 				$entry->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value );
305 305
 				if ( $include_key ) {
306 306
 					$entry->metas[ $meta_val->field_key ] = $entry->metas[ $meta_val->field_id ];
307 307
 				}
308
-                 continue;
309
-            }
308
+				 continue;
309
+			}
310 310
 
311
-            // include sub entries in an array
311
+			// include sub entries in an array
312 312
 			if ( ! isset( $entry_metas[ $meta_val->field_id ] ) ) {
313 313
 				$entry->metas[ $meta_val->field_id ] = array();
314
-            }
314
+			}
315 315
 
316 316
 			$entry->metas[ $meta_val->field_id ][] = maybe_unserialize( $meta_val->meta_value );
317 317
 
318
-            unset($meta_val);
319
-        }
320
-        unset($metas);
318
+			unset($meta_val);
319
+		}
320
+		unset($metas);
321 321
 
322
-        wp_cache_set( $entry->id, $entry, 'frm_entry');
322
+		wp_cache_set( $entry->id, $entry, 'frm_entry');
323 323
 
324
-        return $entry;
325
-    }
324
+		return $entry;
325
+	}
326 326
 
327
-    /**
328
-     * @param string $id
329
-     */
327
+	/**
328
+	 * @param string $id
329
+	 */
330 330
 	public static function &exists( $id ) {
331
-        global $wpdb;
331
+		global $wpdb;
332 332
 
333
-        if ( FrmAppHelper::check_cache( $id, 'frm_entry' ) ) {
334
-            $exists = true;
335
-            return $exists;
336
-        }
333
+		if ( FrmAppHelper::check_cache( $id, 'frm_entry' ) ) {
334
+			$exists = true;
335
+			return $exists;
336
+		}
337 337
 
338
-        if ( is_numeric($id) ) {
339
-            $where = array( 'id' => $id );
340
-        } else {
341
-            $where = array( 'item_key' => $id );
342
-        }
343
-        $id = FrmDb::get_var( $wpdb->prefix .'frm_items', $where );
338
+		if ( is_numeric($id) ) {
339
+			$where = array( 'id' => $id );
340
+		} else {
341
+			$where = array( 'item_key' => $id );
342
+		}
343
+		$id = FrmDb::get_var( $wpdb->prefix .'frm_items', $where );
344 344
 
345
-        $exists = ($id && $id > 0) ? true : false;
346
-        return $exists;
347
-    }
345
+		$exists = ($id && $id > 0) ? true : false;
346
+		return $exists;
347
+	}
348 348
 
349
-    public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) {
349
+	public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) {
350 350
 		global $wpdb;
351 351
 
352
-        $limit = FrmAppHelper::esc_limit($limit);
352
+		$limit = FrmAppHelper::esc_limit($limit);
353 353
 
354
-        $cache_key = maybe_serialize($where) . $order_by . $limit . $inc_form;
355
-        $entries = wp_cache_get($cache_key, 'frm_entry');
354
+		$cache_key = maybe_serialize($where) . $order_by . $limit . $inc_form;
355
+		$entries = wp_cache_get($cache_key, 'frm_entry');
356 356
 
357
-        if ( false === $entries ) {
358
-            $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';
359
-            $table = $wpdb->prefix .'frm_items it ';
357
+		if ( false === $entries ) {
358
+			$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';
359
+			$table = $wpdb->prefix .'frm_items it ';
360 360
 
361
-            if ( $inc_form ) {
362
-                $fields = 'it.*, fr.name as form_name,fr.form_key as form_key';
363
-                $table .= 'LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id ';
364
-            }
361
+			if ( $inc_form ) {
362
+				$fields = 'it.*, fr.name as form_name,fr.form_key as form_key';
363
+				$table .= 'LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id ';
364
+			}
365 365
 
366
-            if ( preg_match( '/ meta_([0-9]+)/', $order_by, $order_matches ) ) {
367
-    		    // sort by a requested field
368
-                $field_id = (int) $order_matches[1];
366
+			if ( preg_match( '/ meta_([0-9]+)/', $order_by, $order_matches ) ) {
367
+				// sort by a requested field
368
+				$field_id = (int) $order_matches[1];
369 369
 				$fields .= ', (SELECT meta_value FROM '. $wpdb->prefix .'frm_item_metas WHERE field_id = '. $field_id .' AND item_id = it.id) as meta_'. $field_id;
370 370
 				unset( $order_matches, $field_id );
371
-		    }
371
+			}
372 372
 
373 373
 			// prepare the query
374 374
 			$query = 'SELECT ' . $fields . ' FROM ' . $table . FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
375 375
 
376
-            $entries = $wpdb->get_results($query, OBJECT_K);
377
-            unset($query);
376
+			$entries = $wpdb->get_results($query, OBJECT_K);
377
+			unset($query);
378 378
 
379 379
 			if ( ! FrmAppHelper::prevent_caching() ) {
380 380
 				wp_cache_set( $cache_key, $entries, 'frm_entry', 300 );
381 381
 			}
382
-        }
382
+		}
383 383
 
384
-        if ( ! $meta || ! $entries ) {
385
-            return stripslashes_deep($entries);
386
-        }
387
-        unset($meta);
384
+		if ( ! $meta || ! $entries ) {
385
+			return stripslashes_deep($entries);
386
+		}
387
+		unset($meta);
388 388
 
389
-        if ( ! is_array( $where ) && preg_match('/^it\.form_id=\d+$/', $where) ) {
389
+		if ( ! is_array( $where ) && preg_match('/^it\.form_id=\d+$/', $where) ) {
390 390
 			$where = array( 'it.form_id' => substr( $where, 11 ) );
391
-        }
391
+		}
392 392
 
393
-        $meta_where = array( 'field_id !' => 0 );
394
-        if ( $limit == '' && is_array($where) && count($where) == 1 && isset($where['it.form_id']) ) {
395
-            $meta_where['fi.form_id'] = $where['it.form_id'];
396
-        } else {
397
-            $meta_where['item_id'] = array_keys( $entries );
398
-        }
393
+		$meta_where = array( 'field_id !' => 0 );
394
+		if ( $limit == '' && is_array($where) && count($where) == 1 && isset($where['it.form_id']) ) {
395
+			$meta_where['fi.form_id'] = $where['it.form_id'];
396
+		} else {
397
+			$meta_where['item_id'] = array_keys( $entries );
398
+		}
399 399
 
400
-        $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' );
400
+		$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' );
401 401
 
402
-        unset( $meta_where );
402
+		unset( $meta_where );
403 403
 
404
-        if ( ! $metas ) {
405
-            return stripslashes_deep($entries);
406
-        }
404
+		if ( ! $metas ) {
405
+			return stripslashes_deep($entries);
406
+		}
407 407
 
408
-        foreach ( $metas as $m_key => $meta_val ) {
409
-            if ( ! isset( $entries[ $meta_val->item_id ] ) ) {
410
-                continue;
411
-            }
408
+		foreach ( $metas as $m_key => $meta_val ) {
409
+			if ( ! isset( $entries[ $meta_val->item_id ] ) ) {
410
+				continue;
411
+			}
412 412
 
413
-            if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) {
413
+			if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) {
414 414
 				$entries[ $meta_val->item_id ]->metas = array();
415
-            }
415
+			}
416 416
 
417 417
 			$entries[ $meta_val->item_id ]->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value );
418 418
 
419
-            unset($m_key, $meta_val);
420
-        }
419
+			unset($m_key, $meta_val);
420
+		}
421 421
 
422 422
 		if ( ! FrmAppHelper::prevent_caching() ) {
423 423
 			foreach ( $entries as $entry ) {
@@ -426,46 +426,46 @@  discard block
 block discarded – undo
426 426
 			}
427 427
 		}
428 428
 
429
-        return stripslashes_deep($entries);
430
-    }
431
-
432
-    // Pagination Methods
433
-    public static function getRecordCount( $where = '' ) {
434
-        global $wpdb;
435
-        $table_join = $wpdb->prefix .'frm_items it LEFT OUTER JOIN '. $wpdb->prefix .'frm_forms fr ON it.form_id=fr.id';
436
-
437
-        if ( is_numeric($where) ) {
438
-            $table_join = 'frm_items';
439
-            $where = array( 'form_id' => $where );
440
-        }
441
-
442
-        if ( is_array( $where ) ) {
443
-            $count = FrmDb::get_count( $table_join, $where );
444
-        } else {
445
-            $cache_key = 'count_'. maybe_serialize($where);
446
-            $query = 'SELECT COUNT(*) FROM '. $table_join . FrmAppHelper::prepend_and_or_where(' WHERE ', $where);
447
-            $count = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, 'get_var');
448
-        }
449
-
450
-        return $count;
451
-    }
452
-
453
-    public static function getPageCount( $p_size, $where = '' ) {
454
-        if ( is_numeric($where) ) {
455
-            return ceil( (int) $where / (int) $p_size );
456
-        } else {
457
-            return ceil( (int) self::getRecordCount($where) / (int) $p_size );
458
-        }
459
-    }
460
-
461
-	/**
462
-	* Prepare the data before inserting it into the database
463
-	*
464
-	* @since 2.0.16
465
-	* @param array $values
466
-	* @param string $type
467
-	* @return array $new_values
468
-	*/
429
+		return stripslashes_deep($entries);
430
+	}
431
+
432
+	// Pagination Methods
433
+	public static function getRecordCount( $where = '' ) {
434
+		global $wpdb;
435
+		$table_join = $wpdb->prefix .'frm_items it LEFT OUTER JOIN '. $wpdb->prefix .'frm_forms fr ON it.form_id=fr.id';
436
+
437
+		if ( is_numeric($where) ) {
438
+			$table_join = 'frm_items';
439
+			$where = array( 'form_id' => $where );
440
+		}
441
+
442
+		if ( is_array( $where ) ) {
443
+			$count = FrmDb::get_count( $table_join, $where );
444
+		} else {
445
+			$cache_key = 'count_'. maybe_serialize($where);
446
+			$query = 'SELECT COUNT(*) FROM '. $table_join . FrmAppHelper::prepend_and_or_where(' WHERE ', $where);
447
+			$count = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, 'get_var');
448
+		}
449
+
450
+		return $count;
451
+	}
452
+
453
+	public static function getPageCount( $p_size, $where = '' ) {
454
+		if ( is_numeric($where) ) {
455
+			return ceil( (int) $where / (int) $p_size );
456
+		} else {
457
+			return ceil( (int) self::getRecordCount($where) / (int) $p_size );
458
+		}
459
+	}
460
+
461
+	/**
462
+	 * Prepare the data before inserting it into the database
463
+	 *
464
+	 * @since 2.0.16
465
+	 * @param array $values
466
+	 * @param string $type
467
+	 * @return array $new_values
468
+	 */
469 469
 	private static function before_insert_entry_in_database( &$values, $type ) {
470 470
 
471 471
 		self::sanitize_entry_post( $values );
@@ -480,13 +480,13 @@  discard block
 block discarded – undo
480 480
 	}
481 481
 
482 482
 	/**
483
-	* Create an entry and perform after create actions
484
-	*
485
-	* @since 2.0.16
486
-	* @param array $values
487
-	* @param array $new_values
488
-	* @return boolean|int $entry_id
489
-	*/
483
+	 * Create an entry and perform after create actions
484
+	 *
485
+	 * @since 2.0.16
486
+	 * @param array $values
487
+	 * @param array $new_values
488
+	 * @return boolean|int $entry_id
489
+	 */
490 490
 	private static function continue_to_create_entry( $values, $new_values ) {
491 491
 		$entry_id = self::insert_entry_into_database( $new_values );
492 492
 		if ( ! $entry_id ) {
@@ -498,37 +498,37 @@  discard block
 block discarded – undo
498 498
 		return $entry_id;
499 499
 	}
500 500
 
501
-    /**
502
-     * Sanitize the POST values before we use them
503
-     *
504
-     * @since 2.0
505
-     * @param array $values The POST values by reference
506
-     */
507
-    public static function sanitize_entry_post( &$values ) {
508
-        $sanitize_method = array(
509
-            'form_id'       => 'absint',
510
-            'frm_action'    => 'sanitize_title',
511
-            'form_key'      => 'sanitize_title',
512
-            'item_key'      => 'sanitize_title',
513
-            'item_name'     => 'sanitize_text_field',
514
-            'frm_saving_draft' => 'absint',
515
-            'is_draft'      => 'absint',
516
-            'post_id'       => 'absint',
517
-            'parent_item_id' => 'absint',
518
-            'created_at'    => 'sanitize_text_field',
519
-            'updated_at'    => 'sanitize_text_field',
520
-        );
521
-
522
-        FrmAppHelper::sanitize_request( $sanitize_method, $values );
523
-    }
524
-
525
-	/**
526
-	* Prepare the new values for inserting into the database
527
-	*
528
-	* @since 2.0.16
529
-	* @param array $values
530
-	* @return array $new_values
531
-	*/
501
+	/**
502
+	 * Sanitize the POST values before we use them
503
+	 *
504
+	 * @since 2.0
505
+	 * @param array $values The POST values by reference
506
+	 */
507
+	public static function sanitize_entry_post( &$values ) {
508
+		$sanitize_method = array(
509
+			'form_id'       => 'absint',
510
+			'frm_action'    => 'sanitize_title',
511
+			'form_key'      => 'sanitize_title',
512
+			'item_key'      => 'sanitize_title',
513
+			'item_name'     => 'sanitize_text_field',
514
+			'frm_saving_draft' => 'absint',
515
+			'is_draft'      => 'absint',
516
+			'post_id'       => 'absint',
517
+			'parent_item_id' => 'absint',
518
+			'created_at'    => 'sanitize_text_field',
519
+			'updated_at'    => 'sanitize_text_field',
520
+		);
521
+
522
+		FrmAppHelper::sanitize_request( $sanitize_method, $values );
523
+	}
524
+
525
+	/**
526
+	 * Prepare the new values for inserting into the database
527
+	 *
528
+	 * @since 2.0.16
529
+	 * @param array $values
530
+	 * @return array $new_values
531
+	 */
532 532
 	private static function package_entry_data( &$values ) {
533 533
 		global $wpdb;
534 534
 
@@ -561,67 +561,67 @@  discard block
 block discarded – undo
561 561
 	}
562 562
 
563 563
 	/**
564
-	* Get the is_draft value for a new entry
565
-	*
566
-	* @since 2.0.16
567
-	* @param array $values
568
-	* @return int
569
-	*/
564
+	 * Get the is_draft value for a new entry
565
+	 *
566
+	 * @since 2.0.16
567
+	 * @param array $values
568
+	 * @return int
569
+	 */
570 570
 	private static function get_is_draft_value( $values ) {
571 571
 		return ( ( isset( $values['frm_saving_draft'] ) && $values['frm_saving_draft'] == 1 ) ||  ( isset( $values['is_draft'] ) && $values['is_draft'] == 1 ) ) ? 1 : 0;
572 572
 	}
573 573
 
574 574
 	/**
575
-	* Get the form_id value for a new entry
576
-	*
577
-	* @since 2.0.16
578
-	* @param array $values
579
-	* @return int|null
580
-	*/
575
+	 * Get the form_id value for a new entry
576
+	 *
577
+	 * @since 2.0.16
578
+	 * @param array $values
579
+	 * @return int|null
580
+	 */
581 581
 	private static function get_form_id( $values ) {
582 582
 		return isset( $values['form_id'] ) ? (int) $values['form_id'] : null;
583 583
 	}
584 584
 
585 585
 	/**
586
-	* Get the post_id value for a new entry
587
-	*
588
-	* @since 2.0.16
589
-	* @param array $values
590
-	* @return int
591
-	*/
586
+	 * Get the post_id value for a new entry
587
+	 *
588
+	 * @since 2.0.16
589
+	 * @param array $values
590
+	 * @return int
591
+	 */
592 592
 	private static function get_post_id( $values ) {
593 593
 		return isset( $values['post_id'] ) ? (int) $values['post_id']: 0;
594 594
 	}
595 595
 
596 596
 	/**
597
-	* Get the parent_item_id value for a new entry
598
-	*
599
-	* @since 2.0.16
600
-	* @param array $values
601
-	* @return int
602
-	*/
597
+	 * Get the parent_item_id value for a new entry
598
+	 *
599
+	 * @since 2.0.16
600
+	 * @param array $values
601
+	 * @return int
602
+	 */
603 603
 	private static function get_parent_item_id( $values ) {
604 604
 		return isset( $values['parent_item_id'] ) ? (int) $values['parent_item_id']: 0;
605 605
 	}
606 606
 
607 607
 	/**
608
-	* Get the created_at value for a new entry
609
-	*
610
-	* @since 2.0.16
611
-	* @param array $values
612
-	* @return string
613
-	*/
608
+	 * Get the created_at value for a new entry
609
+	 *
610
+	 * @since 2.0.16
611
+	 * @param array $values
612
+	 * @return string
613
+	 */
614 614
 	private static function get_created_at( $values ) {
615 615
 		return isset( $values['created_at'] ) ? $values['created_at']: current_time('mysql', 1);
616 616
 	}
617 617
 
618 618
 	/**
619
-	* Get the updated_at value for a new entry
620
-	*
621
-	* @since 2.0.16
622
-	* @param array $values
623
-	* @return string
624
-	*/
619
+	 * Get the updated_at value for a new entry
620
+	 *
621
+	 * @since 2.0.16
622
+	 * @param array $values
623
+	 * @return string
624
+	 */
625 625
 	private static function get_updated_at( $values ) {
626 626
 		if ( isset( $values['updated_at'] ) ) {
627 627
 			$updated_at = $values['updated_at'];
@@ -633,12 +633,12 @@  discard block
 block discarded – undo
633 633
 	}
634 634
 
635 635
 	/**
636
-	* Get the description value for a new entry
637
-	*
638
-	* @since 2.0.16
639
-	* @param array $values
640
-	* @return string
641
-	*/
636
+	 * Get the description value for a new entry
637
+	 *
638
+	 * @since 2.0.16
639
+	 * @param array $values
640
+	 * @return string
641
+	 */
642 642
 	private static function get_entry_description( $values ) {
643 643
 		if ( isset( $values['description'] ) && ! empty( $values['description'] ) ) {
644 644
 			$description = maybe_serialize( $values['description'] );
@@ -653,12 +653,12 @@  discard block
 block discarded – undo
653 653
 	}
654 654
 
655 655
 	/**
656
-	* Get the user_id value for a new entry
657
-	*
658
-	* @since 2.0.16
659
-	* @param array $values
660
-	* @return int
661
-	*/
656
+	 * Get the user_id value for a new entry
657
+	 *
658
+	 * @since 2.0.16
659
+	 * @param array $values
660
+	 * @return int
661
+	 */
662 662
 	private static function get_entry_user_id( $values ) {
663 663
 		if ( isset( $values['frm_user_id'] ) && ( is_numeric( $values['frm_user_id'] ) || FrmAppHelper::is_admin() ) ) {
664 664
 			$user_id = $values['frm_user_id'];
@@ -671,12 +671,12 @@  discard block
 block discarded – undo
671 671
 	}
672 672
 
673 673
 	/**
674
-	* Insert new entry into the database
675
-	*
676
-	* @since 2.0.16
677
-	* @param array $new_values
678
-	* @return int | boolean $entry_id
679
-	*/
674
+	 * Insert new entry into the database
675
+	 *
676
+	 * @since 2.0.16
677
+	 * @param array $new_values
678
+	 * @return int | boolean $entry_id
679
+	 */
680 680
 	private static function insert_entry_into_database( $new_values ) {
681 681
 		global $wpdb;
682 682
 
@@ -692,11 +692,11 @@  discard block
 block discarded – undo
692 692
 	}
693 693
 
694 694
 	/**
695
-	* Add the new entry to global $frm_vars
696
-	*
697
-	* @since 2.0.16
698
-	* @param int $entry_id
699
-	*/
695
+	 * Add the new entry to global $frm_vars
696
+	 *
697
+	 * @since 2.0.16
698
+	 * @param int $entry_id
699
+	 */
700 700
 	private static function add_new_entry_to_frm_vars( $entry_id ) {
701 701
 		global $frm_vars;
702 702
 
@@ -708,12 +708,12 @@  discard block
 block discarded – undo
708 708
 	}
709 709
 
710 710
 	/**
711
-	* Add entry metas, if there are any
712
-	*
713
-	* @since 2.0.16
714
-	* @param array $values
715
-	* @param int $entry_id
716
-	*/
711
+	 * Add entry metas, if there are any
712
+	 *
713
+	 * @since 2.0.16
714
+	 * @param array $values
715
+	 * @param int $entry_id
716
+	 */
717 717
 	private static function maybe_add_entry_metas( $values, $entry_id ) {
718 718
 		if ( isset($values['item_meta']) ) {
719 719
 			FrmEntryMeta::update_entry_metas( $entry_id, $values['item_meta'] );
@@ -721,12 +721,12 @@  discard block
 block discarded – undo
721 721
 	}
722 722
 
723 723
 	/**
724
-	* Trigger frm_after_create_entry hooks
725
-	*
726
-	* @since 2.0.16
727
-	* @param int $entry_id
728
-	* @param array $new_values
729
-	*/
724
+	 * Trigger frm_after_create_entry hooks
725
+	 *
726
+	 * @since 2.0.16
727
+	 * @param int $entry_id
728
+	 * @param array $new_values
729
+	 */
730 730
 	private static function after_entry_created_actions( $entry_id, $values, $new_values ) {
731 731
 		// this is a child entry
732 732
 		$is_child = isset( $values['parent_form_id'] ) && isset( $values['parent_nonce'] ) && ! empty( $values['parent_form_id'] ) && wp_verify_nonce( $values['parent_nonce'], 'parent' );
@@ -736,13 +736,13 @@  discard block
 block discarded – undo
736 736
 	}
737 737
 
738 738
 	/**
739
-	* Actions to perform immediately after an entry is inserted in the frm_items database
740
-	*
741
-	* @since 2.0.16
742
-	* @param array $values
743
-	* @param array $new_values
744
-	* @param int $entry_id
745
-	*/
739
+	 * Actions to perform immediately after an entry is inserted in the frm_items database
740
+	 *
741
+	 * @since 2.0.16
742
+	 * @param array $values
743
+	 * @param array $new_values
744
+	 * @param int $entry_id
745
+	 */
746 746
 	private static function after_insert_entry_in_database( $values, $new_values, $entry_id ) {
747 747
 
748 748
 		self::add_new_entry_to_frm_vars( $entry_id );
@@ -755,14 +755,14 @@  discard block
 block discarded – undo
755 755
 	}
756 756
 
757 757
 	/**
758
-	* Perform some actions right before updating an entry
759
-	*
760
-	* @since 2.0.16
761
-	* @param int $id
762
-	* @param array $values
763
-	* @param string $update_type
764
-	* @return boolean $update
765
-	*/
758
+	 * Perform some actions right before updating an entry
759
+	 *
760
+	 * @since 2.0.16
761
+	 * @param int $id
762
+	 * @param array $values
763
+	 * @param string $update_type
764
+	 * @return boolean $update
765
+	 */
766 766
 	private static function before_update_entry( $id, &$values, $update_type ) {
767 767
 		$update = true;
768 768
 
@@ -780,13 +780,13 @@  discard block
 block discarded – undo
780 780
 	}
781 781
 
782 782
 	/**
783
-	* Package the entry data for updating
784
-	*
785
-	* @since 2.0.16
786
-	* @param int $id
787
-	* @param array $values
788
-	* @return array $new_values
789
-	*/
783
+	 * Package the entry data for updating
784
+	 *
785
+	 * @since 2.0.16
786
+	 * @param int $id
787
+	 * @param array $values
788
+	 * @return array $new_values
789
+	 */
790 790
 	private static function package_entry_to_update( $id, $values ) {
791 791
 		global $wpdb;
792 792
 
@@ -820,14 +820,14 @@  discard block
 block discarded – undo
820 820
 	}
821 821
 
822 822
 	/**
823
-	* Perform some actions right after updating an entry
824
-	*
825
-	* @since 2.0.16
826
-	* @param boolean|int $query_results
827
-	* @param int $id
828
-	* @param array $values
829
-	* @param array $new_values
830
-	*/
823
+	 * Perform some actions right after updating an entry
824
+	 *
825
+	 * @since 2.0.16
826
+	 * @param boolean|int $query_results
827
+	 * @param int $id
828
+	 * @param array $values
829
+	 * @param array $new_values
830
+	 */
831 831
 	private static function after_update_entry( $query_results, $id, $values, $new_values ) {
832 832
 		if ( $query_results ) {
833 833
 			self::clear_cache();
@@ -849,13 +849,13 @@  discard block
 block discarded – undo
849 849
 	}
850 850
 
851 851
 	/**
852
-	* Create entry from an XML import
853
-	* Certain actions aren't necessary when importing (like saving sub entries, checking for duplicates, etc.)
854
-	*
855
-	* @since 2.0.16
856
-	* @param array $values
857
-	* @return int | boolean $entry_id
858
-	*/
852
+	 * Create entry from an XML import
853
+	 * Certain actions aren't necessary when importing (like saving sub entries, checking for duplicates, etc.)
854
+	 *
855
+	 * @since 2.0.16
856
+	 * @param array $values
857
+	 * @return int | boolean $entry_id
858
+	 */
859 859
 	public static function create_entry_from_xml( $values ) {
860 860
 		$entry_id = self::create_entry( $values, 'xml' );
861 861
 
@@ -863,28 +863,28 @@  discard block
 block discarded – undo
863 863
 	}
864 864
 
865 865
 	/**
866
-	* Update entry from an XML import
867
-	* Certain actions aren't necessary when importing (like saving sub entries and modifying other vals)
868
-	*
869
-	* @since 2.0.16
870
-	* @param int $id
871
-	* @param array $values
872
-	* @return int | boolean $updated
873
-	*/
866
+	 * Update entry from an XML import
867
+	 * Certain actions aren't necessary when importing (like saving sub entries and modifying other vals)
868
+	 *
869
+	 * @since 2.0.16
870
+	 * @param int $id
871
+	 * @param array $values
872
+	 * @return int | boolean $updated
873
+	 */
874 874
 	public static function update_entry_from_xml( $id, $values ) {
875 875
 		$updated = self::update_entry( $id, $values, 'xml' );
876 876
 
877 877
 		return $updated;
878 878
 	}
879 879
 
880
-    /**
881
-     * @param string $key
882
-     * @return int entry_id
883
-     */
880
+	/**
881
+	 * @param string $key
882
+	 * @return int entry_id
883
+	 */
884 884
 	public static function get_id_by_key( $key ) {
885
-        $entry_id = FrmDb::get_var( 'frm_items', array( 'item_key' => sanitize_title( $key ) ) );
886
-        return $entry_id;
887
-    }
885
+		$entry_id = FrmDb::get_var( 'frm_items', array( 'item_key' => sanitize_title( $key ) ) );
886
+		return $entry_id;
887
+	}
888 888
 
889 889
 	public static function validate( $values, $exclude = false ) {
890 890
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryValidate::validate' );
Please login to merge, or discard this patch.
Spacing   +87 added lines, -87 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
                 }
@@ -107,9 +107,9 @@  discard block
 block discarded – undo
107 107
 	 * @param int $duplicate_entry_time
108 108
 	 * @return bool
109 109
 	 */
110
-	private static function is_duplicate_check_needed( $new_values, $values, &$duplicate_entry_time ){
110
+	private static function is_duplicate_check_needed( $new_values, $values, &$duplicate_entry_time ) {
111 111
 		// If CSV is importing, don't check for duplicates
112
-		if ( defined('WP_IMPORTING') && WP_IMPORTING ) {
112
+		if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
113 113
 			return false;
114 114
 		}
115 115
 
@@ -133,14 +133,14 @@  discard block
 block discarded – undo
133 133
         $values = self::getOne( $id );
134 134
 
135 135
         $new_values = array();
136
-        $new_values['item_key'] = FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_items', 'item_key');
136
+        $new_values['item_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_items', 'item_key' );
137 137
         $new_values['name'] = $values->name;
138 138
         $new_values['is_draft'] = $values->is_draft;
139 139
         $new_values['user_id'] = $new_values['updated_by'] = (int) $values->user_id;
140
-        $new_values['form_id'] = $values->form_id ? (int) $values->form_id: null;
141
-        $new_values['created_at'] = $new_values['updated_at'] = current_time('mysql', 1);
140
+        $new_values['form_id'] = $values->form_id ? (int) $values->form_id : null;
141
+        $new_values['created_at'] = $new_values['updated_at'] = current_time( 'mysql', 1 );
142 142
 
143
-        $query_results = $wpdb->insert( $wpdb->prefix .'frm_items', $new_values );
143
+        $query_results = $wpdb->insert( $wpdb->prefix . 'frm_items', $new_values );
144 144
         if ( ! $query_results ) {
145 145
             return false;
146 146
         }
@@ -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,10 +209,10 @@  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
-        $wpdb->query( $wpdb->prepare('DELETE FROM ' . $wpdb->prefix .'frm_item_metas WHERE item_id=%d', $id) );
215
-        $result = $wpdb->query( $wpdb->prepare('DELETE FROM ' . $wpdb->prefix .'frm_items WHERE id=%d', $id) );
214
+        $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE item_id=%d', $id ) );
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
 
@@ -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();
@@ -268,24 +268,24 @@  discard block
 block discarded – undo
268 268
         $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it
269 269
                   LEFT OUTER JOIN {$wpdb->prefix}frm_forms fr ON it.form_id=fr.id WHERE ";
270 270
 
271
-        $query .= is_numeric($id) ? 'it.id=%d' : 'it.item_key=%s';
271
+        $query .= is_numeric( $id ) ? 'it.id=%d' : 'it.item_key=%s';
272 272
         $query_args = array( $id );
273 273
         $query = $wpdb->prepare( $query, $query_args );
274 274
 
275 275
         if ( ! $meta ) {
276
-            $entry = FrmAppHelper::check_cache( $id .'_nometa', 'frm_entry', $query, 'get_row' );
277
-            return stripslashes_deep($entry);
276
+            $entry = FrmAppHelper::check_cache( $id . '_nometa', 'frm_entry', $query, 'get_row' );
277
+            return stripslashes_deep( $entry );
278 278
         }
279 279
 
280 280
         $entry = FrmAppHelper::check_cache( $id, 'frm_entry' );
281 281
         if ( $entry !== false ) {
282
-            return stripslashes_deep($entry);
282
+            return stripslashes_deep( $entry );
283 283
         }
284 284
 
285 285
         $entry = $wpdb->get_row( $query );
286
-        $entry = self::get_meta($entry);
286
+        $entry = self::get_meta( $entry );
287 287
 
288
-        return stripslashes_deep($entry);
288
+        return stripslashes_deep( $entry );
289 289
     }
290 290
 
291 291
 	public static function get_meta( $entry ) {
@@ -301,25 +301,25 @@  discard block
 block discarded – undo
301 301
 		$include_key = apply_filters( 'frm_include_meta_keys', false );
302 302
         foreach ( $metas as $meta_val ) {
303 303
             if ( $meta_val->item_id == $entry->id ) {
304
-				$entry->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value );
304
+				$entry->metas[$meta_val->field_id] = maybe_unserialize( $meta_val->meta_value );
305 305
 				if ( $include_key ) {
306
-					$entry->metas[ $meta_val->field_key ] = $entry->metas[ $meta_val->field_id ];
306
+					$entry->metas[$meta_val->field_key] = $entry->metas[$meta_val->field_id];
307 307
 				}
308 308
                  continue;
309 309
             }
310 310
 
311 311
             // include sub entries in an array
312
-			if ( ! isset( $entry_metas[ $meta_val->field_id ] ) ) {
313
-				$entry->metas[ $meta_val->field_id ] = array();
312
+			if ( ! isset( $entry_metas[$meta_val->field_id] ) ) {
313
+				$entry->metas[$meta_val->field_id] = array();
314 314
             }
315 315
 
316
-			$entry->metas[ $meta_val->field_id ][] = maybe_unserialize( $meta_val->meta_value );
316
+			$entry->metas[$meta_val->field_id][] = maybe_unserialize( $meta_val->meta_value );
317 317
 
318
-            unset($meta_val);
318
+            unset( $meta_val );
319 319
         }
320
-        unset($metas);
320
+        unset( $metas );
321 321
 
322
-        wp_cache_set( $entry->id, $entry, 'frm_entry');
322
+        wp_cache_set( $entry->id, $entry, 'frm_entry' );
323 323
 
324 324
         return $entry;
325 325
     }
@@ -335,28 +335,28 @@  discard block
 block discarded – undo
335 335
             return $exists;
336 336
         }
337 337
 
338
-        if ( is_numeric($id) ) {
338
+        if ( is_numeric( $id ) ) {
339 339
             $where = array( 'id' => $id );
340 340
         } else {
341 341
             $where = array( 'item_key' => $id );
342 342
         }
343
-        $id = FrmDb::get_var( $wpdb->prefix .'frm_items', $where );
343
+        $id = FrmDb::get_var( $wpdb->prefix . 'frm_items', $where );
344 344
 
345
-        $exists = ($id && $id > 0) ? true : false;
345
+        $exists = ( $id && $id > 0 ) ? true : false;
346 346
         return $exists;
347 347
     }
348 348
 
349 349
     public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) {
350 350
 		global $wpdb;
351 351
 
352
-        $limit = FrmAppHelper::esc_limit($limit);
352
+        $limit = FrmAppHelper::esc_limit( $limit );
353 353
 
354
-        $cache_key = maybe_serialize($where) . $order_by . $limit . $inc_form;
355
-        $entries = wp_cache_get($cache_key, 'frm_entry');
354
+        $cache_key = maybe_serialize( $where ) . $order_by . $limit . $inc_form;
355
+        $entries = wp_cache_get( $cache_key, 'frm_entry' );
356 356
 
357 357
         if ( false === $entries ) {
358 358
             $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';
359
-            $table = $wpdb->prefix .'frm_items it ';
359
+            $table = $wpdb->prefix . 'frm_items it ';
360 360
 
361 361
             if ( $inc_form ) {
362 362
                 $fields = 'it.*, fr.name as form_name,fr.form_key as form_key';
@@ -366,15 +366,15 @@  discard block
 block discarded – undo
366 366
             if ( preg_match( '/ meta_([0-9]+)/', $order_by, $order_matches ) ) {
367 367
     		    // sort by a requested field
368 368
                 $field_id = (int) $order_matches[1];
369
-				$fields .= ', (SELECT meta_value FROM '. $wpdb->prefix .'frm_item_metas WHERE field_id = '. $field_id .' AND item_id = it.id) as meta_'. $field_id;
369
+				$fields .= ', (SELECT meta_value FROM ' . $wpdb->prefix . 'frm_item_metas WHERE field_id = ' . $field_id . ' AND item_id = it.id) as meta_' . $field_id;
370 370
 				unset( $order_matches, $field_id );
371 371
 		    }
372 372
 
373 373
 			// prepare the query
374
-			$query = 'SELECT ' . $fields . ' FROM ' . $table . FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
374
+			$query = 'SELECT ' . $fields . ' FROM ' . $table . FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
375 375
 
376
-            $entries = $wpdb->get_results($query, OBJECT_K);
377
-            unset($query);
376
+            $entries = $wpdb->get_results( $query, OBJECT_K );
377
+            unset( $query );
378 378
 
379 379
 			if ( ! FrmAppHelper::prevent_caching() ) {
380 380
 				wp_cache_set( $cache_key, $entries, 'frm_entry', 300 );
@@ -382,16 +382,16 @@  discard block
 block discarded – undo
382 382
         }
383 383
 
384 384
         if ( ! $meta || ! $entries ) {
385
-            return stripslashes_deep($entries);
385
+            return stripslashes_deep( $entries );
386 386
         }
387
-        unset($meta);
387
+        unset( $meta );
388 388
 
389
-        if ( ! is_array( $where ) && preg_match('/^it\.form_id=\d+$/', $where) ) {
389
+        if ( ! is_array( $where ) && preg_match( '/^it\.form_id=\d+$/', $where ) ) {
390 390
 			$where = array( 'it.form_id' => substr( $where, 11 ) );
391 391
         }
392 392
 
393 393
         $meta_where = array( 'field_id !' => 0 );
394
-        if ( $limit == '' && is_array($where) && count($where) == 1 && isset($where['it.form_id']) ) {
394
+        if ( $limit == '' && is_array( $where ) && count( $where ) == 1 && isset( $where['it.form_id'] ) ) {
395 395
             $meta_where['fi.form_id'] = $where['it.form_id'];
396 396
         } else {
397 397
             $meta_where['item_id'] = array_keys( $entries );
@@ -402,21 +402,21 @@  discard block
 block discarded – undo
402 402
         unset( $meta_where );
403 403
 
404 404
         if ( ! $metas ) {
405
-            return stripslashes_deep($entries);
405
+            return stripslashes_deep( $entries );
406 406
         }
407 407
 
408 408
         foreach ( $metas as $m_key => $meta_val ) {
409
-            if ( ! isset( $entries[ $meta_val->item_id ] ) ) {
409
+            if ( ! isset( $entries[$meta_val->item_id] ) ) {
410 410
                 continue;
411 411
             }
412 412
 
413
-            if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) {
414
-				$entries[ $meta_val->item_id ]->metas = array();
413
+            if ( ! isset( $entries[$meta_val->item_id]->metas ) ) {
414
+				$entries[$meta_val->item_id]->metas = array();
415 415
             }
416 416
 
417
-			$entries[ $meta_val->item_id ]->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value );
417
+			$entries[$meta_val->item_id]->metas[$meta_val->field_id] = maybe_unserialize( $meta_val->meta_value );
418 418
 
419
-            unset($m_key, $meta_val);
419
+            unset( $m_key, $meta_val );
420 420
         }
421 421
 
422 422
 		if ( ! FrmAppHelper::prevent_caching() ) {
@@ -426,15 +426,15 @@  discard block
 block discarded – undo
426 426
 			}
427 427
 		}
428 428
 
429
-        return stripslashes_deep($entries);
429
+        return stripslashes_deep( $entries );
430 430
     }
431 431
 
432 432
     // Pagination Methods
433 433
     public static function getRecordCount( $where = '' ) {
434 434
         global $wpdb;
435
-        $table_join = $wpdb->prefix .'frm_items it LEFT OUTER JOIN '. $wpdb->prefix .'frm_forms fr ON it.form_id=fr.id';
435
+        $table_join = $wpdb->prefix . 'frm_items it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id';
436 436
 
437
-        if ( is_numeric($where) ) {
437
+        if ( is_numeric( $where ) ) {
438 438
             $table_join = 'frm_items';
439 439
             $where = array( 'form_id' => $where );
440 440
         }
@@ -442,19 +442,19 @@  discard block
 block discarded – undo
442 442
         if ( is_array( $where ) ) {
443 443
             $count = FrmDb::get_count( $table_join, $where );
444 444
         } else {
445
-            $cache_key = 'count_'. maybe_serialize($where);
446
-            $query = 'SELECT COUNT(*) FROM '. $table_join . FrmAppHelper::prepend_and_or_where(' WHERE ', $where);
447
-            $count = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, 'get_var');
445
+            $cache_key = 'count_' . maybe_serialize( $where );
446
+            $query = 'SELECT COUNT(*) FROM ' . $table_join . FrmAppHelper::prepend_and_or_where( ' WHERE ', $where );
447
+            $count = FrmAppHelper::check_cache( $cache_key, 'frm_entry', $query, 'get_var' );
448 448
         }
449 449
 
450 450
         return $count;
451 451
     }
452 452
 
453 453
     public static function getPageCount( $p_size, $where = '' ) {
454
-        if ( is_numeric($where) ) {
454
+        if ( is_numeric( $where ) ) {
455 455
             return ceil( (int) $where / (int) $p_size );
456 456
         } else {
457
-            return ceil( (int) self::getRecordCount($where) / (int) $p_size );
457
+            return ceil( (int) self::getRecordCount( $where ) / (int) $p_size );
458 458
         }
459 459
     }
460 460
 
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
 		self::sanitize_entry_post( $values );
472 472
 
473 473
 		if ( $type != 'xml' ) {
474
-			$values = apply_filters('frm_pre_create_entry', $values);
474
+			$values = apply_filters( 'frm_pre_create_entry', $values );
475 475
 		}
476 476
 
477 477
 		$new_values = self::package_entry_data( $values );
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 
539 539
 		$item_name = self::get_new_entry_name( $values, $values['item_key'] );
540 540
 		$new_values = array(
541
-			'item_key'  => FrmAppHelper::get_unique_key($values['item_key'], $wpdb->prefix .'frm_items', 'item_key'),
541
+			'item_key'  => FrmAppHelper::get_unique_key( $values['item_key'], $wpdb->prefix . 'frm_items', 'item_key' ),
542 542
 			'name'      => FrmAppHelper::truncate( $item_name, 255, 1, '' ),
543 543
 			'ip'        => FrmAppHelper::get_ip_address(),
544 544
 			'is_draft'  => self::get_is_draft_value( $values ),
@@ -551,11 +551,11 @@  discard block
 block discarded – undo
551 551
 			'user_id' => self::get_entry_user_id( $values ),
552 552
 		);
553 553
 
554
-		if ( is_array($new_values['name']) ) {
555
-			$new_values['name'] = reset($new_values['name']);
554
+		if ( is_array( $new_values['name'] ) ) {
555
+			$new_values['name'] = reset( $new_values['name'] );
556 556
 		}
557 557
 
558
-		$new_values['updated_by'] = isset($values['updated_by']) ? $values['updated_by'] : $new_values['user_id'];
558
+		$new_values['updated_by'] = isset( $values['updated_by'] ) ? $values['updated_by'] : $new_values['user_id'];
559 559
 
560 560
 		return $new_values;
561 561
 	}
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
 	* @return int
569 569
 	*/
570 570
 	private static function get_is_draft_value( $values ) {
571
-		return ( ( isset( $values['frm_saving_draft'] ) && $values['frm_saving_draft'] == 1 ) ||  ( isset( $values['is_draft'] ) && $values['is_draft'] == 1 ) ) ? 1 : 0;
571
+		return ( ( isset( $values['frm_saving_draft'] ) && $values['frm_saving_draft'] == 1 ) || ( isset( $values['is_draft'] ) && $values['is_draft'] == 1 ) ) ? 1 : 0;
572 572
 	}
573 573
 
574 574
 	/**
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 	* @return int
591 591
 	*/
592 592
 	private static function get_post_id( $values ) {
593
-		return isset( $values['post_id'] ) ? (int) $values['post_id']: 0;
593
+		return isset( $values['post_id'] ) ? (int) $values['post_id'] : 0;
594 594
 	}
595 595
 
596 596
 	/**
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 	* @return int
602 602
 	*/
603 603
 	private static function get_parent_item_id( $values ) {
604
-		return isset( $values['parent_item_id'] ) ? (int) $values['parent_item_id']: 0;
604
+		return isset( $values['parent_item_id'] ) ? (int) $values['parent_item_id'] : 0;
605 605
 	}
606 606
 
607 607
 	/**
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
 	* @return string
613 613
 	*/
614 614
 	private static function get_created_at( $values ) {
615
-		return isset( $values['created_at'] ) ? $values['created_at']: current_time('mysql', 1);
615
+		return isset( $values['created_at'] ) ? $values['created_at'] : current_time( 'mysql', 1 );
616 616
 	}
617 617
 
618 618
 	/**
@@ -680,7 +680,7 @@  discard block
 block discarded – undo
680 680
 	private static function insert_entry_into_database( $new_values ) {
681 681
 		global $wpdb;
682 682
 
683
-		$query_results = $wpdb->insert( $wpdb->prefix .'frm_items', $new_values );
683
+		$query_results = $wpdb->insert( $wpdb->prefix . 'frm_items', $new_values );
684 684
 
685 685
 		if ( ! $query_results ) {
686 686
 			$entry_id = false;
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
 	private static function add_new_entry_to_frm_vars( $entry_id ) {
701 701
 		global $frm_vars;
702 702
 
703
-		if ( ! isset($frm_vars['saved_entries']) ) {
703
+		if ( ! isset( $frm_vars['saved_entries'] ) ) {
704 704
 			$frm_vars['saved_entries'] = array();
705 705
 		}
706 706
 
@@ -715,7 +715,7 @@  discard block
 block discarded – undo
715 715
 	* @param int $entry_id
716 716
 	*/
717 717
 	private static function maybe_add_entry_metas( $values, $entry_id ) {
718
-		if ( isset($values['item_meta']) ) {
718
+		if ( isset( $values['item_meta'] ) ) {
719 719
 			FrmEntryMeta::update_entry_metas( $entry_id, $values['item_meta'] );
720 720
 		}
721 721
 	}
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
 		$is_child = isset( $values['parent_form_id'] ) && isset( $values['parent_nonce'] ) && ! empty( $values['parent_form_id'] ) && wp_verify_nonce( $values['parent_nonce'], 'parent' );
733 733
 
734 734
 		do_action( 'frm_after_create_entry', $entry_id, $new_values['form_id'], compact( 'is_child' ) );
735
-		do_action( 'frm_after_create_entry_'. $new_values['form_id'], $entry_id , compact( 'is_child' ) );
735
+		do_action( 'frm_after_create_entry_' . $new_values['form_id'], $entry_id, compact( 'is_child' ) );
736 736
 	}
737 737
 
738 738
 	/**
@@ -773,7 +773,7 @@  discard block
 block discarded – undo
773 773
 		}
774 774
 
775 775
 		if ( $update && $update_type != 'xml' ) {
776
-			$values = apply_filters('frm_pre_update_entry', $values, $id);
776
+			$values = apply_filters( 'frm_pre_update_entry', $values, $id );
777 777
 		}
778 778
 
779 779
 		return $update;
@@ -794,27 +794,27 @@  discard block
 block discarded – undo
794 794
 			'name'      => self::get_new_entry_name( $values ),
795 795
 			'form_id'   => self::get_form_id( $values ),
796 796
 			'is_draft'  => self::get_is_draft_value( $values ),
797
-			'updated_at' => current_time('mysql', 1),
798
-			'updated_by' => isset($values['updated_by']) ? $values['updated_by'] : get_current_user_id(),
797
+			'updated_at' => current_time( 'mysql', 1 ),
798
+			'updated_by' => isset( $values['updated_by'] ) ? $values['updated_by'] : get_current_user_id(),
799 799
 		);
800 800
 
801
-		if ( isset($values['post_id']) ) {
801
+		if ( isset( $values['post_id'] ) ) {
802 802
 			$new_values['post_id'] = (int) $values['post_id'];
803 803
 		}
804 804
 
805
-		if ( isset($values['item_key']) ) {
806
-			$new_values['item_key'] = FrmAppHelper::get_unique_key($values['item_key'], $wpdb->prefix .'frm_items', 'item_key', $id);
805
+		if ( isset( $values['item_key'] ) ) {
806
+			$new_values['item_key'] = FrmAppHelper::get_unique_key( $values['item_key'], $wpdb->prefix . 'frm_items', 'item_key', $id );
807 807
 		}
808 808
 
809
-		if ( isset($values['parent_item_id']) ) {
809
+		if ( isset( $values['parent_item_id'] ) ) {
810 810
 			$new_values['parent_item_id'] = (int) $values['parent_item_id'];
811 811
 		}
812 812
 
813
-		if ( isset($values['frm_user_id']) && is_numeric($values['frm_user_id']) ) {
813
+		if ( isset( $values['frm_user_id'] ) && is_numeric( $values['frm_user_id'] ) ) {
814 814
 			$new_values['user_id'] = $values['frm_user_id'];
815 815
 		}
816 816
 
817
-		$new_values = apply_filters('frm_update_entry', $new_values, $id);
817
+		$new_values = apply_filters( 'frm_update_entry', $new_values, $id );
818 818
 
819 819
 		return $new_values;
820 820
 	}
@@ -844,8 +844,8 @@  discard block
 block discarded – undo
844 844
 			FrmEntryMeta::update_entry_metas( $id, $values['item_meta'] );
845 845
 		}
846 846
 
847
-		do_action('frm_after_update_entry', $id, $new_values['form_id'] );
848
-		do_action('frm_after_update_entry_'. $new_values['form_id'], $id );
847
+		do_action( 'frm_after_update_entry', $id, $new_values['form_id'] );
848
+		do_action( 'frm_after_update_entry_' . $new_values['form_id'], $id );
849 849
 	}
850 850
 
851 851
 	/**
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@
 block discarded – undo
107 107
 	 * @param int $duplicate_entry_time
108 108
 	 * @return bool
109 109
 	 */
110
-	private static function is_duplicate_check_needed( $new_values, $values, &$duplicate_entry_time ){
110
+	private static function is_duplicate_check_needed( $new_values, $values, &$duplicate_entry_time ) {
111 111
 		// If CSV is importing, don't check for duplicates
112 112
 		if ( defined('WP_IMPORTING') && WP_IMPORTING ) {
113 113
 			return false;
Please login to merge, or discard this patch.
classes/views/frm-fields/input.php 2 patches
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -3,48 +3,48 @@  discard block
 block discarded – undo
3 3
 <?php } else if ( $field['type'] == 'textarea' ) { ?>
4 4
 <textarea name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php
5 5
 if ( $field['max'] ) {
6
-    echo 'rows="'. esc_attr( $field['max'] ) .'" ';
6
+	echo 'rows="'. esc_attr( $field['max'] ) .'" ';
7 7
 }
8 8
 do_action('frm_field_input_html', $field);
9 9
 ?>><?php echo FrmAppHelper::esc_textarea($field['value']) ?></textarea>
10 10
 <?php
11 11
 
12 12
 } else if ( $field['type'] == 'radio' ) {
13
-    $read_only = false;
13
+	$read_only = false;
14 14
 	if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) {
15
-        $read_only = true; ?>
15
+		$read_only = true; ?>
16 16
 <input type="hidden" value="<?php echo esc_attr( $field['value'] ) ?>" name="<?php echo esc_attr( $field_name ) ?>" />
17 17
 <?php
18
-    }
18
+	}
19 19
 
20
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
20
+	if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
21 21
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
22
-    } else if ( is_array($field['options']) ) {
23
-        foreach ( $field['options'] as $opt_key => $opt ) {
22
+	} else if ( is_array($field['options']) ) {
23
+		foreach ( $field['options'] as $opt_key => $opt ) {
24 24
 			if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) {
25
-                continue;
26
-            }
25
+				continue;
26
+			}
27 27
 
28
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
29
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); ?>
28
+			$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
29
+			$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); ?>
30 30
 			<div class="<?php echo esc_attr( apply_filters( 'frm_radio_class', 'frm_radio', $field, $field_val ) ) ?>"><?php
31 31
 
32 32
 			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
33 33
 				?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
34
-            }
35
-            $checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' ';
34
+			}
35
+			$checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' ';
36 36
 
37
-            $other_opt = false;
38
-            $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked );
39
-            ?>
37
+			$other_opt = false;
38
+			$other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked );
39
+			?>
40 40
             <input type="radio" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php
41
-            echo $checked;
42
-            do_action('frm_field_input_html', $field);
41
+			echo $checked;
42
+			do_action('frm_field_input_html', $field);
43 43
 ?>/><?php
44 44
 
45 45
 			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
46
-                echo ' '. $opt .'</label>';
47
-            }
46
+				echo ' '. $opt .'</label>';
47
+			}
48 48
 
49 49
 			FrmFieldsHelper::include_other_input( array(
50 50
 				'other_opt' => $other_opt, 'read_only' => $read_only,
@@ -53,14 +53,14 @@  discard block
 block discarded – undo
53 53
 				'html_id' => $html_id, 'opt_key' => $opt_key,
54 54
 			) );
55 55
 
56
-            unset( $other_opt, $other_args );
56
+			unset( $other_opt, $other_args );
57 57
 ?></div>
58 58
 <?php
59
-        }
60
-    }
59
+		}
60
+	}
61 61
 } else if ( $field['type'] == 'select' ) {
62
-    $read_only = false;
63
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
62
+	$read_only = false;
63
+	if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
64 64
 		echo FrmFieldsHelper::dropdown_categories( array( 'name' => $field_name, 'field' => $field ) );
65 65
 	} else {
66 66
 		if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) {
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 			?>
94 94
 		<option value="<?php echo esc_attr($field_val) ?>" <?php echo $selected ? ' selected="selected"' : ''; ?><?php echo ( FrmFieldsHelper::is_other_opt( $opt_key ) ) ? ' class="frm_other_trigger"' : '';?>><?php echo ($opt == '') ? ' ' : $opt; ?></option>
95 95
     <?php
96
-    	} ?>
96
+		} ?>
97 97
 </select>
98 98
 <?php
99 99
 		FrmFieldsHelper::include_other_input( array(
@@ -102,52 +102,52 @@  discard block
 block discarded – undo
102 102
 			'value' => $other_args['value'], 'field' => $field,
103 103
 			'html_id' => $html_id, 'opt_key' => false,
104 104
 		) );
105
-    }
105
+	}
106 106
 } else if ( $field['type'] == 'checkbox' ) {
107
-    $checked_values = $field['value'];
108
-    $read_only = false;
107
+	$checked_values = $field['value'];
108
+	$read_only = false;
109 109
 
110 110
 	if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) {
111
-        $read_only = true;
112
-        if ( $checked_values ) {
113
-            foreach ( (array) $checked_values as $checked_value ) { ?>
111
+		$read_only = true;
112
+		if ( $checked_values ) {
113
+			foreach ( (array) $checked_values as $checked_value ) { ?>
114 114
 <input type="hidden" value="<?php echo esc_attr( $checked_value ) ?>" name="<?php echo esc_attr( $field_name ) ?>[]" />
115 115
 <?php
116
-            }
117
-        } else { ?>
116
+			}
117
+		} else { ?>
118 118
 <input type="hidden" value="" name="<?php echo esc_attr( $field_name ) ?>[]" />
119 119
 <?php
120
-        }
121
-    }
120
+		}
121
+	}
122 122
 
123
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
123
+	if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
124 124
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
125
-    } else if ( $field['options'] ) {
126
-        foreach ( $field['options'] as $opt_key => $opt ) {
127
-            if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] != $opt_key) ) {
128
-                continue;
129
-            }
130
-
131
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
132
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
133
-            $checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : '';
134
-
135
-            // Check if other opt, and get values for other field if needed
136
-            $other_opt = false;
125
+	} else if ( $field['options'] ) {
126
+		foreach ( $field['options'] as $opt_key => $opt ) {
127
+			if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] != $opt_key) ) {
128
+				continue;
129
+			}
130
+
131
+			$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
132
+			$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
133
+			$checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : '';
134
+
135
+			// Check if other opt, and get values for other field if needed
136
+			$other_opt = false;
137 137
 			$other_args = FrmFieldsHelper::prepare_other_input( compact( 'field', 'field_name', 'opt_key' ), $other_opt, $checked );
138 138
 
139
-            ?>
139
+			?>
140 140
 			<div class="<?php echo esc_attr( apply_filters( 'frm_checkbox_class', 'frm_checkbox', $field, $field_val ) ) ?>" id="frm_checkbox_<?php echo esc_attr( $field['id'] ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
141 141
 
142
-            if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
143
-                ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
144
-            }
142
+			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
143
+				?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
144
+			}
145 145
 
146
-            ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php
146
+			?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php
147 147
 
148
-            if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
149
-                echo ' '. $opt .'</label>';
150
-            }
148
+			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
149
+				echo ' '. $opt .'</label>';
150
+			}
151 151
 
152 152
 			FrmFieldsHelper::include_other_input( array(
153 153
 				'other_opt' => $other_opt, 'read_only' => $read_only,
@@ -156,17 +156,17 @@  discard block
 block discarded – undo
156 156
 				'html_id' => $html_id, 'opt_key' => $opt_key,
157 157
 			) );
158 158
 
159
-            unset( $other_opt, $other_args, $checked );
159
+			unset( $other_opt, $other_args, $checked );
160 160
 
161
-            ?></div>
161
+			?></div>
162 162
 <?php
163
-        }
164
-    }
163
+		}
164
+	}
165 165
 } else if ( $field['type'] == 'captcha' && ! FrmAppHelper::is_admin() ) {
166
-    $frm_settings = FrmAppHelper::get_settings();
167
-    if ( ! empty($frm_settings->pubkey) ) {
168
-        FrmFieldsHelper::display_recaptcha($field);
169
-    }
166
+	$frm_settings = FrmAppHelper::get_settings();
167
+	if ( ! empty($frm_settings->pubkey) ) {
168
+		FrmFieldsHelper::display_recaptcha($field);
169
+	}
170 170
 } else {
171 171
 	do_action( 'frm_form_fields', $field, $field_name, compact( 'errors', 'html_id' ) );
172 172
 	do_action( 'frm_form_field_' . $field['type'], $field, $field_name, compact( 'errors', 'html_id' ) );
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php if ( in_array( $field['type'], array( 'email', 'url', 'text' ) ) ) { ?>
2
-<input type="<?php echo ( $frm_settings->use_html || $field['type'] == 'password' ) ? $field['type'] : 'text'; ?>" id="<?php echo esc_attr( $html_id ) ?>" name="<?php echo esc_attr( $field_name ) ?>" value="<?php echo esc_attr( $field['value'] ) ?>" <?php do_action('frm_field_input_html', $field) ?>/>
2
+<input type="<?php echo ( $frm_settings->use_html || $field['type'] == 'password' ) ? $field['type'] : 'text'; ?>" id="<?php echo esc_attr( $html_id ) ?>" name="<?php echo esc_attr( $field_name ) ?>" value="<?php echo esc_attr( $field['value'] ) ?>" <?php do_action( 'frm_field_input_html', $field ) ?>/>
3 3
 <?php } else if ( $field['type'] == 'textarea' ) { ?>
4 4
 <textarea name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php
5 5
 if ( $field['max'] ) {
6
-    echo 'rows="'. esc_attr( $field['max'] ) .'" ';
6
+    echo 'rows="' . esc_attr( $field['max'] ) . '" ';
7 7
 }
8
-do_action('frm_field_input_html', $field);
9
-?>><?php echo FrmAppHelper::esc_textarea($field['value']) ?></textarea>
8
+do_action( 'frm_field_input_html', $field );
9
+?>><?php echo FrmAppHelper::esc_textarea( $field['value'] ) ?></textarea>
10 10
 <?php
11 11
 
12 12
 } else if ( $field['type'] == 'radio' ) {
@@ -17,33 +17,33 @@  discard block
 block discarded – undo
17 17
 <?php
18 18
     }
19 19
 
20
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
20
+    if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) {
21 21
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
22
-    } else if ( is_array($field['options']) ) {
22
+    } else if ( is_array( $field['options'] ) ) {
23 23
         foreach ( $field['options'] as $opt_key => $opt ) {
24 24
 			if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) {
25 25
                 continue;
26 26
             }
27 27
 
28
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
29
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); ?>
28
+            $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
29
+            $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field ); ?>
30 30
 			<div class="<?php echo esc_attr( apply_filters( 'frm_radio_class', 'frm_radio', $field, $field_val ) ) ?>"><?php
31 31
 
32 32
 			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
33 33
 				?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
34 34
             }
35
-            $checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' ';
35
+            $checked = FrmAppHelper::check_selected( $field['value'], $field_val ) ? 'checked="checked" ' : ' ';
36 36
 
37 37
             $other_opt = false;
38 38
             $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked );
39 39
             ?>
40 40
             <input type="radio" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php
41 41
             echo $checked;
42
-            do_action('frm_field_input_html', $field);
42
+            do_action( 'frm_field_input_html', $field );
43 43
 ?>/><?php
44 44
 
45 45
 			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
46
-                echo ' '. $opt .'</label>';
46
+                echo ' ' . $opt . '</label>';
47 47
             }
48 48
 
49 49
 			FrmFieldsHelper::include_other_input( array(
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     }
61 61
 } else if ( $field['type'] == 'select' ) {
62 62
     $read_only = false;
63
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
63
+    if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) {
64 64
 		echo FrmFieldsHelper::dropdown_categories( array( 'name' => $field_name, 'field' => $field ) );
65 65
 	} else {
66 66
 		if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) {
@@ -71,12 +71,12 @@  discard block
 block discarded – undo
71 71
 					<input type="hidden" value="<?php echo esc_attr( $selected_value ) ?>" name="<?php echo esc_attr( $field_name ) ?>[]" /> <?php
72 72
 				}
73 73
 			} else { ?>
74
-				<input type="hidden" value="<?php echo esc_attr($field['value']) ?>" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" /> <?php
74
+				<input type="hidden" value="<?php echo esc_attr( $field['value'] ) ?>" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" /> <?php
75 75
 			} ?>
76
-				<select disabled="disabled" <?php do_action('frm_field_input_html', $field) ?>> <?php
76
+				<select disabled="disabled" <?php do_action( 'frm_field_input_html', $field ) ?>> <?php
77 77
 
78 78
 		} else { ?>
79
-<select name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php do_action('frm_field_input_html', $field) ?>>
79
+<select name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php do_action( 'frm_field_input_html', $field ) ?>>
80 80
 <?php   }
81 81
 
82 82
 		$other_opt = $other_checked = false;
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 				}
92 92
 			}
93 93
 			?>
94
-		<option value="<?php echo esc_attr($field_val) ?>" <?php echo $selected ? ' selected="selected"' : ''; ?><?php echo ( FrmFieldsHelper::is_other_opt( $opt_key ) ) ? ' class="frm_other_trigger"' : '';?>><?php echo ($opt == '') ? ' ' : $opt; ?></option>
94
+		<option value="<?php echo esc_attr( $field_val ) ?>" <?php echo $selected ? ' selected="selected"' : ''; ?><?php echo ( FrmFieldsHelper::is_other_opt( $opt_key ) ) ? ' class="frm_other_trigger"' : ''; ?>><?php echo ( $opt == '' ) ? ' ' : $opt; ?></option>
95 95
     <?php
96 96
     	} ?>
97 97
 </select>
@@ -120,17 +120,17 @@  discard block
 block discarded – undo
120 120
         }
121 121
     }
122 122
 
123
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
123
+    if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) {
124 124
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
125 125
     } else if ( $field['options'] ) {
126 126
         foreach ( $field['options'] as $opt_key => $opt ) {
127
-            if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] != $opt_key) ) {
127
+            if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) {
128 128
                 continue;
129 129
             }
130 130
 
131
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
132
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
133
-            $checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : '';
131
+            $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
132
+            $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field );
133
+            $checked = FrmAppHelper::check_selected( $checked_values, $field_val ) ? ' checked="checked"' : '';
134 134
 
135 135
             // Check if other opt, and get values for other field if needed
136 136
             $other_opt = false;
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
                 ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
144 144
             }
145 145
 
146
-            ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php
146
+            ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action( 'frm_field_input_html', $field ) ?> /><?php
147 147
 
148 148
             if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
149
-                echo ' '. $opt .'</label>';
149
+                echo ' ' . $opt . '</label>';
150 150
             }
151 151
 
152 152
 			FrmFieldsHelper::include_other_input( array(
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
     }
165 165
 } else if ( $field['type'] == 'captcha' && ! FrmAppHelper::is_admin() ) {
166 166
     $frm_settings = FrmAppHelper::get_settings();
167
-    if ( ! empty($frm_settings->pubkey) ) {
168
-        FrmFieldsHelper::display_recaptcha($field);
167
+    if ( ! empty( $frm_settings->pubkey ) ) {
168
+        FrmFieldsHelper::display_recaptcha( $field );
169 169
     }
170 170
 } else {
171 171
 	do_action( 'frm_form_fields', $field, $field_name, compact( 'errors', 'html_id' ) );
Please login to merge, or discard this patch.
classes/controllers/FrmFieldsController.php 2 patches
Indentation   +462 added lines, -462 removed lines patch added patch discarded remove patch
@@ -2,137 +2,137 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmFieldsController {
4 4
 
5
-    public static function load_field() {
5
+	public static function load_field() {
6 6
 		FrmAppHelper::permission_check('frm_edit_forms');
7
-        check_ajax_referer( 'frm_ajax', 'nonce' );
7
+		check_ajax_referer( 'frm_ajax', 'nonce' );
8 8
 
9
-        $fields = $_POST['field'];
10
-        if ( empty( $fields ) ) {
11
-            wp_die();
12
-        }
9
+		$fields = $_POST['field'];
10
+		if ( empty( $fields ) ) {
11
+			wp_die();
12
+		}
13 13
 
14
-        $_GET['page'] = 'formidable';
15
-        $fields = stripslashes_deep( $fields );
14
+		$_GET['page'] = 'formidable';
15
+		$fields = stripslashes_deep( $fields );
16 16
 
17
-        $ajax = true;
17
+		$ajax = true;
18 18
 		$values = array( 'id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ) );
19
-        $path = FrmAppHelper::plugin_path();
20
-        $field_html = array();
21
-
22
-        foreach ( $fields as $field ) {
23
-            $field = htmlspecialchars_decode( nl2br( $field ) );
24
-            $field = json_decode( $field, true );
25
-            if ( ! isset( $field['id'] ) ) {
26
-                // this field may have already been loaded
27
-                continue;
28
-            }
19
+		$path = FrmAppHelper::plugin_path();
20
+		$field_html = array();
21
+
22
+		foreach ( $fields as $field ) {
23
+			$field = htmlspecialchars_decode( nl2br( $field ) );
24
+			$field = json_decode( $field, true );
25
+			if ( ! isset( $field['id'] ) ) {
26
+				// this field may have already been loaded
27
+				continue;
28
+			}
29 29
 
30
-            $field_id = absint( $field['id'] );
30
+			$field_id = absint( $field['id'] );
31 31
 
32
-            if ( ! isset( $field['value'] ) ) {
33
-                $field['value'] = '';
34
-            }
32
+			if ( ! isset( $field['value'] ) ) {
33
+				$field['value'] = '';
34
+			}
35 35
 
36
-            $field_name = 'item_meta['. $field_id .']';
37
-            $html_id = FrmFieldsHelper::get_html_id($field);
36
+			$field_name = 'item_meta['. $field_id .']';
37
+			$html_id = FrmFieldsHelper::get_html_id($field);
38 38
 
39
-            ob_start();
40
-            include($path .'/classes/views/frm-forms/add_field.php');
41
-            $field_html[ $field_id ] = ob_get_contents();
42
-            ob_end_clean();
43
-        }
39
+			ob_start();
40
+			include($path .'/classes/views/frm-forms/add_field.php');
41
+			$field_html[ $field_id ] = ob_get_contents();
42
+			ob_end_clean();
43
+		}
44 44
 
45
-        unset($path);
45
+		unset($path);
46 46
 
47
-        echo json_encode($field_html);
47
+		echo json_encode($field_html);
48 48
 
49
-        wp_die();
50
-    }
49
+		wp_die();
50
+	}
51 51
 
52
-    public static function create() {
52
+	public static function create() {
53 53
 		FrmAppHelper::permission_check('frm_edit_forms');
54
-        check_ajax_referer( 'frm_ajax', 'nonce' );
54
+		check_ajax_referer( 'frm_ajax', 'nonce' );
55 55
 
56 56
 		$field_type = FrmAppHelper::get_post_param( 'field', '', 'sanitize_text_field' );
57 57
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
58 58
 
59
-        $field = self::include_new_field($field_type, $form_id);
59
+		$field = self::include_new_field($field_type, $form_id);
60 60
 
61
-        // this hook will allow for multiple fields to be added at once
62
-        do_action('frm_after_field_created', $field, $form_id);
61
+		// this hook will allow for multiple fields to be added at once
62
+		do_action('frm_after_field_created', $field, $form_id);
63 63
 
64
-        wp_die();
65
-    }
64
+		wp_die();
65
+	}
66 66
 
67
-    /**
68
-     * @param integer $form_id
69
-     */
67
+	/**
68
+	 * @param integer $form_id
69
+	 */
70 70
 	public static function include_new_field( $field_type, $form_id ) {
71
-        $values = array();
72
-        if ( FrmAppHelper::pro_is_installed() ) {
73
-            $values['post_type'] = FrmProFormsHelper::post_type($form_id);
74
-        }
71
+		$values = array();
72
+		if ( FrmAppHelper::pro_is_installed() ) {
73
+			$values['post_type'] = FrmProFormsHelper::post_type($form_id);
74
+		}
75 75
 
76
-        $field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_type, $form_id));
77
-        $field_id = FrmField::create( $field_values );
76
+		$field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_type, $form_id));
77
+		$field_id = FrmField::create( $field_values );
78 78
 
79
-        if ( ! $field_id ) {
80
-            return false;
81
-        }
79
+		if ( ! $field_id ) {
80
+			return false;
81
+		}
82 82
 
83
-        $field = self::include_single_field($field_id, $values, $form_id);
83
+		$field = self::include_single_field($field_id, $values, $form_id);
84 84
 
85
-        return $field;
86
-    }
85
+		return $field;
86
+	}
87 87
 
88
-    public static function update_form_id() {
88
+	public static function update_form_id() {
89 89
 		FrmAppHelper::permission_check('frm_edit_forms');
90
-        check_ajax_referer( 'frm_ajax', 'nonce' );
90
+		check_ajax_referer( 'frm_ajax', 'nonce' );
91 91
 
92 92
 		$field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
93 93
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
94 94
 
95
-        if ( ! $field_id || ! $form_id ) {
96
-            wp_die();
97
-        }
95
+		if ( ! $field_id || ! $form_id ) {
96
+			wp_die();
97
+		}
98 98
 
99 99
 		$updated = FrmField::update( $field_id, compact( 'form_id' ) );
100 100
 		echo absint( $updated );
101 101
 
102
-        wp_die();
103
-    }
102
+		wp_die();
103
+	}
104 104
 
105 105
 	public static function edit_name( $field = 'name', $id = '' ) {
106 106
 		FrmAppHelper::permission_check('frm_edit_forms');
107
-        check_ajax_referer( 'frm_ajax', 'nonce' );
107
+		check_ajax_referer( 'frm_ajax', 'nonce' );
108 108
 
109
-        if ( empty($field) ) {
110
-            $field = 'name';
111
-        }
109
+		if ( empty($field) ) {
110
+			$field = 'name';
111
+		}
112 112
 
113
-        if ( empty($id) ) {
113
+		if ( empty($id) ) {
114 114
 			$id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
115 115
 			$id = str_replace( 'field_label_', '', $id );
116
-        }
116
+		}
117 117
 
118 118
 		$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' );
119 119
 		$value = trim( $value );
120
-        if ( trim(strip_tags($value)) == '' ) {
121
-            // set blank value if there is no content
122
-            $value = '';
123
-        }
120
+		if ( trim(strip_tags($value)) == '' ) {
121
+			// set blank value if there is no content
122
+			$value = '';
123
+		}
124 124
 
125 125
 		FrmField::update( $id, array( $field => $value ) );
126 126
 
127 127
 		do_action( 'frm_after_update_field_' . $field, compact( 'id', 'value' ) );
128 128
 
129 129
 		echo stripslashes( wp_kses_post( $value ) );
130
-        wp_die();
131
-    }
130
+		wp_die();
131
+	}
132 132
 
133
-    public static function update_ajax_option() {
133
+	public static function update_ajax_option() {
134 134
 		FrmAppHelper::permission_check('frm_edit_forms');
135
-        check_ajax_referer( 'frm_ajax', 'nonce' );
135
+		check_ajax_referer( 'frm_ajax', 'nonce' );
136 136
 
137 137
 		$field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
138 138
 		if ( ! $field_id ) {
@@ -147,141 +147,141 @@  discard block
 block discarded – undo
147 147
 			unset($new_val);
148 148
 		}
149 149
 
150
-        FrmField::update( $field_id, array(
151
-            'field_options' => $field->field_options,
150
+		FrmField::update( $field_id, array(
151
+			'field_options' => $field->field_options,
152 152
 			'form_id'		=> $field->form_id,
153
-        ) );
154
-        wp_die();
155
-    }
153
+		) );
154
+		wp_die();
155
+	}
156 156
 
157
-    public static function duplicate() {
157
+	public static function duplicate() {
158 158
 		FrmAppHelper::permission_check('frm_edit_forms');
159
-        check_ajax_referer( 'frm_ajax', 'nonce' );
159
+		check_ajax_referer( 'frm_ajax', 'nonce' );
160 160
 
161
-        global $wpdb;
161
+		global $wpdb;
162 162
 
163 163
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
164 164
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
165 165
 
166 166
 		$copy_field = FrmField::getOne( $field_id );
167
-        if ( ! $copy_field ) {
168
-            wp_die();
169
-        }
167
+		if ( ! $copy_field ) {
168
+			wp_die();
169
+		}
170 170
 
171
-        do_action('frm_duplicate_field', $copy_field, $form_id);
172
-        do_action('frm_duplicate_field_'. $copy_field->type, $copy_field, $form_id);
171
+		do_action('frm_duplicate_field', $copy_field, $form_id);
172
+		do_action('frm_duplicate_field_'. $copy_field->type, $copy_field, $form_id);
173 173
 
174
-        $values = array( 'id' => $form_id );
175
-        FrmFieldsHelper::fill_field( $values, $copy_field, $form_id );
174
+		$values = array( 'id' => $form_id );
175
+		FrmFieldsHelper::fill_field( $values, $copy_field, $form_id );
176 176
 
177 177
 		$field_count = FrmDb::get_count( $wpdb->prefix .'frm_fields fi LEFT JOIN '. $wpdb->prefix .'frm_forms fr ON (fi.form_id = fr.id)', array( 'or' => 1, 'fr.id' => $form_id, 'fr.parent_form_id' => $form_id ) );
178 178
 
179
-        $values['field_order'] = $field_count + 1;
179
+		$values['field_order'] = $field_count + 1;
180 180
 
181
-        if ( ! $field_id = FrmField::create($values) ) {
182
-            wp_die();
183
-        }
181
+		if ( ! $field_id = FrmField::create($values) ) {
182
+			wp_die();
183
+		}
184 184
 
185
-        self::include_single_field($field_id, $values);
185
+		self::include_single_field($field_id, $values);
186 186
 
187
-        wp_die();
188
-    }
187
+		wp_die();
188
+	}
189 189
 
190
-    /**
191
-     * Load a single field in the form builder along with all needed variables
192
-     */
193
-    public static function include_single_field( $field_id, $values, $form_id = 0 ) {
194
-        $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
195
-        $field_name = 'item_meta['. $field_id .']';
196
-        $html_id = FrmFieldsHelper::get_html_id($field);
197
-        $id = $form_id ? $form_id : $field['form_id'];
198
-        if ( $field['type'] == 'html' ) {
199
-            $field['stop_filter'] = true;
200
-        }
190
+	/**
191
+	 * Load a single field in the form builder along with all needed variables
192
+	 */
193
+	public static function include_single_field( $field_id, $values, $form_id = 0 ) {
194
+		$field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
195
+		$field_name = 'item_meta['. $field_id .']';
196
+		$html_id = FrmFieldsHelper::get_html_id($field);
197
+		$id = $form_id ? $form_id : $field['form_id'];
198
+		if ( $field['type'] == 'html' ) {
199
+			$field['stop_filter'] = true;
200
+		}
201 201
 
202
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/add_field.php');
202
+		require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/add_field.php');
203 203
 
204
-        return $field;
205
-    }
204
+		return $field;
205
+	}
206 206
 
207
-    public static function destroy() {
207
+	public static function destroy() {
208 208
 		FrmAppHelper::permission_check('frm_edit_forms');
209
-        check_ajax_referer( 'frm_ajax', 'nonce' );
209
+		check_ajax_referer( 'frm_ajax', 'nonce' );
210 210
 
211 211
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
212 212
 		FrmField::destroy( $field_id );
213
-        wp_die();
214
-    }
213
+		wp_die();
214
+	}
215 215
 
216
-    /* Field Options */
216
+	/* Field Options */
217 217
 
218
-    //Add Single Option or Other Option
219
-    public static function add_option() {
218
+	//Add Single Option or Other Option
219
+	public static function add_option() {
220 220
 		FrmAppHelper::permission_check('frm_edit_forms');
221
-        check_ajax_referer( 'frm_ajax', 'nonce' );
221
+		check_ajax_referer( 'frm_ajax', 'nonce' );
222 222
 
223 223
 		$id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
224 224
 		$opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' );
225 225
 
226
-        //Get the field
227
-        $field = FrmField::getOne($id);
226
+		//Get the field
227
+		$field = FrmField::getOne($id);
228 228
 
229 229
 		if ( ! empty( $field->options ) ) {
230 230
 			$keys = array_keys( $field->options );
231
-            $last = str_replace( 'other_', '', end( $keys ) );
232
-        } else {
233
-            $last = 0;
234
-        }
235
-        $opt_key = $last + 1;
231
+			$last = str_replace( 'other_', '', end( $keys ) );
232
+		} else {
233
+			$last = 0;
234
+		}
235
+		$opt_key = $last + 1;
236 236
 
237
-        if ( 'other' == $opt_type ) {
237
+		if ( 'other' == $opt_type ) {
238 238
 			$opt = esc_html__( 'Other', 'formidable' );
239
-            $other_val = '';
240
-            $opt_key = 'other_' . $opt_key;
241
-
242
-            //Update value of "other" in DB
243
-            $field_options = maybe_unserialize( $field->field_options );
244
-            $field_options['other'] = 1;
245
-            FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) );
246
-        } else {
239
+			$other_val = '';
240
+			$opt_key = 'other_' . $opt_key;
241
+
242
+			//Update value of "other" in DB
243
+			$field_options = maybe_unserialize( $field->field_options );
244
+			$field_options['other'] = 1;
245
+			FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) );
246
+		} else {
247 247
 			$first_opt = reset( $field->options );
248 248
 			$next_opt = count( $field->options );
249
-            if ( $first_opt != '' ) {
250
-                $next_opt++;
251
-            }
252
-            $opt = esc_html__( 'Option', 'formidable' ) .' '. $next_opt;
253
-            unset($next_opt);
254
-        }
255
-        $field_val = $opt;
249
+			if ( $first_opt != '' ) {
250
+				$next_opt++;
251
+			}
252
+			$opt = esc_html__( 'Option', 'formidable' ) .' '. $next_opt;
253
+			unset($next_opt);
254
+		}
255
+		$field_val = $opt;
256 256
 		$field->options[ $opt_key ] = $opt;
257 257
 
258
-        //Update options in DB
258
+		//Update options in DB
259 259
 		FrmField::update( $id, array( 'options' => $field->options ) );
260 260
 
261
-        $field_data = $field;
262
-        $field = array(
263
-            'type'  => $field_data->type,
264
-            'id'    => $id,
265
-            'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0,
266
-            'form_id' => $field_data->form_id,
267
-            'field_key' => $field_data->field_key,
268
-        );
269
-
270
-        $field_name = 'item_meta['. $id .']';
271
-        $html_id = FrmFieldsHelper::get_html_id($field);
272
-        $checked = '';
273
-
274
-        if ( 'other' == $opt_type ) {
275
-            require(FrmAppHelper::plugin_path() .'/pro/classes/views/frmpro-fields/other-option.php');
276
-        } else {
277
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/single-option.php');
278
-        }
279
-        wp_die();
280
-    }
281
-
282
-    public static function edit_option() {
261
+		$field_data = $field;
262
+		$field = array(
263
+			'type'  => $field_data->type,
264
+			'id'    => $id,
265
+			'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0,
266
+			'form_id' => $field_data->form_id,
267
+			'field_key' => $field_data->field_key,
268
+		);
269
+
270
+		$field_name = 'item_meta['. $id .']';
271
+		$html_id = FrmFieldsHelper::get_html_id($field);
272
+		$checked = '';
273
+
274
+		if ( 'other' == $opt_type ) {
275
+			require(FrmAppHelper::plugin_path() .'/pro/classes/views/frmpro-fields/other-option.php');
276
+		} else {
277
+			require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/single-option.php');
278
+		}
279
+		wp_die();
280
+	}
281
+
282
+	public static function edit_option() {
283 283
 		FrmAppHelper::permission_check('frm_edit_forms');
284
-        check_ajax_referer( 'frm_ajax', 'nonce' );
284
+		check_ajax_referer( 'frm_ajax', 'nonce' );
285 285
 
286 286
 		$element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
287 287
 		$ids = explode( '-', $element_id );
@@ -289,43 +289,43 @@  discard block
 block discarded – undo
289 289
 
290 290
 		$orig_update_value = $update_value = trim( FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ) );
291 291
 		if ( strpos( $element_id, 'key_' ) ) {
292
-            $new_value = $update_value;
293
-        } else {
294
-            $new_label = $update_value;
295
-        }
292
+			$new_value = $update_value;
293
+		} else {
294
+			$new_label = $update_value;
295
+		}
296 296
 
297
-        $field = FrmField::getOne($id);
298
-        $separate_values = FrmField::is_option_true( $field, 'separate_value' );
297
+		$field = FrmField::getOne($id);
298
+		$separate_values = FrmField::is_option_true( $field, 'separate_value' );
299 299
 
300
-        $this_opt_id = end($ids);
300
+		$this_opt_id = end($ids);
301 301
 		$this_opt = (array) $field->options[ $this_opt_id ];
302 302
 		$other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false );
303 303
 
304
-        $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt);
305
-        $value = isset($this_opt['value']) ? $this_opt['value'] : '';
304
+		$label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt);
305
+		$value = isset($this_opt['value']) ? $this_opt['value'] : '';
306 306
 
307
-        if ( ! isset( $new_label ) ) {
308
-            $new_label = $label;
309
-        }
307
+		if ( ! isset( $new_label ) ) {
308
+			$new_label = $label;
309
+		}
310 310
 
311
-        if ( isset($new_value) || isset($value) ) {
312
-            $update_value = isset($new_value) ? $new_value : $value;
313
-        }
311
+		if ( isset($new_value) || isset($value) ) {
312
+			$update_value = isset($new_value) ? $new_value : $value;
313
+		}
314 314
 
315 315
 		if ( $update_value != $new_label && $other_opt === false && $separate_values ) {
316 316
 			$field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label );
317
-        } else {
317
+		} else {
318 318
 			$field->options[ $this_opt_id ] = $orig_update_value;
319
-        }
319
+		}
320 320
 
321 321
 		FrmField::update( $field->id, array( 'options' => $field->options ) );
322 322
 		echo ( $orig_update_value == '' ) ? esc_html__( '(Blank)', 'formidable' ) : stripslashes( $orig_update_value );
323
-        wp_die();
324
-    }
323
+		wp_die();
324
+	}
325 325
 
326
-    public static function delete_option() {
326
+	public static function delete_option() {
327 327
 		FrmAppHelper::permission_check('frm_edit_forms');
328
-        check_ajax_referer( 'frm_ajax', 'nonce' );
328
+		check_ajax_referer( 'frm_ajax', 'nonce' );
329 329
 
330 330
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
331 331
 		$field = FrmField::getOne( $field_id );
@@ -333,310 +333,310 @@  discard block
 block discarded – undo
333 333
 		$opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' );
334 334
 
335 335
 		$options = $field->options;
336
-        unset( $options[ $opt_key ] );
337
-        $response = array( 'other' => true );
336
+		unset( $options[ $opt_key ] );
337
+		$response = array( 'other' => true );
338 338
 
339
-        //If the deleted option is an "other" option
339
+		//If the deleted option is an "other" option
340 340
 		if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) {
341
-            //Assume all other options are gone, unless proven otherwise
342
-            $other = false;
341
+			//Assume all other options are gone, unless proven otherwise
342
+			$other = false;
343 343
 
344
-            //Check if all other options are really gone
345
-            foreach ( $options as $o_key => $o_val ) {
346
-                //If there is still an other option in the field, set other to true
344
+			//Check if all other options are really gone
345
+			foreach ( $options as $o_key => $o_val ) {
346
+				//If there is still an other option in the field, set other to true
347 347
 				if ( FrmFieldsHelper::is_other_opt( $o_key ) ) {
348
-                    $other = true;
349
-                    break;
350
-                }
351
-                unset( $o_key, $o_val );
352
-            }
353
-
354
-            //If all other options are gone
355
-            if ( false === $other ) {
356
-                $field_options = maybe_unserialize( $field->field_options );
357
-                $field_options['other'] = 0;
348
+					$other = true;
349
+					break;
350
+				}
351
+				unset( $o_key, $o_val );
352
+			}
353
+
354
+			//If all other options are gone
355
+			if ( false === $other ) {
356
+				$field_options = maybe_unserialize( $field->field_options );
357
+				$field_options['other'] = 0;
358 358
 				FrmField::update( $field_id, array( 'field_options' => maybe_serialize( $field_options ) ) );
359
-                $response = array( 'other' => false );
360
-            }
361
-        }
362
-        echo json_encode( $response );
359
+				$response = array( 'other' => false );
360
+			}
361
+		}
362
+		echo json_encode( $response );
363 363
 
364 364
 		FrmField::update( $field_id, array( 'options' => maybe_serialize( $options ) ) );
365 365
 
366
-        wp_die();
367
-    }
366
+		wp_die();
367
+	}
368 368
 
369
-    public static function import_choices() {
370
-        FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
369
+	public static function import_choices() {
370
+		FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
371 371
 
372 372
 		$field_id = absint( $_REQUEST['field_id'] );
373 373
 
374
-        global $current_screen, $hook_suffix;
374
+		global $current_screen, $hook_suffix;
375 375
 
376
-        // Catch plugins that include admin-header.php before admin.php completes.
377
-        if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) {
378
-            $hook_suffix = '';
379
-        	set_current_screen();
380
-        }
376
+		// Catch plugins that include admin-header.php before admin.php completes.
377
+		if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) {
378
+			$hook_suffix = '';
379
+			set_current_screen();
380
+		}
381 381
 
382
-        if ( function_exists( 'register_admin_color_schemes' ) ) {
383
-            register_admin_color_schemes();
384
-        }
382
+		if ( function_exists( 'register_admin_color_schemes' ) ) {
383
+			register_admin_color_schemes();
384
+		}
385 385
 
386
-        $hook_suffix = $admin_body_class = '';
386
+		$hook_suffix = $admin_body_class = '';
387 387
 
388
-        if ( get_user_setting( 'mfold' ) == 'f' ) {
389
-        	$admin_body_class .= ' folded';
390
-        }
388
+		if ( get_user_setting( 'mfold' ) == 'f' ) {
389
+			$admin_body_class .= ' folded';
390
+		}
391 391
 
392
-        if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) {
393
-        	$admin_body_class .= ' admin-bar';
394
-        }
392
+		if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) {
393
+			$admin_body_class .= ' admin-bar';
394
+		}
395 395
 
396
-        if ( is_rtl() ) {
397
-        	$admin_body_class .= ' rtl';
398
-        }
396
+		if ( is_rtl() ) {
397
+			$admin_body_class .= ' rtl';
398
+		}
399 399
 
400
-        $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
401
-        $prepop = array();
402
-        FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
400
+		$admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
401
+		$prepop = array();
402
+		FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
403 403
 
404
-        $field = FrmField::getOne($field_id);
404
+		$field = FrmField::getOne($field_id);
405 405
 
406
-        wp_enqueue_script( 'utils' );
407
-        wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url(). '/css/frm_admin.css' );
408
-        FrmAppHelper::load_admin_wide_js();
406
+		wp_enqueue_script( 'utils' );
407
+		wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url(). '/css/frm_admin.css' );
408
+		FrmAppHelper::load_admin_wide_js();
409 409
 
410
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/import_choices.php');
411
-        wp_die();
412
-    }
410
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/import_choices.php');
411
+		wp_die();
412
+	}
413 413
 
414
-    public static function import_options() {
414
+	public static function import_options() {
415 415
 		FrmAppHelper::permission_check('frm_edit_forms');
416
-        check_ajax_referer( 'frm_ajax', 'nonce' );
416
+		check_ajax_referer( 'frm_ajax', 'nonce' );
417 417
 
418
-        if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
419
-            return;
420
-        }
418
+		if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
419
+			return;
420
+		}
421 421
 
422 422
 		$field_id = absint( $_POST['field_id'] );
423
-        $field = FrmField::getOne($field_id);
423
+		$field = FrmField::getOne($field_id);
424 424
 
425 425
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) {
426
-            return;
427
-        }
428
-
429
-        $field = FrmFieldsHelper::setup_edit_vars($field);
430
-        $opts = stripslashes_deep($_POST['opts']);
431
-        $opts = explode("\n", rtrim($opts, "\n"));
432
-        if ( $field['separate_value'] ) {
433
-            foreach ( $opts as $opt_key => $opt ) {
434
-                if ( strpos($opt, '|') !== false ) {
435
-                    $vals = explode('|', $opt);
436
-                    if ( $vals[0] != $vals[1] ) {
437
-                        $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
438
-                    }
439
-                    unset($vals);
440
-                }
441
-                unset($opt_key, $opt);
442
-            }
443
-        }
444
-
445
-        //Keep other options after bulk update
446
-        if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
447
-            $other_array = array();
448
-            foreach ( $field['options'] as $opt_key => $opt ) {
449
-                if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) {
450
-                    $other_array[ $opt_key ] = $opt;
451
-                }
452
-                unset($opt_key, $opt);
453
-            }
454
-            if ( ! empty($other_array) ) {
455
-                $opts = array_merge( $opts, $other_array);
456
-            }
457
-        }
458
-
459
-        FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) );
460
-
461
-        $field['options'] = $opts;
462
-        $field_name = $field['name'];
463
-
464
-        // Get html_id which will be used in single-option.php
465
-        $html_id = FrmFieldsHelper::get_html_id( $field );
466
-
467
-        if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
468
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/radio.php');
469
-        } else {
470
-            FrmFieldsHelper::show_single_option($field);
471
-        }
472
-
473
-        wp_die();
474
-    }
475
-
476
-    public static function update_order() {
426
+			return;
427
+		}
428
+
429
+		$field = FrmFieldsHelper::setup_edit_vars($field);
430
+		$opts = stripslashes_deep($_POST['opts']);
431
+		$opts = explode("\n", rtrim($opts, "\n"));
432
+		if ( $field['separate_value'] ) {
433
+			foreach ( $opts as $opt_key => $opt ) {
434
+				if ( strpos($opt, '|') !== false ) {
435
+					$vals = explode('|', $opt);
436
+					if ( $vals[0] != $vals[1] ) {
437
+						$opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
438
+					}
439
+					unset($vals);
440
+				}
441
+				unset($opt_key, $opt);
442
+			}
443
+		}
444
+
445
+		//Keep other options after bulk update
446
+		if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
447
+			$other_array = array();
448
+			foreach ( $field['options'] as $opt_key => $opt ) {
449
+				if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) {
450
+					$other_array[ $opt_key ] = $opt;
451
+				}
452
+				unset($opt_key, $opt);
453
+			}
454
+			if ( ! empty($other_array) ) {
455
+				$opts = array_merge( $opts, $other_array);
456
+			}
457
+		}
458
+
459
+		FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) );
460
+
461
+		$field['options'] = $opts;
462
+		$field_name = $field['name'];
463
+
464
+		// Get html_id which will be used in single-option.php
465
+		$html_id = FrmFieldsHelper::get_html_id( $field );
466
+
467
+		if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
468
+			require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/radio.php');
469
+		} else {
470
+			FrmFieldsHelper::show_single_option($field);
471
+		}
472
+
473
+		wp_die();
474
+	}
475
+
476
+	public static function update_order() {
477 477
 		FrmAppHelper::permission_check('frm_edit_forms');
478
-        check_ajax_referer( 'frm_ajax', 'nonce' );
478
+		check_ajax_referer( 'frm_ajax', 'nonce' );
479 479
 
480 480
 		$fields = FrmAppHelper::get_post_param( 'frm_field_id' );
481 481
 		foreach ( (array) $fields as $position => $item ) {
482 482
 			FrmField::update( absint( $item ), array( 'field_order' => absint( $position ) ) );
483 483
 		}
484
-        wp_die();
485
-    }
484
+		wp_die();
485
+	}
486 486
 
487 487
 	public static function change_type( $type ) {
488
-        $type_switch = array(
489
-            'scale'     => 'radio',
490
-            '10radio'   => 'radio',
491
-            'rte'       => 'textarea',
492
-            'website'   => 'url',
493
-        );
494
-        if ( isset( $type_switch[ $type ] ) ) {
495
-            $type = $type_switch[ $type ];
496
-        }
488
+		$type_switch = array(
489
+			'scale'     => 'radio',
490
+			'10radio'   => 'radio',
491
+			'rte'       => 'textarea',
492
+			'website'   => 'url',
493
+		);
494
+		if ( isset( $type_switch[ $type ] ) ) {
495
+			$type = $type_switch[ $type ];
496
+		}
497 497
 
498 498
 		$frm_field_selection = FrmField::field_selection();
499
-        $types = array_keys($frm_field_selection);
500
-        if ( ! in_array($type, $types) && $type != 'captcha' ) {
501
-            $type = 'text';
502
-        }
499
+		$types = array_keys($frm_field_selection);
500
+		if ( ! in_array($type, $types) && $type != 'captcha' ) {
501
+			$type = 'text';
502
+		}
503 503
 
504
-        return $type;
505
-    }
504
+		return $type;
505
+	}
506 506
 
507 507
 	public static function display_field_options( $display ) {
508 508
 		switch ( $display['type'] ) {
509
-            case 'captcha':
510
-                $display['required'] = false;
511
-                $display['invalid'] = true;
512
-                $display['default_blank'] = false;
509
+			case 'captcha':
510
+				$display['required'] = false;
511
+				$display['invalid'] = true;
512
+				$display['default_blank'] = false;
513 513
 				$display['captcha_size'] = true;
514
-            break;
515
-            case 'radio':
516
-                $display['default_blank'] = false;
517
-            break;
518
-            case 'text':
519
-            case 'textarea':
520
-                $display['size'] = true;
521
-                $display['clear_on_focus'] = true;
522
-            break;
523
-            case 'select':
524
-                $display['size'] = true;
525
-            break;
526
-            case 'url':
527
-            case 'website':
528
-            case 'email':
529
-                $display['size'] = true;
530
-                $display['clear_on_focus'] = true;
531
-                $display['invalid'] = true;
532
-        }
533
-
534
-        return $display;
535
-    }
536
-
537
-    public static function input_html( $field, $echo = true ) {
538
-        $class = array(); //$field['type'];
539
-        self::add_input_classes($field, $class);
540
-
541
-        $add_html = array();
542
-        self::add_html_size($field, $add_html);
543
-        self::add_html_length($field, $add_html);
544
-        self::add_html_placeholder($field, $add_html, $class);
514
+			break;
515
+			case 'radio':
516
+				$display['default_blank'] = false;
517
+			break;
518
+			case 'text':
519
+			case 'textarea':
520
+				$display['size'] = true;
521
+				$display['clear_on_focus'] = true;
522
+			break;
523
+			case 'select':
524
+				$display['size'] = true;
525
+			break;
526
+			case 'url':
527
+			case 'website':
528
+			case 'email':
529
+				$display['size'] = true;
530
+				$display['clear_on_focus'] = true;
531
+				$display['invalid'] = true;
532
+		}
533
+
534
+		return $display;
535
+	}
536
+
537
+	public static function input_html( $field, $echo = true ) {
538
+		$class = array(); //$field['type'];
539
+		self::add_input_classes($field, $class);
540
+
541
+		$add_html = array();
542
+		self::add_html_size($field, $add_html);
543
+		self::add_html_length($field, $add_html);
544
+		self::add_html_placeholder($field, $add_html, $class);
545 545
 		self::add_validation_messages( $field, $add_html );
546 546
 
547
-        $class = apply_filters('frm_field_classes', implode(' ', $class), $field);
547
+		$class = apply_filters('frm_field_classes', implode(' ', $class), $field);
548 548
 
549 549
 		FrmFormsHelper::add_html_attr( $class, 'class', $add_html );
550 550
 
551
-        self::add_shortcodes_to_html($field, $add_html);
551
+		self::add_shortcodes_to_html($field, $add_html);
552 552
 
553 553
 		$add_html = apply_filters( 'frm_field_extra_html', $add_html, $field );
554 554
 		$add_html = ' ' . implode( ' ', $add_html ) . '  ';
555 555
 
556
-        if ( $echo ) {
557
-            echo $add_html;
558
-        }
556
+		if ( $echo ) {
557
+			echo $add_html;
558
+		}
559 559
 
560
-        return $add_html;
561
-    }
560
+		return $add_html;
561
+	}
562 562
 
563 563
 	private static function add_input_classes( $field, array &$class ) {
564
-        if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
565
-            $class[] = $field['input_class'];
566
-        }
564
+		if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
565
+			$class[] = $field['input_class'];
566
+		}
567 567
 
568
-        if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) {
569
-            return;
570
-        }
568
+		if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) {
569
+			return;
570
+		}
571 571
 
572
-        global $frm_vars;
572
+		global $frm_vars;
573 573
 		if ( is_admin() && ! FrmAppHelper::is_preview_page() && ! in_array( $field['type'], array( 'scale', 'radio', 'checkbox', 'data' ) ) ) {
574
-            $class[] = 'dyn_default_value';
575
-        }
574
+			$class[] = 'dyn_default_value';
575
+		}
576 576
 
577
-        if ( isset($field['size']) && $field['size'] > 0 ) {
578
-            $class[] = 'auto_width';
579
-        }
580
-    }
577
+		if ( isset($field['size']) && $field['size'] > 0 ) {
578
+			$class[] = 'auto_width';
579
+		}
580
+	}
581 581
 
582 582
 	private static function add_html_size( $field, array &$add_html ) {
583 583
 		if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden' ) ) ) {
584
-            return;
585
-        }
584
+			return;
585
+		}
586 586
 
587
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
588
-            return;
589
-        }
587
+		if ( FrmAppHelper::is_admin_page('formidable' ) ) {
588
+			return;
589
+		}
590 590
 
591
-        if ( is_numeric($field['size']) ) {
592
-            $field['size'] .= 'px';
593
-        }
591
+		if ( is_numeric($field['size']) ) {
592
+			$field['size'] .= 'px';
593
+		}
594 594
 
595
-        $important = apply_filters('frm_use_important_width', 1, $field);
596
-        // Note: This inline styling must stay since we cannot realistically set a class for every possible field size
597
-        $add_html['style'] = 'style="width:'. esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) .'"';
595
+		$important = apply_filters('frm_use_important_width', 1, $field);
596
+		// Note: This inline styling must stay since we cannot realistically set a class for every possible field size
597
+		$add_html['style'] = 'style="width:'. esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) .'"';
598 598
 
599
-        self::add_html_cols($field, $add_html);
600
-    }
599
+		self::add_html_cols($field, $add_html);
600
+	}
601 601
 
602 602
 	private static function add_html_cols( $field, array &$add_html ) {
603 603
 		if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) {
604
-            return;
605
-        }
604
+			return;
605
+		}
606 606
 
607
-        // convert to cols for textareas
608
-        $calc = array(
609
-            ''      => 9,
610
-            'px'    => 9,
611
-            'rem'   => 0.444,
612
-            'em'    => 0.544,
613
-        );
607
+		// convert to cols for textareas
608
+		$calc = array(
609
+			''      => 9,
610
+			'px'    => 9,
611
+			'rem'   => 0.444,
612
+			'em'    => 0.544,
613
+		);
614 614
 
615
-        // include "col" for valid html
616
-        $unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
615
+		// include "col" for valid html
616
+		$unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
617 617
 
618
-        if ( ! isset( $calc[ $unit ] ) ) {
619
-            return;
620
-        }
618
+		if ( ! isset( $calc[ $unit ] ) ) {
619
+			return;
620
+		}
621 621
 
622
-        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
622
+		$size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
623 623
 
624 624
 		$add_html['cols'] = 'cols="' . absint( $size ) . '"';
625
-    }
625
+	}
626 626
 
627 627
 	private static function add_html_length( $field, array &$add_html ) {
628
-        // check for max setting and if this field accepts maxlength
628
+		// check for max setting and if this field accepts maxlength
629 629
 		if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden' ) ) ) {
630
-            return;
631
-        }
630
+			return;
631
+		}
632 632
 
633
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
634
-            // don't load on form builder page
635
-            return;
636
-        }
633
+		if ( FrmAppHelper::is_admin_page('formidable' ) ) {
634
+			// don't load on form builder page
635
+			return;
636
+		}
637 637
 
638 638
 		$add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"';
639
-    }
639
+	}
640 640
 
641 641
 	private static function add_html_placeholder( $field, array &$add_html, array &$class ) {
642 642
 		if ( empty( $field['default_value'] ) || FrmAppHelper::is_admin_page( 'formidable' ) ) {
@@ -644,35 +644,35 @@  discard block
 block discarded – undo
644 644
 		}
645 645
 
646 646
 		$default_value_array = is_array( $field['default_value'] );
647
-        if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) {
647
+		if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) {
648 648
 			if ( $default_value_array ) {
649 649
 				$field['default_value'] = json_encode( $field['default_value'] );
650 650
 			}
651 651
 			$add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['default_value'] ) . '"';
652
-            return;
653
-        }
652
+			return;
653
+		}
654 654
 
655 655
 		if ( $default_value_array ) {
656 656
 			// don't include a json placeholder
657 657
 			return;
658 658
 		}
659 659
 
660
-        $frm_settings = FrmAppHelper::get_settings();
660
+		$frm_settings = FrmAppHelper::get_settings();
661 661
 
662 662
 		if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) {
663
-            // use HMTL5 placeholder with js fallback
664
-            $add_html['placeholder'] = 'placeholder="'. esc_attr($field['default_value']) .'"';
665
-            wp_enqueue_script('jquery-placeholder');
666
-        } else if ( ! $frm_settings->use_html ) {
663
+			// use HMTL5 placeholder with js fallback
664
+			$add_html['placeholder'] = 'placeholder="'. esc_attr($field['default_value']) .'"';
665
+			wp_enqueue_script('jquery-placeholder');
666
+		} else if ( ! $frm_settings->use_html ) {
667 667
 			$val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( '&#039;', "'", esc_attr( $field['default_value'] ) ) ) );
668
-            $add_html['data-frmval'] = 'data-frmval="'. esc_attr($val) .'"';
669
-            $class[] = 'frm_toggle_default';
668
+			$add_html['data-frmval'] = 'data-frmval="'. esc_attr($val) .'"';
669
+			$class[] = 'frm_toggle_default';
670 670
 
671
-            if ( $field['value'] == $field['default_value'] ) {
672
-                $class[] = 'frm_default';
673
-            }
674
-        }
675
-    }
671
+			if ( $field['value'] == $field['default_value'] ) {
672
+				$class[] = 'frm_default';
673
+			}
674
+		}
675
+	}
676 676
 
677 677
 	private static function add_validation_messages( $field, array &$add_html ) {
678 678
 		if ( FrmField::is_required( $field ) ) {
@@ -693,44 +693,44 @@  discard block
 block discarded – undo
693 693
 		}
694 694
 	}
695 695
 
696
-    private static function add_shortcodes_to_html( $field, array &$add_html ) {
697
-        if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
698
-            return;
699
-        }
700
-
701
-        foreach ( $field['shortcodes'] as $k => $v ) {
702
-            if ( 'opt' === $k ) {
703
-                continue;
704
-            }
705
-
706
-            if ( is_numeric($k) && strpos($v, '=') ) {
707
-                $add_html[] = $v;
708
-            } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
709
-                $add_html[ $k ] = str_replace( $k .'="', $k .'="'. $v, $add_html[ $k ] );
710
-            } else {
696
+	private static function add_shortcodes_to_html( $field, array &$add_html ) {
697
+		if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
698
+			return;
699
+		}
700
+
701
+		foreach ( $field['shortcodes'] as $k => $v ) {
702
+			if ( 'opt' === $k ) {
703
+				continue;
704
+			}
705
+
706
+			if ( is_numeric($k) && strpos($v, '=') ) {
707
+				$add_html[] = $v;
708
+			} else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
709
+				$add_html[ $k ] = str_replace( $k .'="', $k .'="'. $v, $add_html[ $k ] );
710
+			} else {
711 711
 				$add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
712
-            }
713
-
714
-            unset($k, $v);
715
-        }
716
-    }
717
-
718
-    public static function check_value( $opt, $opt_key, $field ) {
719
-        if ( is_array( $opt ) ) {
720
-            if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
721
-                $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
722
-            } else {
723
-                $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
724
-            }
725
-        }
726
-        return $opt;
727
-    }
712
+			}
713
+
714
+			unset($k, $v);
715
+		}
716
+	}
717
+
718
+	public static function check_value( $opt, $opt_key, $field ) {
719
+		if ( is_array( $opt ) ) {
720
+			if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
721
+				$opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
722
+			} else {
723
+				$opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
724
+			}
725
+		}
726
+		return $opt;
727
+	}
728 728
 
729 729
 	public static function check_label( $opt ) {
730
-        if ( is_array($opt) ) {
731
-            $opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
732
-        }
730
+		if ( is_array($opt) ) {
731
+			$opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
732
+		}
733 733
 
734
-        return $opt;
735
-    }
734
+		return $opt;
735
+	}
736 736
 }
Please login to merge, or discard this patch.
Spacing   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 class FrmFieldsController {
4 4
 
5 5
     public static function load_field() {
6
-		FrmAppHelper::permission_check('frm_edit_forms');
6
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
7 7
         check_ajax_referer( 'frm_ajax', 'nonce' );
8 8
 
9 9
         $fields = $_POST['field'];
@@ -33,33 +33,33 @@  discard block
 block discarded – undo
33 33
                 $field['value'] = '';
34 34
             }
35 35
 
36
-            $field_name = 'item_meta['. $field_id .']';
37
-            $html_id = FrmFieldsHelper::get_html_id($field);
36
+            $field_name = 'item_meta[' . $field_id . ']';
37
+            $html_id = FrmFieldsHelper::get_html_id( $field );
38 38
 
39 39
             ob_start();
40
-            include($path .'/classes/views/frm-forms/add_field.php');
41
-            $field_html[ $field_id ] = ob_get_contents();
40
+            include( $path . '/classes/views/frm-forms/add_field.php' );
41
+            $field_html[$field_id] = ob_get_contents();
42 42
             ob_end_clean();
43 43
         }
44 44
 
45
-        unset($path);
45
+        unset( $path );
46 46
 
47
-        echo json_encode($field_html);
47
+        echo json_encode( $field_html );
48 48
 
49 49
         wp_die();
50 50
     }
51 51
 
52 52
     public static function create() {
53
-		FrmAppHelper::permission_check('frm_edit_forms');
53
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
54 54
         check_ajax_referer( 'frm_ajax', 'nonce' );
55 55
 
56 56
 		$field_type = FrmAppHelper::get_post_param( 'field', '', 'sanitize_text_field' );
57 57
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
58 58
 
59
-        $field = self::include_new_field($field_type, $form_id);
59
+        $field = self::include_new_field( $field_type, $form_id );
60 60
 
61 61
         // this hook will allow for multiple fields to be added at once
62
-        do_action('frm_after_field_created', $field, $form_id);
62
+        do_action( 'frm_after_field_created', $field, $form_id );
63 63
 
64 64
         wp_die();
65 65
     }
@@ -70,23 +70,23 @@  discard block
 block discarded – undo
70 70
 	public static function include_new_field( $field_type, $form_id ) {
71 71
         $values = array();
72 72
         if ( FrmAppHelper::pro_is_installed() ) {
73
-            $values['post_type'] = FrmProFormsHelper::post_type($form_id);
73
+            $values['post_type'] = FrmProFormsHelper::post_type( $form_id );
74 74
         }
75 75
 
76
-        $field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_type, $form_id));
76
+        $field_values = apply_filters( 'frm_before_field_created', FrmFieldsHelper::setup_new_vars( $field_type, $form_id ) );
77 77
         $field_id = FrmField::create( $field_values );
78 78
 
79 79
         if ( ! $field_id ) {
80 80
             return false;
81 81
         }
82 82
 
83
-        $field = self::include_single_field($field_id, $values, $form_id);
83
+        $field = self::include_single_field( $field_id, $values, $form_id );
84 84
 
85 85
         return $field;
86 86
     }
87 87
 
88 88
     public static function update_form_id() {
89
-		FrmAppHelper::permission_check('frm_edit_forms');
89
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
90 90
         check_ajax_referer( 'frm_ajax', 'nonce' );
91 91
 
92 92
 		$field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
@@ -103,21 +103,21 @@  discard block
 block discarded – undo
103 103
     }
104 104
 
105 105
 	public static function edit_name( $field = 'name', $id = '' ) {
106
-		FrmAppHelper::permission_check('frm_edit_forms');
106
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
107 107
         check_ajax_referer( 'frm_ajax', 'nonce' );
108 108
 
109
-        if ( empty($field) ) {
109
+        if ( empty( $field ) ) {
110 110
             $field = 'name';
111 111
         }
112 112
 
113
-        if ( empty($id) ) {
113
+        if ( empty( $id ) ) {
114 114
 			$id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
115 115
 			$id = str_replace( 'field_label_', '', $id );
116 116
         }
117 117
 
118 118
 		$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' );
119 119
 		$value = trim( $value );
120
-        if ( trim(strip_tags($value)) == '' ) {
120
+        if ( trim( strip_tags( $value ) ) == '' ) {
121 121
             // set blank value if there is no content
122 122
             $value = '';
123 123
         }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
     }
132 132
 
133 133
     public static function update_ajax_option() {
134
-		FrmAppHelper::permission_check('frm_edit_forms');
134
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
135 135
         check_ajax_referer( 'frm_ajax', 'nonce' );
136 136
 
137 137
 		$field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 		if ( isset( $_POST['separate_value'] ) ) {
145 145
 			$new_val = FrmField::is_option_true( $field, 'separate_value' ) ? 0 : 1;
146 146
 			$field->field_options['separate_value'] = $new_val;
147
-			unset($new_val);
147
+			unset( $new_val );
148 148
 		}
149 149
 
150 150
         FrmField::update( $field_id, array(
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
     }
156 156
 
157 157
     public static function duplicate() {
158
-		FrmAppHelper::permission_check('frm_edit_forms');
158
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
159 159
         check_ajax_referer( 'frm_ajax', 'nonce' );
160 160
 
161 161
         global $wpdb;
@@ -168,21 +168,21 @@  discard block
 block discarded – undo
168 168
             wp_die();
169 169
         }
170 170
 
171
-        do_action('frm_duplicate_field', $copy_field, $form_id);
172
-        do_action('frm_duplicate_field_'. $copy_field->type, $copy_field, $form_id);
171
+        do_action( 'frm_duplicate_field', $copy_field, $form_id );
172
+        do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id );
173 173
 
174 174
         $values = array( 'id' => $form_id );
175 175
         FrmFieldsHelper::fill_field( $values, $copy_field, $form_id );
176 176
 
177
-		$field_count = FrmDb::get_count( $wpdb->prefix .'frm_fields fi LEFT JOIN '. $wpdb->prefix .'frm_forms fr ON (fi.form_id = fr.id)', array( 'or' => 1, 'fr.id' => $form_id, 'fr.parent_form_id' => $form_id ) );
177
+		$field_count = FrmDb::get_count( $wpdb->prefix . 'frm_fields fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id)', array( 'or' => 1, 'fr.id' => $form_id, 'fr.parent_form_id' => $form_id ) );
178 178
 
179 179
         $values['field_order'] = $field_count + 1;
180 180
 
181
-        if ( ! $field_id = FrmField::create($values) ) {
181
+        if ( ! $field_id = FrmField::create( $values ) ) {
182 182
             wp_die();
183 183
         }
184 184
 
185
-        self::include_single_field($field_id, $values);
185
+        self::include_single_field( $field_id, $values );
186 186
 
187 187
         wp_die();
188 188
     }
@@ -191,21 +191,21 @@  discard block
 block discarded – undo
191 191
      * Load a single field in the form builder along with all needed variables
192 192
      */
193 193
     public static function include_single_field( $field_id, $values, $form_id = 0 ) {
194
-        $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
195
-        $field_name = 'item_meta['. $field_id .']';
196
-        $html_id = FrmFieldsHelper::get_html_id($field);
194
+        $field = FrmFieldsHelper::setup_edit_vars( FrmField::getOne( $field_id ) );
195
+        $field_name = 'item_meta[' . $field_id . ']';
196
+        $html_id = FrmFieldsHelper::get_html_id( $field );
197 197
         $id = $form_id ? $form_id : $field['form_id'];
198 198
         if ( $field['type'] == 'html' ) {
199 199
             $field['stop_filter'] = true;
200 200
         }
201 201
 
202
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/add_field.php');
202
+        require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php' );
203 203
 
204 204
         return $field;
205 205
     }
206 206
 
207 207
     public static function destroy() {
208
-		FrmAppHelper::permission_check('frm_edit_forms');
208
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
209 209
         check_ajax_referer( 'frm_ajax', 'nonce' );
210 210
 
211 211
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
@@ -217,14 +217,14 @@  discard block
 block discarded – undo
217 217
 
218 218
     //Add Single Option or Other Option
219 219
     public static function add_option() {
220
-		FrmAppHelper::permission_check('frm_edit_forms');
220
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
221 221
         check_ajax_referer( 'frm_ajax', 'nonce' );
222 222
 
223 223
 		$id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
224 224
 		$opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' );
225 225
 
226 226
         //Get the field
227
-        $field = FrmField::getOne($id);
227
+        $field = FrmField::getOne( $id );
228 228
 
229 229
 		if ( ! empty( $field->options ) ) {
230 230
 			$keys = array_keys( $field->options );
@@ -247,13 +247,13 @@  discard block
 block discarded – undo
247 247
 			$first_opt = reset( $field->options );
248 248
 			$next_opt = count( $field->options );
249 249
             if ( $first_opt != '' ) {
250
-                $next_opt++;
250
+                $next_opt ++;
251 251
             }
252
-            $opt = esc_html__( 'Option', 'formidable' ) .' '. $next_opt;
253
-            unset($next_opt);
252
+            $opt = esc_html__( 'Option', 'formidable' ) . ' ' . $next_opt;
253
+            unset( $next_opt );
254 254
         }
255 255
         $field_val = $opt;
256
-		$field->options[ $opt_key ] = $opt;
256
+		$field->options[$opt_key] = $opt;
257 257
 
258 258
         //Update options in DB
259 259
 		FrmField::update( $id, array( 'options' => $field->options ) );
@@ -262,25 +262,25 @@  discard block
 block discarded – undo
262 262
         $field = array(
263 263
             'type'  => $field_data->type,
264 264
             'id'    => $id,
265
-            'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0,
265
+            'separate_value' => isset( $field_data->field_options['separate_value'] ) ? $field_data->field_options['separate_value'] : 0,
266 266
             'form_id' => $field_data->form_id,
267 267
             'field_key' => $field_data->field_key,
268 268
         );
269 269
 
270
-        $field_name = 'item_meta['. $id .']';
271
-        $html_id = FrmFieldsHelper::get_html_id($field);
270
+        $field_name = 'item_meta[' . $id . ']';
271
+        $html_id = FrmFieldsHelper::get_html_id( $field );
272 272
         $checked = '';
273 273
 
274 274
         if ( 'other' == $opt_type ) {
275
-            require(FrmAppHelper::plugin_path() .'/pro/classes/views/frmpro-fields/other-option.php');
275
+            require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' );
276 276
         } else {
277
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/single-option.php');
277
+            require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' );
278 278
         }
279 279
         wp_die();
280 280
     }
281 281
 
282 282
     public static function edit_option() {
283
-		FrmAppHelper::permission_check('frm_edit_forms');
283
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
284 284
         check_ajax_referer( 'frm_ajax', 'nonce' );
285 285
 
286 286
 		$element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
@@ -294,28 +294,28 @@  discard block
 block discarded – undo
294 294
             $new_label = $update_value;
295 295
         }
296 296
 
297
-        $field = FrmField::getOne($id);
297
+        $field = FrmField::getOne( $id );
298 298
         $separate_values = FrmField::is_option_true( $field, 'separate_value' );
299 299
 
300
-        $this_opt_id = end($ids);
301
-		$this_opt = (array) $field->options[ $this_opt_id ];
302
-		$other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false );
300
+        $this_opt_id = end( $ids );
301
+		$this_opt = (array) $field->options[$this_opt_id];
302
+		$other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other' ) !== false );
303 303
 
304
-        $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt);
305
-        $value = isset($this_opt['value']) ? $this_opt['value'] : '';
304
+        $label = isset( $this_opt['label'] ) ? $this_opt['label'] : reset( $this_opt );
305
+        $value = isset( $this_opt['value'] ) ? $this_opt['value'] : '';
306 306
 
307 307
         if ( ! isset( $new_label ) ) {
308 308
             $new_label = $label;
309 309
         }
310 310
 
311
-        if ( isset($new_value) || isset($value) ) {
312
-            $update_value = isset($new_value) ? $new_value : $value;
311
+        if ( isset( $new_value ) || isset( $value ) ) {
312
+            $update_value = isset( $new_value ) ? $new_value : $value;
313 313
         }
314 314
 
315 315
 		if ( $update_value != $new_label && $other_opt === false && $separate_values ) {
316
-			$field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label );
316
+			$field->options[$this_opt_id] = array( 'value' => $update_value, 'label' => $new_label );
317 317
         } else {
318
-			$field->options[ $this_opt_id ] = $orig_update_value;
318
+			$field->options[$this_opt_id] = $orig_update_value;
319 319
         }
320 320
 
321 321
 		FrmField::update( $field->id, array( 'options' => $field->options ) );
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
     }
325 325
 
326 326
     public static function delete_option() {
327
-		FrmAppHelper::permission_check('frm_edit_forms');
327
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
328 328
         check_ajax_referer( 'frm_ajax', 'nonce' );
329 329
 
330 330
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 		$opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' );
334 334
 
335 335
 		$options = $field->options;
336
-        unset( $options[ $opt_key ] );
336
+        unset( $options[$opt_key] );
337 337
         $response = array( 'other' => true );
338 338
 
339 339
         //If the deleted option is an "other" option
@@ -399,46 +399,46 @@  discard block
 block discarded – undo
399 399
 
400 400
         $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
401 401
         $prepop = array();
402
-        FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
402
+        FrmFieldsHelper::get_bulk_prefilled_opts( $prepop );
403 403
 
404
-        $field = FrmField::getOne($field_id);
404
+        $field = FrmField::getOne( $field_id );
405 405
 
406 406
         wp_enqueue_script( 'utils' );
407
-        wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url(). '/css/frm_admin.css' );
407
+        wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' );
408 408
         FrmAppHelper::load_admin_wide_js();
409 409
 
410
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/import_choices.php');
410
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/import_choices.php' );
411 411
         wp_die();
412 412
     }
413 413
 
414 414
     public static function import_options() {
415
-		FrmAppHelper::permission_check('frm_edit_forms');
415
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
416 416
         check_ajax_referer( 'frm_ajax', 'nonce' );
417 417
 
418
-        if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
418
+        if ( ! is_admin() || ! current_user_can( 'frm_edit_forms' ) ) {
419 419
             return;
420 420
         }
421 421
 
422 422
 		$field_id = absint( $_POST['field_id'] );
423
-        $field = FrmField::getOne($field_id);
423
+        $field = FrmField::getOne( $field_id );
424 424
 
425 425
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) {
426 426
             return;
427 427
         }
428 428
 
429
-        $field = FrmFieldsHelper::setup_edit_vars($field);
430
-        $opts = stripslashes_deep($_POST['opts']);
431
-        $opts = explode("\n", rtrim($opts, "\n"));
429
+        $field = FrmFieldsHelper::setup_edit_vars( $field );
430
+        $opts = stripslashes_deep( $_POST['opts'] );
431
+        $opts = explode( "\n", rtrim( $opts, "\n" ) );
432 432
         if ( $field['separate_value'] ) {
433 433
             foreach ( $opts as $opt_key => $opt ) {
434
-                if ( strpos($opt, '|') !== false ) {
435
-                    $vals = explode('|', $opt);
434
+                if ( strpos( $opt, '|' ) !== false ) {
435
+                    $vals = explode( '|', $opt );
436 436
                     if ( $vals[0] != $vals[1] ) {
437
-                        $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
437
+                        $opts[$opt_key] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
438 438
                     }
439
-                    unset($vals);
439
+                    unset( $vals );
440 440
                 }
441
-                unset($opt_key, $opt);
441
+                unset( $opt_key, $opt );
442 442
             }
443 443
         }
444 444
 
@@ -447,12 +447,12 @@  discard block
 block discarded – undo
447 447
             $other_array = array();
448 448
             foreach ( $field['options'] as $opt_key => $opt ) {
449 449
                 if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) {
450
-                    $other_array[ $opt_key ] = $opt;
450
+                    $other_array[$opt_key] = $opt;
451 451
                 }
452
-                unset($opt_key, $opt);
452
+                unset( $opt_key, $opt );
453 453
             }
454
-            if ( ! empty($other_array) ) {
455
-                $opts = array_merge( $opts, $other_array);
454
+            if ( ! empty( $other_array ) ) {
455
+                $opts = array_merge( $opts, $other_array );
456 456
             }
457 457
         }
458 458
 
@@ -465,16 +465,16 @@  discard block
 block discarded – undo
465 465
         $html_id = FrmFieldsHelper::get_html_id( $field );
466 466
 
467 467
         if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
468
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/radio.php');
468
+            require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' );
469 469
         } else {
470
-            FrmFieldsHelper::show_single_option($field);
470
+            FrmFieldsHelper::show_single_option( $field );
471 471
         }
472 472
 
473 473
         wp_die();
474 474
     }
475 475
 
476 476
     public static function update_order() {
477
-		FrmAppHelper::permission_check('frm_edit_forms');
477
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
478 478
         check_ajax_referer( 'frm_ajax', 'nonce' );
479 479
 
480 480
 		$fields = FrmAppHelper::get_post_param( 'frm_field_id' );
@@ -491,13 +491,13 @@  discard block
 block discarded – undo
491 491
             'rte'       => 'textarea',
492 492
             'website'   => 'url',
493 493
         );
494
-        if ( isset( $type_switch[ $type ] ) ) {
495
-            $type = $type_switch[ $type ];
494
+        if ( isset( $type_switch[$type] ) ) {
495
+            $type = $type_switch[$type];
496 496
         }
497 497
 
498 498
 		$frm_field_selection = FrmField::field_selection();
499
-        $types = array_keys($frm_field_selection);
500
-        if ( ! in_array($type, $types) && $type != 'captcha' ) {
499
+        $types = array_keys( $frm_field_selection );
500
+        if ( ! in_array( $type, $types ) && $type != 'captcha' ) {
501 501
             $type = 'text';
502 502
         }
503 503
 
@@ -536,19 +536,19 @@  discard block
 block discarded – undo
536 536
 
537 537
     public static function input_html( $field, $echo = true ) {
538 538
         $class = array(); //$field['type'];
539
-        self::add_input_classes($field, $class);
539
+        self::add_input_classes( $field, $class );
540 540
 
541 541
         $add_html = array();
542
-        self::add_html_size($field, $add_html);
543
-        self::add_html_length($field, $add_html);
544
-        self::add_html_placeholder($field, $add_html, $class);
542
+        self::add_html_size( $field, $add_html );
543
+        self::add_html_length( $field, $add_html );
544
+        self::add_html_placeholder( $field, $add_html, $class );
545 545
 		self::add_validation_messages( $field, $add_html );
546 546
 
547
-        $class = apply_filters('frm_field_classes', implode(' ', $class), $field);
547
+        $class = apply_filters( 'frm_field_classes', implode( ' ', $class ), $field );
548 548
 
549 549
 		FrmFormsHelper::add_html_attr( $class, 'class', $add_html );
550 550
 
551
-        self::add_shortcodes_to_html($field, $add_html);
551
+        self::add_shortcodes_to_html( $field, $add_html );
552 552
 
553 553
 		$add_html = apply_filters( 'frm_field_extra_html', $add_html, $field );
554 554
 		$add_html = ' ' . implode( ' ', $add_html ) . '  ';
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
     }
562 562
 
563 563
 	private static function add_input_classes( $field, array &$class ) {
564
-        if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
564
+        if ( isset( $field['input_class'] ) && ! empty( $field['input_class'] ) ) {
565 565
             $class[] = $field['input_class'];
566 566
         }
567 567
 
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
             $class[] = 'dyn_default_value';
575 575
         }
576 576
 
577
-        if ( isset($field['size']) && $field['size'] > 0 ) {
577
+        if ( isset( $field['size'] ) && $field['size'] > 0 ) {
578 578
             $class[] = 'auto_width';
579 579
         }
580 580
     }
@@ -584,19 +584,19 @@  discard block
 block discarded – undo
584 584
             return;
585 585
         }
586 586
 
587
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
587
+        if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
588 588
             return;
589 589
         }
590 590
 
591
-        if ( is_numeric($field['size']) ) {
591
+        if ( is_numeric( $field['size'] ) ) {
592 592
             $field['size'] .= 'px';
593 593
         }
594 594
 
595
-        $important = apply_filters('frm_use_important_width', 1, $field);
595
+        $important = apply_filters( 'frm_use_important_width', 1, $field );
596 596
         // Note: This inline styling must stay since we cannot realistically set a class for every possible field size
597
-        $add_html['style'] = 'style="width:'. esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) .'"';
597
+        $add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"';
598 598
 
599
-        self::add_html_cols($field, $add_html);
599
+        self::add_html_cols( $field, $add_html );
600 600
     }
601 601
 
602 602
 	private static function add_html_cols( $field, array &$add_html ) {
@@ -613,13 +613,13 @@  discard block
 block discarded – undo
613 613
         );
614 614
 
615 615
         // include "col" for valid html
616
-        $unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
616
+        $unit = trim( preg_replace( '/[0-9]+/', '', $field['size'] ) );
617 617
 
618
-        if ( ! isset( $calc[ $unit ] ) ) {
618
+        if ( ! isset( $calc[$unit] ) ) {
619 619
             return;
620 620
         }
621 621
 
622
-        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
622
+        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[$unit];
623 623
 
624 624
 		$add_html['cols'] = 'cols="' . absint( $size ) . '"';
625 625
     }
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
             return;
631 631
         }
632 632
 
633
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
633
+        if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
634 634
             // don't load on form builder page
635 635
             return;
636 636
         }
@@ -661,11 +661,11 @@  discard block
 block discarded – undo
661 661
 
662 662
 		if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) {
663 663
             // use HMTL5 placeholder with js fallback
664
-            $add_html['placeholder'] = 'placeholder="'. esc_attr($field['default_value']) .'"';
665
-            wp_enqueue_script('jquery-placeholder');
664
+            $add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"';
665
+            wp_enqueue_script( 'jquery-placeholder' );
666 666
         } else if ( ! $frm_settings->use_html ) {
667 667
 			$val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( '&#039;', "'", esc_attr( $field['default_value'] ) ) ) );
668
-            $add_html['data-frmval'] = 'data-frmval="'. esc_attr($val) .'"';
668
+            $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"';
669 669
             $class[] = 'frm_toggle_default';
670 670
 
671 671
             if ( $field['value'] == $field['default_value'] ) {
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
 			$format = FrmEntryValidate::phone_format( $field );
690 690
 			$format = substr( $format, 2, -2 );
691 691
 			$key = 'pattern';
692
-			$add_html[ $key ] = $key . '="' . esc_attr( $format ) . '"';
692
+			$add_html[$key] = $key . '="' . esc_attr( $format ) . '"';
693 693
 		}
694 694
 	}
695 695
 
@@ -703,15 +703,15 @@  discard block
 block discarded – undo
703 703
                 continue;
704 704
             }
705 705
 
706
-            if ( is_numeric($k) && strpos($v, '=') ) {
706
+            if ( is_numeric( $k ) && strpos( $v, '=' ) ) {
707 707
                 $add_html[] = $v;
708
-            } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
709
-                $add_html[ $k ] = str_replace( $k .'="', $k .'="'. $v, $add_html[ $k ] );
708
+            } else if ( ! empty( $k ) && isset( $add_html[$k] ) ) {
709
+                $add_html[$k] = str_replace( $k . '="', $k . '="' . $v, $add_html[$k] );
710 710
             } else {
711
-				$add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
711
+				$add_html[$k] = $k . '="' . esc_attr( $v ) . '"';
712 712
             }
713 713
 
714
-            unset($k, $v);
714
+            unset( $k, $v );
715 715
         }
716 716
     }
717 717
 
@@ -727,8 +727,8 @@  discard block
 block discarded – undo
727 727
     }
728 728
 
729 729
 	public static function check_label( $opt ) {
730
-        if ( is_array($opt) ) {
731
-            $opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
730
+        if ( is_array( $opt ) ) {
731
+            $opt = ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
732 732
         }
733 733
 
734 734
         return $opt;
Please login to merge, or discard this patch.