Completed
Push — master ( 065334...ead3be )
by Jamie
03:33
created
classes/models/FrmEntryMeta.php 3 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -61,6 +61,9 @@  discard block
 block discarded – undo
61 61
         return $wpdb->update( $wpdb->prefix .'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values );
62 62
     }
63 63
 
64
+	/**
65
+	 * @param integer $entry_id
66
+	 */
64 67
 	public static function update_entry_metas( $entry_id, $values ) {
65 68
         global $wpdb;
66 69
 
@@ -286,6 +289,7 @@  discard block
 block discarded – undo
286 289
      * @param string|array $where
287 290
      * @param string $order_by
288 291
      * @param string $limit
292
+     * @param boolean $unique
289 293
      */
290 294
 	private static function get_ids_query( $where, $order_by, $limit, $unique, $args, array &$query ) {
291 295
         global $wpdb;
Please login to merge, or discard this patch.
Indentation   +203 added lines, -203 removed lines patch added patch discarded remove patch
@@ -5,27 +5,27 @@  discard block
 block discarded – undo
5 5
 
6 6
 class FrmEntryMeta {
7 7
 
8
-    /**
9
-     * @param string $meta_key
10
-     */
8
+	/**
9
+	 * @param string $meta_key
10
+	 */
11 11
 	public static function add_entry_meta( $entry_id, $field_id, $meta_key = null, $meta_value ) {
12
-        global $wpdb;
12
+		global $wpdb;
13 13
 
14
-        if ( FrmAppHelper::is_empty_value( $meta_value ) ) {
15
-            // don't save blank fields
16
-            return;
17
-        }
14
+		if ( FrmAppHelper::is_empty_value( $meta_value ) ) {
15
+			// don't save blank fields
16
+			return;
17
+		}
18 18
 
19
-        $new_values = array(
19
+		$new_values = array(
20 20
 			'meta_value'    => is_array( $meta_value ) ? serialize( array_filter( $meta_value, 'FrmAppHelper::is_not_empty_value' ) ) : trim( $meta_value ),
21
-            'item_id'       => $entry_id,
22
-            'field_id'      => $field_id,
23
-            'created_at'    => current_time('mysql', 1),
24
-        );
21
+			'item_id'       => $entry_id,
22
+			'field_id'      => $field_id,
23
+			'created_at'    => current_time('mysql', 1),
24
+		);
25 25
 
26
-        $new_values = apply_filters('frm_add_entry_meta', $new_values);
26
+		$new_values = apply_filters('frm_add_entry_meta', $new_values);
27 27
 
28
-        $query_results = $wpdb->insert( $wpdb->prefix .'frm_item_metas', $new_values );
28
+		$query_results = $wpdb->insert( $wpdb->prefix .'frm_item_metas', $new_values );
29 29
 
30 30
 		if ( $query_results ) {
31 31
 			self::clear_cache();
@@ -34,40 +34,40 @@  discard block
 block discarded – undo
34 34
 			$id = 0;
35 35
 		}
36 36
 
37
-        return $id;
38
-    }
37
+		return $id;
38
+	}
39 39
 
40
-    /**
41
-     * @param string $meta_key
42
-     */
40
+	/**
41
+	 * @param string $meta_key
42
+	 */
43 43
 	public static function update_entry_meta( $entry_id, $field_id, $meta_key = null, $meta_value ) {
44
-        if ( ! $field_id ) {
45
-            return false;
46
-        }
44
+		if ( ! $field_id ) {
45
+			return false;
46
+		}
47 47
 
48
-        global $wpdb;
48
+		global $wpdb;
49 49
 
50
-        $values = $where_values = array( 'item_id' => $entry_id, 'field_id' => $field_id );
51
-        $values['meta_value'] = $meta_value;
52
-        $values = apply_filters('frm_update_entry_meta', $values);
50
+		$values = $where_values = array( 'item_id' => $entry_id, 'field_id' => $field_id );
51
+		$values['meta_value'] = $meta_value;
52
+		$values = apply_filters('frm_update_entry_meta', $values);
53 53
 		if ( is_array($values['meta_value']) ) {
54 54
 			$values['meta_value'] = array_filter( $values['meta_value'], 'FrmAppHelper::is_not_empty_value' );
55 55
 		}
56
-        $meta_value = maybe_serialize($values['meta_value']);
56
+		$meta_value = maybe_serialize($values['meta_value']);
57 57
 
58
-        wp_cache_delete( $entry_id, 'frm_entry');
58
+		wp_cache_delete( $entry_id, 'frm_entry');
59 59
 		self::clear_cache();
60 60
 
61
-        return $wpdb->update( $wpdb->prefix .'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values );
62
-    }
61
+		return $wpdb->update( $wpdb->prefix .'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values );
62
+	}
63 63
 
64 64
 	public static function update_entry_metas( $entry_id, $values ) {
65
-        global $wpdb;
65
+		global $wpdb;
66 66
 
67 67
 		$prev_values = FrmDb::get_col( $wpdb->prefix .'frm_item_metas', array( 'item_id' => $entry_id, 'field_id !' => 0 ), 'field_id' );
68 68
 
69
-        foreach ( $values as $field_id => $meta_value ) {
70
-            // set the value for the file upload field and add new tags (in Pro version)
69
+		foreach ( $values as $field_id => $meta_value ) {
70
+			// set the value for the file upload field and add new tags (in Pro version)
71 71
 			$meta_value = apply_filters( 'frm_prepare_data_before_db', $meta_value, $field_id, $entry_id );
72 72
 
73 73
 			if ( $prev_values && in_array($field_id, $prev_values) ) {
@@ -85,39 +85,39 @@  discard block
 block discarded – undo
85 85
 			}
86 86
 		}
87 87
 
88
-        if ( empty($prev_values) ) {
89
-            return;
90
-        }
88
+		if ( empty($prev_values) ) {
89
+			return;
90
+		}
91 91
 
92
-        $prev_values = array_diff($prev_values, array_keys($values));
92
+		$prev_values = array_diff($prev_values, array_keys($values));
93 93
 
94
-        if ( empty($prev_values) ) {
95
-            return;
96
-        }
94
+		if ( empty($prev_values) ) {
95
+			return;
96
+		}
97 97
 
98 98
 		// prepare the query
99 99
 		$where = array( 'item_id' => $entry_id, 'field_id' => $prev_values );
100 100
 		FrmDb::get_where_clause_and_values( $where );
101 101
 
102
-        // Delete any leftovers
103
-        $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas ' . $where['where'], $where['values'] ) );
102
+		// Delete any leftovers
103
+		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas ' . $where['where'], $where['values'] ) );
104 104
 		self::clear_cache();
105
-    }
105
+	}
106 106
 
107 107
 	public static function duplicate_entry_metas( $old_id, $new_id ) {
108
-        $metas = self::get_entry_meta_info($old_id);
109
-        foreach ( $metas as $meta ) {
110
-            self::add_entry_meta($new_id, $meta->field_id, null, $meta->meta_value);
111
-            unset($meta);
112
-        }
108
+		$metas = self::get_entry_meta_info($old_id);
109
+		foreach ( $metas as $meta ) {
110
+			self::add_entry_meta($new_id, $meta->field_id, null, $meta->meta_value);
111
+			unset($meta);
112
+		}
113 113
 		self::clear_cache();
114
-    }
114
+	}
115 115
 
116 116
 	public static function delete_entry_meta( $entry_id, $field_id ) {
117
-        global $wpdb;
117
+		global $wpdb;
118 118
 		self::clear_cache();
119
-        return $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id));
120
-    }
119
+		return $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id));
120
+	}
121 121
 
122 122
 	/**
123 123
 	 * Clear entry meta caching
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	}
143 143
 
144 144
 	public static function get_entry_meta_by_field( $entry_id, $field_id ) {
145
-        global $wpdb;
145
+		global $wpdb;
146 146
 
147 147
 		if ( is_object( $entry_id ) ) {
148 148
 			$entry = $entry_id;
@@ -155,24 +155,24 @@  discard block
 block discarded – undo
155 155
 
156 156
 		if ( $cached && isset( $cached->metas ) && isset( $cached->metas[ $field_id ] ) ) {
157 157
 			$result = $cached->metas[ $field_id ];
158
-            return stripslashes_deep($result);
159
-        }
158
+			return stripslashes_deep($result);
159
+		}
160 160
 
161 161
 		$get_table = $wpdb->prefix .'frm_item_metas';
162 162
 		$query = array( 'item_id' => $entry_id );
163
-        if ( is_numeric($field_id) ) {
163
+		if ( is_numeric($field_id) ) {
164 164
 			$query['field_id'] = $field_id;
165
-        } else {
165
+		} else {
166 166
 			$get_table .= ' it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id';
167 167
 			$query['fi.field_key'] = $field_id;
168
-        }
168
+		}
169 169
 
170 170
 		$result = FrmDb::get_var( $get_table, $query, 'meta_value' );
171
-        $result = maybe_unserialize($result);
172
-        $result = stripslashes_deep($result);
171
+		$result = maybe_unserialize($result);
172
+		$result = stripslashes_deep($result);
173 173
 
174
-        return $result;
175
-    }
174
+		return $result;
175
+	}
176 176
 
177 177
 	public static function get_entry_meta( $entry_id, $field_id ) {
178 178
 		_deprecated_function( __FUNCTION__, '2.0', 'FrmEntryMeta::get_entry_meta_by_field' );
@@ -180,117 +180,117 @@  discard block
 block discarded – undo
180 180
 	}
181 181
 
182 182
 	public static function get_entry_metas( $entry_id ) {
183
-        _deprecated_function( __FUNCTION__, '1.07.10');
183
+		_deprecated_function( __FUNCTION__, '1.07.10');
184 184
 
185
-        global $wpdb;
185
+		global $wpdb;
186 186
 		return FrmDb::get_col( $wpdb->prefix . 'frm_item_metas', array( 'item_id' => $entry_id ), 'meta_value' );
187
-    }
187
+	}
188 188
 
189
-    public static function get_entry_metas_for_field( $field_id, $order = '', $limit = '', $args = array() ) {
189
+	public static function get_entry_metas_for_field( $field_id, $order = '', $limit = '', $args = array() ) {
190 190
 		$defaults = array( 'value' => false, 'unique' => false, 'stripslashes' => true, 'is_draft' => false );
191
-        $args = wp_parse_args( $args, $defaults );
191
+		$args = wp_parse_args( $args, $defaults );
192 192
 
193
-        $query = array();
194
-        self::meta_field_query($field_id, $order, $limit, $args, $query);
195
-        $query = implode(' ', $query);
193
+		$query = array();
194
+		self::meta_field_query($field_id, $order, $limit, $args, $query);
195
+		$query = implode(' ', $query);
196 196
 
197
-        $cache_key = 'entry_metas_for_field_'. $field_id . $order . $limit . maybe_serialize($args);
198
-        $values = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, 'get_col');
197
+		$cache_key = 'entry_metas_for_field_'. $field_id . $order . $limit . maybe_serialize($args);
198
+		$values = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, 'get_col');
199 199
 
200
-        if ( ! $args['stripslashes'] ) {
201
-            return $values;
202
-        }
200
+		if ( ! $args['stripslashes'] ) {
201
+			return $values;
202
+		}
203 203
 
204 204
 		foreach ( $values as $k => $v ) {
205 205
 			$values[ $k ] = maybe_unserialize( $v );
206
-            unset($k, $v);
207
-        }
206
+			unset($k, $v);
207
+		}
208 208
 
209
-        return stripslashes_deep($values);
210
-    }
209
+		return stripslashes_deep($values);
210
+	}
211 211
 
212
-    /**
213
-     * @param string $order
214
-     * @param string $limit
215
-     */
212
+	/**
213
+	 * @param string $order
214
+	 * @param string $limit
215
+	 */
216 216
 	private static function meta_field_query( $field_id, $order, $limit, $args, array &$query ) {
217
-        global $wpdb;
218
-        $query[] = 'SELECT';
219
-        $query[] = $args['unique'] ? 'DISTINCT(em.meta_value)' : 'em.meta_value';
220
-        $query[] = 'FROM '. $wpdb->prefix .'frm_item_metas em ';
221
-
222
-        if ( ! $args['is_draft'] ) {
223
-            $query[] = 'INNER JOIN '. $wpdb->prefix .'frm_items e ON (e.id=em.item_id)';
224
-        }
225
-
226
-        if ( is_numeric($field_id) ) {
227
-            $query[] = $wpdb->prepare('WHERE em.field_id=%d', $field_id);
228
-        } else {
229
-            $query[] = $wpdb->prepare('LEFT JOIN '. $wpdb->prefix .'frm_fields fi ON (em.field_id = fi.id) WHERE fi.field_key=%s', $field_id);
230
-        }
231
-
232
-        if ( ! $args['is_draft'] ) {
233
-            $query[] = 'AND e.is_draft=0';
234
-        }
235
-
236
-        if ( $args['value'] ) {
237
-            $query[] = $wpdb->prepare(' AND meta_value=%s', $args['value']);
238
-        }
239
-        $query[] = $order . $limit;
240
-    }
217
+		global $wpdb;
218
+		$query[] = 'SELECT';
219
+		$query[] = $args['unique'] ? 'DISTINCT(em.meta_value)' : 'em.meta_value';
220
+		$query[] = 'FROM '. $wpdb->prefix .'frm_item_metas em ';
221
+
222
+		if ( ! $args['is_draft'] ) {
223
+			$query[] = 'INNER JOIN '. $wpdb->prefix .'frm_items e ON (e.id=em.item_id)';
224
+		}
225
+
226
+		if ( is_numeric($field_id) ) {
227
+			$query[] = $wpdb->prepare('WHERE em.field_id=%d', $field_id);
228
+		} else {
229
+			$query[] = $wpdb->prepare('LEFT JOIN '. $wpdb->prefix .'frm_fields fi ON (em.field_id = fi.id) WHERE fi.field_key=%s', $field_id);
230
+		}
231
+
232
+		if ( ! $args['is_draft'] ) {
233
+			$query[] = 'AND e.is_draft=0';
234
+		}
235
+
236
+		if ( $args['value'] ) {
237
+			$query[] = $wpdb->prepare(' AND meta_value=%s', $args['value']);
238
+		}
239
+		$query[] = $order . $limit;
240
+	}
241 241
 
242 242
 	public static function get_entry_meta_info( $entry_id ) {
243 243
 		return FrmDb::get_results( 'frm_item_metas', array( 'item_id' => $entry_id ) );
244
-    }
244
+	}
245 245
 
246 246
 	public static function getAll( $where = array(), $order_by = '', $limit = '', $stripslashes = false ) {
247
-        global $wpdb;
248
-        $query = 'SELECT it.*, fi.type as field_type, fi.field_key as field_key,
247
+		global $wpdb;
248
+		$query = 'SELECT it.*, fi.type as field_type, fi.field_key as field_key,
249 249
             fi.required as required, fi.form_id as field_form_id, fi.name as field_name, fi.options as fi_options
250 250
             FROM '. $wpdb->prefix .'frm_item_metas it LEFT OUTER JOIN '. $wpdb->prefix .'frm_fields fi ON it.field_id=fi.id' .
251
-            FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
251
+			FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
252 252
 
253
-        $cache_key = 'all_'. maybe_serialize($where) . $order_by . $limit;
254
-        $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_row' : 'get_results'));
253
+		$cache_key = 'all_'. maybe_serialize($where) . $order_by . $limit;
254
+		$results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_row' : 'get_results'));
255 255
 
256
-        if ( ! $results || ! $stripslashes ) {
257
-            return $results;
258
-        }
256
+		if ( ! $results || ! $stripslashes ) {
257
+			return $results;
258
+		}
259 259
 
260
-        foreach ( $results as $k => $result ) {
260
+		foreach ( $results as $k => $result ) {
261 261
 			$results[ $k ]->meta_value = stripslashes_deep( maybe_unserialize( $result->meta_value ) );
262
-            unset($k, $result);
263
-        }
262
+			unset($k, $result);
263
+		}
264 264
 
265
-        return $results;
266
-    }
265
+		return $results;
266
+	}
267 267
 
268
-    public static function getEntryIds( $where = array(), $order_by = '', $limit = '', $unique = true, $args = array() ) {
268
+	public static function getEntryIds( $where = array(), $order_by = '', $limit = '', $unique = true, $args = array() ) {
269 269
 		$defaults = array(
270 270
 			'is_draft' => false,
271 271
 			'user_id'  => '',
272 272
 			'group_by' => '',
273 273
 		);
274
-        $args = wp_parse_args($args, $defaults);
274
+		$args = wp_parse_args($args, $defaults);
275 275
 
276
-        $query = array();
277
-        self::get_ids_query($where, $order_by, $limit, $unique, $args, $query );
278
-        $query = implode(' ', $query);
276
+		$query = array();
277
+		self::get_ids_query($where, $order_by, $limit, $unique, $args, $query );
278
+		$query = implode(' ', $query);
279 279
 
280
-        $cache_key = 'ids_'. maybe_serialize($where) . $order_by . 'l'. $limit . 'u'. $unique . maybe_serialize($args);
281
-        $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_var' : 'get_col'));
280
+		$cache_key = 'ids_'. maybe_serialize($where) . $order_by . 'l'. $limit . 'u'. $unique . maybe_serialize($args);
281
+		$results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_var' : 'get_col'));
282 282
 
283
-        return $results;
284
-    }
283
+		return $results;
284
+	}
285 285
 
286
-    /**
287
-     * @param string|array $where
288
-     * @param string $order_by
289
-     * @param string $limit
290
-     */
286
+	/**
287
+	 * @param string|array $where
288
+	 * @param string $order_by
289
+	 * @param string $limit
290
+	 */
291 291
 	private static function get_ids_query( $where, $order_by, $limit, $unique, $args, array &$query ) {
292
-        global $wpdb;
293
-        $query[] = 'SELECT';
292
+		global $wpdb;
293
+		$query[] = 'SELECT';
294 294
 
295 295
 		$defaults = array( 'return_parent_id' => false );
296 296
 		$args = array_merge( $defaults, $args );
@@ -301,91 +301,91 @@  discard block
 block discarded – undo
301 301
 			$query[] = $unique ? 'DISTINCT(it.item_id)' : 'it.item_id';
302 302
 		}
303 303
 
304
-        $query[] = 'FROM '. $wpdb->prefix .'frm_item_metas it LEFT OUTER JOIN '. $wpdb->prefix .'frm_fields fi ON it.field_id=fi.id';
304
+		$query[] = 'FROM '. $wpdb->prefix .'frm_item_metas it LEFT OUTER JOIN '. $wpdb->prefix .'frm_fields fi ON it.field_id=fi.id';
305 305
 
306
-        $query[] = 'INNER JOIN '. $wpdb->prefix .'frm_items e ON (e.id=it.item_id)';
307
-        if ( is_array($where) ) {
308
-            if ( ! $args['is_draft'] ) {
309
-                $where['e.is_draft'] = 0;
310
-            } else if ( $args['is_draft'] == 1 ) {
311
-                $where['e.is_draft'] = 1;
312
-            }
306
+		$query[] = 'INNER JOIN '. $wpdb->prefix .'frm_items e ON (e.id=it.item_id)';
307
+		if ( is_array($where) ) {
308
+			if ( ! $args['is_draft'] ) {
309
+				$where['e.is_draft'] = 0;
310
+			} else if ( $args['is_draft'] == 1 ) {
311
+				$where['e.is_draft'] = 1;
312
+			}
313 313
 
314
-            if ( ! empty($args['user_id']) ) {
315
-                $where['e.user_id'] = $args['user_id'];
316
-            }
317
-            $query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
314
+			if ( ! empty($args['user_id']) ) {
315
+				$where['e.user_id'] = $args['user_id'];
316
+			}
317
+			$query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
318 318
 
319 319
 			if ( $args['group_by'] ) {
320 320
 				$query[] = ' GROUP BY '. sanitize_text_field( $args['group_by'] );
321 321
 			}
322
-            return;
323
-        }
322
+			return;
323
+		}
324 324
 
325 325
 		$draft_where = $user_where = '';
326
-        if ( ! $args['is_draft'] ) {
326
+		if ( ! $args['is_draft'] ) {
327 327
 			$draft_where = $wpdb->prepare( ' AND e.is_draft=%d', 0 );
328
-        } else if ( $args['is_draft'] == 1 ) {
328
+		} else if ( $args['is_draft'] == 1 ) {
329 329
 			$draft_where = $wpdb->prepare( ' AND e.is_draft=%d', 1 );
330
-        }
331
-
332
-        if ( ! empty($args['user_id']) ) {
333
-            $user_where = $wpdb->prepare(' AND e.user_id=%d', $args['user_id']);
334
-        }
335
-
336
-        if ( strpos($where, ' GROUP BY ') ) {
337
-            // don't inject WHERE filtering after GROUP BY
338
-            $parts = explode(' GROUP BY ', $where);
339
-            $where = $parts[0];
340
-            $where .= $draft_where . $user_where;
341
-            $where .= ' GROUP BY '. $parts[1];
342
-        } else {
343
-            $where .= $draft_where . $user_where;
344
-        }
330
+		}
331
+
332
+		if ( ! empty($args['user_id']) ) {
333
+			$user_where = $wpdb->prepare(' AND e.user_id=%d', $args['user_id']);
334
+		}
335
+
336
+		if ( strpos($where, ' GROUP BY ') ) {
337
+			// don't inject WHERE filtering after GROUP BY
338
+			$parts = explode(' GROUP BY ', $where);
339
+			$where = $parts[0];
340
+			$where .= $draft_where . $user_where;
341
+			$where .= ' GROUP BY '. $parts[1];
342
+		} else {
343
+			$where .= $draft_where . $user_where;
344
+		}
345 345
 
346 346
 		// The query has already been prepared
347 347
 		$query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
348
-    }
348
+	}
349 349
 
350
-    public static function search_entry_metas( $search, $field_id = '', $operator ) {
351
-        $cache_key = 'search_'. maybe_serialize($search) . $field_id . $operator;
352
-        $results = wp_cache_get($cache_key, 'frm_entry');
353
-        if ( false !== $results ) {
354
-            return $results;
355
-        }
350
+	public static function search_entry_metas( $search, $field_id = '', $operator ) {
351
+		$cache_key = 'search_'. maybe_serialize($search) . $field_id . $operator;
352
+		$results = wp_cache_get($cache_key, 'frm_entry');
353
+		if ( false !== $results ) {
354
+			return $results;
355
+		}
356 356
 
357
-        global $wpdb;
357
+		global $wpdb;
358 358
 		if ( is_array( $search ) ) {
359
-            $where = '';
359
+			$where = '';
360 360
 			foreach ( $search as $field => $value ) {
361 361
 				if ( $value <= 0 || ! in_array( $field, array( 'year', 'month', 'day' ) ) ) {
362
-                    continue;
363
-                }
364
-
365
-                switch ( $field ) {
366
-                    case 'year':
367
-                        $value = '%'. $value;
368
-                    break;
369
-                    case 'month':
370
-                        $value .= '%';
371
-                    break;
372
-                    case 'day':
373
-                        $value = '%'. $value .'%';
374
-                }
375
-                $where .= $wpdb->prepare(' meta_value '. $operator .' %s and', $value);
376
-            }
377
-            $where .= $wpdb->prepare(' field_id=%d', $field_id);
378
-            $query = "SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas". FrmAppHelper::prepend_and_or_where(' WHERE ', $where);
379
-        } else {
362
+					continue;
363
+				}
364
+
365
+				switch ( $field ) {
366
+					case 'year':
367
+						$value = '%'. $value;
368
+					break;
369
+					case 'month':
370
+						$value .= '%';
371
+					break;
372
+					case 'day':
373
+						$value = '%'. $value .'%';
374
+				}
375
+				$where .= $wpdb->prepare(' meta_value '. $operator .' %s and', $value);
376
+			}
377
+			$where .= $wpdb->prepare(' field_id=%d', $field_id);
378
+			$query = "SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas". FrmAppHelper::prepend_and_or_where(' WHERE ', $where);
379
+		} else {
380 380
 			if ( $operator == 'LIKE' ) {
381
-                $search = '%' . $search . '%';
381
+				$search = '%' . $search . '%';
382 382
 			}
383
-            $query = $wpdb->prepare("SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id);
384
-        }
383
+			$query = $wpdb->prepare("SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id);
384
+		}
385 385
 
386
-        $results = $wpdb->get_col($query, 0);
387
-        wp_cache_set($cache_key, $results, 'frm_entry', 300);
386
+		$results = $wpdb->get_col($query, 0);
387
+		wp_cache_set($cache_key, $results, 'frm_entry', 300);
388 388
 
389
-        return $results;
390
-    }
389
+		return $results;
390
+	}
391 391
 }
Please login to merge, or discard this patch.
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -20,12 +20,12 @@  discard block
 block discarded – undo
20 20
 			'meta_value'    => is_array( $meta_value ) ? serialize( array_filter( $meta_value, 'FrmAppHelper::is_not_empty_value' ) ) : trim( $meta_value ),
21 21
             'item_id'       => $entry_id,
22 22
             'field_id'      => $field_id,
23
-            'created_at'    => current_time('mysql', 1),
23
+            'created_at'    => current_time( 'mysql', 1 ),
24 24
         );
25 25
 
26
-        $new_values = apply_filters('frm_add_entry_meta', $new_values);
26
+        $new_values = apply_filters( 'frm_add_entry_meta', $new_values );
27 27
 
28
-        $query_results = $wpdb->insert( $wpdb->prefix .'frm_item_metas', $new_values );
28
+        $query_results = $wpdb->insert( $wpdb->prefix . 'frm_item_metas', $new_values );
29 29
 
30 30
 		if ( $query_results ) {
31 31
 			self::clear_cache();
@@ -49,32 +49,32 @@  discard block
 block discarded – undo
49 49
 
50 50
         $values = $where_values = array( 'item_id' => $entry_id, 'field_id' => $field_id );
51 51
         $values['meta_value'] = $meta_value;
52
-        $values = apply_filters('frm_update_entry_meta', $values);
53
-		if ( is_array($values['meta_value']) ) {
52
+        $values = apply_filters( 'frm_update_entry_meta', $values );
53
+		if ( is_array( $values['meta_value'] ) ) {
54 54
 			$values['meta_value'] = array_filter( $values['meta_value'], 'FrmAppHelper::is_not_empty_value' );
55 55
 		}
56
-        $meta_value = maybe_serialize($values['meta_value']);
56
+        $meta_value = maybe_serialize( $values['meta_value'] );
57 57
 
58
-        wp_cache_delete( $entry_id, 'frm_entry');
58
+        wp_cache_delete( $entry_id, 'frm_entry' );
59 59
 		self::clear_cache();
60 60
 
61
-        return $wpdb->update( $wpdb->prefix .'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values );
61
+        return $wpdb->update( $wpdb->prefix . 'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values );
62 62
     }
63 63
 
64 64
 	public static function update_entry_metas( $entry_id, $values ) {
65 65
         global $wpdb;
66 66
 
67
-		$prev_values = FrmDb::get_col( $wpdb->prefix .'frm_item_metas', array( 'item_id' => $entry_id, 'field_id !' => 0 ), 'field_id' );
67
+		$prev_values = FrmDb::get_col( $wpdb->prefix . 'frm_item_metas', array( 'item_id' => $entry_id, 'field_id !' => 0 ), 'field_id' );
68 68
 
69 69
         foreach ( $values as $field_id => $meta_value ) {
70 70
             // set the value for the file upload field and add new tags (in Pro version)
71 71
 			$meta_value = apply_filters( 'frm_prepare_data_before_db', $meta_value, $field_id, $entry_id );
72 72
 
73
-			if ( $prev_values && in_array($field_id, $prev_values) ) {
73
+			if ( $prev_values && in_array( $field_id, $prev_values ) ) {
74 74
 
75 75
 				if ( ( is_array( $meta_value ) && empty( $meta_value ) ) || ( ! is_array( $meta_value ) && trim( $meta_value ) == '' ) ) {
76 76
 					// remove blank fields
77
-					unset( $values[ $field_id ] );
77
+					unset( $values[$field_id] );
78 78
 				} else {
79 79
 					// if value exists, then update it
80 80
 					self::update_entry_meta( $entry_id, $field_id, '', $meta_value );
@@ -85,13 +85,13 @@  discard block
 block discarded – undo
85 85
 			}
86 86
 		}
87 87
 
88
-        if ( empty($prev_values) ) {
88
+        if ( empty( $prev_values ) ) {
89 89
             return;
90 90
         }
91 91
 
92
-        $prev_values = array_diff($prev_values, array_keys($values));
92
+        $prev_values = array_diff( $prev_values, array_keys( $values ) );
93 93
 
94
-        if ( empty($prev_values) ) {
94
+        if ( empty( $prev_values ) ) {
95 95
             return;
96 96
         }
97 97
 
@@ -105,10 +105,10 @@  discard block
 block discarded – undo
105 105
     }
106 106
 
107 107
 	public static function duplicate_entry_metas( $old_id, $new_id ) {
108
-        $metas = self::get_entry_meta_info($old_id);
108
+        $metas = self::get_entry_meta_info( $old_id );
109 109
         foreach ( $metas as $meta ) {
110
-            self::add_entry_meta($new_id, $meta->field_id, null, $meta->meta_value);
111
-            unset($meta);
110
+            self::add_entry_meta( $new_id, $meta->field_id, null, $meta->meta_value );
111
+            unset( $meta );
112 112
         }
113 113
 		self::clear_cache();
114 114
     }
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	public static function delete_entry_meta( $entry_id, $field_id ) {
117 117
         global $wpdb;
118 118
 		self::clear_cache();
119
-        return $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id));
119
+        return $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id ) );
120 120
     }
121 121
 
122 122
 	/**
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	 */
136 136
 	public static function get_meta_value( $entry, $field_id ) {
137 137
 		if ( isset( $entry->metas ) ) {
138
-			return isset( $entry->metas[ $field_id ] ) ? $entry->metas[ $field_id ] : false;
138
+			return isset( $entry->metas[$field_id] ) ? $entry->metas[$field_id] : false;
139 139
 		} else {
140 140
 			return self::get_entry_meta_by_field( $entry->id, $field_id );
141 141
 		}
@@ -153,14 +153,14 @@  discard block
 block discarded – undo
153 153
 			$cached = FrmAppHelper::check_cache( $entry_id, 'frm_entry' );
154 154
 		}
155 155
 
156
-		if ( $cached && isset( $cached->metas ) && isset( $cached->metas[ $field_id ] ) ) {
157
-			$result = $cached->metas[ $field_id ];
158
-            return stripslashes_deep($result);
156
+		if ( $cached && isset( $cached->metas ) && isset( $cached->metas[$field_id] ) ) {
157
+			$result = $cached->metas[$field_id];
158
+            return stripslashes_deep( $result );
159 159
         }
160 160
 
161
-		$get_table = $wpdb->prefix .'frm_item_metas';
161
+		$get_table = $wpdb->prefix . 'frm_item_metas';
162 162
 		$query = array( 'item_id' => $entry_id );
163
-        if ( is_numeric($field_id) ) {
163
+        if ( is_numeric( $field_id ) ) {
164 164
 			$query['field_id'] = $field_id;
165 165
         } else {
166 166
 			$get_table .= ' it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id';
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
         }
169 169
 
170 170
 		$result = FrmDb::get_var( $get_table, $query, 'meta_value' );
171
-        $result = maybe_unserialize($result);
172
-        $result = stripslashes_deep($result);
171
+        $result = maybe_unserialize( $result );
172
+        $result = stripslashes_deep( $result );
173 173
 
174 174
         return $result;
175 175
     }
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 	}
181 181
 
182 182
 	public static function get_entry_metas( $entry_id ) {
183
-        _deprecated_function( __FUNCTION__, '1.07.10');
183
+        _deprecated_function( __FUNCTION__, '1.07.10' );
184 184
 
185 185
         global $wpdb;
186 186
 		return FrmDb::get_col( $wpdb->prefix . 'frm_item_metas', array( 'item_id' => $entry_id ), 'meta_value' );
@@ -191,22 +191,22 @@  discard block
 block discarded – undo
191 191
         $args = wp_parse_args( $args, $defaults );
192 192
 
193 193
         $query = array();
194
-        self::meta_field_query($field_id, $order, $limit, $args, $query);
195
-        $query = implode(' ', $query);
194
+        self::meta_field_query( $field_id, $order, $limit, $args, $query );
195
+        $query = implode( ' ', $query );
196 196
 
197
-        $cache_key = 'entry_metas_for_field_'. $field_id . $order . $limit . maybe_serialize($args);
198
-        $values = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, 'get_col');
197
+        $cache_key = 'entry_metas_for_field_' . $field_id . $order . $limit . maybe_serialize( $args );
198
+        $values = FrmAppHelper::check_cache( $cache_key, 'frm_entry', $query, 'get_col' );
199 199
 
200 200
         if ( ! $args['stripslashes'] ) {
201 201
             return $values;
202 202
         }
203 203
 
204 204
 		foreach ( $values as $k => $v ) {
205
-			$values[ $k ] = maybe_unserialize( $v );
206
-            unset($k, $v);
205
+			$values[$k] = maybe_unserialize( $v );
206
+            unset( $k, $v );
207 207
         }
208 208
 
209
-        return stripslashes_deep($values);
209
+        return stripslashes_deep( $values );
210 210
     }
211 211
 
212 212
     /**
@@ -217,16 +217,16 @@  discard block
 block discarded – undo
217 217
         global $wpdb;
218 218
         $query[] = 'SELECT';
219 219
         $query[] = $args['unique'] ? 'DISTINCT(em.meta_value)' : 'em.meta_value';
220
-        $query[] = 'FROM '. $wpdb->prefix .'frm_item_metas em ';
220
+        $query[] = 'FROM ' . $wpdb->prefix . 'frm_item_metas em ';
221 221
 
222 222
         if ( ! $args['is_draft'] ) {
223
-            $query[] = 'INNER JOIN '. $wpdb->prefix .'frm_items e ON (e.id=em.item_id)';
223
+            $query[] = 'INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=em.item_id)';
224 224
         }
225 225
 
226
-        if ( is_numeric($field_id) ) {
227
-            $query[] = $wpdb->prepare('WHERE em.field_id=%d', $field_id);
226
+        if ( is_numeric( $field_id ) ) {
227
+            $query[] = $wpdb->prepare( 'WHERE em.field_id=%d', $field_id );
228 228
         } else {
229
-            $query[] = $wpdb->prepare('LEFT JOIN '. $wpdb->prefix .'frm_fields fi ON (em.field_id = fi.id) WHERE fi.field_key=%s', $field_id);
229
+            $query[] = $wpdb->prepare( 'LEFT JOIN ' . $wpdb->prefix . 'frm_fields fi ON (em.field_id = fi.id) WHERE fi.field_key=%s', $field_id );
230 230
         }
231 231
 
232 232
         if ( ! $args['is_draft'] ) {
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
         }
235 235
 
236 236
         if ( $args['value'] ) {
237
-            $query[] = $wpdb->prepare(' AND meta_value=%s', $args['value']);
237
+            $query[] = $wpdb->prepare( ' AND meta_value=%s', $args['value'] );
238 238
         }
239 239
         $query[] = $order . $limit;
240 240
     }
@@ -247,19 +247,19 @@  discard block
 block discarded – undo
247 247
         global $wpdb;
248 248
         $query = 'SELECT it.*, fi.type as field_type, fi.field_key as field_key,
249 249
             fi.required as required, fi.form_id as field_form_id, fi.name as field_name, fi.options as fi_options
250
-            FROM '. $wpdb->prefix .'frm_item_metas it LEFT OUTER JOIN '. $wpdb->prefix .'frm_fields fi ON it.field_id=fi.id' .
251
-            FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
250
+            FROM '. $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id' .
251
+            FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
252 252
 
253
-        $cache_key = 'all_'. maybe_serialize($where) . $order_by . $limit;
254
-        $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_row' : 'get_results'));
253
+        $cache_key = 'all_' . maybe_serialize( $where ) . $order_by . $limit;
254
+        $results = FrmAppHelper::check_cache( $cache_key, 'frm_entry', $query, ( $limit == ' LIMIT 1' ? 'get_row' : 'get_results' ) );
255 255
 
256 256
         if ( ! $results || ! $stripslashes ) {
257 257
             return $results;
258 258
         }
259 259
 
260 260
         foreach ( $results as $k => $result ) {
261
-			$results[ $k ]->meta_value = stripslashes_deep( maybe_unserialize( $result->meta_value ) );
262
-            unset($k, $result);
261
+			$results[$k]->meta_value = stripslashes_deep( maybe_unserialize( $result->meta_value ) );
262
+            unset( $k, $result );
263 263
         }
264 264
 
265 265
         return $results;
@@ -271,14 +271,14 @@  discard block
 block discarded – undo
271 271
 			'user_id'  => '',
272 272
 			'group_by' => '',
273 273
 		);
274
-        $args = wp_parse_args($args, $defaults);
274
+        $args = wp_parse_args( $args, $defaults );
275 275
 
276 276
         $query = array();
277
-        self::get_ids_query($where, $order_by, $limit, $unique, $args, $query );
278
-        $query = implode(' ', $query);
277
+        self::get_ids_query( $where, $order_by, $limit, $unique, $args, $query );
278
+        $query = implode( ' ', $query );
279 279
 
280
-        $cache_key = 'ids_'. maybe_serialize($where) . $order_by . 'l'. $limit . 'u'. $unique . maybe_serialize($args);
281
-        $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_var' : 'get_col'));
280
+        $cache_key = 'ids_' . maybe_serialize( $where ) . $order_by . 'l' . $limit . 'u' . $unique . maybe_serialize( $args );
281
+        $results = FrmAppHelper::check_cache( $cache_key, 'frm_entry', $query, ( $limit == ' LIMIT 1' ? 'get_var' : 'get_col' ) );
282 282
 
283 283
         return $results;
284 284
     }
@@ -301,23 +301,23 @@  discard block
 block discarded – undo
301 301
 			$query[] = $unique ? 'DISTINCT(it.item_id)' : 'it.item_id';
302 302
 		}
303 303
 
304
-        $query[] = 'FROM '. $wpdb->prefix .'frm_item_metas it LEFT OUTER JOIN '. $wpdb->prefix .'frm_fields fi ON it.field_id=fi.id';
304
+        $query[] = 'FROM ' . $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id';
305 305
 
306
-        $query[] = 'INNER JOIN '. $wpdb->prefix .'frm_items e ON (e.id=it.item_id)';
307
-        if ( is_array($where) ) {
306
+        $query[] = 'INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=it.item_id)';
307
+        if ( is_array( $where ) ) {
308 308
             if ( ! $args['is_draft'] ) {
309 309
                 $where['e.is_draft'] = 0;
310 310
             } else if ( $args['is_draft'] == 1 ) {
311 311
                 $where['e.is_draft'] = 1;
312 312
             }
313 313
 
314
-            if ( ! empty($args['user_id']) ) {
314
+            if ( ! empty( $args['user_id'] ) ) {
315 315
                 $where['e.user_id'] = $args['user_id'];
316 316
             }
317
-            $query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
317
+            $query[] = FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
318 318
 
319 319
 			if ( $args['group_by'] ) {
320
-				$query[] = ' GROUP BY '. sanitize_text_field( $args['group_by'] );
320
+				$query[] = ' GROUP BY ' . sanitize_text_field( $args['group_by'] );
321 321
 			}
322 322
             return;
323 323
         }
@@ -329,27 +329,27 @@  discard block
 block discarded – undo
329 329
 			$draft_where = $wpdb->prepare( ' AND e.is_draft=%d', 1 );
330 330
         }
331 331
 
332
-        if ( ! empty($args['user_id']) ) {
333
-            $user_where = $wpdb->prepare(' AND e.user_id=%d', $args['user_id']);
332
+        if ( ! empty( $args['user_id'] ) ) {
333
+            $user_where = $wpdb->prepare( ' AND e.user_id=%d', $args['user_id'] );
334 334
         }
335 335
 
336
-        if ( strpos($where, ' GROUP BY ') ) {
336
+        if ( strpos( $where, ' GROUP BY ' ) ) {
337 337
             // don't inject WHERE filtering after GROUP BY
338
-            $parts = explode(' GROUP BY ', $where);
338
+            $parts = explode( ' GROUP BY ', $where );
339 339
             $where = $parts[0];
340 340
             $where .= $draft_where . $user_where;
341
-            $where .= ' GROUP BY '. $parts[1];
341
+            $where .= ' GROUP BY ' . $parts[1];
342 342
         } else {
343 343
             $where .= $draft_where . $user_where;
344 344
         }
345 345
 
346 346
 		// The query has already been prepared
347
-		$query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
347
+		$query[] = FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
348 348
     }
349 349
 
350 350
     public static function search_entry_metas( $search, $field_id = '', $operator ) {
351
-        $cache_key = 'search_'. maybe_serialize($search) . $field_id . $operator;
352
-        $results = wp_cache_get($cache_key, 'frm_entry');
351
+        $cache_key = 'search_' . maybe_serialize( $search ) . $field_id . $operator;
352
+        $results = wp_cache_get( $cache_key, 'frm_entry' );
353 353
         if ( false !== $results ) {
354 354
             return $results;
355 355
         }
@@ -364,27 +364,27 @@  discard block
 block discarded – undo
364 364
 
365 365
                 switch ( $field ) {
366 366
                     case 'year':
367
-                        $value = '%'. $value;
367
+                        $value = '%' . $value;
368 368
                     break;
369 369
                     case 'month':
370 370
                         $value .= '%';
371 371
                     break;
372 372
                     case 'day':
373
-                        $value = '%'. $value .'%';
373
+                        $value = '%' . $value . '%';
374 374
                 }
375
-                $where .= $wpdb->prepare(' meta_value '. $operator .' %s and', $value);
375
+                $where .= $wpdb->prepare( ' meta_value ' . $operator . ' %s and', $value );
376 376
             }
377
-            $where .= $wpdb->prepare(' field_id=%d', $field_id);
378
-            $query = "SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas". FrmAppHelper::prepend_and_or_where(' WHERE ', $where);
377
+            $where .= $wpdb->prepare( ' field_id=%d', $field_id );
378
+            $query = "SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas" . FrmAppHelper::prepend_and_or_where( ' WHERE ', $where );
379 379
         } else {
380 380
 			if ( $operator == 'LIKE' ) {
381 381
                 $search = '%' . $search . '%';
382 382
 			}
383
-            $query = $wpdb->prepare("SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id);
383
+            $query = $wpdb->prepare( "SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id );
384 384
         }
385 385
 
386
-        $results = $wpdb->get_col($query, 0);
387
-        wp_cache_set($cache_key, $results, 'frm_entry', 300);
386
+        $results = $wpdb->get_col( $query, 0 );
387
+        wp_cache_set( $cache_key, $results, 'frm_entry', 300 );
388 388
 
389 389
         return $results;
390 390
     }
Please login to merge, or discard this patch.
classes/models/FrmStyle.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@
 block discarded – undo
4 4
 	public $id = 0; // the id of the post
5 5
 
6 6
 	/**
7
-	 * @param int|string $id The id of the stylsheet or 'default'
7
+	 * @param integer $id The id of the stylsheet or 'default'
8 8
 	 */
9 9
 	public function __construct( $id = 0 ) {
10 10
         $this->id = $id;
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class FrmStyle {
3
-    public $number = false;	// Unique ID number of the current instance.
3
+    public $number = false; // Unique ID number of the current instance.
4 4
 	public $id = 0; // the id of the post
5 5
 
6 6
 	/**
@@ -13,9 +13,9 @@  discard block
 block discarded – undo
13 13
     public function get_new() {
14 14
 		$this->id = 0;
15 15
 
16
-        $max_slug_value = pow(36, 6);
16
+        $max_slug_value = pow( 36, 6 );
17 17
         $min_slug_value = 37; // we want to have at least 2 characters in the slug
18
-        $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
18
+        $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
19 19
 
20 20
         $style = array(
21 21
             'post_type'     => FrmStylesController::$post_type,
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     public function update( $id = 'default' ) {
42 42
  		$all_instances = $this->get_all();
43 43
 
44
- 		if ( empty($id) ) {
44
+ 		if ( empty( $id ) ) {
45 45
  		     $new_style = (array) $this->get_new();
46 46
  		     $all_instances[] = $new_style;
47 47
  		}
@@ -49,15 +49,15 @@  discard block
 block discarded – undo
49 49
         $action_ids = array();
50 50
 
51 51
  		foreach ( $all_instances as $number => $new_instance ) {
52
- 			$new_instance = stripslashes_deep( (array) $new_instance);
52
+ 			$new_instance = stripslashes_deep( (array) $new_instance );
53 53
  			$this->id = $new_instance['ID'];
54
- 			if ( $id != $this->id || ! $_POST || ! isset($_POST['frm_style_setting']) ) {
55
-				$all_instances[ $number ] = $new_instance;
54
+ 			if ( $id != $this->id || ! $_POST || ! isset( $_POST['frm_style_setting'] ) ) {
55
+				$all_instances[$number] = $new_instance;
56 56
 
57
- 			    if ( $new_instance['menu_order'] && $_POST && empty($_POST['prev_menu_order']) && isset($_POST['frm_style_setting']['menu_order']) ) {
57
+ 			    if ( $new_instance['menu_order'] && $_POST && empty( $_POST['prev_menu_order'] ) && isset( $_POST['frm_style_setting']['menu_order'] ) ) {
58 58
  			        // this style was set to default, so remove default setting on previous default style
59 59
  			        $new_instance['menu_order'] = 0;
60
- 			        $action_ids[] = $this->save($new_instance);
60
+ 			        $action_ids[] = $this->save( $new_instance );
61 61
  			    }
62 62
 
63 63
  			    // don't continue if not saving this style
@@ -67,10 +67,10 @@  discard block
 block discarded – undo
67 67
  			$new_instance['post_title'] = sanitize_text_field( $_POST['frm_style_setting']['post_title'] );
68 68
  			$new_instance['post_content'] = $_POST['frm_style_setting']['post_content'];
69 69
  			$new_instance['post_type']  = FrmStylesController::$post_type;
70
-            $new_instance['post_status']  = 'publish';
70
+            $new_instance['post_status'] = 'publish';
71 71
 			$new_instance['menu_order']  = isset( $_POST['frm_style_setting']['menu_order'] ) ? absint( $_POST['frm_style_setting']['menu_order'] ) : 0;
72 72
 
73
-            if ( empty($id) ) {
73
+            if ( empty( $id ) ) {
74 74
                 $new_instance['post_name'] = $new_instance['post_title'];
75 75
             }
76 76
 
@@ -79,19 +79,19 @@  discard block
 block discarded – undo
79 79
             foreach ( $default_settings as $setting => $default ) {
80 80
 				if ( strpos( $setting, 'color' ) !== false || in_array( $setting, array( 'error_bg', 'error_border', 'error_text' ) ) ) {
81 81
                     //if is a color
82
-					$new_instance['post_content'][ $setting ] = str_replace( '#', '', $new_instance['post_content'][ $setting ] );
83
-				} else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][ $setting ] ) ) {
84
-					$new_instance['post_content'][ $setting ] = 0;
82
+					$new_instance['post_content'][$setting] = str_replace( '#', '', $new_instance['post_content'][$setting] );
83
+				} else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][$setting] ) ) {
84
+					$new_instance['post_content'][$setting] = 0;
85 85
                 }
86 86
             }
87 87
 
88
-			$all_instances[ $number ] = $new_instance;
88
+			$all_instances[$number] = $new_instance;
89 89
 
90
-            $action_ids[] = $this->save($new_instance);
90
+            $action_ids[] = $this->save( $new_instance );
91 91
 
92 92
  		}
93 93
 
94
- 		$this->save_settings($all_instances);
94
+ 		$this->save_settings( $all_instances );
95 95
 
96 96
  		return $action_ids;
97 97
  	}
@@ -100,30 +100,30 @@  discard block
 block discarded – undo
100 100
      * Create static css file
101 101
      */
102 102
 	public function save_settings( $styles ) {
103
-        $filename = FrmAppHelper::plugin_path() .'/css/custom_theme.css.php';
103
+        $filename = FrmAppHelper::plugin_path() . '/css/custom_theme.css.php';
104 104
 
105
-        if ( ! is_file($filename) ) {
105
+        if ( ! is_file( $filename ) ) {
106 106
             return;
107 107
         }
108 108
 
109 109
         $defaults = $this->get_defaults();
110 110
         $uploads = wp_upload_dir();
111
-        $target_path = $uploads['basedir'] .'/formidable';
112
-        $needed_dirs = array( $target_path, $target_path .'/css' );
111
+        $target_path = $uploads['basedir'] . '/formidable';
112
+        $needed_dirs = array( $target_path, $target_path . '/css' );
113 113
         $dirs_exist = true;
114 114
 
115 115
         $saving = true;
116
-        $css = '/* '. __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) .' */'. "\n";
116
+        $css = '/* ' . __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) . ' */' . "\n";
117 117
 
118 118
         ob_start();
119 119
         $frm_style = $this;
120
-        include($filename);
120
+        include( $filename );
121 121
 		$css .= preg_replace( '/\/\*(.|\s)*?\*\//', '', str_replace( array( "\r\n", "\r", "\n", "\t", '    ' ), '', ob_get_contents() ) );
122 122
         ob_end_clean();
123 123
 
124 124
         $access_type = get_filesystem_method();
125 125
         if ( $access_type === 'direct' ) {
126
-        	$creds = request_filesystem_credentials( site_url() .'/wp-admin/', '', false, false, array() );
126
+        	$creds = request_filesystem_credentials( site_url() . '/wp-admin/', '', false, false, array() );
127 127
 		} else {
128 128
 			$creds = $this->get_ftp_creds( $access_type );
129 129
 		}
@@ -138,8 +138,8 @@  discard block
 block discarded – undo
138 138
             if ( $dirs_exist ) {
139 139
 	        	global $wp_filesystem;
140 140
 
141
-            	$chmod_dir = defined('FS_CHMOD_DIR') ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 );
142
-            	$chmod_file = defined('FS_CHMOD_FILE') ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 );
141
+            	$chmod_dir = defined( 'FS_CHMOD_DIR' ) ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 );
142
+            	$chmod_file = defined( 'FS_CHMOD_FILE' ) ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 );
143 143
 
144 144
                 // Create the directories if need be:
145 145
             	foreach ( $needed_dirs as $_dir ) {
@@ -149,33 +149,33 @@  discard block
 block discarded – undo
149 149
                     }
150 150
             	}
151 151
 
152
-                $index_path = $target_path .'/index.php';
152
+                $index_path = $target_path . '/index.php';
153 153
                 $wp_filesystem->put_contents( $index_path, "<?php\n// Silence is golden.\n?>", $chmod_file );
154 154
 
155 155
                 // only write the file if the folders exist
156 156
                 if ( $dirs_exist ) {
157
-                    $css_file = $target_path .'/css/formidablepro.css';
157
+                    $css_file = $target_path . '/css/formidablepro.css';
158 158
                     $wp_filesystem->put_contents( $css_file, $css, $chmod_file );
159 159
                 }
160 160
             }
161 161
         }
162 162
 
163
-        update_option('frmpro_css', $css);
163
+        update_option( 'frmpro_css', $css );
164 164
 
165
-        delete_transient('frmpro_css');
166
-        set_transient('frmpro_css', $css);
165
+        delete_transient( 'frmpro_css' );
166
+        set_transient( 'frmpro_css', $css );
167 167
 	}
168 168
 
169 169
 	private function get_ftp_creds( $type ) {
170 170
 		$credentials = get_option( 'ftp_credentials', array( 'hostname' => '', 'username' => '' ) );
171 171
 
172
-		$credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : $credentials['hostname'];
173
-		$credentials['username'] = defined('FTP_USER') ? FTP_USER : $credentials['username'];
174
-		$credentials['password'] = defined('FTP_PASS') ? FTP_PASS : '';
172
+		$credentials['hostname'] = defined( 'FTP_HOST' ) ? FTP_HOST : $credentials['hostname'];
173
+		$credentials['username'] = defined( 'FTP_USER' ) ? FTP_USER : $credentials['username'];
174
+		$credentials['password'] = defined( 'FTP_PASS' ) ? FTP_PASS : '';
175 175
 
176 176
 		// Check to see if we are setting the public/private keys for ssh
177
-		$credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : '';
178
-		$credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : '';
177
+		$credentials['public_key'] = defined( 'FTP_PUBKEY' ) ? FTP_PUBKEY : '';
178
+		$credentials['private_key'] = defined( 'FTP_PRIKEY' ) ? FTP_PRIKEY : '';
179 179
 
180 180
 		// Sanitize the hostname, Some people might pass in odd-data:
181 181
 		$credentials['hostname'] = preg_replace( '|\w+://|', '', $credentials['hostname'] ); //Strip any schemes off
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 	}
218 218
 
219 219
 	public function destroy( $id ) {
220
-        return wp_delete_post($id);
220
+        return wp_delete_post( $id );
221 221
     }
222 222
 
223 223
     public function get_one() {
@@ -231,19 +231,19 @@  discard block
 block discarded – undo
231 231
             return $style;
232 232
         }
233 233
 
234
-        $style = get_post($this->id);
234
+        $style = get_post( $this->id );
235 235
 
236 236
         if ( ! $style ) {
237 237
             return $style;
238 238
         }
239 239
 
240
-        $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
240
+        $style->post_content = FrmAppHelper::maybe_json_decode( $style->post_content );
241 241
 
242 242
         $default_values = $this->get_defaults();
243 243
 
244 244
         // fill default values
245
-        $style->post_content = $this->override_defaults($style->post_content);
246
-        $style->post_content = wp_parse_args( $style->post_content, $default_values);
245
+        $style->post_content = $this->override_defaults( $style->post_content );
246
+        $style->post_content = wp_parse_args( $style->post_content, $default_values );
247 247
 
248 248
         return $style;
249 249
     }
@@ -257,21 +257,21 @@  discard block
 block discarded – undo
257 257
 			'order'       => $order,
258 258
         );
259 259
 
260
-        $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts');
260
+        $temp_styles = FrmAppHelper::check_cache( serialize( $post_atts ), 'frm_styles', $post_atts, 'get_posts' );
261 261
 
262
-        if ( empty($temp_styles) ) {
262
+        if ( empty( $temp_styles ) ) {
263 263
             global $wpdb;
264 264
             // make sure there wasn't a conflict with the query
265
-            $query = $wpdb->prepare('SELECT * FROM '. $wpdb->posts .' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish');
266
-            $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results');
265
+            $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->posts . ' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish' );
266
+            $temp_styles = FrmAppHelper::check_cache( 'frm_backup_style_check', 'frm_styles', $query, 'get_results' );
267 267
 
268
-            if ( empty($temp_styles) ) {
268
+            if ( empty( $temp_styles ) ) {
269 269
                 // create a new style if there are none
270 270
          		$new = $this->get_new();
271 271
          		$new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' );
272 272
          		$new->menu_order = 1;
273
-         		$new = $this->save( (array) $new);
274
-         		$this->update('default');
273
+         		$new = $this->save( (array) $new );
274
+         		$this->update( 'default' );
275 275
 
276 276
                 $post_atts['include'] = $new;
277 277
 
@@ -295,25 +295,25 @@  discard block
 block discarded – undo
295 295
                 }
296 296
             }
297 297
 
298
-            $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
298
+            $style->post_content = FrmAppHelper::maybe_json_decode( $style->post_content );
299 299
 
300 300
             // fill default values
301
-            $style->post_content = $this->override_defaults($style->post_content);
302
-            $style->post_content = wp_parse_args( $style->post_content, $default_values);
301
+            $style->post_content = $this->override_defaults( $style->post_content );
302
+            $style->post_content = wp_parse_args( $style->post_content, $default_values );
303 303
 
304
-			$styles[ $style->ID ] = $style;
304
+			$styles[$style->ID] = $style;
305 305
         }
306 306
 
307 307
         if ( ! $default_style ) {
308
-            $default_style = reset($styles);
309
-			$styles[ $default_style->ID ]->menu_order = 1;
308
+            $default_style = reset( $styles );
309
+			$styles[$default_style->ID]->menu_order = 1;
310 310
         }
311 311
 
312 312
         return $styles;
313 313
     }
314 314
 
315 315
 	public function get_default_style( $styles = null ) {
316
-        if ( ! isset($styles) ) {
316
+        if ( ! isset( $styles ) ) {
317 317
 			$styles = $this->get_all( 'menu_order', 'DESC', 1 );
318 318
         }
319 319
 
@@ -325,24 +325,24 @@  discard block
 block discarded – undo
325 325
     }
326 326
 
327 327
 	public function override_defaults( $settings ) {
328
-	    if ( ! is_array($settings) ) {
328
+	    if ( ! is_array( $settings ) ) {
329 329
 	        return $settings;
330 330
 	    }
331 331
 
332
-	    $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height'];
332
+	    $settings['line_height'] = ( ! isset( $settings['field_height'] ) || $settings['field_height'] == '' || $settings['field_height'] == 'auto' ) ? 'normal' : $settings['field_height'];
333 333
 
334
-	    if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) {
334
+	    if ( ! isset( $settings['form_desc_size'] ) && isset( $settings['description_font_size'] ) ) {
335 335
 	        $settings['form_desc_size'] = $settings['description_font_size'];
336 336
 	        $settings['form_desc_color'] = $settings['description_color'];
337 337
 	        $settings['title_color'] = $settings['label_color'];
338 338
 	    }
339 339
 
340
-	    if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) {
340
+	    if ( ! isset( $settings['section_color'] ) && isset( $settings['label_color'] ) ) {
341 341
 	        $settings['section_color'] = $settings['label_color'];
342 342
 	        $settings['section_border_color'] = $settings['border_color'];
343 343
 	    }
344 344
 
345
-	    if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) {
345
+	    if ( ! isset( $settings['submit_hover_bg_color'] ) && isset( $settings['submit_bg_color'] ) ) {
346 346
 	        $settings['submit_hover_bg_color'] = $settings['submit_bg_color'];
347 347
 	        $settings['submit_hover_color'] = $settings['submit_text_color'];
348 348
 	        $settings['submit_hover_border_color'] = $settings['submit_border_color'];
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
     }
478 478
 
479 479
 	public function get_field_name( $field_name, $post_field = 'post_content' ) {
480
-		return 'frm_style_setting'. ( empty($post_field) ? '' : '['. $post_field .']' ) .'[' . $field_name . ']';
480
+		return 'frm_style_setting' . ( empty( $post_field ) ? '' : '[' . $post_field . ']' ) . '[' . $field_name . ']';
481 481
 	}
482 482
 
483 483
 	public static function get_bold_options() {
Please login to merge, or discard this patch.
Indentation   +315 added lines, -315 removed lines patch added patch discarded remove patch
@@ -1,52 +1,52 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class FrmStyle {
3
-    public $number = false;	// Unique ID number of the current instance.
3
+	public $number = false;	// Unique ID number of the current instance.
4 4
 	public $id = 0; // the id of the post
5 5
 
6 6
 	/**
7 7
 	 * @param int|string $id The id of the stylsheet or 'default'
8 8
 	 */
9 9
 	public function __construct( $id = 0 ) {
10
-        $this->id = $id;
11
-    }
10
+		$this->id = $id;
11
+	}
12 12
 
13
-    public function get_new() {
13
+	public function get_new() {
14 14
 		$this->id = 0;
15 15
 
16
-        $max_slug_value = pow(36, 6);
17
-        $min_slug_value = 37; // we want to have at least 2 characters in the slug
18
-        $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
19
-
20
-        $style = array(
21
-            'post_type'     => FrmStylesController::$post_type,
22
-            'ID'            => '',
23
-            'post_title'    => __( 'New Style', 'formidable' ),
24
-            'post_name'     => $key,
25
-            'post_content'  => $this->get_defaults(),
26
-            'menu_order'    => '',
27
-            'post_status'   => 'publish',
28
-        );
16
+		$max_slug_value = pow(36, 6);
17
+		$min_slug_value = 37; // we want to have at least 2 characters in the slug
18
+		$key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
19
+
20
+		$style = array(
21
+			'post_type'     => FrmStylesController::$post_type,
22
+			'ID'            => '',
23
+			'post_title'    => __( 'New Style', 'formidable' ),
24
+			'post_name'     => $key,
25
+			'post_content'  => $this->get_defaults(),
26
+			'menu_order'    => '',
27
+			'post_status'   => 'publish',
28
+		);
29 29
 
30
-        return (object) $style;
31
-    }
30
+		return (object) $style;
31
+	}
32 32
 
33 33
 	public function save( $settings ) {
34 34
 		return FrmAppHelper::save_settings( $settings, 'frm_styles' );
35
-    }
35
+	}
36 36
 
37 37
 	public function duplicate( $id ) {
38
-        // duplicating is a pro feature
39
-    }
38
+		// duplicating is a pro feature
39
+	}
40 40
 
41
-    public function update( $id = 'default' ) {
41
+	public function update( $id = 'default' ) {
42 42
  		$all_instances = $this->get_all();
43 43
 
44 44
  		if ( empty($id) ) {
45
- 		     $new_style = (array) $this->get_new();
46
- 		     $all_instances[] = $new_style;
45
+ 			 $new_style = (array) $this->get_new();
46
+ 			 $all_instances[] = $new_style;
47 47
  		}
48 48
 
49
-        $action_ids = array();
49
+		$action_ids = array();
50 50
 
51 51
  		foreach ( $all_instances as $number => $new_instance ) {
52 52
  			$new_instance = stripslashes_deep( (array) $new_instance);
@@ -54,40 +54,40 @@  discard block
 block discarded – undo
54 54
  			if ( $id != $this->id || ! $_POST || ! isset($_POST['frm_style_setting']) ) {
55 55
 				$all_instances[ $number ] = $new_instance;
56 56
 
57
- 			    if ( $new_instance['menu_order'] && $_POST && empty($_POST['prev_menu_order']) && isset($_POST['frm_style_setting']['menu_order']) ) {
58
- 			        // this style was set to default, so remove default setting on previous default style
59
- 			        $new_instance['menu_order'] = 0;
60
- 			        $action_ids[] = $this->save($new_instance);
61
- 			    }
57
+ 				if ( $new_instance['menu_order'] && $_POST && empty($_POST['prev_menu_order']) && isset($_POST['frm_style_setting']['menu_order']) ) {
58
+ 					// this style was set to default, so remove default setting on previous default style
59
+ 					$new_instance['menu_order'] = 0;
60
+ 					$action_ids[] = $this->save($new_instance);
61
+ 				}
62 62
 
63
- 			    // don't continue if not saving this style
64
- 			    continue;
63
+ 				// don't continue if not saving this style
64
+ 				continue;
65 65
  			}
66 66
 
67 67
  			$new_instance['post_title'] = sanitize_text_field( $_POST['frm_style_setting']['post_title'] );
68 68
  			$new_instance['post_content'] = $_POST['frm_style_setting']['post_content'];
69 69
  			$new_instance['post_type']  = FrmStylesController::$post_type;
70
-            $new_instance['post_status']  = 'publish';
70
+			$new_instance['post_status']  = 'publish';
71 71
 			$new_instance['menu_order']  = isset( $_POST['frm_style_setting']['menu_order'] ) ? absint( $_POST['frm_style_setting']['menu_order'] ) : 0;
72 72
 
73
-            if ( empty($id) ) {
74
-                $new_instance['post_name'] = $new_instance['post_title'];
75
-            }
73
+			if ( empty($id) ) {
74
+				$new_instance['post_name'] = $new_instance['post_title'];
75
+			}
76 76
 
77
-            $default_settings = $this->get_defaults();
77
+			$default_settings = $this->get_defaults();
78 78
 
79
-            foreach ( $default_settings as $setting => $default ) {
79
+			foreach ( $default_settings as $setting => $default ) {
80 80
 				if ( strpos( $setting, 'color' ) !== false || in_array( $setting, array( 'error_bg', 'error_border', 'error_text' ) ) ) {
81
-                    //if is a color
81
+					//if is a color
82 82
 					$new_instance['post_content'][ $setting ] = str_replace( '#', '', $new_instance['post_content'][ $setting ] );
83 83
 				} else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][ $setting ] ) ) {
84 84
 					$new_instance['post_content'][ $setting ] = 0;
85
-                }
86
-            }
85
+				}
86
+			}
87 87
 
88 88
 			$all_instances[ $number ] = $new_instance;
89 89
 
90
-            $action_ids[] = $this->save($new_instance);
90
+			$action_ids[] = $this->save($new_instance);
91 91
 
92 92
  		}
93 93
 
@@ -96,74 +96,74 @@  discard block
 block discarded – undo
96 96
  		return $action_ids;
97 97
  	}
98 98
 
99
-    /**
100
-     * Create static css file
101
-     */
99
+	/**
100
+	 * Create static css file
101
+	 */
102 102
 	public function save_settings( $styles ) {
103
-        $filename = FrmAppHelper::plugin_path() .'/css/custom_theme.css.php';
103
+		$filename = FrmAppHelper::plugin_path() .'/css/custom_theme.css.php';
104 104
 
105
-        if ( ! is_file($filename) ) {
106
-            return;
107
-        }
105
+		if ( ! is_file($filename) ) {
106
+			return;
107
+		}
108 108
 
109
-        $defaults = $this->get_defaults();
110
-        $uploads = wp_upload_dir();
111
-        $target_path = $uploads['basedir'] .'/formidable';
112
-        $needed_dirs = array( $target_path, $target_path .'/css' );
113
-        $dirs_exist = true;
109
+		$defaults = $this->get_defaults();
110
+		$uploads = wp_upload_dir();
111
+		$target_path = $uploads['basedir'] .'/formidable';
112
+		$needed_dirs = array( $target_path, $target_path .'/css' );
113
+		$dirs_exist = true;
114 114
 
115
-        $saving = true;
116
-        $css = '/* '. __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) .' */'. "\n";
115
+		$saving = true;
116
+		$css = '/* '. __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) .' */'. "\n";
117 117
 
118
-        ob_start();
119
-        $frm_style = $this;
120
-        include($filename);
118
+		ob_start();
119
+		$frm_style = $this;
120
+		include($filename);
121 121
 		$css .= preg_replace( '/\/\*(.|\s)*?\*\//', '', str_replace( array( "\r\n", "\r", "\n", "\t", '    ' ), '', ob_get_contents() ) );
122
-        ob_end_clean();
122
+		ob_end_clean();
123 123
 
124
-        $access_type = get_filesystem_method();
125
-        if ( $access_type === 'direct' ) {
126
-        	$creds = request_filesystem_credentials( site_url() .'/wp-admin/', '', false, false, array() );
124
+		$access_type = get_filesystem_method();
125
+		if ( $access_type === 'direct' ) {
126
+			$creds = request_filesystem_credentials( site_url() .'/wp-admin/', '', false, false, array() );
127 127
 		} else {
128 128
 			$creds = $this->get_ftp_creds( $access_type );
129 129
 		}
130 130
 
131 131
 		if ( ! empty( $creds ) ) {
132
-        	// initialize the API
133
-        	if ( ! WP_Filesystem( $creds ) ) {
134
-        		// any problems and we exit
135
-        		$dirs_exist = false;
132
+			// initialize the API
133
+			if ( ! WP_Filesystem( $creds ) ) {
134
+				// any problems and we exit
135
+				$dirs_exist = false;
136 136
 			}
137 137
 
138
-            if ( $dirs_exist ) {
139
-	        	global $wp_filesystem;
138
+			if ( $dirs_exist ) {
139
+				global $wp_filesystem;
140 140
 
141
-            	$chmod_dir = defined('FS_CHMOD_DIR') ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 );
142
-            	$chmod_file = defined('FS_CHMOD_FILE') ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 );
141
+				$chmod_dir = defined('FS_CHMOD_DIR') ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 );
142
+				$chmod_file = defined('FS_CHMOD_FILE') ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 );
143 143
 
144
-                // Create the directories if need be:
145
-            	foreach ( $needed_dirs as $_dir ) {
146
-                    // Only check to see if the Dir exists upon creation failure. Less I/O this way.
147
-            		if ( ! $wp_filesystem->mkdir( $_dir, $chmod_dir ) && ! $wp_filesystem->is_dir( $_dir ) ) {
148
-            			$dirs_exist = false;
149
-                    }
150
-            	}
144
+				// Create the directories if need be:
145
+				foreach ( $needed_dirs as $_dir ) {
146
+					// Only check to see if the Dir exists upon creation failure. Less I/O this way.
147
+					if ( ! $wp_filesystem->mkdir( $_dir, $chmod_dir ) && ! $wp_filesystem->is_dir( $_dir ) ) {
148
+						$dirs_exist = false;
149
+					}
150
+				}
151 151
 
152
-                $index_path = $target_path .'/index.php';
153
-                $wp_filesystem->put_contents( $index_path, "<?php\n// Silence is golden.\n?>", $chmod_file );
152
+				$index_path = $target_path .'/index.php';
153
+				$wp_filesystem->put_contents( $index_path, "<?php\n// Silence is golden.\n?>", $chmod_file );
154 154
 
155
-                // only write the file if the folders exist
156
-                if ( $dirs_exist ) {
157
-                    $css_file = $target_path .'/css/formidablepro.css';
158
-                    $wp_filesystem->put_contents( $css_file, $css, $chmod_file );
159
-                }
160
-            }
161
-        }
155
+				// only write the file if the folders exist
156
+				if ( $dirs_exist ) {
157
+					$css_file = $target_path .'/css/formidablepro.css';
158
+					$wp_filesystem->put_contents( $css_file, $css, $chmod_file );
159
+				}
160
+			}
161
+		}
162 162
 
163
-        update_option('frmpro_css', $css);
163
+		update_option('frmpro_css', $css);
164 164
 
165
-        delete_transient('frmpro_css');
166
-        set_transient('frmpro_css', $css);
165
+		delete_transient('frmpro_css');
166
+		set_transient('frmpro_css', $css);
167 167
 	}
168 168
 
169 169
 	private function get_ftp_creds( $type ) {
@@ -217,267 +217,267 @@  discard block
 block discarded – undo
217 217
 	}
218 218
 
219 219
 	public function destroy( $id ) {
220
-        return wp_delete_post($id);
221
-    }
220
+		return wp_delete_post($id);
221
+	}
222 222
 
223
-    public function get_one() {
224
-        if ( 'default' == $this->id ) {
225
-            $style = $this->get_default_style();
226
-            if ( $style ) {
227
-                $this->id = $style->ID;
228
-            } else {
229
-                $this->id = 0;
230
-            }
231
-            return $style;
232
-        }
223
+	public function get_one() {
224
+		if ( 'default' == $this->id ) {
225
+			$style = $this->get_default_style();
226
+			if ( $style ) {
227
+				$this->id = $style->ID;
228
+			} else {
229
+				$this->id = 0;
230
+			}
231
+			return $style;
232
+		}
233 233
 
234
-        $style = get_post($this->id);
234
+		$style = get_post($this->id);
235 235
 
236
-        if ( ! $style ) {
237
-            return $style;
238
-        }
236
+		if ( ! $style ) {
237
+			return $style;
238
+		}
239 239
 
240
-        $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
240
+		$style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
241 241
 
242
-        $default_values = $this->get_defaults();
242
+		$default_values = $this->get_defaults();
243 243
 
244
-        // fill default values
245
-        $style->post_content = $this->override_defaults($style->post_content);
246
-        $style->post_content = wp_parse_args( $style->post_content, $default_values);
244
+		// fill default values
245
+		$style->post_content = $this->override_defaults($style->post_content);
246
+		$style->post_content = wp_parse_args( $style->post_content, $default_values);
247 247
 
248
-        return $style;
249
-    }
248
+		return $style;
249
+	}
250 250
 
251
-    public function get_all( $orderby = 'title', $order = 'ASC', $limit = 99 ) {
252
-        $post_atts = array(
251
+	public function get_all( $orderby = 'title', $order = 'ASC', $limit = 99 ) {
252
+		$post_atts = array(
253 253
 			'post_type'   => FrmStylesController::$post_type,
254 254
 			'post_status' => 'publish',
255 255
 			'numberposts' => $limit,
256 256
 			'orderby'     => $orderby,
257 257
 			'order'       => $order,
258
-        );
259
-
260
-        $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts');
261
-
262
-        if ( empty($temp_styles) ) {
263
-            global $wpdb;
264
-            // make sure there wasn't a conflict with the query
265
-            $query = $wpdb->prepare('SELECT * FROM '. $wpdb->posts .' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish');
266
-            $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results');
267
-
268
-            if ( empty($temp_styles) ) {
269
-                // create a new style if there are none
270
-         		$new = $this->get_new();
271
-         		$new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' );
272
-         		$new->menu_order = 1;
273
-         		$new = $this->save( (array) $new);
274
-         		$this->update('default');
275
-
276
-                $post_atts['include'] = $new;
277
-
278
-                $temp_styles = get_posts( $post_atts );
279
-            }
280
-        }
281
-
282
-        $default_values = $this->get_defaults();
283
-        $default_style = false;
284
-
285
-        $styles = array();
286
-        foreach ( $temp_styles as $style ) {
287
-            $this->id = $style->ID;
288
-            if ( $style->menu_order ) {
289
-                if ( $default_style ) {
290
-                    // only return one default
291
-                    $style->menu_order = 0;
292
-                } else {
293
-                    // check for a default style
294
-                    $default_style = $style->ID;
295
-                }
296
-            }
297
-
298
-            $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
299
-
300
-            // fill default values
301
-            $style->post_content = $this->override_defaults($style->post_content);
302
-            $style->post_content = wp_parse_args( $style->post_content, $default_values);
258
+		);
259
+
260
+		$temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts');
261
+
262
+		if ( empty($temp_styles) ) {
263
+			global $wpdb;
264
+			// make sure there wasn't a conflict with the query
265
+			$query = $wpdb->prepare('SELECT * FROM '. $wpdb->posts .' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish');
266
+			$temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results');
267
+
268
+			if ( empty($temp_styles) ) {
269
+				// create a new style if there are none
270
+		 		$new = $this->get_new();
271
+		 		$new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' );
272
+		 		$new->menu_order = 1;
273
+		 		$new = $this->save( (array) $new);
274
+		 		$this->update('default');
275
+
276
+				$post_atts['include'] = $new;
277
+
278
+				$temp_styles = get_posts( $post_atts );
279
+			}
280
+		}
281
+
282
+		$default_values = $this->get_defaults();
283
+		$default_style = false;
284
+
285
+		$styles = array();
286
+		foreach ( $temp_styles as $style ) {
287
+			$this->id = $style->ID;
288
+			if ( $style->menu_order ) {
289
+				if ( $default_style ) {
290
+					// only return one default
291
+					$style->menu_order = 0;
292
+				} else {
293
+					// check for a default style
294
+					$default_style = $style->ID;
295
+				}
296
+			}
297
+
298
+			$style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
299
+
300
+			// fill default values
301
+			$style->post_content = $this->override_defaults($style->post_content);
302
+			$style->post_content = wp_parse_args( $style->post_content, $default_values);
303 303
 
304 304
 			$styles[ $style->ID ] = $style;
305
-        }
305
+		}
306 306
 
307
-        if ( ! $default_style ) {
308
-            $default_style = reset($styles);
307
+		if ( ! $default_style ) {
308
+			$default_style = reset($styles);
309 309
 			$styles[ $default_style->ID ]->menu_order = 1;
310
-        }
310
+		}
311 311
 
312
-        return $styles;
313
-    }
312
+		return $styles;
313
+	}
314 314
 
315 315
 	public function get_default_style( $styles = null ) {
316
-        if ( ! isset($styles) ) {
316
+		if ( ! isset($styles) ) {
317 317
 			$styles = $this->get_all( 'menu_order', 'DESC', 1 );
318
-        }
318
+		}
319 319
 
320
-        foreach ( $styles as $style ) {
321
-            if ( $style->menu_order ) {
322
-                return $style;
323
-            }
324
-        }
325
-    }
320
+		foreach ( $styles as $style ) {
321
+			if ( $style->menu_order ) {
322
+				return $style;
323
+			}
324
+		}
325
+	}
326 326
 
327 327
 	public function override_defaults( $settings ) {
328
-	    if ( ! is_array($settings) ) {
329
-	        return $settings;
330
-	    }
331
-
332
-	    $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height'];
333
-
334
-	    if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) {
335
-	        $settings['form_desc_size'] = $settings['description_font_size'];
336
-	        $settings['form_desc_color'] = $settings['description_color'];
337
-	        $settings['title_color'] = $settings['label_color'];
338
-	    }
339
-
340
-	    if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) {
341
-	        $settings['section_color'] = $settings['label_color'];
342
-	        $settings['section_border_color'] = $settings['border_color'];
343
-	    }
344
-
345
-	    if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) {
346
-	        $settings['submit_hover_bg_color'] = $settings['submit_bg_color'];
347
-	        $settings['submit_hover_color'] = $settings['submit_text_color'];
348
-	        $settings['submit_hover_border_color'] = $settings['submit_border_color'];
349
-
350
-	        $settings['submit_active_bg_color'] = $settings['submit_bg_color'];
351
-	        $settings['submit_active_color'] = $settings['submit_text_color'];
352
-            $settings['submit_active_border_color'] = $settings['submit_border_color'];
353
-	    }
354
-
355
-	    return $settings;
328
+		if ( ! is_array($settings) ) {
329
+			return $settings;
330
+		}
331
+
332
+		$settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height'];
333
+
334
+		if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) {
335
+			$settings['form_desc_size'] = $settings['description_font_size'];
336
+			$settings['form_desc_color'] = $settings['description_color'];
337
+			$settings['title_color'] = $settings['label_color'];
338
+		}
339
+
340
+		if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) {
341
+			$settings['section_color'] = $settings['label_color'];
342
+			$settings['section_border_color'] = $settings['border_color'];
343
+		}
344
+
345
+		if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) {
346
+			$settings['submit_hover_bg_color'] = $settings['submit_bg_color'];
347
+			$settings['submit_hover_color'] = $settings['submit_text_color'];
348
+			$settings['submit_hover_border_color'] = $settings['submit_border_color'];
349
+
350
+			$settings['submit_active_bg_color'] = $settings['submit_bg_color'];
351
+			$settings['submit_active_color'] = $settings['submit_text_color'];
352
+			$settings['submit_active_border_color'] = $settings['submit_border_color'];
353
+		}
354
+
355
+		return $settings;
356 356
 	}
357 357
 
358 358
 	public function get_defaults() {
359
-        return array(
360
-            'theme_css'         => 'ui-lightness',
361
-            'theme_name'        => 'UI Lightness',
359
+		return array(
360
+			'theme_css'         => 'ui-lightness',
361
+			'theme_name'        => 'UI Lightness',
362 362
 
363 363
 			'center_form'		=> '',
364
-            'form_width'        => '100%',
365
-            'form_align'        => 'left',
366
-            'direction'         => is_rtl() ? 'rtl' : 'ltr',
367
-            'fieldset'          => '0px',
368
-            'fieldset_color'    => '000000',
369
-            'fieldset_padding'  => '0 0 15px 0',
370
-            'fieldset_bg_color' => '',
371
-
372
-            'title_size'        => '20px',
373
-            'title_color'       => '444444',
374
-            'form_desc_size'    => '14px',
375
-            'form_desc_color'   => '666666',
376
-
377
-            'font'              => '"Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif',
378
-            'font_size'         => '14px',
379
-            'label_color'       => '444444',
380
-            'weight'            => 'bold',
381
-            'position'          => 'none',
382
-            'align'             => 'left',
383
-            'width'             => '150px',
384
-            'required_color'    => 'B94A48',
385
-            'required_weight'   => 'bold',
386
-            'label_padding'     => '0 0 3px 0',
387
-
388
-            'description_font_size' => '12px',
389
-            'description_color' => '666666',
390
-            'description_weight' => 'normal',
391
-            'description_style' => 'normal',
392
-            'description_align' => 'left',
393
-
394
-            'field_font_size'   => '14px',
395
-            'field_height' 		=> '32px',
396
-            'line_height'		=> 'normal',
397
-            'field_width'       => '100%',
398
-            'auto_width'        => false,
399
-            'field_pad'         => '6px 10px',
400
-            'field_margin'      => '20px',
364
+			'form_width'        => '100%',
365
+			'form_align'        => 'left',
366
+			'direction'         => is_rtl() ? 'rtl' : 'ltr',
367
+			'fieldset'          => '0px',
368
+			'fieldset_color'    => '000000',
369
+			'fieldset_padding'  => '0 0 15px 0',
370
+			'fieldset_bg_color' => '',
371
+
372
+			'title_size'        => '20px',
373
+			'title_color'       => '444444',
374
+			'form_desc_size'    => '14px',
375
+			'form_desc_color'   => '666666',
376
+
377
+			'font'              => '"Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif',
378
+			'font_size'         => '14px',
379
+			'label_color'       => '444444',
380
+			'weight'            => 'bold',
381
+			'position'          => 'none',
382
+			'align'             => 'left',
383
+			'width'             => '150px',
384
+			'required_color'    => 'B94A48',
385
+			'required_weight'   => 'bold',
386
+			'label_padding'     => '0 0 3px 0',
387
+
388
+			'description_font_size' => '12px',
389
+			'description_color' => '666666',
390
+			'description_weight' => 'normal',
391
+			'description_style' => 'normal',
392
+			'description_align' => 'left',
393
+
394
+			'field_font_size'   => '14px',
395
+			'field_height' 		=> '32px',
396
+			'line_height'		=> 'normal',
397
+			'field_width'       => '100%',
398
+			'auto_width'        => false,
399
+			'field_pad'         => '6px 10px',
400
+			'field_margin'      => '20px',
401 401
 			'field_weight' => 'normal',
402
-            'text_color'        => '555555',
403
-            //'border_color_hv'   => 'cccccc',
404
-            'border_color'      => 'cccccc',
405
-            'field_border_width' => '1px',
406
-            'field_border_style' => 'solid',
407
-
408
-            'bg_color'          => 'ffffff',
409
-            //'bg_color_hv'       => 'ffffff',
402
+			'text_color'        => '555555',
403
+			//'border_color_hv'   => 'cccccc',
404
+			'border_color'      => 'cccccc',
405
+			'field_border_width' => '1px',
406
+			'field_border_style' => 'solid',
407
+
408
+			'bg_color'          => 'ffffff',
409
+			//'bg_color_hv'       => 'ffffff',
410 410
 			'remove_box_shadow' => '',
411
-            'bg_color_active'   => 'ffffff',
411
+			'bg_color_active'   => 'ffffff',
412 412
 			'border_color_active' => '66afe9',
413 413
 			'remove_box_shadow_active' => '',
414
-            'text_color_error'  => '444444',
415
-            'bg_color_error'    => 'ffffff',
414
+			'text_color_error'  => '444444',
415
+			'bg_color_error'    => 'ffffff',
416 416
 			'border_color_error' => 'B94A48',
417 417
 			'border_width_error' => '1px',
418 418
 			'border_style_error' => 'solid',
419
-            'bg_color_disabled' => 'ffffff',
420
-            'border_color_disabled' => 'E5E5E5',
421
-            'text_color_disabled' => 'A1A1A1',
422
-
423
-            'radio_align'       => 'block',
424
-            'check_align'       => 'block',
425
-            'check_font_size'   => '13px',
426
-            'check_label_color' => '444444',
427
-            'check_weight'      => 'normal',
428
-
429
-            'section_font_size' => '18px',
430
-            'section_color'     => '444444',
431
-            'section_weight'    => 'bold',
432
-            'section_pad'       => '15px 0 3px 0',
433
-            'section_mar_top'   => '15px',
419
+			'bg_color_disabled' => 'ffffff',
420
+			'border_color_disabled' => 'E5E5E5',
421
+			'text_color_disabled' => 'A1A1A1',
422
+
423
+			'radio_align'       => 'block',
424
+			'check_align'       => 'block',
425
+			'check_font_size'   => '13px',
426
+			'check_label_color' => '444444',
427
+			'check_weight'      => 'normal',
428
+
429
+			'section_font_size' => '18px',
430
+			'section_color'     => '444444',
431
+			'section_weight'    => 'bold',
432
+			'section_pad'       => '15px 0 3px 0',
433
+			'section_mar_top'   => '15px',
434 434
 			'section_mar_bottom' => '12px',
435
-            'section_bg_color'  => '',
436
-            'section_border_color' => 'e8e8e8',
437
-            'section_border_width' => '2px',
438
-            'section_border_style' => 'solid',
439
-            'section_border_loc' => '-top',
440
-            'collapse_icon'     => '6',
441
-            'collapse_pos'      => 'after',
442
-            'repeat_icon'       => '1',
443
-
444
-            'submit_style'      => false,
445
-            'submit_font_size'  => '14px',
446
-            'submit_width'      => 'auto',
447
-            'submit_height'     => 'auto',
448
-            'submit_bg_color'   => 'ffffff',
449
-            'submit_border_color' => 'cccccc',
450
-            'submit_border_width' => '1px',
451
-            'submit_text_color' => '444444',
452
-            'submit_weight'     => 'normal',
453
-            'submit_border_radius' => '4px',
454
-            'submit_bg_img'     => '',
455
-            'submit_margin'     => '10px',
456
-            'submit_padding'    => '6px 11px',
457
-            'submit_shadow_color' => 'eeeeee',
458
-            'submit_hover_bg_color' => 'efefef',
459
-            'submit_hover_color' => '444444',
460
-            'submit_hover_border_color' => 'cccccc',
461
-            'submit_active_bg_color' => 'efefef',
462
-            'submit_active_color' => '444444',
463
-            'submit_active_border_color' => 'cccccc',
464
-
465
-            'border_radius'     => '4px',
466
-            'error_bg'          => 'F2DEDE',
467
-            'error_border'      => 'EBCCD1',
468
-            'error_text'        => 'B94A48',
469
-            'error_font_size'   => '14px',
470
-
471
-            'success_bg_color'  => 'DFF0D8',
472
-            'success_border_color' => 'D6E9C6',
473
-            'success_text_color' => '468847',
474
-            'success_font_size' => '14px',
475
-
476
-            'important_style'   => false,
477
-
478
-            'custom_css'        => '',
479
-        );
480
-    }
435
+			'section_bg_color'  => '',
436
+			'section_border_color' => 'e8e8e8',
437
+			'section_border_width' => '2px',
438
+			'section_border_style' => 'solid',
439
+			'section_border_loc' => '-top',
440
+			'collapse_icon'     => '6',
441
+			'collapse_pos'      => 'after',
442
+			'repeat_icon'       => '1',
443
+
444
+			'submit_style'      => false,
445
+			'submit_font_size'  => '14px',
446
+			'submit_width'      => 'auto',
447
+			'submit_height'     => 'auto',
448
+			'submit_bg_color'   => 'ffffff',
449
+			'submit_border_color' => 'cccccc',
450
+			'submit_border_width' => '1px',
451
+			'submit_text_color' => '444444',
452
+			'submit_weight'     => 'normal',
453
+			'submit_border_radius' => '4px',
454
+			'submit_bg_img'     => '',
455
+			'submit_margin'     => '10px',
456
+			'submit_padding'    => '6px 11px',
457
+			'submit_shadow_color' => 'eeeeee',
458
+			'submit_hover_bg_color' => 'efefef',
459
+			'submit_hover_color' => '444444',
460
+			'submit_hover_border_color' => 'cccccc',
461
+			'submit_active_bg_color' => 'efefef',
462
+			'submit_active_color' => '444444',
463
+			'submit_active_border_color' => 'cccccc',
464
+
465
+			'border_radius'     => '4px',
466
+			'error_bg'          => 'F2DEDE',
467
+			'error_border'      => 'EBCCD1',
468
+			'error_text'        => 'B94A48',
469
+			'error_font_size'   => '14px',
470
+
471
+			'success_bg_color'  => 'DFF0D8',
472
+			'success_border_color' => 'D6E9C6',
473
+			'success_text_color' => '468847',
474
+			'success_font_size' => '14px',
475
+
476
+			'important_style'   => false,
477
+
478
+			'custom_css'        => '',
479
+		);
480
+	}
481 481
 
482 482
 	public function get_field_name( $field_name, $post_field = 'post_content' ) {
483 483
 		return 'frm_style_setting'. ( empty($post_field) ? '' : '['. $post_field .']' ) .'[' . $field_name . ']';
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,114 +113,114 @@  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() {
140
-        check_ajax_referer( 'frm_ajax', 'nonce' );
139
+	public static function add_form_action() {
140
+		check_ajax_referer( 'frm_ajax', 'nonce' );
141 141
 
142
-        global $frm_vars;
142
+		global $frm_vars;
143 143
 
144 144
 		$action_key = absint( $_POST['list_id'] );
145
-        $action_type = sanitize_text_field( $_POST['type'] );
145
+		$action_type = sanitize_text_field( $_POST['type'] );
146 146
 
147
-        $action_control = self::get_form_actions( $action_type );
148
-        $action_control->_set($action_key);
147
+		$action_control = self::get_form_actions( $action_type );
148
+		$action_control->_set($action_key);
149 149
 
150
-        $form_id = absint( $_POST['form_id'] );
150
+		$form_id = absint( $_POST['form_id'] );
151 151
 
152
-        $form_action = $action_control->prepare_new($form_id);
152
+		$form_action = $action_control->prepare_new($form_id);
153 153
 
154
-        $values = array();
155
-        $form = self::fields_to_values($form_id, $values);
154
+		$values = array();
155
+		$form = self::fields_to_values($form_id, $values);
156 156
 
157
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php');
158
-        wp_die();
159
-    }
157
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php');
158
+		wp_die();
159
+	}
160 160
 
161
-    public static function fill_action() {
162
-        check_ajax_referer( 'frm_ajax', 'nonce' );
161
+	public static function fill_action() {
162
+		check_ajax_referer( 'frm_ajax', 'nonce' );
163 163
 
164
-        $action_key = absint( $_POST['action_id'] );
165
-        $action_type = sanitize_text_field( $_POST['action_type'] );
164
+		$action_key = absint( $_POST['action_id'] );
165
+		$action_type = sanitize_text_field( $_POST['action_type'] );
166 166
 
167
-        $action_control = self::get_form_actions( $action_type );
168
-        if ( empty($action_control) ) {
169
-            wp_die();
170
-        }
167
+		$action_control = self::get_form_actions( $action_type );
168
+		if ( empty($action_control) ) {
169
+			wp_die();
170
+		}
171 171
 
172
-        $form_action = $action_control->get_single_action( $action_key );
172
+		$form_action = $action_control->get_single_action( $action_key );
173 173
 
174
-        $values = array();
175
-        $form = self::fields_to_values($form_action->menu_order, $values);
174
+		$values = array();
175
+		$form = self::fields_to_values($form_action->menu_order, $values);
176 176
 
177
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/_action_inside.php');
178
-        wp_die();
179
-    }
177
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/_action_inside.php');
178
+		wp_die();
179
+	}
180 180
 
181 181
 	private static function fields_to_values( $form_id, array &$values ) {
182
-        $form = FrmForm::getOne($form_id);
182
+		$form = FrmForm::getOne($form_id);
183 183
 
184 184
 		$values = array( 'fields' => array(), 'id' => $form->id );
185 185
 
186
-        $fields = FrmField::get_all_for_form($form->id);
187
-        foreach ( $fields as $k => $f ) {
188
-            $f = (array) $f;
189
-            $opts = (array) $f['field_options'];
190
-            $f = array_merge($opts, $f);
191
-            if ( ! isset( $f['post_field'] ) ) {
192
-                $f['post_field'] = '';
193
-            }
194
-            $values['fields'][] = $f;
195
-            unset($k, $f);
196
-        }
197
-
198
-        return $form;
199
-    }
186
+		$fields = FrmField::get_all_for_form($form->id);
187
+		foreach ( $fields as $k => $f ) {
188
+			$f = (array) $f;
189
+			$opts = (array) $f['field_options'];
190
+			$f = array_merge($opts, $f);
191
+			if ( ! isset( $f['post_field'] ) ) {
192
+				$f['post_field'] = '';
193
+			}
194
+			$values['fields'][] = $f;
195
+			unset($k, $f);
196
+		}
197
+
198
+		return $form;
199
+	}
200 200
 
201 201
 	public static function update_settings( $form_id ) {
202
-        global $wpdb;
202
+		global $wpdb;
203 203
 
204
-        $registered_actions = self::$registered_actions->actions;
204
+		$registered_actions = self::$registered_actions->actions;
205 205
 
206 206
 		$old_actions = FrmDb::get_col( $wpdb->posts, array( 'post_type' => self::$action_post_type, 'menu_order' => $form_id ), 'ID' );
207
-        $new_actions = array();
207
+		$new_actions = array();
208 208
 
209
-        foreach ( $registered_actions as $registered_action ) {
210
-            $action_ids = $registered_action->update_callback($form_id);
211
-            if ( ! empty( $action_ids ) ) {
212
-                $new_actions[] = $action_ids;
213
-            }
214
-        }
209
+		foreach ( $registered_actions as $registered_action ) {
210
+			$action_ids = $registered_action->update_callback($form_id);
211
+			if ( ! empty( $action_ids ) ) {
212
+				$new_actions[] = $action_ids;
213
+			}
214
+		}
215 215
 
216
-        //Only use array_merge if there are new actions
217
-        if ( ! empty( $new_actions ) ) {
218
-            $new_actions = call_user_func_array( 'array_merge', $new_actions );
219
-        }
220
-        $old_actions = array_diff( $old_actions, $new_actions );
216
+		//Only use array_merge if there are new actions
217
+		if ( ! empty( $new_actions ) ) {
218
+			$new_actions = call_user_func_array( 'array_merge', $new_actions );
219
+		}
220
+		$old_actions = array_diff( $old_actions, $new_actions );
221 221
 
222 222
 		self::delete_missing_actions( $old_actions );
223
-    }
223
+	}
224 224
 
225 225
 	public static function delete_missing_actions( $old_actions ) {
226 226
 		if ( ! empty( $old_actions ) ) {
@@ -235,36 +235,36 @@  discard block
 block discarded – undo
235 235
 		self::trigger_actions( 'create', $form_id, $entry_id, 'all', $args );
236 236
 	}
237 237
 
238
-    /**
239
-     * @param string $event
240
-     */
238
+	/**
239
+	 * @param string $event
240
+	 */
241 241
 	public static function trigger_actions( $event, $form, $entry, $type = 'all', $args = array() ) {
242 242
 		$form_actions = FrmFormAction::get_action_for_form( ( is_object( $form ) ? $form->id : $form ), $type );
243 243
 
244 244
 		if ( empty( $form_actions ) ) {
245
-            return;
246
-        }
245
+			return;
246
+		}
247 247
 
248 248
 		FrmForm::maybe_get_form( $form );
249 249
 
250
-        $link_settings = self::get_form_actions( $type );
251
-        if ( 'all' != $type ) {
252
-            $link_settings = array( $type => $link_settings );
253
-        }
250
+		$link_settings = self::get_form_actions( $type );
251
+		if ( 'all' != $type ) {
252
+			$link_settings = array( $type => $link_settings );
253
+		}
254 254
 
255
-        $stored_actions = $action_priority = array();
255
+		$stored_actions = $action_priority = array();
256 256
 
257 257
 		$importing = in_array( $event, array( 'create', 'update' ) ) && defined( 'WP_IMPORTING' ) && WP_IMPORTING;
258 258
 
259
-        foreach ( $form_actions as $action ) {
259
+		foreach ( $form_actions as $action ) {
260 260
 			$trigger_on_import = $importing && in_array( 'import', $action->post_content['event'] );
261 261
 			if ( ! in_array( $event, $action->post_content['event'] ) && ! $trigger_on_import ) {
262
-                continue;
263
-            }
262
+				continue;
263
+			}
264 264
 
265
-            if ( ! is_object( $entry ) ) {
266
-                $entry = FrmEntry::getOne( $entry, true );
267
-            }
265
+			if ( ! is_object( $entry ) ) {
266
+				$entry = FrmEntry::getOne( $entry, true );
267
+			}
268 268
 
269 269
 			if ( empty( $entry ) || $entry->is_draft ) {
270 270
 				continue;
@@ -273,66 +273,66 @@  discard block
 block discarded – undo
273 273
 			$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'] ) );
274 274
 
275 275
 			if ( $child_entry ) {
276
-                //don't trigger actions for sub forms
277
-                continue;
278
-            }
276
+				//don't trigger actions for sub forms
277
+				continue;
278
+			}
279 279
 
280
-            // check conditional logic
280
+			// check conditional logic
281 281
 			$stop = FrmFormAction::action_conditions_met( $action, $entry );
282
-            if ( $stop ) {
283
-                continue;
284
-            }
282
+			if ( $stop ) {
283
+				continue;
284
+			}
285 285
 
286
-            // store actions so they can be triggered with the correct priority
287
-            $stored_actions[ $action->ID ] = $action;
288
-            $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority'];
286
+			// store actions so they can be triggered with the correct priority
287
+			$stored_actions[ $action->ID ] = $action;
288
+			$action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority'];
289 289
 
290
-            unset($action);
291
-        }
290
+			unset($action);
291
+		}
292 292
 
293
-        if ( ! empty( $stored_actions ) ) {
294
-            asort($action_priority);
293
+		if ( ! empty( $stored_actions ) ) {
294
+			asort($action_priority);
295 295
 
296
-            // make sure hooks are loaded
297
-            new FrmNotification();
296
+			// make sure hooks are loaded
297
+			new FrmNotification();
298 298
 
299
-            foreach ( $action_priority as $action_id => $priority ) {
300
-                $action = $stored_actions[ $action_id ];
301
-                do_action('frm_trigger_'. $action->post_excerpt .'_action', $action, $entry, $form, $event);
302
-                do_action('frm_trigger_'. $action->post_excerpt .'_'. $event .'_action', $action, $entry, $form);
299
+			foreach ( $action_priority as $action_id => $priority ) {
300
+				$action = $stored_actions[ $action_id ];
301
+				do_action('frm_trigger_'. $action->post_excerpt .'_action', $action, $entry, $form, $event);
302
+				do_action('frm_trigger_'. $action->post_excerpt .'_'. $event .'_action', $action, $entry, $form);
303 303
 
304
-                // If post is created, get updated $entry object
305
-                if ( $action->post_excerpt == 'wppost' && $event == 'create' ) {
306
-                    $entry = FrmEntry::getOne($entry->id, true);
307
-                }
308
-            }
309
-        }
310
-    }
304
+				// If post is created, get updated $entry object
305
+				if ( $action->post_excerpt == 'wppost' && $event == 'create' ) {
306
+					$entry = FrmEntry::getOne($entry->id, true);
307
+				}
308
+			}
309
+		}
310
+	}
311 311
 
312 312
 	public static function duplicate_form_actions( $form_id, $values, $args = array() ) {
313
-        if ( ! isset($args['old_id']) || empty($args['old_id']) ) {
314
-            // continue if we know which actions to copy
315
-            return;
316
-        }
313
+		if ( ! isset($args['old_id']) || empty($args['old_id']) ) {
314
+			// continue if we know which actions to copy
315
+			return;
316
+		}
317 317
 
318
-        $action_controls = self::get_form_actions( );
318
+		$action_controls = self::get_form_actions( );
319 319
 
320
-        foreach ( $action_controls as $action_control ) {
321
-            $action_control->duplicate_form_actions( $form_id, $args['old_id'] );
322
-            unset( $action_control );
323
-        }
324
-    }
320
+		foreach ( $action_controls as $action_control ) {
321
+			$action_control->duplicate_form_actions( $form_id, $args['old_id'] );
322
+			unset( $action_control );
323
+		}
324
+	}
325 325
 
326
-    public static function limit_by_type( $where ) {
327
-        global $frm_vars, $wpdb;
326
+	public static function limit_by_type( $where ) {
327
+		global $frm_vars, $wpdb;
328 328
 
329
-        if ( ! isset( $frm_vars['action_type'] ) ) {
330
-            return $where;
331
-        }
329
+		if ( ! isset( $frm_vars['action_type'] ) ) {
330
+			return $where;
331
+		}
332 332
 
333
-        $where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] );
334
-        return $where;
335
-    }
333
+		$where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] );
334
+		return $where;
335
+	}
336 336
 }
337 337
 
338 338
 
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 		foreach ( $keys as $key ) {
360 360
 			// don't register new action if old action with the same id is already registered
361 361
 			if ( ! isset( $this->actions[ $key ] ) ) {
362
-			    $this->actions[ $key ]->_register();
362
+				$this->actions[ $key ]->_register();
363 363
 			}
364 364
 		}
365 365
 	}
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 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,22 +118,22 @@  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() {
@@ -145,16 +145,16 @@  discard block
 block discarded – undo
145 145
         $action_type = sanitize_text_field( $_POST['type'] );
146 146
 
147 147
         $action_control = self::get_form_actions( $action_type );
148
-        $action_control->_set($action_key);
148
+        $action_control->_set( $action_key );
149 149
 
150 150
         $form_id = absint( $_POST['form_id'] );
151 151
 
152
-        $form_action = $action_control->prepare_new($form_id);
152
+        $form_action = $action_control->prepare_new( $form_id );
153 153
 
154 154
         $values = array();
155
-        $form = self::fields_to_values($form_id, $values);
155
+        $form = self::fields_to_values( $form_id, $values );
156 156
 
157
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php');
157
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' );
158 158
         wp_die();
159 159
     }
160 160
 
@@ -165,34 +165,34 @@  discard block
 block discarded – undo
165 165
         $action_type = sanitize_text_field( $_POST['action_type'] );
166 166
 
167 167
         $action_control = self::get_form_actions( $action_type );
168
-        if ( empty($action_control) ) {
168
+        if ( empty( $action_control ) ) {
169 169
             wp_die();
170 170
         }
171 171
 
172 172
         $form_action = $action_control->get_single_action( $action_key );
173 173
 
174 174
         $values = array();
175
-        $form = self::fields_to_values($form_action->menu_order, $values);
175
+        $form = self::fields_to_values( $form_action->menu_order, $values );
176 176
 
177
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/_action_inside.php');
177
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_inside.php' );
178 178
         wp_die();
179 179
     }
180 180
 
181 181
 	private static function fields_to_values( $form_id, array &$values ) {
182
-        $form = FrmForm::getOne($form_id);
182
+        $form = FrmForm::getOne( $form_id );
183 183
 
184 184
 		$values = array( 'fields' => array(), 'id' => $form->id );
185 185
 
186
-        $fields = FrmField::get_all_for_form($form->id);
186
+        $fields = FrmField::get_all_for_form( $form->id );
187 187
         foreach ( $fields as $k => $f ) {
188 188
             $f = (array) $f;
189 189
             $opts = (array) $f['field_options'];
190
-            $f = array_merge($opts, $f);
190
+            $f = array_merge( $opts, $f );
191 191
             if ( ! isset( $f['post_field'] ) ) {
192 192
                 $f['post_field'] = '';
193 193
             }
194 194
             $values['fields'][] = $f;
195
-            unset($k, $f);
195
+            unset( $k, $f );
196 196
         }
197 197
 
198 198
         return $form;
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
         $new_actions = array();
208 208
 
209 209
         foreach ( $registered_actions as $registered_action ) {
210
-            $action_ids = $registered_action->update_callback($form_id);
210
+            $action_ids = $registered_action->update_callback( $form_id );
211 211
             if ( ! empty( $action_ids ) ) {
212 212
                 $new_actions[] = $action_ids;
213 213
             }
@@ -284,33 +284,33 @@  discard block
 block discarded – undo
284 284
             }
285 285
 
286 286
             // store actions so they can be triggered with the correct priority
287
-            $stored_actions[ $action->ID ] = $action;
288
-            $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority'];
287
+            $stored_actions[$action->ID] = $action;
288
+            $action_priority[$action->ID] = $link_settings[$action->post_excerpt]->action_options['priority'];
289 289
 
290
-            unset($action);
290
+            unset( $action );
291 291
         }
292 292
 
293 293
         if ( ! empty( $stored_actions ) ) {
294
-            asort($action_priority);
294
+            asort( $action_priority );
295 295
 
296 296
             // make sure hooks are loaded
297 297
             new FrmNotification();
298 298
 
299 299
             foreach ( $action_priority as $action_id => $priority ) {
300
-                $action = $stored_actions[ $action_id ];
301
-                do_action('frm_trigger_'. $action->post_excerpt .'_action', $action, $entry, $form, $event);
302
-                do_action('frm_trigger_'. $action->post_excerpt .'_'. $event .'_action', $action, $entry, $form);
300
+                $action = $stored_actions[$action_id];
301
+                do_action( 'frm_trigger_' . $action->post_excerpt . '_action', $action, $entry, $form, $event );
302
+                do_action( 'frm_trigger_' . $action->post_excerpt . '_' . $event . '_action', $action, $entry, $form );
303 303
 
304 304
                 // If post is created, get updated $entry object
305 305
                 if ( $action->post_excerpt == 'wppost' && $event == 'create' ) {
306
-                    $entry = FrmEntry::getOne($entry->id, true);
306
+                    $entry = FrmEntry::getOne( $entry->id, true );
307 307
                 }
308 308
             }
309 309
         }
310 310
     }
311 311
 
312 312
 	public static function duplicate_form_actions( $form_id, $values, $args = array() ) {
313
-        if ( ! isset($args['old_id']) || empty($args['old_id']) ) {
313
+        if ( ! isset( $args['old_id'] ) || empty( $args['old_id'] ) ) {
314 314
             // continue if we know which actions to copy
315 315
             return;
316 316
         }
@@ -344,22 +344,22 @@  discard block
 block discarded – undo
344 344
 	}
345 345
 
346 346
 	public function register( $action_class ) {
347
-		$this->actions[ $action_class ] = new $action_class();
347
+		$this->actions[$action_class] = new $action_class();
348 348
 	}
349 349
 
350 350
 	public function unregister( $action_class ) {
351
-		if ( isset( $this->actions[ $action_class ] ) ) {
352
-			unset($this->actions[ $action_class ]);
351
+		if ( isset( $this->actions[$action_class] ) ) {
352
+			unset( $this->actions[$action_class] );
353 353
 		}
354 354
 	}
355 355
 
356 356
 	public function _register_actions() {
357
-		$keys = array_keys($this->actions);
357
+		$keys = array_keys( $this->actions );
358 358
 
359 359
 		foreach ( $keys as $key ) {
360 360
 			// don't register new action if old action with the same id is already registered
361
-			if ( ! isset( $this->actions[ $key ] ) ) {
362
-			    $this->actions[ $key ]->_register();
361
+			if ( ! isset( $this->actions[$key] ) ) {
362
+			    $this->actions[$key]->_register();
363 363
 			}
364 364
 		}
365 365
 	}
Please login to merge, or discard this patch.
classes/controllers/FrmHooksController.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -143,8 +143,8 @@
 block discarded – undo
143 143
         add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' );
144 144
 
145 145
 		// Addons Controller
146
-		add_action('wp_ajax_frm_addon_activate', 'FrmAddon::activate' );
147
-		add_action('wp_ajax_frm_addon_deactivate', 'FrmAddon::deactivate' );
146
+		add_action( 'wp_ajax_frm_addon_activate', 'FrmAddon::activate' );
147
+		add_action( 'wp_ajax_frm_addon_deactivate', 'FrmAddon::deactivate' );
148 148
 
149 149
         // Fields Controller
150 150
         add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' );
Please login to merge, or discard this patch.
Indentation   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -1,91 +1,91 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class FrmHooksController {
4
-    /**
5
-     * Trigger plugin-wide hook loading
6
-     */
7
-    public static function trigger_load_hook( $hooks = 'load_hooks' ) {
8
-        $controllers = apply_filters( 'frm_load_controllers', array( 'FrmHooksController' ) );
9
-
10
-        $trigger_hooks = $hooks;
11
-        $hooks = (array) $hooks;
12
-
13
-        if ( 'load_hooks' == $trigger_hooks ) {
14
-            if ( is_admin() ) {
15
-                $hooks[] = 'load_admin_hooks';
16
-                if ( defined( 'DOING_AJAX' ) ) {
17
-                    $hooks[] = 'load_ajax_hooks';
18
-                    $hooks[] = 'load_form_hooks';
19
-                }
20
-            }
21
-
22
-            if ( is_multisite() ) {
23
-                $hooks[] = 'load_multisite_hooks';
24
-            }
25
-        } else {
26
-            // Make sure the hooks are only triggered once
27
-            add_filter( 'frm' . str_replace( 'load', '', $trigger_hooks ) . '_loaded', '__return_true' );
28
-        }
29
-        unset( $trigger_hooks );
30
-
31
-        // Instansiate Controllers
32
-        foreach ( $controllers as $c ) {
33
-            foreach ( $hooks as $hook ) {
4
+	/**
5
+	 * Trigger plugin-wide hook loading
6
+	 */
7
+	public static function trigger_load_hook( $hooks = 'load_hooks' ) {
8
+		$controllers = apply_filters( 'frm_load_controllers', array( 'FrmHooksController' ) );
9
+
10
+		$trigger_hooks = $hooks;
11
+		$hooks = (array) $hooks;
12
+
13
+		if ( 'load_hooks' == $trigger_hooks ) {
14
+			if ( is_admin() ) {
15
+				$hooks[] = 'load_admin_hooks';
16
+				if ( defined( 'DOING_AJAX' ) ) {
17
+					$hooks[] = 'load_ajax_hooks';
18
+					$hooks[] = 'load_form_hooks';
19
+				}
20
+			}
21
+
22
+			if ( is_multisite() ) {
23
+				$hooks[] = 'load_multisite_hooks';
24
+			}
25
+		} else {
26
+			// Make sure the hooks are only triggered once
27
+			add_filter( 'frm' . str_replace( 'load', '', $trigger_hooks ) . '_loaded', '__return_true' );
28
+		}
29
+		unset( $trigger_hooks );
30
+
31
+		// Instansiate Controllers
32
+		foreach ( $controllers as $c ) {
33
+			foreach ( $hooks as $hook ) {
34 34
 				call_user_func( array( $c, $hook ) );
35 35
 				unset( $hook );
36
-            }
36
+			}
37 37
 			unset( $c );
38
-        }
38
+		}
39 39
 
40
-    }
40
+	}
41 41
 
42
-    public static function trigger_load_form_hooks() {
43
-        self::trigger_load_hook( 'load_form_hooks' );
44
-    }
42
+	public static function trigger_load_form_hooks() {
43
+		self::trigger_load_hook( 'load_form_hooks' );
44
+	}
45 45
 
46 46
 	public static function load_hooks() {
47
-        if ( ! is_admin() ) {
48
-            add_filter( 'the_content', 'FrmAppController::page_route', 10 );
49
-        }
50
-
51
-        add_action( 'plugins_loaded', 'FrmAppController::load_lang' );
52
-        add_filter( 'widget_text', 'FrmAppController::widget_text_filter', 8 );
53
-
54
-        // Entries controller
55
-        add_action( 'wp_loaded', 'FrmEntriesController::process_entry', 10, 0 );
56
-        add_filter( 'frm_redirect_url', 'FrmEntriesController::delete_entry_before_redirect', 50, 3 );
57
-        add_action( 'frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100 );
58
-        add_filter( 'frm_email_value', 'FrmEntriesController::filter_email_value', 10, 3 );
59
-        add_filter( 'frmpro_fields_replace_shortcodes', 'FrmEntriesController::filter_shortcode_value', 10, 4 );
60
-
61
-        // Form Actions Controller
62
-        add_action( 'init', 'FrmFormActionsController::register_post_types', 1 );
47
+		if ( ! is_admin() ) {
48
+			add_filter( 'the_content', 'FrmAppController::page_route', 10 );
49
+		}
50
+
51
+		add_action( 'plugins_loaded', 'FrmAppController::load_lang' );
52
+		add_filter( 'widget_text', 'FrmAppController::widget_text_filter', 8 );
53
+
54
+		// Entries controller
55
+		add_action( 'wp_loaded', 'FrmEntriesController::process_entry', 10, 0 );
56
+		add_filter( 'frm_redirect_url', 'FrmEntriesController::delete_entry_before_redirect', 50, 3 );
57
+		add_action( 'frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100 );
58
+		add_filter( 'frm_email_value', 'FrmEntriesController::filter_email_value', 10, 3 );
59
+		add_filter( 'frmpro_fields_replace_shortcodes', 'FrmEntriesController::filter_shortcode_value', 10, 4 );
60
+
61
+		// Form Actions Controller
62
+		add_action( 'init', 'FrmFormActionsController::register_post_types', 1 );
63 63
 		add_action( 'frm_after_create_entry', 'FrmFormActionsController::trigger_create_actions', 20, 3 );
64 64
 
65
-        // Forms Controller
66
-        add_action( 'widgets_init', 'FrmFormsController::register_widgets' );
65
+		// Forms Controller
66
+		add_action( 'widgets_init', 'FrmFormsController::register_widgets' );
67 67
 		add_action( 'init', 'FrmFormsController::front_head' );
68
-        add_filter( 'frm_content', 'FrmFormsController::filter_content', 10, 3 );
69
-        add_filter( 'frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20, 3 );
70
-        add_action( 'admin_bar_init', 'FrmFormsController::admin_bar_css' );
68
+		add_filter( 'frm_content', 'FrmFormsController::filter_content', 10, 3 );
69
+		add_filter( 'frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20, 3 );
70
+		add_action( 'admin_bar_init', 'FrmFormsController::admin_bar_css' );
71 71
 		add_action( 'wp_footer', 'FrmFormsController::footer_js', 1, 0 );
72 72
 
73 73
 		add_action( 'wp_scheduled_delete', 'FrmForm::scheduled_delete' );
74 74
 
75
-        // Form Shortcodes
76
-        add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' );
75
+		// Form Shortcodes
76
+		add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' );
77 77
 
78
-        // Styles Controller
79
-        add_action( 'init', 'FrmStylesController::register_post_types', 0 );
80
-        add_filter( 'frm_get_style_opts', 'FrmStylesController::get_style_opts' );
81
-        add_filter( 'frm_add_form_style_class', 'FrmStylesController::get_form_style_class', 10, 2 );
82
-        add_filter( 'frm_show_entry_styles', 'FrmStylesController::show_entry_styles' );
83
-    }
78
+		// Styles Controller
79
+		add_action( 'init', 'FrmStylesController::register_post_types', 0 );
80
+		add_filter( 'frm_get_style_opts', 'FrmStylesController::get_style_opts' );
81
+		add_filter( 'frm_add_form_style_class', 'FrmStylesController::get_form_style_class', 10, 2 );
82
+		add_filter( 'frm_show_entry_styles', 'FrmStylesController::show_entry_styles' );
83
+	}
84 84
 
85 85
 	public static function load_admin_hooks() {
86
-        add_action( 'admin_menu', 'FrmAppController::menu', 1 );
87
-        add_action( 'admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' );
88
-        add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' );
86
+		add_action( 'admin_menu', 'FrmAppController::menu', 1 );
87
+		add_action( 'admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' );
88
+		add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' );
89 89
 		add_action( 'admin_init', 'FrmAppController::admin_init', 11 );
90 90
 		add_filter( 'admin_body_class', 'FrmAppController::wp_admin_body_class' );
91 91
 		add_filter( 'plugin_action_links_' . FrmAppHelper::plugin_folder() . '/formidable.php', 'FrmAppController::settings_link' );
@@ -94,122 +94,122 @@  discard block
 block discarded – undo
94 94
 		// Addons Controller
95 95
 		add_action( 'admin_menu', 'FrmAddonsController::menu', 100 );
96 96
 
97
-        // Entries Controller
98
-        add_action( 'admin_menu', 'FrmEntriesController::menu', 12 );
99
-        add_filter( 'contextual_help', 'FrmEntriesController::contextual_help', 10, 3 );
100
-        add_filter( 'set-screen-option', 'FrmEntriesController::save_per_page', 10, 3 );
101
-        add_filter( 'update_user_metadata', 'FrmEntriesController::check_hidden_cols', 10, 5 );
102
-        add_action( 'updated_user_meta', 'FrmEntriesController::update_hidden_cols', 10, 4 );
97
+		// Entries Controller
98
+		add_action( 'admin_menu', 'FrmEntriesController::menu', 12 );
99
+		add_filter( 'contextual_help', 'FrmEntriesController::contextual_help', 10, 3 );
100
+		add_filter( 'set-screen-option', 'FrmEntriesController::save_per_page', 10, 3 );
101
+		add_filter( 'update_user_metadata', 'FrmEntriesController::check_hidden_cols', 10, 5 );
102
+		add_action( 'updated_user_meta', 'FrmEntriesController::update_hidden_cols', 10, 4 );
103 103
 
104
-        // Fields Controller
105
-        add_filter( 'frm_display_field_options', 'FrmFieldsController::display_field_options' );
104
+		// Fields Controller
105
+		add_filter( 'frm_display_field_options', 'FrmFieldsController::display_field_options' );
106 106
 
107
-        // Form Actions Controller
108
-        if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
109
-            add_action( 'frm_before_update_form_settings', 'FrmFormActionsController::update_settings' );
110
-        }
111
-        add_action( 'frm_after_duplicate_form', 'FrmFormActionsController::duplicate_form_actions', 20, 3 );
107
+		// Form Actions Controller
108
+		if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
109
+			add_action( 'frm_before_update_form_settings', 'FrmFormActionsController::update_settings' );
110
+		}
111
+		add_action( 'frm_after_duplicate_form', 'FrmFormActionsController::duplicate_form_actions', 20, 3 );
112 112
 
113
-        // Forms Controller
114
-        add_action( 'admin_menu', 'FrmFormsController::menu', 10 );
115
-        add_action( 'admin_head-toplevel_page_formidable', 'FrmFormsController::head' );
113
+		// Forms Controller
114
+		add_action( 'admin_menu', 'FrmFormsController::menu', 10 );
115
+		add_action( 'admin_head-toplevel_page_formidable', 'FrmFormsController::head' );
116 116
 
117
-        add_filter( 'set-screen-option', 'FrmFormsController::save_per_page', 10, 3 );
118
-        add_action( 'admin_footer', 'FrmFormsController::insert_form_popup' );
117
+		add_filter( 'set-screen-option', 'FrmFormsController::save_per_page', 10, 3 );
118
+		add_action( 'admin_footer', 'FrmFormsController::insert_form_popup' );
119 119
 		add_action( 'media_buttons', 'FrmFormsController::insert_form_button' );
120 120
 
121
-        // Forms Model
122
-        add_action( 'frm_after_duplicate_form', 'FrmForm::after_duplicate', 10, 2 );
121
+		// Forms Model
122
+		add_action( 'frm_after_duplicate_form', 'FrmForm::after_duplicate', 10, 2 );
123 123
 
124
-        // Settings Controller
125
-        add_action( 'admin_menu', 'FrmSettingsController::menu', 45 );
126
-        add_action( 'frm_before_settings', 'FrmSettingsController::license_box' );
124
+		// Settings Controller
125
+		add_action( 'admin_menu', 'FrmSettingsController::menu', 45 );
126
+		add_action( 'frm_before_settings', 'FrmSettingsController::license_box' );
127 127
 
128
-        // Styles Controller
129
-        add_action( 'admin_menu', 'FrmStylesController::menu', 14 );
130
-        add_action( 'admin_init', 'FrmStylesController::admin_init' );
128
+		// Styles Controller
129
+		add_action( 'admin_menu', 'FrmStylesController::menu', 14 );
130
+		add_action( 'admin_init', 'FrmStylesController::admin_init' );
131 131
 
132
-        // XML Controller
133
-        add_action( 'admin_menu', 'FrmXMLController::menu', 41 );
134
-    }
132
+		// XML Controller
133
+		add_action( 'admin_menu', 'FrmXMLController::menu', 41 );
134
+	}
135 135
 
136 136
 	public static function load_ajax_hooks() {
137 137
 		add_action( 'wp_ajax_frm_silent_upgrade', 'FrmAppController::ajax_install' );
138 138
 		add_action( 'wp_ajax_nopriv_frm_silent_upgrade', 'FrmAppController::ajax_install' );
139 139
 		add_action( 'wp_ajax_frm_install', 'FrmAppController::ajax_install' );
140
-        add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' );
141
-        add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' );
140
+		add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' );
141
+		add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' );
142 142
 
143 143
 		// Addons Controller
144 144
 		add_action('wp_ajax_frm_addon_activate', 'FrmAddon::activate' );
145 145
 		add_action('wp_ajax_frm_addon_deactivate', 'FrmAddon::deactivate' );
146 146
 
147
-        // Fields Controller
148
-        add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' );
149
-        add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' );
150
-        add_action( 'wp_ajax_frm_update_field_form_id', 'FrmFieldsController::update_form_id' );
151
-        add_action( 'wp_ajax_frm_field_name_in_place_edit', 'FrmFieldsController::edit_name' );
152
-        add_action( 'wp_ajax_frm_update_ajax_option', 'FrmFieldsController::update_ajax_option' );
153
-        add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' );
154
-        add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' );
155
-        add_action( 'wp_ajax_frm_add_field_option', 'FrmFieldsController::add_option' );
156
-        add_action( 'wp_ajax_frm_field_option_ipe', 'FrmFieldsController::edit_option' );
157
-        add_action( 'wp_ajax_frm_delete_field_option', 'FrmFieldsController::delete_option' );
158
-        add_action( 'wp_ajax_frm_import_choices', 'FrmFieldsController::import_choices' );
159
-        add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' );
160
-        add_action( 'wp_ajax_frm_update_field_order', 'FrmFieldsController::update_order' );
161
-
162
-        // Form Actions Controller
163
-        add_action( 'wp_ajax_frm_add_form_action', 'FrmFormActionsController::add_form_action' );
164
-        add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' );
165
-
166
-        // Forms Controller
147
+		// Fields Controller
148
+		add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' );
149
+		add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' );
150
+		add_action( 'wp_ajax_frm_update_field_form_id', 'FrmFieldsController::update_form_id' );
151
+		add_action( 'wp_ajax_frm_field_name_in_place_edit', 'FrmFieldsController::edit_name' );
152
+		add_action( 'wp_ajax_frm_update_ajax_option', 'FrmFieldsController::update_ajax_option' );
153
+		add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' );
154
+		add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' );
155
+		add_action( 'wp_ajax_frm_add_field_option', 'FrmFieldsController::add_option' );
156
+		add_action( 'wp_ajax_frm_field_option_ipe', 'FrmFieldsController::edit_option' );
157
+		add_action( 'wp_ajax_frm_delete_field_option', 'FrmFieldsController::delete_option' );
158
+		add_action( 'wp_ajax_frm_import_choices', 'FrmFieldsController::import_choices' );
159
+		add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' );
160
+		add_action( 'wp_ajax_frm_update_field_order', 'FrmFieldsController::update_order' );
161
+
162
+		// Form Actions Controller
163
+		add_action( 'wp_ajax_frm_add_form_action', 'FrmFormActionsController::add_form_action' );
164
+		add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' );
165
+
166
+		// Forms Controller
167 167
 		add_action( 'wp_ajax_frm_create_from_template', 'FrmFormsController::_create_from_template' );
168 168
 		add_action( 'wp_ajax_frm_save_form', 'FrmFormsController::route' );
169 169
 		add_action( 'wp_ajax_frm_form_key_in_place_edit', 'FrmFormsController::edit_key' );
170 170
 		add_action( 'wp_ajax_frm_form_desc_in_place_edit', 'FrmFormsController::edit_description' );
171
-        add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' );
172
-        add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' );
173
-        add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' );
174
-        add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' );
175
-
176
-        // Styles Controller
177
-        add_action( 'wp_ajax_frm_settings_reset', 'FrmStylesController::reset_styling' );
178
-        add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' );
179
-        add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' );
180
-        add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' );
171
+		add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' );
172
+		add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' );
173
+		add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' );
174
+		add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' );
175
+
176
+		// Styles Controller
177
+		add_action( 'wp_ajax_frm_settings_reset', 'FrmStylesController::reset_styling' );
178
+		add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' );
179
+		add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' );
180
+		add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' );
181 181
 		add_action( 'wp_ajax_frmpro_css', 'FrmStylesController::load_saved_css' );
182 182
 		add_action( 'wp_ajax_nopriv_frmpro_css', 'FrmStylesController::load_saved_css' );
183 183
 
184
-        // XML Controller
184
+		// XML Controller
185 185
 		add_action( 'wp_ajax_frm_entries_csv', 'FrmXMLController::csv' );
186 186
 		add_action( 'wp_ajax_nopriv_frm_entries_csv', 'FrmXMLController::csv' );
187
-        add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' );
188
-    }
187
+		add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' );
188
+	}
189 189
 
190 190
 	public static function load_form_hooks() {
191
-        // Fields Controller
192
-        add_filter( 'frm_field_type', 'FrmFieldsController::change_type' );
193
-        add_action( 'frm_field_input_html', 'FrmFieldsController::input_html' );
194
-        add_filter( 'frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3 );
195
-        add_filter( 'frm_field_label_seen', 'FrmFieldsController::check_label' );
191
+		// Fields Controller
192
+		add_filter( 'frm_field_type', 'FrmFieldsController::change_type' );
193
+		add_action( 'frm_field_input_html', 'FrmFieldsController::input_html' );
194
+		add_filter( 'frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3 );
195
+		add_filter( 'frm_field_label_seen', 'FrmFieldsController::check_label' );
196 196
 
197 197
 		// Forms Controller
198 198
 		add_filter( 'frm_form_classes', 'FrmFormsController::form_classes' );
199 199
 
200
-        // Styles Controller
201
-        add_filter( 'frm_use_important_width', 'FrmStylesController::important_style', 10, 2 );
202
-    }
200
+		// Styles Controller
201
+		add_filter( 'frm_use_important_width', 'FrmStylesController::important_style', 10, 2 );
202
+	}
203 203
 
204 204
 	public static function load_view_hooks() {
205
-        // Hooks go here when a view is loaded
206
-    }
205
+		// Hooks go here when a view is loaded
206
+	}
207 207
 
208 208
 	public static function load_multisite_hooks() {
209 209
 		add_action( 'init', 'FrmAppController::front_head' );
210 210
 		add_action( 'wpmu_upgrade_site', 'FrmAppController::network_upgrade_site' );
211 211
 
212
-        // drop tables when mu site is deleted
213
-        add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' );
214
-    }
212
+		// drop tables when mu site is deleted
213
+		add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' );
214
+	}
215 215
 }
Please login to merge, or discard this patch.
classes/controllers/FrmSettingsController.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -2,78 +2,78 @@
 block discarded – undo
2 2
 
3 3
 class FrmSettingsController {
4 4
 
5
-    public static function menu() {
5
+	public static function menu() {
6 6
 		// Make sure admins can see the menu items
7 7
 		FrmAppHelper::force_capability( 'frm_change_settings' );
8 8
 
9
-        add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' );
10
-    }
9
+		add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' );
10
+	}
11 11
 
12
-    public static function license_box() {
12
+	public static function license_box() {
13 13
 		$a = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' );
14
-        include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' );
15
-    }
14
+		include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' );
15
+	}
16 16
 
17
-    public static function display_form( $errors = array(), $message = '' ) {
18
-        global $frm_vars;
17
+	public static function display_form( $errors = array(), $message = '' ) {
18
+		global $frm_vars;
19 19
 
20
-        $frm_settings = FrmAppHelper::get_settings();
21
-        $frm_roles = FrmAppHelper::frm_capabilities();
20
+		$frm_settings = FrmAppHelper::get_settings();
21
+		$frm_roles = FrmAppHelper::frm_capabilities();
22 22
 
23
-        $uploads = wp_upload_dir();
24
-        $target_path = $uploads['basedir'] . '/formidable/css';
23
+		$uploads = wp_upload_dir();
24
+		$target_path = $uploads['basedir'] . '/formidable/css';
25 25
 
26 26
 		$sections = array();
27 27
 		if ( apply_filters( 'frm_include_addon_page', false ) ) {
28 28
 			$sections['licenses'] = array( 'class' => 'FrmAddonsController', 'function' => 'show_addons' );
29 29
 		}
30
-        $sections = apply_filters( 'frm_add_settings_section', $sections );
30
+		$sections = apply_filters( 'frm_add_settings_section', $sections );
31 31
 
32
-        $captcha_lang = FrmAppHelper::locales( 'captcha' );
32
+		$captcha_lang = FrmAppHelper::locales( 'captcha' );
33 33
 
34
-        require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' );
35
-    }
34
+		require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' );
35
+	}
36 36
 
37
-    public static function process_form( $stop_load = false ) {
38
-        global $frm_vars;
37
+	public static function process_form( $stop_load = false ) {
38
+		global $frm_vars;
39 39
 
40
-        $frm_settings = FrmAppHelper::get_settings();
40
+		$frm_settings = FrmAppHelper::get_settings();
41 41
 
42 42
 		$process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' );
43 43
 		if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) {
44
-            wp_die( $frm_settings->admin_permission );
45
-        }
44
+			wp_die( $frm_settings->admin_permission );
45
+		}
46 46
 
47
-        $errors = array();
48
-        $message = '';
47
+		$errors = array();
48
+		$message = '';
49 49
 
50
-        if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) {
51
-            //$errors = $frm_settings->validate($_POST,array());
52
-            $frm_settings->update( stripslashes_deep( $_POST ) );
50
+		if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) {
51
+			//$errors = $frm_settings->validate($_POST,array());
52
+			$frm_settings->update( stripslashes_deep( $_POST ) );
53 53
 
54
-            if ( empty( $errors ) ) {
55
-                $frm_settings->store();
56
-                $message = __( 'Settings Saved', 'formidable' );
57
-            }
58
-        } else {
59
-            $message = __( 'Settings Saved', 'formidable' );
60
-        }
54
+			if ( empty( $errors ) ) {
55
+				$frm_settings->store();
56
+				$message = __( 'Settings Saved', 'formidable' );
57
+			}
58
+		} else {
59
+			$message = __( 'Settings Saved', 'formidable' );
60
+		}
61 61
 
62 62
 		if ( $stop_load == 'stop_load' ) {
63
-            $frm_vars['settings_routed'] = true;
64
-            return;
65
-        }
63
+			$frm_vars['settings_routed'] = true;
64
+			return;
65
+		}
66 66
 
67
-        self::display_form( $errors, $message );
68
-    }
67
+		self::display_form( $errors, $message );
68
+	}
69 69
 
70
-    public static function route( $stop_load = false ) {
71
-        $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
70
+	public static function route( $stop_load = false ) {
71
+		$action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
72 72
 		$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
73
-        if ( $action == 'process-form' ) {
74
-            return self::process_form( $stop_load );
75
-        } else if ( $stop_load != 'stop_load' ) {
76
-            return self::display_form();
77
-        }
78
-    }
73
+		if ( $action == 'process-form' ) {
74
+			return self::process_form( $stop_load );
75
+		} else if ( $stop_load != 'stop_load' ) {
76
+			return self::display_form();
77
+		}
78
+	}
79 79
 }
Please login to merge, or discard this patch.
classes/controllers/FrmStylesController.php 2 patches
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -41,25 +41,25 @@  discard block
 block discarded – undo
41 41
     }
42 42
 
43 43
     public static function menu() {
44
-        add_submenu_page('formidable', 'Formidable | '. __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route');
44
+        add_submenu_page( 'formidable', 'Formidable | ' . __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route' );
45 45
     }
46 46
 
47 47
     public static function admin_init() {
48
-        if ( ! FrmAppHelper::is_admin_page('formidable-styles') ) {
48
+        if ( ! FrmAppHelper::is_admin_page( 'formidable-styles' ) ) {
49 49
             return;
50 50
         }
51 51
 
52 52
         self::load_pro_hooks();
53
-        wp_enqueue_script('jquery-ui-datepicker');
53
+        wp_enqueue_script( 'jquery-ui-datepicker' );
54 54
 
55 55
         $version = FrmAppHelper::plugin_version();
56 56
 		wp_enqueue_script( 'jquery-frm-themepicker', FrmAppHelper::plugin_url() . '/js/jquery/jquery-ui-themepicker.js', array( 'jquery' ), $version );
57 57
 
58
-        wp_enqueue_style('frm-custom-theme', admin_url('admin-ajax.php') .'?action=frmpro_css');
58
+        wp_enqueue_style( 'frm-custom-theme', admin_url( 'admin-ajax.php' ) . '?action=frmpro_css' );
59 59
 
60
-        $style = apply_filters('frm_style_head', false);
60
+        $style = apply_filters( 'frm_style_head', false );
61 61
         if ( $style ) {
62
-            wp_enqueue_style('frm-single-custom-theme', admin_url('admin-ajax.php') .'?action=frmpro_load_css&flat=1&'. http_build_query($style->post_content));
62
+            wp_enqueue_style( 'frm-single-custom-theme', admin_url( 'admin-ajax.php' ) . '?action=frmpro_load_css&flat=1&' . http_build_query( $style->post_content ) );
63 63
         }
64 64
     }
65 65
 
@@ -129,18 +129,18 @@  discard block
 block discarded – undo
129 129
 
130 130
 	public static function new_style( $return = '' ) {
131 131
         FrmAppHelper::update_message( __( 'create multiple styling templates', 'formidable' ), 'wrap' );
132
-        self::load_styler('default');
132
+        self::load_styler( 'default' );
133 133
     }
134 134
 
135 135
 	public static function duplicate() {
136 136
 		FrmAppHelper::update_message( __( 'duplicate styling templates', 'formidable' ), 'wrap' );
137
-		self::load_styler('default');
137
+		self::load_styler( 'default' );
138 138
 	}
139 139
 
140 140
 	public static function edit( $style_id = false, $message = '' ) {
141 141
         if ( ! $style_id ) {
142 142
 			$style_id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
143
-            if ( empty($style_id) ) {
143
+            if ( empty( $style_id ) ) {
144 144
                 $style_id = 'default';
145 145
             }
146 146
         }
@@ -148,12 +148,12 @@  discard block
 block discarded – undo
148 148
         if ( 'default' == $style_id ) {
149 149
             $style = 'default';
150 150
         } else {
151
-            $frm_style = new FrmStyle($style_id);
151
+            $frm_style = new FrmStyle( $style_id );
152 152
             $style = $frm_style->get_one();
153 153
             $style = $style->ID;
154 154
         }
155 155
 
156
-        self::load_styler($style, $message);
156
+        self::load_styler( $style, $message );
157 157
     }
158 158
 
159 159
     public static function save() {
@@ -163,17 +163,17 @@  discard block
 block discarded – undo
163 163
 		$style_nonce = FrmAppHelper::get_post_param( 'frm_style', '', 'sanitize_text_field' );
164 164
 
165 165
 		if ( $post_id !== false && wp_verify_nonce( $style_nonce, 'frm_style_nonce' ) ) {
166
-            $id = $frm_style->update($post_id);
167
-            if ( empty($post_id) && ! empty($id) ) {
166
+            $id = $frm_style->update( $post_id );
167
+            if ( empty( $post_id ) && ! empty( $id ) ) {
168 168
                 // set the post id to the new style so it will be loaded for editing
169
-                $post_id = reset($id);
169
+                $post_id = reset( $id );
170 170
             }
171 171
             // include the CSS that includes this style
172 172
 			echo '<link href="' . esc_url( admin_url( 'admin-ajax.php' ) . '?action=frmpro_css' ) . '" type="text/css" rel="Stylesheet" class="frm-custom-theme" />';
173 173
             $message = __( 'Your styling settings have been saved.', 'formidable' );
174 174
         }
175 175
 
176
-        return self::edit($post_id, $message);
176
+        return self::edit( $post_id, $message );
177 177
     }
178 178
 
179 179
 	public static function load_styler( $style, $message = '' ) {
@@ -182,15 +182,15 @@  discard block
 block discarded – undo
182 182
         $frm_style = new FrmStyle();
183 183
         $styles = $frm_style->get_all();
184 184
 
185
-        if ( is_numeric($style) ) {
186
-            $style = $styles[ $style ];
185
+        if ( is_numeric( $style ) ) {
186
+            $style = $styles[$style];
187 187
         } else if ( 'default' == $style ) {
188
-            $style = $frm_style->get_default_style($styles);
188
+            $style = $frm_style->get_default_style( $styles );
189 189
         }
190 190
 
191 191
         self::add_meta_boxes();
192 192
 
193
-        include(FrmAppHelper::plugin_path() .'/classes/views/styles/show.php');
193
+        include( FrmAppHelper::plugin_path() . '/classes/views/styles/show.php' );
194 194
     }
195 195
 
196 196
 	/**
@@ -200,13 +200,13 @@  discard block
 block discarded – undo
200 200
 	private static function manage( $message = '', $forms = array() ) {
201 201
         $frm_style = new FrmStyle();
202 202
         $styles = $frm_style->get_all();
203
-        $default_style = $frm_style->get_default_style($styles);
203
+        $default_style = $frm_style->get_default_style( $styles );
204 204
 
205
-        if ( empty($forms) ) {
205
+        if ( empty( $forms ) ) {
206 206
             $forms = FrmForm::get_published_forms();
207 207
         }
208 208
 
209
-        include(FrmAppHelper::plugin_path() .'/classes/views/styles/manage.php');
209
+        include( FrmAppHelper::plugin_path() . '/classes/views/styles/manage.php' );
210 210
     }
211 211
 
212 212
     private static function manage_styles() {
@@ -219,31 +219,31 @@  discard block
 block discarded – undo
219 219
 
220 220
 		$forms = FrmForm::get_published_forms();
221 221
         foreach ( $forms as $form ) {
222
-            if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) {
222
+            if ( $_POST['style'][$form->id] == $_POST['prev_style'][$form->id] ) {
223 223
                 continue;
224 224
             }
225 225
 
226
-            $form->options['custom_style'] = $_POST['style'][ $form->id ];
226
+            $form->options['custom_style'] = $_POST['style'][$form->id];
227 227
 
228 228
 			$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $form->options ) ), array( 'id' => $form->id ) );
229
-            unset($form);
229
+            unset( $form );
230 230
         }
231 231
 
232 232
         $message = __( 'Your form styles have been saved.', 'formidable' );
233
-        return self::manage($message, $forms);
233
+        return self::manage( $message, $forms );
234 234
     }
235 235
 
236 236
     public static function custom_css( $message = '', $style = null ) {
237
-        wp_enqueue_style('codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css');
238
-        wp_enqueue_script('codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7');
237
+        wp_enqueue_style( 'codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css' );
238
+        wp_enqueue_script( 'codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7' );
239 239
         wp_enqueue_script( 'codemirror-css', FrmAppHelper::plugin_url() . '/js/codemirror/css.js', array( 'codemirror' ), '4.7' );
240 240
 
241
-        if ( ! isset($style) ) {
241
+        if ( ! isset( $style ) ) {
242 242
             $frm_style = new FrmStyle();
243 243
             $style = $frm_style->get_default_style();
244 244
         }
245 245
 
246
-        include(FrmAppHelper::plugin_path() .'/classes/views/styles/custom_css.php');
246
+        include( FrmAppHelper::plugin_path() . '/classes/views/styles/custom_css.php' );
247 247
     }
248 248
 
249 249
     public static function save_css() {
@@ -253,11 +253,11 @@  discard block
 block discarded – undo
253 253
 		$post_id = FrmAppHelper::get_post_param( 'ID', false, 'sanitize_text_field' );
254 254
 		$nonce = FrmAppHelper::get_post_param( 'frm_custom_css', '', 'sanitize_text_field' );
255 255
 		if ( wp_verify_nonce( $nonce, 'frm_custom_css_nonce' ) ) {
256
-            $frm_style->update($post_id);
256
+            $frm_style->update( $post_id );
257 257
             $message = __( 'Your styling settings have been saved.', 'formidable' );
258 258
         }
259 259
 
260
-        return self::custom_css($message);
260
+        return self::custom_css( $message );
261 261
     }
262 262
 
263 263
     public static function route() {
@@ -303,13 +303,13 @@  discard block
 block discarded – undo
303 303
 
304 304
         // remove the # from the colors
305 305
         foreach ( $_GET['frm_style_setting']['post_content'] as $k => $v ) {
306
-            if ( ! is_array($v) && strpos($v, '#') === 0 ) {
307
-                $_GET['frm_style_setting']['post_content'][ $k ] = str_replace( '#', '', $v );
306
+            if ( ! is_array( $v ) && strpos( $v, '#' ) === 0 ) {
307
+                $_GET['frm_style_setting']['post_content'][$k] = str_replace( '#', '', $v );
308 308
             }
309 309
         }
310 310
 
311 311
         echo '<style type="text/css">';
312
-        include(FrmAppHelper::plugin_path() .'/css/_single_theme.css.php');
312
+        include( FrmAppHelper::plugin_path() . '/css/_single_theme.css.php' );
313 313
         echo '</style>';
314 314
         wp_die();
315 315
     }
@@ -331,24 +331,24 @@  discard block
 block discarded – undo
331 331
         );
332 332
 
333 333
         foreach ( $meta_boxes as $nicename => $name ) {
334
-            add_meta_box( $nicename .'-style', $name, 'FrmStylesController::include_style_section', self::$screen, 'side', 'default', $nicename );
335
-            unset($nicename, $name);
334
+            add_meta_box( $nicename . '-style', $name, 'FrmStylesController::include_style_section', self::$screen, 'side', 'default', $nicename );
335
+            unset( $nicename, $name );
336 336
         }
337 337
     }
338 338
 
339 339
 	public static function include_style_section( $atts, $sec ) {
340
-        extract($atts);
340
+        extract( $atts );
341 341
 		$current_tab = FrmAppHelper::simple_get( 'page-tab', 'sanitize_title', 'default' );
342
-        include(FrmAppHelper::plugin_path() .'/classes/views/styles/_'. $sec['args'] .'.php');
342
+        include( FrmAppHelper::plugin_path() . '/classes/views/styles/_' . $sec['args'] . '.php' );
343 343
     }
344 344
 
345 345
     public static function load_css() {
346
-        header('Content-type: text/css');
346
+        header( 'Content-type: text/css' );
347 347
 
348 348
         $frm_style = new FrmStyle();
349 349
         $defaults = $frm_style->get_defaults();
350 350
 
351
-        include(FrmAppHelper::plugin_path() .'/css/_single_theme.css.php');
351
+        include( FrmAppHelper::plugin_path() . '/css/_single_theme.css.php' );
352 352
         wp_die();
353 353
     }
354 354
 
@@ -407,11 +407,11 @@  discard block
 block discarded – undo
407 407
             $style = 'default';
408 408
         }
409 409
 
410
-        $frm_style = new FrmStyle($style);
410
+        $frm_style = new FrmStyle( $style );
411 411
         $style = $frm_style->get_one();
412 412
 
413 413
         if ( $style ) {
414
-            $class .= ' frm_style_'. $style->post_name;
414
+            $class .= ' frm_style_' . $style->post_name;
415 415
         }
416 416
 
417 417
         return $class;
@@ -421,14 +421,14 @@  discard block
 block discarded – undo
421 421
      * @param string $val
422 422
      */
423 423
 	public static function get_style_val( $val, $form = 'default' ) {
424
-        $style = self::get_form_style($form);
425
-        if ( $style && isset( $style->post_content[ $val ] ) ) {
426
-            return $style->post_content[ $val ];
424
+        $style = self::get_form_style( $form );
425
+        if ( $style && isset( $style->post_content[$val] ) ) {
426
+            return $style->post_content[$val];
427 427
         }
428 428
     }
429 429
 
430 430
 	public static function show_entry_styles( $default_styles ) {
431
-        $frm_style = new FrmStyle('default');
431
+        $frm_style = new FrmStyle( 'default' );
432 432
         $style = $frm_style->get_one();
433 433
 
434 434
         if ( ! $style ) {
@@ -442,15 +442,15 @@  discard block
 block discarded – undo
442 442
             } else if ( 'alt_bg_color' == $name ) {
443 443
                 $setting = 'bg_color_active';
444 444
             }
445
-            $default_styles[ $name ] = $style->post_content[ $setting ];
446
-            unset($name, $val);
445
+            $default_styles[$name] = $style->post_content[$setting];
446
+            unset( $name, $val );
447 447
         }
448 448
 
449 449
         return $default_styles;
450 450
     }
451 451
 
452 452
 	public static function &important_style( $important, $field ) {
453
-        $important = self::get_style_val('important_style', $field['form_id']);
453
+        $important = self::get_style_val( 'important_style', $field['form_id'] );
454 454
         return $important;
455 455
     }
456 456
 
@@ -476,18 +476,18 @@  discard block
 block discarded – undo
476 476
     	$i = 0;
477 477
     	$first_open = false;
478 478
     	do {
479
-			if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[ $page ] ) || ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
479
+			if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[$page] ) || ! isset( $wp_meta_boxes[$page][$context] ) ) {
480 480
 				break;
481 481
 			}
482 482
 
483 483
     		foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
484
-    			if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
485
-    				foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
484
+    			if ( isset( $wp_meta_boxes[$page][$context][$priority] ) ) {
485
+    				foreach ( $wp_meta_boxes[$page][$context][$priority] as $box ) {
486 486
     					if ( false == $box || ! $box['title'] ) {
487 487
     						continue;
488 488
 						}
489 489
 
490
-    					$i++;
490
+    					$i ++;
491 491
     					$hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : '';
492 492
 
493 493
     					if ( ! $first_open && empty( $hidden_class ) ) {
Please login to merge, or discard this patch.
Indentation   +320 added lines, -320 removed lines patch added patch discarded remove patch
@@ -1,21 +1,21 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class FrmStylesController {
4
-    public static $post_type = 'frm_styles';
5
-    public static $screen = 'formidable_page_formidable-styles';
6
-
7
-    public static function load_pro_hooks() {
8
-        if ( FrmAppHelper::pro_is_installed() ) {
9
-            FrmProStylesController::load_pro_hooks();
10
-        }
11
-    }
12
-
13
-    public static function register_post_types() {
14
-        register_post_type( self::$post_type, array(
15
-            'label' => __( 'Styles', 'formidable' ),
16
-            'public' => false,
17
-            'show_ui' => false,
18
-            'capability_type' => 'page',
4
+	public static $post_type = 'frm_styles';
5
+	public static $screen = 'formidable_page_formidable-styles';
6
+
7
+	public static function load_pro_hooks() {
8
+		if ( FrmAppHelper::pro_is_installed() ) {
9
+			FrmProStylesController::load_pro_hooks();
10
+		}
11
+	}
12
+
13
+	public static function register_post_types() {
14
+		register_post_type( self::$post_type, array(
15
+			'label' => __( 'Styles', 'formidable' ),
16
+			'public' => false,
17
+			'show_ui' => false,
18
+			'capability_type' => 'page',
19 19
 			'capabilities' => array(
20 20
 				'edit_post'		=> 'frm_change_settings',
21 21
 				'edit_posts'	=> 'frm_change_settings',
@@ -25,11 +25,11 @@  discard block
 block discarded – undo
25 25
 				'delete_posts'	=> 'frm_change_settings',
26 26
 				'read_private_posts' => 'read_private_posts',
27 27
 			),
28
-            'supports' => array(
28
+			'supports' => array(
29 29
 				'title',
30
-            ),
31
-            'has_archive' => false,
32
-            'labels' => array(
30
+			),
31
+			'has_archive' => false,
32
+			'labels' => array(
33 33
 				'name' => __( 'Styles', 'formidable' ),
34 34
 				'singular_name' => __( 'Style', 'formidable' ),
35 35
 				'menu_name' => __( 'Style', 'formidable' ),
@@ -37,31 +37,31 @@  discard block
 block discarded – undo
37 37
 				'add_new_item' => __( 'Create a New Style', 'formidable' ),
38 38
 				'edit_item'    => __( 'Edit Style', 'formidable' ),
39 39
 			),
40
-        ) );
41
-    }
40
+		) );
41
+	}
42 42
 
43
-    public static function menu() {
44
-        add_submenu_page('formidable', 'Formidable | '. __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route');
45
-    }
43
+	public static function menu() {
44
+		add_submenu_page('formidable', 'Formidable | '. __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route');
45
+	}
46 46
 
47
-    public static function admin_init() {
48
-        if ( ! FrmAppHelper::is_admin_page('formidable-styles') ) {
49
-            return;
50
-        }
47
+	public static function admin_init() {
48
+		if ( ! FrmAppHelper::is_admin_page('formidable-styles') ) {
49
+			return;
50
+		}
51 51
 
52
-        self::load_pro_hooks();
53
-        wp_enqueue_script('jquery-ui-datepicker');
52
+		self::load_pro_hooks();
53
+		wp_enqueue_script('jquery-ui-datepicker');
54 54
 
55
-        $version = FrmAppHelper::plugin_version();
55
+		$version = FrmAppHelper::plugin_version();
56 56
 		wp_enqueue_script( 'jquery-frm-themepicker', FrmAppHelper::plugin_url() . '/js/jquery/jquery-ui-themepicker.js', array( 'jquery' ), $version );
57 57
 
58
-        wp_enqueue_style('frm-custom-theme', admin_url('admin-ajax.php') .'?action=frmpro_css');
58
+		wp_enqueue_style('frm-custom-theme', admin_url('admin-ajax.php') .'?action=frmpro_css');
59 59
 
60
-        $style = apply_filters('frm_style_head', false);
61
-        if ( $style ) {
62
-            wp_enqueue_style('frm-single-custom-theme', admin_url('admin-ajax.php') .'?action=frmpro_load_css&flat=1&'. http_build_query($style->post_content));
63
-        }
64
-    }
60
+		$style = apply_filters('frm_style_head', false);
61
+		if ( $style ) {
62
+			wp_enqueue_style('frm-single-custom-theme', admin_url('admin-ajax.php') .'?action=frmpro_load_css&flat=1&'. http_build_query($style->post_content));
63
+		}
64
+	}
65 65
 
66 66
 	public static function enqueue_css( $register = 'enqueue' ) {
67 67
 		global $frm_vars;
@@ -128,227 +128,227 @@  discard block
 block discarded – undo
128 128
 	}
129 129
 
130 130
 	public static function new_style( $return = '' ) {
131
-        self::load_styler('default');
132
-    }
131
+		self::load_styler('default');
132
+	}
133 133
 
134 134
 	public static function duplicate() {
135 135
 		self::load_styler('default');
136 136
 	}
137 137
 
138 138
 	public static function edit( $style_id = false, $message = '' ) {
139
-        if ( ! $style_id ) {
139
+		if ( ! $style_id ) {
140 140
 			$style_id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
141
-            if ( empty($style_id) ) {
142
-                $style_id = 'default';
143
-            }
144
-        }
145
-
146
-        if ( 'default' == $style_id ) {
147
-            $style = 'default';
148
-        } else {
149
-            $frm_style = new FrmStyle($style_id);
150
-            $style = $frm_style->get_one();
151
-            $style = $style->ID;
152
-        }
153
-
154
-        self::load_styler($style, $message);
155
-    }
156
-
157
-    public static function save() {
158
-        $frm_style = new FrmStyle();
159
-        $message = '';
141
+			if ( empty($style_id) ) {
142
+				$style_id = 'default';
143
+			}
144
+		}
145
+
146
+		if ( 'default' == $style_id ) {
147
+			$style = 'default';
148
+		} else {
149
+			$frm_style = new FrmStyle($style_id);
150
+			$style = $frm_style->get_one();
151
+			$style = $style->ID;
152
+		}
153
+
154
+		self::load_styler($style, $message);
155
+	}
156
+
157
+	public static function save() {
158
+		$frm_style = new FrmStyle();
159
+		$message = '';
160 160
 		$post_id = FrmAppHelper::get_post_param( 'ID', false, 'sanitize_title' );
161 161
 		$style_nonce = FrmAppHelper::get_post_param( 'frm_style', '', 'sanitize_text_field' );
162 162
 
163 163
 		if ( $post_id !== false && wp_verify_nonce( $style_nonce, 'frm_style_nonce' ) ) {
164
-            $id = $frm_style->update($post_id);
165
-            if ( empty($post_id) && ! empty($id) ) {
166
-                // set the post id to the new style so it will be loaded for editing
167
-                $post_id = reset($id);
168
-            }
169
-            // include the CSS that includes this style
164
+			$id = $frm_style->update($post_id);
165
+			if ( empty($post_id) && ! empty($id) ) {
166
+				// set the post id to the new style so it will be loaded for editing
167
+				$post_id = reset($id);
168
+			}
169
+			// include the CSS that includes this style
170 170
 			echo '<link href="' . esc_url( admin_url( 'admin-ajax.php' ) . '?action=frmpro_css' ) . '" type="text/css" rel="Stylesheet" class="frm-custom-theme" />';
171
-            $message = __( 'Your styling settings have been saved.', 'formidable' );
172
-        }
171
+			$message = __( 'Your styling settings have been saved.', 'formidable' );
172
+		}
173 173
 
174
-        return self::edit($post_id, $message);
175
-    }
174
+		return self::edit($post_id, $message);
175
+	}
176 176
 
177 177
 	public static function load_styler( $style, $message = '' ) {
178
-        global $frm_settings;
178
+		global $frm_settings;
179 179
 
180
-        $frm_style = new FrmStyle();
181
-        $styles = $frm_style->get_all();
180
+		$frm_style = new FrmStyle();
181
+		$styles = $frm_style->get_all();
182 182
 
183
-        if ( is_numeric($style) ) {
184
-            $style = $styles[ $style ];
185
-        } else if ( 'default' == $style ) {
186
-            $style = $frm_style->get_default_style($styles);
187
-        }
183
+		if ( is_numeric($style) ) {
184
+			$style = $styles[ $style ];
185
+		} else if ( 'default' == $style ) {
186
+			$style = $frm_style->get_default_style($styles);
187
+		}
188 188
 
189
-        self::add_meta_boxes();
189
+		self::add_meta_boxes();
190 190
 
191
-        include(FrmAppHelper::plugin_path() .'/classes/views/styles/show.php');
192
-    }
191
+		include(FrmAppHelper::plugin_path() .'/classes/views/styles/show.php');
192
+	}
193 193
 
194 194
 	/**
195 195
 	 * @param string $message
196 196
 	 * @param array|object $forms
197 197
 	 */
198 198
 	private static function manage( $message = '', $forms = array() ) {
199
-        $frm_style = new FrmStyle();
200
-        $styles = $frm_style->get_all();
201
-        $default_style = $frm_style->get_default_style($styles);
199
+		$frm_style = new FrmStyle();
200
+		$styles = $frm_style->get_all();
201
+		$default_style = $frm_style->get_default_style($styles);
202 202
 
203
-        if ( empty($forms) ) {
204
-            $forms = FrmForm::get_published_forms();
205
-        }
203
+		if ( empty($forms) ) {
204
+			$forms = FrmForm::get_published_forms();
205
+		}
206 206
 
207
-        include(FrmAppHelper::plugin_path() .'/classes/views/styles/manage.php');
208
-    }
207
+		include(FrmAppHelper::plugin_path() .'/classes/views/styles/manage.php');
208
+	}
209 209
 
210
-    private static function manage_styles() {
210
+	private static function manage_styles() {
211 211
 		$style_nonce = FrmAppHelper::get_post_param( 'frm_manage_style', '', 'sanitize_text_field' );
212 212
 		if ( ! $_POST || ! isset( $_POST['style'] ) || ! wp_verify_nonce( $style_nonce, 'frm_manage_style_nonce' ) ) {
213
-            return self::manage();
214
-        }
213
+			return self::manage();
214
+		}
215 215
 
216
-        global $wpdb;
216
+		global $wpdb;
217 217
 
218 218
 		$forms = FrmForm::get_published_forms();
219
-        foreach ( $forms as $form ) {
220
-            if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) {
221
-                continue;
222
-            }
219
+		foreach ( $forms as $form ) {
220
+			if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) {
221
+				continue;
222
+			}
223 223
 
224
-            $form->options['custom_style'] = $_POST['style'][ $form->id ];
224
+			$form->options['custom_style'] = $_POST['style'][ $form->id ];
225 225
 
226 226
 			$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $form->options ) ), array( 'id' => $form->id ) );
227
-            unset($form);
228
-        }
227
+			unset($form);
228
+		}
229 229
 
230
-        $message = __( 'Your form styles have been saved.', 'formidable' );
231
-        return self::manage($message, $forms);
232
-    }
230
+		$message = __( 'Your form styles have been saved.', 'formidable' );
231
+		return self::manage($message, $forms);
232
+	}
233 233
 
234
-    public static function custom_css( $message = '', $style = null ) {
235
-        wp_enqueue_style('codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css');
236
-        wp_enqueue_script('codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7');
237
-        wp_enqueue_script( 'codemirror-css', FrmAppHelper::plugin_url() . '/js/codemirror/css.js', array( 'codemirror' ), '4.7' );
234
+	public static function custom_css( $message = '', $style = null ) {
235
+		wp_enqueue_style('codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css');
236
+		wp_enqueue_script('codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7');
237
+		wp_enqueue_script( 'codemirror-css', FrmAppHelper::plugin_url() . '/js/codemirror/css.js', array( 'codemirror' ), '4.7' );
238 238
 
239
-        if ( ! isset($style) ) {
240
-            $frm_style = new FrmStyle();
241
-            $style = $frm_style->get_default_style();
242
-        }
239
+		if ( ! isset($style) ) {
240
+			$frm_style = new FrmStyle();
241
+			$style = $frm_style->get_default_style();
242
+		}
243 243
 
244
-        include(FrmAppHelper::plugin_path() .'/classes/views/styles/custom_css.php');
245
-    }
244
+		include(FrmAppHelper::plugin_path() .'/classes/views/styles/custom_css.php');
245
+	}
246 246
 
247
-    public static function save_css() {
248
-        $frm_style = new FrmStyle();
247
+	public static function save_css() {
248
+		$frm_style = new FrmStyle();
249 249
 
250
-        $message = '';
250
+		$message = '';
251 251
 		$post_id = FrmAppHelper::get_post_param( 'ID', false, 'sanitize_text_field' );
252 252
 		$nonce = FrmAppHelper::get_post_param( 'frm_custom_css', '', 'sanitize_text_field' );
253 253
 		if ( wp_verify_nonce( $nonce, 'frm_custom_css_nonce' ) ) {
254
-            $frm_style->update($post_id);
255
-            $message = __( 'Your styling settings have been saved.', 'formidable' );
256
-        }
254
+			$frm_style->update($post_id);
255
+			$message = __( 'Your styling settings have been saved.', 'formidable' );
256
+		}
257 257
 
258
-        return self::custom_css($message);
259
-    }
258
+		return self::custom_css($message);
259
+	}
260 260
 
261
-    public static function route() {
261
+	public static function route() {
262 262
 		$action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' );
263 263
 
264
-        switch ( $action ) {
265
-            case 'edit':
266
-            case 'save':
267
-            case 'manage':
268
-            case 'manage_styles':
269
-            case 'custom_css':
270
-            case 'save_css':
264
+		switch ( $action ) {
265
+			case 'edit':
266
+			case 'save':
267
+			case 'manage':
268
+			case 'manage_styles':
269
+			case 'custom_css':
270
+			case 'save_css':
271 271
 				return self::$action();
272
-            default:
273
-            	do_action( 'frm_style_action_route', $action );
274
-            	if ( apply_filters( 'frm_style_stop_action_route', false, $action ) ) {
275
-                	return;
276
-            	}
277
-
278
-                if ( 'new_style' == $action || 'duplicate' == $action ) {
279
-                    return self::$action();
280
-                }
281
-
282
-                return self::edit();
283
-        }
284
-    }
285
-
286
-    public static function reset_styling() {
287
-        check_ajax_referer( 'frm_ajax', 'nonce' );
288
-
289
-        $frm_style = new FrmStyle();
290
-        $defaults = $frm_style->get_defaults();
291
-
292
-        echo json_encode( $defaults );
293
-        wp_die();
294
-    }
295
-
296
-    public static function change_styling() {
297
-        check_ajax_referer( 'frm_ajax', 'nonce' );
298
-
299
-        $frm_style = new FrmStyle();
300
-        $defaults = $frm_style->get_defaults();
301
-
302
-        // remove the # from the colors
303
-        foreach ( $_GET['frm_style_setting']['post_content'] as $k => $v ) {
304
-            if ( ! is_array($v) && strpos($v, '#') === 0 ) {
305
-                $_GET['frm_style_setting']['post_content'][ $k ] = str_replace( '#', '', $v );
306
-            }
307
-        }
308
-
309
-        echo '<style type="text/css">';
310
-        include(FrmAppHelper::plugin_path() .'/css/_single_theme.css.php');
311
-        echo '</style>';
312
-        wp_die();
313
-    }
314
-
315
-    private static function add_meta_boxes() {
316
-
317
-        // setup meta boxes
318
-        $meta_boxes = array(
319
-            'general'           => __( 'General', 'formidable' ),
320
-            'field-labels'      => __( 'Field Labels', 'formidable' ),
321
-            'field-description' => __( 'Field Description', 'formidable' ),
322
-            'field-colors'      => __( 'Field Colors', 'formidable' ),
323
-            'field-sizes'       => __( 'Field Settings', 'formidable' ),
324
-            'check-box-radio-fields' => __( 'Check Box & Radio Fields', 'formidable' ),
325
-            'section-fields'    => __( 'Section Fields', 'formidable' ),
326
-            'date-fields'       => __( 'Date Fields', 'formidable' ),
327
-            'buttons'           => __( 'Buttons', 'formidable' ),
328
-            'form-messages'     => __( 'Form Messages', 'formidable' ),
329
-        );
330
-
331
-        foreach ( $meta_boxes as $nicename => $name ) {
332
-            add_meta_box( $nicename .'-style', $name, 'FrmStylesController::include_style_section', self::$screen, 'side', 'default', $nicename );
333
-            unset($nicename, $name);
334
-        }
335
-    }
272
+			default:
273
+				do_action( 'frm_style_action_route', $action );
274
+				if ( apply_filters( 'frm_style_stop_action_route', false, $action ) ) {
275
+					return;
276
+				}
277
+
278
+				if ( 'new_style' == $action || 'duplicate' == $action ) {
279
+					return self::$action();
280
+				}
281
+
282
+				return self::edit();
283
+		}
284
+	}
285
+
286
+	public static function reset_styling() {
287
+		check_ajax_referer( 'frm_ajax', 'nonce' );
288
+
289
+		$frm_style = new FrmStyle();
290
+		$defaults = $frm_style->get_defaults();
291
+
292
+		echo json_encode( $defaults );
293
+		wp_die();
294
+	}
295
+
296
+	public static function change_styling() {
297
+		check_ajax_referer( 'frm_ajax', 'nonce' );
298
+
299
+		$frm_style = new FrmStyle();
300
+		$defaults = $frm_style->get_defaults();
301
+
302
+		// remove the # from the colors
303
+		foreach ( $_GET['frm_style_setting']['post_content'] as $k => $v ) {
304
+			if ( ! is_array($v) && strpos($v, '#') === 0 ) {
305
+				$_GET['frm_style_setting']['post_content'][ $k ] = str_replace( '#', '', $v );
306
+			}
307
+		}
308
+
309
+		echo '<style type="text/css">';
310
+		include(FrmAppHelper::plugin_path() .'/css/_single_theme.css.php');
311
+		echo '</style>';
312
+		wp_die();
313
+	}
314
+
315
+	private static function add_meta_boxes() {
316
+
317
+		// setup meta boxes
318
+		$meta_boxes = array(
319
+			'general'           => __( 'General', 'formidable' ),
320
+			'field-labels'      => __( 'Field Labels', 'formidable' ),
321
+			'field-description' => __( 'Field Description', 'formidable' ),
322
+			'field-colors'      => __( 'Field Colors', 'formidable' ),
323
+			'field-sizes'       => __( 'Field Settings', 'formidable' ),
324
+			'check-box-radio-fields' => __( 'Check Box & Radio Fields', 'formidable' ),
325
+			'section-fields'    => __( 'Section Fields', 'formidable' ),
326
+			'date-fields'       => __( 'Date Fields', 'formidable' ),
327
+			'buttons'           => __( 'Buttons', 'formidable' ),
328
+			'form-messages'     => __( 'Form Messages', 'formidable' ),
329
+		);
330
+
331
+		foreach ( $meta_boxes as $nicename => $name ) {
332
+			add_meta_box( $nicename .'-style', $name, 'FrmStylesController::include_style_section', self::$screen, 'side', 'default', $nicename );
333
+			unset($nicename, $name);
334
+		}
335
+	}
336 336
 
337 337
 	public static function include_style_section( $atts, $sec ) {
338
-        extract($atts);
338
+		extract($atts);
339 339
 		$current_tab = FrmAppHelper::simple_get( 'page-tab', 'sanitize_title', 'default' );
340
-        include(FrmAppHelper::plugin_path() .'/classes/views/styles/_'. $sec['args'] .'.php');
341
-    }
340
+		include(FrmAppHelper::plugin_path() .'/classes/views/styles/_'. $sec['args'] .'.php');
341
+	}
342 342
 
343
-    public static function load_css() {
344
-        header('Content-type: text/css');
343
+	public static function load_css() {
344
+		header('Content-type: text/css');
345 345
 
346
-        $frm_style = new FrmStyle();
347
-        $defaults = $frm_style->get_defaults();
346
+		$frm_style = new FrmStyle();
347
+		$defaults = $frm_style->get_defaults();
348 348
 
349
-        include(FrmAppHelper::plugin_path() .'/css/_single_theme.css.php');
350
-        wp_die();
351
-    }
349
+		include(FrmAppHelper::plugin_path() .'/css/_single_theme.css.php');
350
+		wp_die();
351
+	}
352 352
 
353 353
 	public static function load_saved_css() {
354 354
 		$css = get_transient( 'frmpro_css' );
@@ -357,142 +357,142 @@  discard block
 block discarded – undo
357 357
 		wp_die();
358 358
 	}
359 359
 
360
-    /**
361
-     * Check if the Formidable styling should be loaded,
362
-     * then enqueue it for the footer
363
-     * @since 2.0
364
-     */
365
-    public static function enqueue_style() {
366
-        global $frm_vars;
367
-
368
-        if ( isset( $frm_vars['css_loaded'] ) && $frm_vars['css_loaded'] ) {
369
-            // the CSS has already been loaded
370
-            return;
371
-        }
372
-
373
-        $frm_settings = FrmAppHelper::get_settings();
374
-        if ( $frm_settings->load_style != 'none' ) {
375
-            wp_enqueue_style( 'formidable' );
376
-            $frm_vars['css_loaded'] = true;
377
-        }
378
-    }
379
-
380
-    // Get the stylesheets for the form settings page
381
-    public static function get_style_opts() {
382
-        $frm_style = new FrmStyle();
383
-        $styles = $frm_style->get_all();
384
-
385
-        return $styles;
386
-    }
387
-
388
-    public static function get_form_style( $form = 'default' ) {
389
-        $style = FrmFormsHelper::get_form_style( $form );
390
-
391
-        if ( empty( $style ) || 1 == $style ) {
392
-            $style = 'default';
393
-        }
394
-
395
-        $frm_style = new FrmStyle( $style );
396
-        return $frm_style->get_one();
397
-    }
398
-
399
-    /**
400
-     * @param string $class
401
-     * @param string $style
402
-     */
360
+	/**
361
+	 * Check if the Formidable styling should be loaded,
362
+	 * then enqueue it for the footer
363
+	 * @since 2.0
364
+	 */
365
+	public static function enqueue_style() {
366
+		global $frm_vars;
367
+
368
+		if ( isset( $frm_vars['css_loaded'] ) && $frm_vars['css_loaded'] ) {
369
+			// the CSS has already been loaded
370
+			return;
371
+		}
372
+
373
+		$frm_settings = FrmAppHelper::get_settings();
374
+		if ( $frm_settings->load_style != 'none' ) {
375
+			wp_enqueue_style( 'formidable' );
376
+			$frm_vars['css_loaded'] = true;
377
+		}
378
+	}
379
+
380
+	// Get the stylesheets for the form settings page
381
+	public static function get_style_opts() {
382
+		$frm_style = new FrmStyle();
383
+		$styles = $frm_style->get_all();
384
+
385
+		return $styles;
386
+	}
387
+
388
+	public static function get_form_style( $form = 'default' ) {
389
+		$style = FrmFormsHelper::get_form_style( $form );
390
+
391
+		if ( empty( $style ) || 1 == $style ) {
392
+			$style = 'default';
393
+		}
394
+
395
+		$frm_style = new FrmStyle( $style );
396
+		return $frm_style->get_one();
397
+	}
398
+
399
+	/**
400
+	 * @param string $class
401
+	 * @param string $style
402
+	 */
403 403
 	public static function get_form_style_class( $class, $style ) {
404
-        if ( 1 == $style ) {
405
-            $style = 'default';
406
-        }
404
+		if ( 1 == $style ) {
405
+			$style = 'default';
406
+		}
407 407
 
408
-        $frm_style = new FrmStyle($style);
409
-        $style = $frm_style->get_one();
408
+		$frm_style = new FrmStyle($style);
409
+		$style = $frm_style->get_one();
410 410
 
411
-        if ( $style ) {
412
-            $class .= ' frm_style_'. $style->post_name;
413
-        }
411
+		if ( $style ) {
412
+			$class .= ' frm_style_'. $style->post_name;
413
+		}
414 414
 
415
-        return $class;
416
-    }
415
+		return $class;
416
+	}
417 417
 
418
-    /**
419
-     * @param string $val
420
-     */
418
+	/**
419
+	 * @param string $val
420
+	 */
421 421
 	public static function get_style_val( $val, $form = 'default' ) {
422
-        $style = self::get_form_style($form);
423
-        if ( $style && isset( $style->post_content[ $val ] ) ) {
424
-            return $style->post_content[ $val ];
425
-        }
426
-    }
422
+		$style = self::get_form_style($form);
423
+		if ( $style && isset( $style->post_content[ $val ] ) ) {
424
+			return $style->post_content[ $val ];
425
+		}
426
+	}
427 427
 
428 428
 	public static function show_entry_styles( $default_styles ) {
429
-        $frm_style = new FrmStyle('default');
430
-        $style = $frm_style->get_one();
431
-
432
-        if ( ! $style ) {
433
-            return $default_styles;
434
-        }
435
-
436
-        foreach ( $default_styles as $name => $val ) {
437
-            $setting = $name;
438
-            if ( 'border_width' == $name ) {
439
-                $setting = 'field_border_width';
440
-            } else if ( 'alt_bg_color' == $name ) {
441
-                $setting = 'bg_color_active';
442
-            }
443
-            $default_styles[ $name ] = $style->post_content[ $setting ];
444
-            unset($name, $val);
445
-        }
446
-
447
-        return $default_styles;
448
-    }
429
+		$frm_style = new FrmStyle('default');
430
+		$style = $frm_style->get_one();
431
+
432
+		if ( ! $style ) {
433
+			return $default_styles;
434
+		}
435
+
436
+		foreach ( $default_styles as $name => $val ) {
437
+			$setting = $name;
438
+			if ( 'border_width' == $name ) {
439
+				$setting = 'field_border_width';
440
+			} else if ( 'alt_bg_color' == $name ) {
441
+				$setting = 'bg_color_active';
442
+			}
443
+			$default_styles[ $name ] = $style->post_content[ $setting ];
444
+			unset($name, $val);
445
+		}
446
+
447
+		return $default_styles;
448
+	}
449 449
 
450 450
 	public static function &important_style( $important, $field ) {
451
-        $important = self::get_style_val('important_style', $field['form_id']);
452
-        return $important;
453
-    }
451
+		$important = self::get_style_val('important_style', $field['form_id']);
452
+		return $important;
453
+	}
454 454
 
455
-    /**
456
-     * Fallback for WP < 3.6
457
-     */
458
-    public static function do_accordion_sections( $screen, $context, $object ) {
459
-        if ( function_exists( 'do_accordion_sections' ) ) {
460
-            return do_accordion_sections( $screen, $context, $object );
461
-        }
455
+	/**
456
+	 * Fallback for WP < 3.6
457
+	 */
458
+	public static function do_accordion_sections( $screen, $context, $object ) {
459
+		if ( function_exists( 'do_accordion_sections' ) ) {
460
+			return do_accordion_sections( $screen, $context, $object );
461
+		}
462 462
 
463
-    	global $wp_meta_boxes;
463
+		global $wp_meta_boxes;
464 464
 
465
-        $screen = 'formidable_page_formidable-styles';
466
-        $screen = convert_to_screen( $screen );
465
+		$screen = 'formidable_page_formidable-styles';
466
+		$screen = convert_to_screen( $screen );
467 467
 
468
-    	$page = $screen->id;
468
+		$page = $screen->id;
469 469
 
470
-    	$hidden = get_hidden_meta_boxes( $screen );
471
-    	?>
470
+		$hidden = get_hidden_meta_boxes( $screen );
471
+		?>
472 472
     	<div id="side-sortables" class="accordion-container">
473 473
     	<?php
474
-    	$i = 0;
475
-    	$first_open = false;
476
-    	do {
474
+		$i = 0;
475
+		$first_open = false;
476
+		do {
477 477
 			if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[ $page ] ) || ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
478 478
 				break;
479 479
 			}
480 480
 
481
-    		foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
482
-    			if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
483
-    				foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
484
-    					if ( false == $box || ! $box['title'] ) {
485
-    						continue;
481
+			foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
482
+				if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
483
+					foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
484
+						if ( false == $box || ! $box['title'] ) {
485
+							continue;
486 486
 						}
487 487
 
488
-    					$i++;
489
-    					$hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : '';
488
+						$i++;
489
+						$hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : '';
490 490
 
491
-    					if ( ! $first_open && empty( $hidden_class ) ) {
492
-    						$first_open = true;
493
-    					}
491
+						if ( ! $first_open && empty( $hidden_class ) ) {
492
+							$first_open = true;
493
+						}
494 494
 
495
-    					?>
495
+						?>
496 496
 						<div class="postbox <?php echo esc_attr( $box['id'] ); ?>">
497 497
 						<div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'formidable' ) ?>"><br/></div>
498 498
                         <h3 class='hndle'><span><?php echo esc_html( $box['title'] ); ?></span></h3>
@@ -503,13 +503,13 @@  discard block
 block discarded – undo
503 503
     						</div><!-- .accordion-section-content -->
504 504
     					</div><!-- .postbox -->
505 505
     					<?php
506
-    				}
507
-    			}
508
-    		}
509
-    	} while ( 0 );
510
-    	?>
506
+					}
507
+				}
508
+			}
509
+		} while ( 0 );
510
+		?>
511 511
     	</div><!-- .accordion-container -->
512 512
     	<?php
513
-    	return $i;
514
-    }
513
+		return $i;
514
+	}
515 515
 }
Please login to merge, or discard this patch.
classes/helpers/FrmEntriesHelper.php 2 patches
Indentation   +290 added lines, -290 removed lines patch added patch discarded remove patch
@@ -5,68 +5,68 @@  discard block
 block discarded – undo
5 5
 
6 6
 class FrmEntriesHelper {
7 7
 
8
-    public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
9
-        global $frm_vars;
10
-        $values = array();
8
+	public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
9
+		global $frm_vars;
10
+		$values = array();
11 11
 		foreach ( array( 'name' => '', 'description' => '', 'item_key' => '' ) as $var => $default ) {
12
-            $values[ $var ] = FrmAppHelper::get_post_param( $var, $default );
13
-        }
14
-
15
-        $values['fields'] = array();
16
-        if ( empty($fields) ) {
17
-            return apply_filters('frm_setup_new_entry', $values);
18
-        }
19
-
20
-        foreach ( (array) $fields as $field ) {
21
-            $new_value = self::get_field_value_for_new_entry( $field, $reset );
22
-
23
-            $field_array = array(
24
-                'id' => $field->id,
25
-                'value' => $new_value,
26
-                'default_value' => $field->default_value,
27
-                'name' => $field->name,
28
-                'description' => $field->description,
29
-                'type' => apply_filters('frm_field_type', $field->type, $field, $new_value),
30
-                'options' => $field->options,
31
-                'required' => $field->required,
32
-                'field_key' => $field->field_key,
33
-                'field_order' => $field->field_order,
34
-                'form_id' => $field->form_id,
12
+			$values[ $var ] = FrmAppHelper::get_post_param( $var, $default );
13
+		}
14
+
15
+		$values['fields'] = array();
16
+		if ( empty($fields) ) {
17
+			return apply_filters('frm_setup_new_entry', $values);
18
+		}
19
+
20
+		foreach ( (array) $fields as $field ) {
21
+			$new_value = self::get_field_value_for_new_entry( $field, $reset );
22
+
23
+			$field_array = array(
24
+				'id' => $field->id,
25
+				'value' => $new_value,
26
+				'default_value' => $field->default_value,
27
+				'name' => $field->name,
28
+				'description' => $field->description,
29
+				'type' => apply_filters('frm_field_type', $field->type, $field, $new_value),
30
+				'options' => $field->options,
31
+				'required' => $field->required,
32
+				'field_key' => $field->field_key,
33
+				'field_order' => $field->field_order,
34
+				'form_id' => $field->form_id,
35 35
 				'parent_form_id' => isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id,
36
-            );
36
+			);
37 37
 
38
-            $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
39
-            $opt_defaults['required_indicator'] = '';
38
+			$opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
39
+			$opt_defaults['required_indicator'] = '';
40 40
 			$opt_defaults['original_type'] = $field->type;
41 41
 
42 42
 			foreach ( $opt_defaults as $opt => $default_opt ) {
43
-                $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt;
44
-                unset($opt, $default_opt);
45
-            }
43
+				$field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt;
44
+				unset($opt, $default_opt);
45
+			}
46 46
 
47
-            unset($opt_defaults);
47
+			unset($opt_defaults);
48 48
 
49
-            if ( $field_array['custom_html'] == '' ) {
50
-                $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
51
-            }
49
+			if ( $field_array['custom_html'] == '' ) {
50
+				$field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
51
+			}
52 52
 
53
-            $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field);
54
-            $field_array = array_merge( $field->field_options, $field_array );
53
+			$field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field);
54
+			$field_array = array_merge( $field->field_options, $field_array );
55 55
 
56
-            $values['fields'][] = $field_array;
56
+			$values['fields'][] = $field_array;
57 57
 
58
-            if ( ! $form || ! isset($form->id) ) {
59
-                $form = FrmForm::getOne($field->form_id);
60
-            }
61
-        }
58
+			if ( ! $form || ! isset($form->id) ) {
59
+				$form = FrmForm::getOne($field->form_id);
60
+			}
61
+		}
62 62
 
63
-        $form->options = maybe_unserialize($form->options);
64
-        if ( is_array($form->options) ) {
65
-            foreach ( $form->options as $opt => $value ) {
66
-                $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value );
67
-                unset($opt, $value);
68
-            }
69
-        }
63
+		$form->options = maybe_unserialize($form->options);
64
+		if ( is_array($form->options) ) {
65
+			foreach ( $form->options as $opt => $value ) {
66
+				$values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value );
67
+				unset($opt, $value);
68
+			}
69
+		}
70 70
 
71 71
 		$form_defaults = FrmFormsHelper::get_default_opts();
72 72
 
@@ -76,18 +76,18 @@  discard block
 block discarded – undo
76 76
 		$values = array_merge( $form_defaults, $values );
77 77
 
78 78
 		return apply_filters( 'frm_setup_new_entry', $values );
79
-    }
79
+	}
80 80
 
81 81
 	/**
82
-	* Set the value for each field
83
-	* This function is used when the form is first loaded and on all page turns *for a new entry*
84
-	*
85
-	* @since 2.0.13
86
-	*
87
-	* @param object $field - this is passed by reference since it is an object
88
-	* @param boolean $reset
89
-	* @return string|array $new_value
90
-	*/
82
+	 * Set the value for each field
83
+	 * This function is used when the form is first loaded and on all page turns *for a new entry*
84
+	 *
85
+	 * @since 2.0.13
86
+	 *
87
+	 * @param object $field - this is passed by reference since it is an object
88
+	 * @param boolean $reset
89
+	 * @return string|array $new_value
90
+	 */
91 91
 	private static function get_field_value_for_new_entry( $field, $reset ) {
92 92
 		//If checkbox, multi-select dropdown, or checkbox data from entries field, the value should be an array
93 93
 		$return_array = FrmField::is_field_with_multiple_values( $field );
@@ -118,15 +118,15 @@  discard block
 block discarded – undo
118 118
 
119 119
 	public static function setup_edit_vars( $values, $record ) {
120 120
 		$values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' );
121
-        $values['form_id'] = $record->form_id;
122
-        $values['is_draft'] = $record->is_draft;
123
-        return apply_filters('frm_setup_edit_entry_vars', $values, $record);
124
-    }
121
+		$values['form_id'] = $record->form_id;
122
+		$values['is_draft'] = $record->is_draft;
123
+		return apply_filters('frm_setup_edit_entry_vars', $values, $record);
124
+	}
125 125
 
126
-    public static function get_admin_params( $form = null ) {
126
+	public static function get_admin_params( $form = null ) {
127 127
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_admin_params' );
128 128
 		return FrmForm::set_current_form( $form );
129
-    }
129
+	}
130 130
 
131 131
 	public static function set_current_form( $form_id ) {
132 132
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::set_current_form' );
@@ -138,280 +138,280 @@  discard block
 block discarded – undo
138 138
 		return FrmForm::get_current_form( $form_id );
139 139
 	}
140 140
 
141
-    public static function get_current_form_id() {
141
+	public static function get_current_form_id() {
142 142
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_current_form_id' );
143 143
 		return FrmForm::get_current_form_id();
144
-    }
144
+	}
145 145
 
146
-    public static function maybe_get_entry( &$entry ) {
146
+	public static function maybe_get_entry( &$entry ) {
147 147
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntry::maybe_get_entry' );
148 148
 		FrmEntry::maybe_get_entry( $entry );
149
-    }
149
+	}
150 150
 
151 151
 	public static function replace_default_message( $message, $atts ) {
152
-        if ( strpos($message, '[default-message') === false &&
153
-            strpos($message, '[default_message') === false &&
154
-            ! empty( $message ) ) {
155
-            return $message;
156
-        }
157
-
158
-        if ( empty($message) ) {
159
-            $message = '[default-message]';
160
-        }
161
-
162
-        preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER);
163
-
164
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
165
-            $add_atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
166
-            if ( $add_atts ) {
167
-                $this_atts = array_merge($atts, $add_atts);
168
-            } else {
169
-                $this_atts = $atts;
170
-            }
152
+		if ( strpos($message, '[default-message') === false &&
153
+			strpos($message, '[default_message') === false &&
154
+			! empty( $message ) ) {
155
+			return $message;
156
+		}
157
+
158
+		if ( empty($message) ) {
159
+			$message = '[default-message]';
160
+		}
161
+
162
+		preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER);
163
+
164
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
165
+			$add_atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
166
+			if ( $add_atts ) {
167
+				$this_atts = array_merge($atts, $add_atts);
168
+			} else {
169
+				$this_atts = $atts;
170
+			}
171 171
 
172 172
 			$default = FrmEntryFormat::show_entry( $this_atts );
173 173
 
174
-            // Add the default message
175
-            $message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
176
-        }
174
+			// Add the default message
175
+			$message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
176
+		}
177 177
 
178
-        return $message;
179
-    }
178
+		return $message;
179
+	}
180 180
 
181 181
 	public static function prepare_display_value( $entry, $field, $atts ) {
182 182
 		$field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
183
-        if ( FrmAppHelper::pro_is_installed() ) {
183
+		if ( FrmAppHelper::pro_is_installed() ) {
184 184
 			FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
185
-        }
185
+		}
186 186
 
187
-        if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) {
188
-            return self::display_value($field_value, $field, $atts);
189
-        }
187
+		if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) {
188
+			return self::display_value($field_value, $field, $atts);
189
+		}
190 190
 
191
-        // this is an embeded form
192
-        $val = '';
191
+		// this is an embeded form
192
+		$val = '';
193 193
 
194
-	    if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
195
-            //this is a repeating section
194
+		if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
195
+			//this is a repeating section
196 196
 			$child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) );
197
-        } else {
198
-            // get all values for this field
199
-	        $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
197
+		} else {
198
+			// get all values for this field
199
+			$child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
200 200
 
201
-            if ( $child_values ) {
202
-	            $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
203
-	        }
204
-	    }
201
+			if ( $child_values ) {
202
+				$child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
203
+			}
204
+		}
205 205
 
206
-	    $field_value = array();
206
+		$field_value = array();
207 207
 
208
-        if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
209
-            return $val;
210
-        }
208
+		if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
209
+			return $val;
210
+		}
211 211
 
212
-        foreach ( $child_entries as $child_entry ) {
213
-            $atts['item_id'] = $child_entry->id;
214
-            $atts['post_id'] = $child_entry->post_id;
212
+		foreach ( $child_entries as $child_entry ) {
213
+			$atts['item_id'] = $child_entry->id;
214
+			$atts['post_id'] = $child_entry->post_id;
215 215
 
216
-            // get the value for this field -- check for post values as well
217
-            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
216
+			// get the value for this field -- check for post values as well
217
+			$entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
218 218
 
219
-            if ( $entry_val ) {
220
-                // foreach entry get display_value
221
-                $field_value[] = self::display_value($entry_val, $field, $atts);
222
-            }
219
+			if ( $entry_val ) {
220
+				// foreach entry get display_value
221
+				$field_value[] = self::display_value($entry_val, $field, $atts);
222
+			}
223 223
 
224
-            unset($child_entry);
225
-        }
224
+			unset($child_entry);
225
+		}
226 226
 
227
-        $val = implode(', ', (array) $field_value );
227
+		$val = implode(', ', (array) $field_value );
228 228
 		$val = wp_kses_post( $val );
229 229
 
230
-        return $val;
231
-    }
230
+		return $val;
231
+	}
232 232
 
233
-    /**
234
-     * Prepare the saved value for display
235
-     * @return string
236
-     */
233
+	/**
234
+	 * Prepare the saved value for display
235
+	 * @return string
236
+	 */
237 237
 	public static function display_value( $value, $field, $atts = array() ) {
238 238
 
239
-        $defaults = array(
240
-            'type' => '', 'html' => false, 'show_filename' => true,
241
-            'truncate' => false, 'sep' => ', ', 'post_id' => 0,
242
-            'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0,
239
+		$defaults = array(
240
+			'type' => '', 'html' => false, 'show_filename' => true,
241
+			'truncate' => false, 'sep' => ', ', 'post_id' => 0,
242
+			'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0,
243 243
 			'return_array' => false,
244
-        );
244
+		);
245 245
 
246
-        $atts = wp_parse_args( $atts, $defaults );
247
-        $atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
246
+		$atts = wp_parse_args( $atts, $defaults );
247
+		$atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
248 248
 
249
-        if ( ! isset($field->field_options['post_field']) ) {
250
-            $field->field_options['post_field'] = '';
251
-        }
249
+		if ( ! isset($field->field_options['post_field']) ) {
250
+			$field->field_options['post_field'] = '';
251
+		}
252 252
 
253
-        if ( ! isset($field->field_options['custom_field']) ) {
254
-            $field->field_options['custom_field'] = '';
255
-        }
253
+		if ( ! isset($field->field_options['custom_field']) ) {
254
+			$field->field_options['custom_field'] = '';
255
+		}
256 256
 
257
-        if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
258
-            $atts['pre_truncate'] = $atts['truncate'];
259
-            $atts['truncate'] = true;
260
-            $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
257
+		if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
258
+			$atts['pre_truncate'] = $atts['truncate'];
259
+			$atts['truncate'] = true;
260
+			$atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
261 261
 
262
-            $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
263
-            $atts['truncate'] = $atts['pre_truncate'];
264
-        }
262
+			$value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
263
+			$atts['truncate'] = $atts['pre_truncate'];
264
+		}
265 265
 
266
-        if ( $value == '' ) {
267
-            return $value;
268
-        }
266
+		if ( $value == '' ) {
267
+			return $value;
268
+		}
269 269
 
270
-        $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts);
270
+		$value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts);
271 271
 
272
-        $new_value = '';
272
+		$new_value = '';
273 273
 
274
-        if ( is_array($value) && $atts['type'] != 'file' ) {
275
-            foreach ( $value as $val ) {
276
-                if ( is_array($val) ) {
274
+		if ( is_array($value) && $atts['type'] != 'file' ) {
275
+			foreach ( $value as $val ) {
276
+				if ( is_array($val) ) {
277 277
 					//TODO: add options for display (li or ,)
278
-                    $new_value .= implode($atts['sep'], $val);
279
-                    if ( $atts['type'] != 'data' ) {
280
-                        $new_value .= '<br/>';
281
-                    }
282
-                }
283
-                unset($val);
284
-            }
285
-        }
286
-
287
-        if ( ! empty($new_value) ) {
288
-            $value = $new_value;
289
-        } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
290
-            $value = implode($atts['sep'], $value);
291
-        }
292
-
293
-        if ( $atts['truncate'] && $atts['type'] != 'image' ) {
294
-            $value = FrmAppHelper::truncate($value, 50);
295
-        }
278
+					$new_value .= implode($atts['sep'], $val);
279
+					if ( $atts['type'] != 'data' ) {
280
+						$new_value .= '<br/>';
281
+					}
282
+				}
283
+				unset($val);
284
+			}
285
+		}
286
+
287
+		if ( ! empty($new_value) ) {
288
+			$value = $new_value;
289
+		} else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
290
+			$value = implode($atts['sep'], $value);
291
+		}
292
+
293
+		if ( $atts['truncate'] && $atts['type'] != 'image' ) {
294
+			$value = FrmAppHelper::truncate($value, 50);
295
+		}
296 296
 
297 297
 		if ( ! $atts['keepjs'] && ! is_array( $value ) ) {
298 298
 			$value = wp_kses_post( $value );
299 299
 		}
300 300
 
301
-        return apply_filters('frm_display_value', $value, $field, $atts);
302
-    }
301
+		return apply_filters('frm_display_value', $value, $field, $atts);
302
+	}
303 303
 
304 304
 	public static function set_posted_value( $field, $value, $args ) {
305
-        // If validating a field with "other" opt, set back to prev value now
306
-        if ( isset( $args['other'] ) && $args['other'] ) {
307
-            $value = $args['temp_value'];
308
-        }
309
-        if ( empty($args['parent_field_id']) ) {
310
-            $_POST['item_meta'][ $field->id ] = $value;
311
-        } else {
312
-            $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
313
-        }
314
-    }
305
+		// If validating a field with "other" opt, set back to prev value now
306
+		if ( isset( $args['other'] ) && $args['other'] ) {
307
+			$value = $args['temp_value'];
308
+		}
309
+		if ( empty($args['parent_field_id']) ) {
310
+			$_POST['item_meta'][ $field->id ] = $value;
311
+		} else {
312
+			$_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
313
+		}
314
+	}
315 315
 
316 316
 	public static function get_posted_value( $field, &$value, $args ) {
317 317
 		$field_id = is_object( $field ) ? $field->id : $field;
318 318
 
319
-        if ( empty($args['parent_field_id']) ) {
320
-            $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
321
-        } else {
322
-            $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
323
-        }
324
-    }
325
-
326
-    /**
327
-    * Check if field has an "Other" option and if any other values are posted
328
-    *
329
-    * @since 2.0
330
-    *
331
-    * @param object $field
332
-    * @param string|array $value
333
-    * @param array $args
334
-    */
335
-    public static function maybe_set_other_validation( $field, &$value, &$args ) {
336
-        $args['other'] = false;
337
-        if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) {
338
-            return;
339
-        }
340
-
341
-        // Get other value for fields in repeating section
342
-        self::set_other_repeating_vals( $field, $value, $args );
343
-
344
-        // Check if there are any posted "Other" values
319
+		if ( empty($args['parent_field_id']) ) {
320
+			$value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
321
+		} else {
322
+			$value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
323
+		}
324
+	}
325
+
326
+	/**
327
+	 * Check if field has an "Other" option and if any other values are posted
328
+	 *
329
+	 * @since 2.0
330
+	 *
331
+	 * @param object $field
332
+	 * @param string|array $value
333
+	 * @param array $args
334
+	 */
335
+	public static function maybe_set_other_validation( $field, &$value, &$args ) {
336
+		$args['other'] = false;
337
+		if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) {
338
+			return;
339
+		}
340
+
341
+		// Get other value for fields in repeating section
342
+		self::set_other_repeating_vals( $field, $value, $args );
343
+
344
+		// Check if there are any posted "Other" values
345 345
 		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) {
346 346
 
347
-            // Save original value
348
-            $args['temp_value'] = $value;
349
-            $args['other'] = true;
350
-            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
351
-
352
-            // Set the validation value now
353
-            self::set_other_validation_val( $value, $other_vals, $field, $args );
354
-        }
355
-    }
356
-
357
-    /**
358
-    * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
359
-    *
360
-    * @since 2.0
361
-    *
362
-    * @param object $field
363
-    * @param string|array $value
364
-    * @param array $args
365
-    */
366
-    public static function set_other_repeating_vals( $field, &$value, &$args ) {
367
-        if ( ! $args['parent_field_id'] ) {
368
-            return;
369
-        }
370
-
371
-        // Check if there are any other posted "other" values for this field
347
+			// Save original value
348
+			$args['temp_value'] = $value;
349
+			$args['other'] = true;
350
+			$other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
351
+
352
+			// Set the validation value now
353
+			self::set_other_validation_val( $value, $other_vals, $field, $args );
354
+		}
355
+	}
356
+
357
+	/**
358
+	 * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
359
+	 *
360
+	 * @since 2.0
361
+	 *
362
+	 * @param object $field
363
+	 * @param string|array $value
364
+	 * @param array $args
365
+	 */
366
+	public static function set_other_repeating_vals( $field, &$value, &$args ) {
367
+		if ( ! $args['parent_field_id'] ) {
368
+			return;
369
+		}
370
+
371
+		// Check if there are any other posted "other" values for this field
372 372
 		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) {
373
-            // Save original value
374
-            $args['temp_value'] = $value;
375
-            $args['other'] = true;
376
-
377
-            $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
378
-
379
-            // Set the validation value now
380
-            self::set_other_validation_val( $value, $other_vals, $field, $args );
381
-        }
382
-    }
383
-
384
-    /**
385
-    * Modify value used for validation
386
-    * This function essentially removes the "Other" radio or checkbox value from the $value being validated.
387
-    * It also adds any text from the free text fields to the value
388
-    *
389
-    * Needs to accommodate for times when other opt is selected, but no other free text is entered
390
-    *
391
-    * @since 2.0
392
-    *
393
-    * @param string|array $value
394
-    * @param string|array $other_vals (usually of posted values)
395
-    * @param object $field
396
-    * @param array $args
397
-    */
398
-    public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) {
399
-        // Checkboxes and multi-select dropdowns
400
-        if ( is_array( $value ) && $field->type == 'checkbox' ) {
401
-            // Combine "Other" values with checked values. "Other" values will override checked box values.
402
-            $value = array_merge( $value, $other_vals );
403
-            $value = array_filter( $value );
404
-            if ( count( $value ) == 0 ) {
405
-                $value = '';
406
-            }
407
-        } else {
373
+			// Save original value
374
+			$args['temp_value'] = $value;
375
+			$args['other'] = true;
376
+
377
+			$other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
378
+
379
+			// Set the validation value now
380
+			self::set_other_validation_val( $value, $other_vals, $field, $args );
381
+		}
382
+	}
383
+
384
+	/**
385
+	 * Modify value used for validation
386
+	 * This function essentially removes the "Other" radio or checkbox value from the $value being validated.
387
+	 * It also adds any text from the free text fields to the value
388
+	 *
389
+	 * Needs to accommodate for times when other opt is selected, but no other free text is entered
390
+	 *
391
+	 * @since 2.0
392
+	 *
393
+	 * @param string|array $value
394
+	 * @param string|array $other_vals (usually of posted values)
395
+	 * @param object $field
396
+	 * @param array $args
397
+	 */
398
+	public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) {
399
+		// Checkboxes and multi-select dropdowns
400
+		if ( is_array( $value ) && $field->type == 'checkbox' ) {
401
+			// Combine "Other" values with checked values. "Other" values will override checked box values.
402
+			$value = array_merge( $value, $other_vals );
403
+			$value = array_filter( $value );
404
+			if ( count( $value ) == 0 ) {
405
+				$value = '';
406
+			}
407
+		} else {
408 408
 			// Radio and dropdowns
409
-            $other_key = array_filter( array_keys($field->options), 'is_string');
410
-            $other_key = reset( $other_key );
409
+			$other_key = array_filter( array_keys($field->options), 'is_string');
410
+			$other_key = reset( $other_key );
411 411
 
412
-            // Multi-select dropdown
413
-            if ( is_array( $value ) ) {
414
-                $o_key = array_search( $field->options[ $other_key ], $value );
412
+			// Multi-select dropdown
413
+			if ( is_array( $value ) ) {
414
+				$o_key = array_search( $field->options[ $other_key ], $value );
415 415
 
416 416
 				if ( $o_key !== false ) {
417 417
 					// Modify the original value so other key will be preserved
@@ -426,20 +426,20 @@  discard block
 block discarded – undo
426 426
 					$args['temp_value'] = $value;
427 427
 					$value[ $other_key ] = reset( $other_vals );
428 428
 				}
429
-            } else if ( $field->options[ $other_key ] == $value ) {
430
-                $value = $other_vals;
431
-            }
432
-        }
433
-    }
429
+			} else if ( $field->options[ $other_key ] == $value ) {
430
+				$value = $other_vals;
431
+			}
432
+		}
433
+	}
434 434
 
435 435
 	public static function enqueue_scripts( $params ) {
436 436
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmFormsController::enqueue_scripts' );
437 437
 		return FrmFormsController::enqueue_scripts( $params );
438 438
 	}
439 439
 
440
-    // Add submitted values to a string for spam checking
440
+	// Add submitted values to a string for spam checking
441 441
 	public static function entry_array_to_string( $values ) {
442
-        $content = '';
442
+		$content = '';
443 443
 		foreach ( $values['item_meta'] as $val ) {
444 444
 			if ( $content != '' ) {
445 445
 				$content .= "\n\n";
@@ -447,14 +447,14 @@  discard block
 block discarded – undo
447 447
 
448 448
 			if ( is_array($val) ) {
449 449
 				$val = FrmAppHelper::array_flatten( $val );
450
-			    $val = implode(',', $val);
450
+				$val = implode(',', $val);
451 451
 			}
452 452
 
453 453
 			$content .= $val;
454 454
 		}
455 455
 
456 456
 		return $content;
457
-    }
457
+	}
458 458
 
459 459
 	public static function fill_entry_values( $atts, $f, array &$values ) {
460 460
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryFormat::fill_entry_values' );
Please login to merge, or discard this patch.
Spacing   +74 added lines, -74 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
 
@@ -9,12 +9,12 @@  discard block
 block discarded – undo
9 9
         global $frm_vars;
10 10
         $values = array();
11 11
 		foreach ( array( 'name' => '', 'description' => '', 'item_key' => '' ) as $var => $default ) {
12
-            $values[ $var ] = FrmAppHelper::get_post_param( $var, $default );
12
+            $values[$var] = FrmAppHelper::get_post_param( $var, $default );
13 13
         }
14 14
 
15 15
         $values['fields'] = array();
16
-        if ( empty($fields) ) {
17
-            return apply_filters('frm_setup_new_entry', $values);
16
+        if ( empty( $fields ) ) {
17
+            return apply_filters( 'frm_setup_new_entry', $values );
18 18
         }
19 19
 
20 20
         foreach ( (array) $fields as $field ) {
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
                 'default_value' => $field->default_value,
27 27
                 'name' => $field->name,
28 28
                 'description' => $field->description,
29
-                'type' => apply_filters('frm_field_type', $field->type, $field, $new_value),
29
+                'type' => apply_filters( 'frm_field_type', $field->type, $field, $new_value ),
30 30
                 'options' => $field->options,
31 31
                 'required' => $field->required,
32 32
                 'field_key' => $field->field_key,
@@ -35,43 +35,43 @@  discard block
 block discarded – undo
35 35
 				'parent_form_id' => isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id,
36 36
             );
37 37
 
38
-            $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
38
+            $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true );
39 39
             $opt_defaults['required_indicator'] = '';
40 40
 			$opt_defaults['original_type'] = $field->type;
41 41
 
42 42
 			foreach ( $opt_defaults as $opt => $default_opt ) {
43
-                $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt;
44
-                unset($opt, $default_opt);
43
+                $field_array[$opt] = ( isset( $field->field_options[$opt] ) && $field->field_options[$opt] != '' ) ? $field->field_options[$opt] : $default_opt;
44
+                unset( $opt, $default_opt );
45 45
             }
46 46
 
47
-            unset($opt_defaults);
47
+            unset( $opt_defaults );
48 48
 
49 49
             if ( $field_array['custom_html'] == '' ) {
50
-                $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
50
+                $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $field->type );
51 51
             }
52 52
 
53
-            $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field);
53
+            $field_array = apply_filters( 'frm_setup_new_fields_vars', $field_array, $field );
54 54
             $field_array = array_merge( $field->field_options, $field_array );
55 55
 
56 56
             $values['fields'][] = $field_array;
57 57
 
58
-            if ( ! $form || ! isset($form->id) ) {
59
-                $form = FrmForm::getOne($field->form_id);
58
+            if ( ! $form || ! isset( $form->id ) ) {
59
+                $form = FrmForm::getOne( $field->form_id );
60 60
             }
61 61
         }
62 62
 
63
-        $form->options = maybe_unserialize($form->options);
64
-        if ( is_array($form->options) ) {
63
+        $form->options = maybe_unserialize( $form->options );
64
+        if ( is_array( $form->options ) ) {
65 65
             foreach ( $form->options as $opt => $value ) {
66
-                $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value );
67
-                unset($opt, $value);
66
+                $values[$opt] = FrmAppHelper::get_post_param( $opt, $value );
67
+                unset( $opt, $value );
68 68
             }
69 69
         }
70 70
 
71 71
 		$form_defaults = FrmFormsHelper::get_default_opts();
72 72
 
73 73
 		$frm_settings = FrmAppHelper::get_settings();
74
-		$form_defaults['custom_style']  = ( $frm_settings->load_style != 'none' );
74
+		$form_defaults['custom_style'] = ( $frm_settings->load_style != 'none' );
75 75
 
76 76
 		$values = array_merge( $form_defaults, $values );
77 77
 
@@ -93,15 +93,15 @@  discard block
 block discarded – undo
93 93
 		$return_array = FrmField::is_field_with_multiple_values( $field );
94 94
 
95 95
 		// Do any shortcodes in default value and allow customization of default value
96
-		$field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true, $return_array);
96
+		$field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true, $return_array );
97 97
 		// Calls FrmProFieldsHelper::get_default_value
98 98
 
99 99
 		$new_value = $field->default_value;
100 100
 
101
-		if ( ! $reset && $_POST && isset( $_POST['item_meta'][ $field->id ] ) ) {
101
+		if ( ! $reset && $_POST && isset( $_POST['item_meta'][$field->id] ) ) {
102 102
 			// If value was posted, get it
103 103
 
104
-			$new_value = stripslashes_deep( $_POST['item_meta'][ $field->id ] );
104
+			$new_value = stripslashes_deep( $_POST['item_meta'][$field->id] );
105 105
 
106 106
 		} else if ( FrmField::is_option_true( $field, 'clear_on_focus' ) ) {
107 107
 			// If clear on focus is selected, the value should be blank (unless it was posted, of course)
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 		}
111 111
 
112 112
 		if ( ! is_array( $new_value ) ) {
113
-			$new_value = str_replace('"', '&quot;', $new_value);
113
+			$new_value = str_replace( '"', '&quot;', $new_value );
114 114
 		}
115 115
 
116 116
 		return $new_value;
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 		$values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' );
121 121
         $values['form_id'] = $record->form_id;
122 122
         $values['is_draft'] = $record->is_draft;
123
-        return apply_filters('frm_setup_edit_entry_vars', $values, $record);
123
+        return apply_filters( 'frm_setup_edit_entry_vars', $values, $record );
124 124
     }
125 125
 
126 126
     public static function get_admin_params( $form = null ) {
@@ -149,22 +149,22 @@  discard block
 block discarded – undo
149 149
     }
150 150
 
151 151
 	public static function replace_default_message( $message, $atts ) {
152
-        if ( strpos($message, '[default-message') === false &&
153
-            strpos($message, '[default_message') === false &&
152
+        if ( strpos( $message, '[default-message' ) === false &&
153
+            strpos( $message, '[default_message' ) === false &&
154 154
             ! empty( $message ) ) {
155 155
             return $message;
156 156
         }
157 157
 
158
-        if ( empty($message) ) {
158
+        if ( empty( $message ) ) {
159 159
             $message = '[default-message]';
160 160
         }
161 161
 
162
-        preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER);
162
+        preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER );
163 163
 
164 164
         foreach ( $shortcodes[0] as $short_key => $tag ) {
165
-            $add_atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
165
+            $add_atts = shortcode_parse_atts( $shortcodes[2][$short_key] );
166 166
             if ( $add_atts ) {
167
-                $this_atts = array_merge($atts, $add_atts);
167
+                $this_atts = array_merge( $atts, $add_atts );
168 168
             } else {
169 169
                 $this_atts = $atts;
170 170
             }
@@ -172,31 +172,31 @@  discard block
 block discarded – undo
172 172
 			$default = FrmEntryFormat::show_entry( $this_atts );
173 173
 
174 174
             // Add the default message
175
-            $message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
175
+            $message = str_replace( $shortcodes[0][$short_key], $default, $message );
176 176
         }
177 177
 
178 178
         return $message;
179 179
     }
180 180
 
181 181
 	public static function prepare_display_value( $entry, $field, $atts ) {
182
-		$field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
182
+		$field_value = isset( $entry->metas[$field->id] ) ? $entry->metas[$field->id] : false;
183 183
         if ( FrmAppHelper::pro_is_installed() ) {
184 184
 			FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
185 185
         }
186 186
 
187
-        if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) {
188
-            return self::display_value($field_value, $field, $atts);
187
+        if ( $field->form_id == $entry->form_id || empty( $atts['embedded_field_id'] ) ) {
188
+            return self::display_value( $field_value, $field, $atts );
189 189
         }
190 190
 
191 191
         // this is an embeded form
192 192
         $val = '';
193 193
 
194
-	    if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
194
+	    if ( strpos( $atts['embedded_field_id'], 'form' ) === 0 ) {
195 195
             //this is a repeating section
196 196
 			$child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) );
197 197
         } else {
198 198
             // get all values for this field
199
-	        $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
199
+	        $child_values = isset( $entry->metas[$atts['embedded_field_id']] ) ? $entry->metas[$atts['embedded_field_id']] : false;
200 200
 
201 201
             if ( $child_values ) {
202 202
 	            $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 
206 206
 	    $field_value = array();
207 207
 
208
-        if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
208
+        if ( ! isset( $child_entries ) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
209 209
             return $val;
210 210
         }
211 211
 
@@ -214,17 +214,17 @@  discard block
 block discarded – undo
214 214
             $atts['post_id'] = $child_entry->post_id;
215 215
 
216 216
             // get the value for this field -- check for post values as well
217
-            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
217
+            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value( $child_entry, $field );
218 218
 
219 219
             if ( $entry_val ) {
220 220
                 // foreach entry get display_value
221
-                $field_value[] = self::display_value($entry_val, $field, $atts);
221
+                $field_value[] = self::display_value( $entry_val, $field, $atts );
222 222
             }
223 223
 
224
-            unset($child_entry);
224
+            unset( $child_entry );
225 225
         }
226 226
 
227
-        $val = implode(', ', (array) $field_value );
227
+        $val = implode( ', ', (array) $field_value );
228 228
 		$val = wp_kses_post( $val );
229 229
 
230 230
         return $val;
@@ -244,22 +244,22 @@  discard block
 block discarded – undo
244 244
         );
245 245
 
246 246
         $atts = wp_parse_args( $atts, $defaults );
247
-        $atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
247
+        $atts = apply_filters( 'frm_display_value_atts', $atts, $field, $value );
248 248
 
249
-        if ( ! isset($field->field_options['post_field']) ) {
249
+        if ( ! isset( $field->field_options['post_field'] ) ) {
250 250
             $field->field_options['post_field'] = '';
251 251
         }
252 252
 
253
-        if ( ! isset($field->field_options['custom_field']) ) {
253
+        if ( ! isset( $field->field_options['custom_field'] ) ) {
254 254
             $field->field_options['custom_field'] = '';
255 255
         }
256 256
 
257 257
         if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
258 258
             $atts['pre_truncate'] = $atts['truncate'];
259 259
             $atts['truncate'] = true;
260
-            $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
260
+            $atts['exclude_cat'] = isset( $field->field_options['exclude_cat'] ) ? $field->field_options['exclude_cat'] : 0;
261 261
 
262
-            $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
262
+            $value = FrmProEntryMetaHelper::get_post_value( $atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts );
263 263
             $atts['truncate'] = $atts['pre_truncate'];
264 264
         }
265 265
 
@@ -267,38 +267,38 @@  discard block
 block discarded – undo
267 267
             return $value;
268 268
         }
269 269
 
270
-        $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts);
270
+        $value = apply_filters( 'frm_display_value_custom', maybe_unserialize( $value ), $field, $atts );
271 271
 
272 272
         $new_value = '';
273 273
 
274
-        if ( is_array($value) && $atts['type'] != 'file' ) {
274
+        if ( is_array( $value ) && $atts['type'] != 'file' ) {
275 275
             foreach ( $value as $val ) {
276
-                if ( is_array($val) ) {
276
+                if ( is_array( $val ) ) {
277 277
 					//TODO: add options for display (li or ,)
278
-                    $new_value .= implode($atts['sep'], $val);
278
+                    $new_value .= implode( $atts['sep'], $val );
279 279
                     if ( $atts['type'] != 'data' ) {
280 280
                         $new_value .= '<br/>';
281 281
                     }
282 282
                 }
283
-                unset($val);
283
+                unset( $val );
284 284
             }
285 285
         }
286 286
 
287
-        if ( ! empty($new_value) ) {
287
+        if ( ! empty( $new_value ) ) {
288 288
             $value = $new_value;
289
-        } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
290
-            $value = implode($atts['sep'], $value);
289
+        } else if ( is_array( $value ) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
290
+            $value = implode( $atts['sep'], $value );
291 291
         }
292 292
 
293 293
         if ( $atts['truncate'] && $atts['type'] != 'image' ) {
294
-            $value = FrmAppHelper::truncate($value, 50);
294
+            $value = FrmAppHelper::truncate( $value, 50 );
295 295
         }
296 296
 
297 297
 		if ( ! $atts['keepjs'] && ! is_array( $value ) ) {
298 298
 			$value = wp_kses_post( $value );
299 299
 		}
300 300
 
301
-        return apply_filters('frm_display_value', $value, $field, $atts);
301
+        return apply_filters( 'frm_display_value', $value, $field, $atts );
302 302
     }
303 303
 
304 304
 	public static function set_posted_value( $field, $value, $args ) {
@@ -306,20 +306,20 @@  discard block
 block discarded – undo
306 306
         if ( isset( $args['other'] ) && $args['other'] ) {
307 307
             $value = $args['temp_value'];
308 308
         }
309
-        if ( empty($args['parent_field_id']) ) {
310
-            $_POST['item_meta'][ $field->id ] = $value;
309
+        if ( empty( $args['parent_field_id'] ) ) {
310
+            $_POST['item_meta'][$field->id] = $value;
311 311
         } else {
312
-            $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
312
+            $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] = $value;
313 313
         }
314 314
     }
315 315
 
316 316
 	public static function get_posted_value( $field, &$value, $args ) {
317 317
 		$field_id = is_object( $field ) ? $field->id : $field;
318 318
 
319
-        if ( empty($args['parent_field_id']) ) {
320
-            $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
319
+        if ( empty( $args['parent_field_id'] ) ) {
320
+            $value = isset( $_POST['item_meta'][$field_id] ) ? $_POST['item_meta'][$field_id] : '';
321 321
         } else {
322
-            $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
322
+            $value = isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] ) ? $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] : '';
323 323
         }
324 324
     }
325 325
 
@@ -342,12 +342,12 @@  discard block
 block discarded – undo
342 342
         self::set_other_repeating_vals( $field, $value, $args );
343 343
 
344 344
         // Check if there are any posted "Other" values
345
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) {
345
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][$field->id] ) ) {
346 346
 
347 347
             // Save original value
348 348
             $args['temp_value'] = $value;
349 349
             $args['other'] = true;
350
-            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
350
+            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][$field->id] );
351 351
 
352 352
             // Set the validation value now
353 353
             self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -369,12 +369,12 @@  discard block
 block discarded – undo
369 369
         }
370 370
 
371 371
         // Check if there are any other posted "other" values for this field
372
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) {
372
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id] ) ) {
373 373
             // Save original value
374 374
             $args['temp_value'] = $value;
375 375
             $args['other'] = true;
376 376
 
377
-            $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
377
+            $other_vals = $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id];
378 378
 
379 379
             // Set the validation value now
380 380
             self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -406,27 +406,27 @@  discard block
 block discarded – undo
406 406
             }
407 407
         } else {
408 408
 			// Radio and dropdowns
409
-            $other_key = array_filter( array_keys($field->options), 'is_string');
409
+            $other_key = array_filter( array_keys( $field->options ), 'is_string' );
410 410
             $other_key = reset( $other_key );
411 411
 
412 412
             // Multi-select dropdown
413 413
             if ( is_array( $value ) ) {
414
-                $o_key = array_search( $field->options[ $other_key ], $value );
414
+                $o_key = array_search( $field->options[$other_key], $value );
415 415
 
416 416
 				if ( $o_key !== false ) {
417 417
 					// Modify the original value so other key will be preserved
418
-					$value[ $other_key ] = $value[ $o_key ];
418
+					$value[$other_key] = $value[$o_key];
419 419
 
420 420
 					// By default, the array keys will be numeric for multi-select dropdowns
421 421
 					// If going backwards and forwards between pages, the array key will match the other key
422 422
 					if ( $o_key != $other_key ) {
423
-						unset( $value[ $o_key ] );
423
+						unset( $value[$o_key] );
424 424
 					}
425 425
 
426 426
 					$args['temp_value'] = $value;
427
-					$value[ $other_key ] = reset( $other_vals );
427
+					$value[$other_key] = reset( $other_vals );
428 428
 				}
429
-            } else if ( $field->options[ $other_key ] == $value ) {
429
+            } else if ( $field->options[$other_key] == $value ) {
430 430
                 $value = $other_vals;
431 431
             }
432 432
         }
@@ -445,9 +445,9 @@  discard block
 block discarded – undo
445 445
 				$content .= "\n\n";
446 446
 			}
447 447
 
448
-			if ( is_array($val) ) {
448
+			if ( is_array( $val ) ) {
449 449
 				$val = FrmAppHelper::array_flatten( $val );
450
-			    $val = implode(',', $val);
450
+			    $val = implode( ',', $val );
451 451
 			}
452 452
 
453 453
 			$content .= $val;
@@ -492,6 +492,6 @@  discard block
 block discarded – undo
492 492
 	}
493 493
 
494 494
 	public static function entries_dropdown() {
495
-		_deprecated_function( __FUNCTION__, '1.07.09');
495
+		_deprecated_function( __FUNCTION__, '1.07.09' );
496 496
 	}
497 497
 }
Please login to merge, or discard this patch.
classes/helpers/FrmEntriesListHelper.php 2 patches
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -6,46 +6,46 @@  discard block
 block discarded – undo
6 6
 	protected $field;
7 7
 
8 8
 	public function prepare_items() {
9
-        global $wpdb, $per_page;
9
+		global $wpdb, $per_page;
10 10
 
11 11
 		$per_page = $this->get_items_per_page( 'formidable_page_formidable_entries_per_page' );
12 12
 
13
-        $form_id = $this->params['form'];
14
-        if ( ! $form_id ) {
15
-            $this->items = array();
16
-    		$this->set_pagination_args( array(
17
-    			'total_items' => 0,
13
+		$form_id = $this->params['form'];
14
+		if ( ! $form_id ) {
15
+			$this->items = array();
16
+			$this->set_pagination_args( array(
17
+				'total_items' => 0,
18 18
 				'per_page' => $per_page,
19
-    		) );
20
-            return;
21
-        }
19
+			) );
20
+			return;
21
+		}
22 22
 
23 23
 		$default_orderby = 'id';
24 24
 		$default_order = 'DESC';
25 25
 
26
-	    $s_query = array( 'it.form_id' => $form_id );
26
+		$s_query = array( 'it.form_id' => $form_id );
27 27
 
28 28
 		$s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
29 29
 
30
-	    if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
31
-	        $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : '';
32
-	        $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid);
33
-	    }
30
+		if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
31
+			$fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : '';
32
+			$s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid);
33
+		}
34 34
 
35
-        $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby;
36
-        if ( strpos($orderby, 'meta') !== false ) {
37
-            $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) );
35
+		$orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby;
36
+		if ( strpos($orderby, 'meta') !== false ) {
37
+			$order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) );
38 38
 			$orderby .= in_array( $order_field_type, array( 'number', 'scale' ) ) ? ' +0 ' : '';
39
-        }
39
+		}
40 40
 
41 41
 		$order = isset( $_REQUEST['order'] ) ? sanitize_title( $_REQUEST['order'] ) : $default_order;
42 42
 		$order = ' ORDER BY ' . $orderby . ' ' . $order;
43 43
 
44
-        $page = $this->get_pagenum();
44
+		$page = $this->get_pagenum();
45 45
 		$start = (int) isset( $_REQUEST['start'] ) ? absint( $_REQUEST['start'] ) : ( ( $page - 1 ) * $per_page );
46 46
 
47
-        $this->items = FrmEntry::getAll($s_query, $order, ' LIMIT '. $start .','. $per_page, true, false);
48
-        $total_items = FrmEntry::getRecordCount($s_query);
47
+		$this->items = FrmEntry::getAll($s_query, $order, ' LIMIT '. $start .','. $per_page, true, false);
48
+		$total_items = FrmEntry::getRecordCount($s_query);
49 49
 
50 50
 		$this->set_pagination_args( array(
51 51
 			'total_items' => $total_items,
@@ -54,19 +54,19 @@  discard block
 block discarded – undo
54 54
 	}
55 55
 
56 56
 	public function no_items() {
57
-        $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
58
-	    if ( ! empty($s) ) {
59
-            _e( 'No Entries Found', 'formidable' );
60
-            return;
61
-        }
62
-
63
-        $form_id = $form = $this->params['form'];
64
-        if ( $form_id ) {
65
-            $form = FrmForm::getOne($form_id);
66
-        }
67
-        $colspan = $this->get_column_count();
68
-
69
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/no_entries.php');
57
+		$s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
58
+		if ( ! empty($s) ) {
59
+			_e( 'No Entries Found', 'formidable' );
60
+			return;
61
+		}
62
+
63
+		$form_id = $form = $this->params['form'];
64
+		if ( $form_id ) {
65
+			$form = FrmForm::getOne($form_id);
66
+		}
67
+		$colspan = $this->get_column_count();
68
+
69
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/no_entries.php');
70 70
 	}
71 71
 
72 72
 	public function search_box( $text, $input_id ) {
@@ -74,12 +74,12 @@  discard block
 block discarded – undo
74 74
 	}
75 75
 
76 76
 	/**
77
-	* Gets the name of the primary column in the Entries screen
78
-	*
79
-	* @since 2.0.14
80
-	*
81
-	* @return string $primary_column
82
-	*/
77
+	 * Gets the name of the primary column in the Entries screen
78
+	 *
79
+	 * @since 2.0.14
80
+	 *
81
+	 * @return string $primary_column
82
+	 */
83 83
 	protected function get_primary_column_name() {
84 84
 		$columns = get_column_headers( $this->screen );
85 85
 		$hidden = get_hidden_columns( $this->screen );
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 
104 104
 		$this->get_actions( $actions, $item, $view_link );
105 105
 
106
-        $action_links = $this->row_actions( $actions );
106
+		$action_links = $this->row_actions( $actions );
107 107
 
108 108
 		// Set up the checkbox ( because the user is editable, otherwise its empty )
109 109
 		$checkbox = "<input type='checkbox' name='item-action[]' id='cb-item-action-{$item->id}' value='{$item->id}' />";
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 		$r = "<tr id='item-action-{$item->id}'$style>";
112 112
 
113 113
 		list( $columns, $hidden, , $primary ) = $this->get_column_info();
114
-        $action_col = false;
114
+		$action_col = false;
115 115
 
116 116
 		foreach ( $columns as $column_name => $column_display_name ) {
117 117
 			$class = $column_name .' column-'. $column_name;
@@ -123,14 +123,14 @@  discard block
 block discarded – undo
123 123
 			if ( in_array( $column_name, $hidden ) ) {
124 124
 				$class .= ' frm_hidden';
125 125
 			} else if ( ! $action_col && ! in_array( $column_name, array( 'cb', 'id', 'form_id', 'post_id' ) ) ) {
126
-			    $action_col = $column_name;
127
-            }
126
+				$action_col = $column_name;
127
+			}
128 128
 
129 129
 			$attributes = 'class="' . esc_attr( $class ) . '"';
130 130
 			unset($class);
131 131
 			$attributes .= ' data-colname="' . $column_display_name  . '"';
132 132
 
133
-            $col_name = preg_replace('/^('. $this->params['form'] .'_)/', '', $column_name);
133
+			$col_name = preg_replace('/^('. $this->params['form'] .'_)/', '', $column_name);
134 134
 			$this->column_name = $col_name;
135 135
 
136 136
 			switch ( $col_name ) {
@@ -140,30 +140,30 @@  discard block
 block discarded – undo
140 140
 				case 'ip':
141 141
 				case 'id':
142 142
 				case 'item_key':
143
-				    $val = $item->{$col_name};
144
-				    break;
143
+					$val = $item->{$col_name};
144
+					break;
145 145
 				case 'name':
146 146
 				case 'description':
147
-				    $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100);
148
-				    break;
147
+					$val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100);
148
+					break;
149 149
 				case 'created_at':
150 150
 				case 'updated_at':
151
-				    $date = FrmAppHelper::get_formatted_time($item->{$col_name});
151
+					$date = FrmAppHelper::get_formatted_time($item->{$col_name});
152 152
 					$val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>';
153 153
 					break;
154 154
 				case 'is_draft':
155
-				    $val = empty($item->is_draft) ? __( 'No') : __( 'Yes');
156
-			        break;
155
+					$val = empty($item->is_draft) ? __( 'No') : __( 'Yes');
156
+					break;
157 157
 				case 'form_id':
158
-				    $val = FrmFormsHelper::edit_form_link($item->form_id);
159
-    				break;
158
+					$val = FrmFormsHelper::edit_form_link($item->form_id);
159
+					break;
160 160
 				case 'post_id':
161
-				    $val = FrmAppHelper::post_edit_link($item->post_id);
162
-				    break;
161
+					$val = FrmAppHelper::post_edit_link($item->post_id);
162
+					break;
163 163
 				case 'user_id':
164
-				    $user = get_userdata($item->user_id);
165
-				    $val = $user->user_login;
166
-				    break;
164
+					$user = get_userdata($item->user_id);
165
+					$val = $user->user_login;
166
+					break;
167 167
 				default:
168 168
 					$val = apply_filters( 'frm_entries_' . $col_name . '_column', false, compact( 'item' ) );
169 169
 					if ( $val === false ) {
@@ -173,15 +173,15 @@  discard block
 block discarded – undo
173 173
 			}
174 174
 
175 175
 			if ( isset( $val ) ) {
176
-			    $r .= "<td $attributes>";
176
+				$r .= "<td $attributes>";
177 177
 				if ( $column_name == $action_col ) {
178 178
 					$edit_link = '?page=formidable-entries&frm_action=edit&id='. $item->id;
179 179
 					$r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> ';
180
-			        $r .= $action_links;
180
+					$r .= $action_links;
181 181
 				} else {
182
-			        $r .= $val;
183
-			    }
184
-			    $r .= '</td>';
182
+					$r .= $val;
183
+				}
184
+				$r .= '</td>';
185 185
 			}
186 186
 			unset($val);
187 187
 		}
@@ -190,19 +190,19 @@  discard block
 block discarded – undo
190 190
 		return $r;
191 191
 	}
192 192
 
193
-    /**
194
-     * @param string $view_link
195
-     */
196
-    private function get_actions( &$actions, $item, $view_link ) {
193
+	/**
194
+	 * @param string $view_link
195
+	 */
196
+	private function get_actions( &$actions, $item, $view_link ) {
197 197
 		$actions['view'] = '<a href="' . esc_url( $view_link ) . '">'. __( 'View', 'formidable' ) .'</a>';
198 198
 
199
-        if ( current_user_can('frm_delete_entries') ) {
200
-            $delete_link = '?page=formidable-entries&frm_action=destroy&id='. $item->id .'&form='. $this->params['form'];
199
+		if ( current_user_can('frm_delete_entries') ) {
200
+			$delete_link = '?page=formidable-entries&frm_action=destroy&id='. $item->id .'&form='. $this->params['form'];
201 201
 			$actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete that?', 'formidable' ) ) . '\')">' . __( 'Delete' ) . '</a>';
202
-	    }
202
+		}
203 203
 
204
-        $actions = apply_filters('frm_row_actions', $actions, $item);
205
-    }
204
+		$actions = apply_filters('frm_row_actions', $actions, $item);
205
+	}
206 206
 
207 207
 	private function get_column_value( $item, &$val ) {
208 208
 		$col_name = $this->column_name;
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -25,15 +25,15 @@  discard block
 block discarded – undo
25 25
 
26 26
 	    $s_query = array( 'it.form_id' => $form_id );
27 27
 
28
-		$s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
28
+		$s = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
29 29
 
30 30
 	    if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
31 31
 	        $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : '';
32
-	        $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid);
32
+	        $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid );
33 33
 	    }
34 34
 
35 35
         $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby;
36
-        if ( strpos($orderby, 'meta') !== false ) {
36
+        if ( strpos( $orderby, 'meta' ) !== false ) {
37 37
             $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) );
38 38
 			$orderby .= in_array( $order_field_type, array( 'number', 'scale' ) ) ? ' +0 ' : '';
39 39
         }
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
         $page = $this->get_pagenum();
45 45
 		$start = (int) isset( $_REQUEST['start'] ) ? absint( $_REQUEST['start'] ) : ( ( $page - 1 ) * $per_page );
46 46
 
47
-        $this->items = FrmEntry::getAll($s_query, $order, ' LIMIT '. $start .','. $per_page, true, false);
48
-        $total_items = FrmEntry::getRecordCount($s_query);
47
+        $this->items = FrmEntry::getAll( $s_query, $order, ' LIMIT ' . $start . ',' . $per_page, true, false );
48
+        $total_items = FrmEntry::getRecordCount( $s_query );
49 49
 
50 50
 		$this->set_pagination_args( array(
51 51
 			'total_items' => $total_items,
@@ -55,18 +55,18 @@  discard block
 block discarded – undo
55 55
 
56 56
 	public function no_items() {
57 57
         $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
58
-	    if ( ! empty($s) ) {
58
+	    if ( ! empty( $s ) ) {
59 59
             _e( 'No Entries Found', 'formidable' );
60 60
             return;
61 61
         }
62 62
 
63 63
         $form_id = $form = $this->params['form'];
64 64
         if ( $form_id ) {
65
-            $form = FrmForm::getOne($form_id);
65
+            $form = FrmForm::getOne( $form_id );
66 66
         }
67 67
         $colspan = $this->get_column_count();
68 68
 
69
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/no_entries.php');
69
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/no_entries.php' );
70 70
 	}
71 71
 
72 72
 	public function search_box( $text, $input_id ) {
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	public function single_row( $item, $style = '' ) {
100 100
 		// Set up the hover actions for this user
101 101
 		$actions = array();
102
-		$view_link = '?page=formidable-entries&frm_action=show&id='. $item->id;
102
+		$view_link = '?page=formidable-entries&frm_action=show&id=' . $item->id;
103 103
 
104 104
 		$this->get_actions( $actions, $item, $view_link );
105 105
 
@@ -110,11 +110,11 @@  discard block
 block discarded – undo
110 110
 
111 111
 		$r = "<tr id='item-action-{$item->id}'$style>";
112 112
 
113
-		list( $columns, $hidden, , $primary ) = $this->get_column_info();
113
+		list( $columns, $hidden,, $primary ) = $this->get_column_info();
114 114
         $action_col = false;
115 115
 
116 116
 		foreach ( $columns as $column_name => $column_display_name ) {
117
-			$class = $column_name .' column-'. $column_name;
117
+			$class = $column_name . ' column-' . $column_name;
118 118
 
119 119
 			if ( $column_name === $primary ) {
120 120
 				$class .= ' column-primary';
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
             }
128 128
 
129 129
 			$attributes = 'class="' . esc_attr( $class ) . '"';
130
-			unset($class);
131
-			$attributes .= ' data-colname="' . $column_display_name  . '"';
130
+			unset( $class );
131
+			$attributes .= ' data-colname="' . $column_display_name . '"';
132 132
 
133
-            $col_name = preg_replace('/^('. $this->params['form'] .'_)/', '', $column_name);
133
+            $col_name = preg_replace( '/^(' . $this->params['form'] . '_)/', '', $column_name );
134 134
 			$this->column_name = $col_name;
135 135
 
136 136
 			switch ( $col_name ) {
@@ -144,24 +144,24 @@  discard block
 block discarded – undo
144 144
 				    break;
145 145
 				case 'name':
146 146
 				case 'description':
147
-				    $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100);
147
+				    $val = FrmAppHelper::truncate( strip_tags( $item->{$col_name}), 100 );
148 148
 				    break;
149 149
 				case 'created_at':
150 150
 				case 'updated_at':
151
-				    $date = FrmAppHelper::get_formatted_time($item->{$col_name});
151
+				    $date = FrmAppHelper::get_formatted_time( $item->{$col_name});
152 152
 					$val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>';
153 153
 					break;
154 154
 				case 'is_draft':
155
-				    $val = empty($item->is_draft) ? __( 'No') : __( 'Yes');
155
+				    $val = empty( $item->is_draft ) ? __( 'No' ) : __( 'Yes' );
156 156
 			        break;
157 157
 				case 'form_id':
158
-				    $val = FrmFormsHelper::edit_form_link($item->form_id);
158
+				    $val = FrmFormsHelper::edit_form_link( $item->form_id );
159 159
     				break;
160 160
 				case 'post_id':
161
-				    $val = FrmAppHelper::post_edit_link($item->post_id);
161
+				    $val = FrmAppHelper::post_edit_link( $item->post_id );
162 162
 				    break;
163 163
 				case 'user_id':
164
-				    $user = get_userdata($item->user_id);
164
+				    $user = get_userdata( $item->user_id );
165 165
 				    $val = $user->user_login;
166 166
 				    break;
167 167
 				default:
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 			if ( isset( $val ) ) {
176 176
 			    $r .= "<td $attributes>";
177 177
 				if ( $column_name == $action_col ) {
178
-					$edit_link = '?page=formidable-entries&frm_action=edit&id='. $item->id;
178
+					$edit_link = '?page=formidable-entries&frm_action=edit&id=' . $item->id;
179 179
 					$r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> ';
180 180
 			        $r .= $action_links;
181 181
 				} else {
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 			    }
184 184
 			    $r .= '</td>';
185 185
 			}
186
-			unset($val);
186
+			unset( $val );
187 187
 		}
188 188
 		$r .= '</tr>';
189 189
 
@@ -194,14 +194,14 @@  discard block
 block discarded – undo
194 194
      * @param string $view_link
195 195
      */
196 196
     private function get_actions( &$actions, $item, $view_link ) {
197
-		$actions['view'] = '<a href="' . esc_url( $view_link ) . '">'. __( 'View', 'formidable' ) .'</a>';
197
+		$actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>';
198 198
 
199
-        if ( current_user_can('frm_delete_entries') ) {
200
-            $delete_link = '?page=formidable-entries&frm_action=destroy&id='. $item->id .'&form='. $this->params['form'];
199
+        if ( current_user_can( 'frm_delete_entries' ) ) {
200
+            $delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form'];
201 201
 			$actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete that?', 'formidable' ) ) . '\')">' . __( 'Delete' ) . '</a>';
202 202
 	    }
203 203
 
204
-        $actions = apply_filters('frm_row_actions', $actions, $item);
204
+        $actions = apply_filters( 'frm_row_actions', $actions, $item );
205 205
     }
206 206
 
207 207
 	private function get_column_value( $item, &$val ) {
Please login to merge, or discard this patch.
classes/helpers/FrmFormsHelper.php 3 patches
Indentation   +276 added lines, -276 removed lines patch added patch discarded remove patch
@@ -11,39 +11,39 @@  discard block
 block discarded – undo
11 11
 	}
12 12
 
13 13
 	public static function get_direct_link( $key, $form = false ) {
14
-        $target_url = esc_url(admin_url('admin-ajax.php') . '?action=frm_forms_preview&form='. $key);
15
-        $target_url = apply_filters('frm_direct_link', $target_url, $key, $form);
16
-
17
-        return $target_url;
18
-    }
19
-
20
-    public static function forms_dropdown( $field_name, $field_value = '', $args = array() ) {
21
-        $defaults = array(
22
-            'blank'     => true,
23
-            'field_id'  => false,
24
-            'onchange'  => false,
25
-            'exclude'   => false,
26
-            'class'     => '',
14
+		$target_url = esc_url(admin_url('admin-ajax.php') . '?action=frm_forms_preview&form='. $key);
15
+		$target_url = apply_filters('frm_direct_link', $target_url, $key, $form);
16
+
17
+		return $target_url;
18
+	}
19
+
20
+	public static function forms_dropdown( $field_name, $field_value = '', $args = array() ) {
21
+		$defaults = array(
22
+			'blank'     => true,
23
+			'field_id'  => false,
24
+			'onchange'  => false,
25
+			'exclude'   => false,
26
+			'class'     => '',
27 27
 			'inc_children' => 'exclude',
28
-        );
29
-        $args = wp_parse_args( $args, $defaults );
28
+		);
29
+		$args = wp_parse_args( $args, $defaults );
30 30
 
31
-        if ( ! $args['field_id'] ) {
32
-            $args['field_id'] = $field_name;
33
-        }
31
+		if ( ! $args['field_id'] ) {
32
+			$args['field_id'] = $field_name;
33
+		}
34 34
 
35 35
 		$query = array();
36
-        if ( $args['exclude'] ) {
36
+		if ( $args['exclude'] ) {
37 37
 			$query['id !'] = $args['exclude'];
38
-        }
38
+		}
39 39
 
40
-        $where = apply_filters('frm_forms_dropdown', $query, $field_name);
40
+		$where = apply_filters('frm_forms_dropdown', $query, $field_name);
41 41
 		$forms = FrmForm::get_published_forms( $where, 999, $args['inc_children'] );
42 42
 		$add_html = array();
43 43
 		self::add_html_attr( $args['onchange'], 'onchange', $add_html );
44 44
 		self::add_html_attr( $args['class'], 'class', $add_html );
45 45
 
46
-        ?>
46
+		?>
47 47
 		<select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $args['field_id'] ) ?>" <?php echo implode( ' ', $add_html ); ?>>
48 48
 		<?php if ( $args['blank'] ) { ?>
49 49
 			<option value=""><?php echo ( $args['blank'] == 1 ) ? ' ' : '- ' . esc_attr( $args['blank'] ) . ' -'; ?></option>
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 		<?php } ?>
56 56
         </select>
57 57
         <?php
58
-    }
58
+	}
59 59
 
60 60
 	/**
61 61
 	 * @param string $class
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 		}
71 71
 	}
72 72
 
73
-    public static function form_switcher() {
73
+	public static function form_switcher() {
74 74
 		$where = apply_filters( 'frm_forms_dropdown', array(), '' );
75 75
 		$forms = FrmForm::get_published_forms( $where );
76 76
 
@@ -79,32 +79,32 @@  discard block
 block discarded – undo
79 79
 			unset( $args['form'] );
80 80
 		} else if ( isset( $_GET['form']) && ! isset( $_GET['id'] ) ) {
81 81
 			unset( $args['id'] );
82
-        }
82
+		}
83 83
 
84 84
 		$frm_action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
85 85
 		if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $frm_action, array( 'edit', 'show', 'destroy_all' ) ) ) {
86
-            $args['frm_action'] = 'list';
87
-            $args['form'] = 0;
86
+			$args['frm_action'] = 'list';
87
+			$args['form'] = 0;
88 88
 		} else if ( FrmAppHelper::is_admin_page('formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) {
89
-            $args['frm_action'] = 'edit';
89
+			$args['frm_action'] = 'edit';
90 90
 		} else if ( isset( $_GET['post'] ) ) {
91
-            $args['form'] = 0;
92
-            $base = admin_url('edit.php?post_type=frm_display');
93
-        }
91
+			$args['form'] = 0;
92
+			$base = admin_url('edit.php?post_type=frm_display');
93
+		}
94 94
 
95
-        ?>
95
+		?>
96 96
 		<li class="dropdown last" id="frm_bs_dropdown">
97 97
 			<a href="#" id="frm-navbarDrop" class="frm-dropdown-toggle" data-toggle="dropdown"><?php _e( 'Switch Form', 'formidable' ) ?> <b class="caret"></b></a>
98 98
 		    <ul class="frm-dropdown-menu frm-on-top" role="menu" aria-labelledby="frm-navbarDrop">
99 99
 			<?php
100 100
 			foreach ( $forms as $form ) {
101 101
 				if ( isset( $args['id'] ) ) {
102
-			        $args['id'] = $form->id;
102
+					$args['id'] = $form->id;
103 103
 				}
104
-			    if ( isset( $args['form'] ) ) {
105
-			        $args['form'] = $form->id;
104
+				if ( isset( $args['form'] ) ) {
105
+					$args['form'] = $form->id;
106 106
 				}
107
-                ?>
107
+				?>
108 108
 				<li><a href="<?php echo esc_url( isset( $base ) ? add_query_arg( $args, $base ) : add_query_arg( $args ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)') : FrmAppHelper::truncate( $form->name, 33 ) ); ?></a></li>
109 109
 			<?php
110 110
 				unset( $form );
@@ -112,12 +112,12 @@  discard block
 block discarded – undo
112 112
 			</ul>
113 113
 		</li>
114 114
         <?php
115
-    }
115
+	}
116 116
 
117 117
 	public static function get_sortable_classes( $col, $sort_col, $sort_dir ) {
118
-        echo ($sort_col == $col) ? 'sorted' : 'sortable';
119
-        echo ($sort_col == $col && $sort_dir == 'desc') ? ' asc' : ' desc';
120
-    }
118
+		echo ($sort_col == $col) ? 'sorted' : 'sortable';
119
+		echo ($sort_col == $col && $sort_dir == 'desc') ? ' asc' : ' desc';
120
+	}
121 121
 
122 122
 	public static function get_success_message( $atts ) {
123 123
 		$message = apply_filters( 'frm_content', $atts['message'], $atts['form'], $atts['entry_id'] );
@@ -125,110 +125,110 @@  discard block
 block discarded – undo
125 125
 		return $message;
126 126
 	}
127 127
 
128
-    /**
129
-     * Used when a form is created
130
-     */
131
-    public static function setup_new_vars( $values = array() ) {
132
-        global $wpdb;
128
+	/**
129
+	 * Used when a form is created
130
+	 */
131
+	public static function setup_new_vars( $values = array() ) {
132
+		global $wpdb;
133 133
 
134
-        if ( ! empty( $values ) ) {
135
-            $post_values = $values;
136
-        } else {
137
-            $values = array();
138
-            $post_values = isset($_POST) ? $_POST : array();
139
-        }
134
+		if ( ! empty( $values ) ) {
135
+			$post_values = $values;
136
+		} else {
137
+			$values = array();
138
+			$post_values = isset($_POST) ? $_POST : array();
139
+		}
140 140
 
141 141
 		foreach ( array( 'name' => '', 'description' => '' ) as $var => $default ) {
142 142
 			if ( ! isset( $values[ $var ] ) ) {
143 143
 				$values[ $var ] = FrmAppHelper::get_param( $var, $default );
144
-            }
145
-        }
144
+			}
145
+		}
146 146
 
147
-        $values['description'] = FrmAppHelper::use_wpautop($values['description']);
147
+		$values['description'] = FrmAppHelper::use_wpautop($values['description']);
148 148
 
149 149
 		foreach ( array( 'form_id' => '', 'logged_in' => '', 'editable' => '', 'default_template' => 0, 'is_template' => 0, 'status' => 'draft', 'parent_form_id' => 0 ) as $var => $default ) {
150
-            if ( ! isset( $values[ $var ] ) ) {
150
+			if ( ! isset( $values[ $var ] ) ) {
151 151
 				$values[ $var ] = FrmAppHelper::get_param( $var, $default );
152
-            }
153
-        }
152
+			}
153
+		}
154 154
 
155
-        if ( ! isset( $values['form_key'] ) ) {
156
-            $values['form_key'] = ($post_values && isset($post_values['form_key'])) ? $post_values['form_key'] : FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_forms', 'form_key');
157
-        }
155
+		if ( ! isset( $values['form_key'] ) ) {
156
+			$values['form_key'] = ($post_values && isset($post_values['form_key'])) ? $post_values['form_key'] : FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_forms', 'form_key');
157
+		}
158 158
 
159
-        $values = self::fill_default_opts($values, false, $post_values);
159
+		$values = self::fill_default_opts($values, false, $post_values);
160 160
 
161
-        if ( $post_values && isset($post_values['options']['custom_style']) ) {
162
-            $values['custom_style'] = $post_values['options']['custom_style'];
163
-        } else {
164
-            $frm_settings = FrmAppHelper::get_settings();
165
-            $values['custom_style'] = ( $frm_settings->load_style != 'none' );
166
-        }
161
+		if ( $post_values && isset($post_values['options']['custom_style']) ) {
162
+			$values['custom_style'] = $post_values['options']['custom_style'];
163
+		} else {
164
+			$frm_settings = FrmAppHelper::get_settings();
165
+			$values['custom_style'] = ( $frm_settings->load_style != 'none' );
166
+		}
167 167
 
168
-        return apply_filters('frm_setup_new_form_vars', $values);
169
-    }
168
+		return apply_filters('frm_setup_new_form_vars', $values);
169
+	}
170 170
 
171
-    /**
172
-     * Used when editing a form
173
-     */
174
-    public static function setup_edit_vars( $values, $record, $post_values = array() ) {
171
+	/**
172
+	 * Used when editing a form
173
+	 */
174
+	public static function setup_edit_vars( $values, $record, $post_values = array() ) {
175 175
 		if ( empty( $post_values ) ) {
176 176
 			$post_values = stripslashes_deep( $_POST );
177 177
 		}
178 178
 
179
-        $values['form_key'] = isset($post_values['form_key']) ? $post_values['form_key'] : $record->form_key;
180
-        $values['default_template'] = isset($post_values['default_template']) ? $post_values['default_template'] : $record->default_template;
181
-        $values['is_template'] = isset($post_values['is_template']) ? $post_values['is_template'] : $record->is_template;
182
-        $values['status'] = $record->status;
179
+		$values['form_key'] = isset($post_values['form_key']) ? $post_values['form_key'] : $record->form_key;
180
+		$values['default_template'] = isset($post_values['default_template']) ? $post_values['default_template'] : $record->default_template;
181
+		$values['is_template'] = isset($post_values['is_template']) ? $post_values['is_template'] : $record->is_template;
182
+		$values['status'] = $record->status;
183 183
 
184
-        $values = self::fill_default_opts($values, $record, $post_values);
184
+		$values = self::fill_default_opts($values, $record, $post_values);
185 185
 
186
-        return apply_filters('frm_setup_edit_form_vars', $values);
187
-    }
186
+		return apply_filters('frm_setup_edit_form_vars', $values);
187
+	}
188 188
 
189 189
 	public static function fill_default_opts( $values, $record, $post_values ) {
190 190
 
191
-        $defaults = self::get_default_opts();
191
+		$defaults = self::get_default_opts();
192 192
 		foreach ( $defaults as $var => $default ) {
193
-            if ( is_array($default) ) {
194
-                if ( ! isset( $values[ $var ] ) ) {
193
+			if ( is_array($default) ) {
194
+				if ( ! isset( $values[ $var ] ) ) {
195 195
 					$values[ $var ] = ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : array();
196
-                }
196
+				}
197 197
 
198
-                foreach ( $default as $k => $v ) {
198
+				foreach ( $default as $k => $v ) {
199 199
 					$values[ $var ][ $k ] = ( $post_values && isset( $post_values[ $var ][ $k ] ) ) ? $post_values[ $var ][ $k ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) ) ? $record->options[ $var ][ $k ] : $v);
200 200
 
201
-                    if ( is_array( $v ) ) {
202
-                        foreach ( $v as $k1 => $v1 ) {
201
+					if ( is_array( $v ) ) {
202
+						foreach ( $v as $k1 => $v1 ) {
203 203
 							$values[ $var ][ $k ][ $k1 ] = ( $post_values && isset( $post_values[ $var ][ $k ][ $k1 ] ) ) ? $post_values[ $var ][ $k ][ $k1 ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) && isset( $record->options[ $var ][ $k ][ $k1 ] ) ) ? $record->options[ $var ][ $k ][ $k1 ] : $v1 );
204
-                            unset( $k1, $v1 );
205
-                        }
206
-                    }
204
+							unset( $k1, $v1 );
205
+						}
206
+					}
207 207
 
208
-                    unset($k, $v);
209
-                }
210
-            } else {
208
+					unset($k, $v);
209
+				}
210
+			} else {
211 211
 				$values[ $var ] = ( $post_values && isset( $post_values['options'][ $var ] ) ) ? $post_values['options'][ $var ] : ( ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : $default );
212
-            }
212
+			}
213 213
 
214
-            unset($var, $default);
215
-        }
214
+			unset($var, $default);
215
+		}
216 216
 
217
-        return $values;
218
-    }
217
+		return $values;
218
+	}
219 219
 
220
-    public static function get_default_opts() {
221
-        $frm_settings = FrmAppHelper::get_settings();
220
+	public static function get_default_opts() {
221
+		$frm_settings = FrmAppHelper::get_settings();
222 222
 
223
-        return array(
224
-            'submit_value' => $frm_settings->submit_value, 'success_action' => 'message',
225
-            'success_msg' => $frm_settings->success_msg, 'show_form' => 0, 'akismet' => '',
226
-            'no_save' => 0, 'ajax_load' => 0, 'form_class' => '', 'custom_style' => 1,
227
-            'before_html' => self::get_default_html('before'),
228
-            'after_html' => '',
229
-            'submit_html' => self::get_default_html('submit'),
230
-        );
231
-    }
223
+		return array(
224
+			'submit_value' => $frm_settings->submit_value, 'success_action' => 'message',
225
+			'success_msg' => $frm_settings->success_msg, 'show_form' => 0, 'akismet' => '',
226
+			'no_save' => 0, 'ajax_load' => 0, 'form_class' => '', 'custom_style' => 1,
227
+			'before_html' => self::get_default_html('before'),
228
+			'after_html' => '',
229
+			'submit_html' => self::get_default_html('submit'),
230
+		);
231
+	}
232 232
 
233 233
 	/**
234 234
 	 * @param array $options
@@ -243,15 +243,15 @@  discard block
 block discarded – undo
243 243
 		}
244 244
 	}
245 245
 
246
-    /**
247
-     * @param string $loc
248
-     */
246
+	/**
247
+	 * @param string $loc
248
+	 */
249 249
 	public static function get_default_html( $loc ) {
250 250
 		if ( $loc == 'submit' ) {
251
-            $sending = __( 'Sending', 'formidable' );
252
-            $draft_link = self::get_draft_link();
253
-            $img = '[frmurl]/images/ajax_loader.gif';
254
-            $default_html = <<<SUBMIT_HTML
251
+			$sending = __( 'Sending', 'formidable' );
252
+			$draft_link = self::get_draft_link();
253
+			$img = '[frmurl]/images/ajax_loader.gif';
254
+			$default_html = <<<SUBMIT_HTML
255 255
 <div class="frm_submit">
256 256
 [if back_button]<input type="button" value="[back_label]" name="frm_prev_page" formnovalidate="formnovalidate" class="frm_prev_page" [back_hook] />[/if back_button]
257 257
 <input type="submit" value="[button_label]" [button_action] />
@@ -260,49 +260,49 @@  discard block
 block discarded – undo
260 260
 </div>
261 261
 SUBMIT_HTML;
262 262
 		} else if ( $loc == 'before' ) {
263
-            $default_html = <<<BEFORE_HTML
263
+			$default_html = <<<BEFORE_HTML
264 264
 <legend class="frm_hidden">[form_name]</legend>
265 265
 [if form_name]<h3>[form_name]</h3>[/if form_name]
266 266
 [if form_description]<div class="frm_description">[form_description]</div>[/if form_description]
267 267
 BEFORE_HTML;
268 268
 		} else {
269
-            $default_html = '';
270
-        }
269
+			$default_html = '';
270
+		}
271 271
 
272
-        return $default_html;
273
-    }
272
+		return $default_html;
273
+	}
274 274
 
275
-    public static function get_draft_link() {
276
-        $link = '[if save_draft]<a href="#" class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]';
277
-        return $link;
278
-    }
275
+	public static function get_draft_link() {
276
+		$link = '[if save_draft]<a href="#" class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]';
277
+		return $link;
278
+	}
279 279
 
280 280
 	public static function get_custom_submit( $html, $form, $submit, $form_action, $values ) {
281
-        $button = self::replace_shortcodes($html, $form, $submit, $form_action, $values);
282
-        if ( ! strpos($button, '[button_action]') ) {
283
-            return;
284
-        }
281
+		$button = self::replace_shortcodes($html, $form, $submit, $form_action, $values);
282
+		if ( ! strpos($button, '[button_action]') ) {
283
+			return;
284
+		}
285 285
 
286
-        $button_parts = explode('[button_action]', $button);
287
-        echo $button_parts[0];
288
-        //echo ' id="frm_submit_"';
286
+		$button_parts = explode('[button_action]', $button);
287
+		echo $button_parts[0];
288
+		//echo ' id="frm_submit_"';
289 289
 
290
-        $classes = apply_filters('frm_submit_button_class', array(), $form);
291
-        if ( ! empty($classes) ) {
290
+		$classes = apply_filters('frm_submit_button_class', array(), $form);
291
+		if ( ! empty($classes) ) {
292 292
 			echo ' class="' . esc_attr( implode( ' ', $classes ) ) . '"';
293
-        }
294
-
295
-        do_action('frm_submit_button_action', $form, $form_action);
296
-        echo $button_parts[1];
297
-    }
298
-
299
-    /**
300
-     * Automatically add end section fields if they don't exist (2.0 migration)
301
-     * @since 2.0
302
-     *
303
-     * @param boolean $reset_fields
304
-     */
305
-    public static function auto_add_end_section_fields( $form, $fields, &$reset_fields ) {
293
+		}
294
+
295
+		do_action('frm_submit_button_action', $form, $form_action);
296
+		echo $button_parts[1];
297
+	}
298
+
299
+	/**
300
+	 * Automatically add end section fields if they don't exist (2.0 migration)
301
+	 * @since 2.0
302
+	 *
303
+	 * @param boolean $reset_fields
304
+	 */
305
+	public static function auto_add_end_section_fields( $form, $fields, &$reset_fields ) {
306 306
 		if ( empty( $fields ) ) {
307 307
 			return;
308 308
 		}
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 		$open = $prev_order = false;
312 312
 		$add_order = 0;
313 313
 		$last_field = false;
314
-        foreach ( $fields as $field ) {
314
+		foreach ( $fields as $field ) {
315 315
 			if ( $prev_order === $field->field_order ) {
316 316
 				$add_order++;
317 317
 			}
@@ -322,48 +322,48 @@  discard block
 block discarded – undo
322 322
 				FrmField::update( $field->id, array( 'field_order' => $field->field_order ) );
323 323
 			}
324 324
 
325
-            switch ( $field->type ) {
326
-                case 'divider':
327
-                    // create an end section if open
325
+			switch ( $field->type ) {
326
+				case 'divider':
327
+					// create an end section if open
328 328
 					self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $field, 'move' );
329 329
 
330
-                    // mark it open for the next end section
331
-                    $open = true;
332
-                break;
333
-                case 'break';
330
+					// mark it open for the next end section
331
+					$open = true;
332
+				break;
333
+				case 'break';
334 334
 					self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $field, 'move' );
335
-                break;
336
-                case 'end_divider':
337
-                    if ( ! $open ) {
338
-                        // the section isn't open, so this is an extra field that needs to be removed
339
-                        FrmField::destroy( $field->id );
340
-                        $reset_fields = true;
341
-                    }
342
-
343
-                    // There is already an end section here, so there is no need to create one
344
-                    $open = false;
345
-            }
335
+				break;
336
+				case 'end_divider':
337
+					if ( ! $open ) {
338
+						// the section isn't open, so this is an extra field that needs to be removed
339
+						FrmField::destroy( $field->id );
340
+						$reset_fields = true;
341
+					}
342
+
343
+					// There is already an end section here, so there is no need to create one
344
+					$open = false;
345
+			}
346 346
 			$prev_order = $field->field_order;
347 347
 
348 348
 			$last_field = $field;
349 349
 			unset( $field );
350
-        }
350
+		}
351 351
 
352 352
 		self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $last_field );
353
-    }
353
+	}
354 354
 
355 355
 	/**
356 356
 	 * Create end section field if it doesn't exist. This is for migration from < 2.0
357 357
 	 * Fix any ordering that may be messed up
358 358
 	 */
359 359
 	public static function maybe_create_end_section( &$open, &$reset_fields, &$add_order, $end_section_values, $field, $move = 'no' ) {
360
-        if ( ! $open ) {
361
-            return;
362
-        }
360
+		if ( ! $open ) {
361
+			return;
362
+		}
363 363
 
364 364
 		$end_section_values['field_order'] = $field->field_order + 1;
365 365
 
366
-        FrmField::create( $end_section_values );
366
+		FrmField::create( $end_section_values );
367 367
 
368 368
 		if ( $move == 'move' ) {
369 369
 			// bump the order of current field unless we're at the end of the form
@@ -371,38 +371,38 @@  discard block
 block discarded – undo
371 371
 		}
372 372
 
373 373
 		$add_order += 2;
374
-        $open = false;
375
-        $reset_fields = true;
376
-    }
374
+		$open = false;
375
+		$reset_fields = true;
376
+	}
377 377
 
378
-    public static function replace_shortcodes( $html, $form, $title = false, $description = false, $values = array() ) {
378
+	public static function replace_shortcodes( $html, $form, $title = false, $description = false, $values = array() ) {
379 379
 		foreach ( array( 'form_name' => $title, 'form_description' => $description, 'entry_key' => true ) as $code => $show ) {
380
-            if ( $code == 'form_name' ) {
381
-                $replace_with = $form->name;
382
-            } else if ( $code == 'form_description' ) {
383
-                $replace_with = FrmAppHelper::use_wpautop($form->description);
384
-            } else if ( $code == 'entry_key' && isset($_GET) && isset($_GET['entry']) ) {
385
-                $replace_with = FrmAppHelper::simple_get( 'entry' );
386
-            } else {
387
-                $replace_with = '';
388
-            }
380
+			if ( $code == 'form_name' ) {
381
+				$replace_with = $form->name;
382
+			} else if ( $code == 'form_description' ) {
383
+				$replace_with = FrmAppHelper::use_wpautop($form->description);
384
+			} else if ( $code == 'entry_key' && isset($_GET) && isset($_GET['entry']) ) {
385
+				$replace_with = FrmAppHelper::simple_get( 'entry' );
386
+			} else {
387
+				$replace_with = '';
388
+			}
389 389
 
390
-            FrmFieldsHelper::remove_inline_conditions( ( FrmAppHelper::is_true($show) && $replace_with != '' ), $code, $replace_with, $html );
391
-        }
390
+			FrmFieldsHelper::remove_inline_conditions( ( FrmAppHelper::is_true($show) && $replace_with != '' ), $code, $replace_with, $html );
391
+		}
392 392
 
393
-        //replace [form_key]
394
-        $html = str_replace('[form_key]', $form->form_key, $html);
393
+		//replace [form_key]
394
+		$html = str_replace('[form_key]', $form->form_key, $html);
395 395
 
396
-        //replace [frmurl]
397
-        $html = str_replace('[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html);
396
+		//replace [frmurl]
397
+		$html = str_replace('[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html);
398 398
 
399 399
 		if ( strpos( $html, '[button_label]' ) ) {
400 400
 			add_filter( 'frm_submit_button', 'FrmFormsHelper::submit_button_label', 1 );
401 401
 			$replace_with = apply_filters( 'frm_submit_button', $title, $form );
402 402
 			$html = str_replace( '[button_label]', $replace_with, $html );
403
-        }
403
+		}
404 404
 
405
-        $html = apply_filters('frm_form_replace_shortcodes', $html, $form, $values);
405
+		$html = apply_filters('frm_form_replace_shortcodes', $html, $form, $values);
406 406
 
407 407
 		if ( strpos( $html, '[if back_button]' ) ) {
408 408
 			$html = preg_replace( '/(\[if\s+back_button\])(.*?)(\[\/if\s+back_button\])/mis', '', $html );
@@ -416,32 +416,32 @@  discard block
 block discarded – undo
416 416
 			$html = do_shortcode( $html );
417 417
 		}
418 418
 
419
-        return $html;
420
-    }
419
+		return $html;
420
+	}
421 421
 
422 422
 	public static function submit_button_label( $submit ) {
423
-        if ( ! $submit || empty($submit) ) {
424
-            $frm_settings = FrmAppHelper::get_settings();
425
-            $submit = $frm_settings->submit_value;
426
-        }
423
+		if ( ! $submit || empty($submit) ) {
424
+			$frm_settings = FrmAppHelper::get_settings();
425
+			$submit = $frm_settings->submit_value;
426
+		}
427 427
 
428
-        return $submit;
429
-    }
428
+		return $submit;
429
+	}
430 430
 
431 431
 	public static function get_form_style_class( $form = false ) {
432
-        $style = self::get_form_style($form);
433
-        $class = ' with_frm_style';
434
-
435
-        if ( empty($style) ) {
436
-            if ( FrmAppHelper::is_admin_page('formidable-entries') ) {
437
-                return $class;
438
-            } else {
439
-                return;
440
-            }
441
-        }
442
-
443
-        //If submit button needs to be inline or centered
444
-        if ( is_object($form) ) {
432
+		$style = self::get_form_style($form);
433
+		$class = ' with_frm_style';
434
+
435
+		if ( empty($style) ) {
436
+			if ( FrmAppHelper::is_admin_page('formidable-entries') ) {
437
+				return $class;
438
+			} else {
439
+				return;
440
+			}
441
+		}
442
+
443
+		//If submit button needs to be inline or centered
444
+		if ( is_object($form) ) {
445 445
 			$form = $form->options;
446 446
 		}
447 447
 
@@ -453,17 +453,17 @@  discard block
 block discarded – undo
453 453
 			$class .= ' frm_center_submit';
454 454
 		}
455 455
 
456
-        $class = apply_filters('frm_add_form_style_class', $class, $style);
456
+		$class = apply_filters('frm_add_form_style_class', $class, $style);
457 457
 
458
-        return $class;
459
-    }
458
+		return $class;
459
+	}
460 460
 
461
-    /**
462
-     * @param string|boolean $form
463
-     *
464
-     * @return string
465
-     */
466
-    public static function get_form_style( $form ) {
461
+	/**
462
+	 * @param string|boolean $form
463
+	 *
464
+	 * @return string
465
+	 */
466
+	public static function get_form_style( $form ) {
467 467
 		$style = 1;
468 468
 		if ( empty( $form ) || 'default' == 'form' ) {
469 469
 			return $style;
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
 		$style = ( $form && is_object( $form ) && isset( $form->options['custom_style'] ) ) ? $form->options['custom_style'] : $style;
484 484
 
485 485
 		return $style;
486
-    }
486
+	}
487 487
 
488 488
 	/**
489 489
 	 * Display the validation error messages when an entry is submitted
@@ -537,74 +537,74 @@  discard block
 block discarded – undo
537 537
 	}
538 538
 
539 539
 	public static function get_scroll_js( $form_id ) {
540
-        ?><script type="text/javascript">jQuery(document).ready(function(){frmFrontForm.scrollMsg(<?php echo (int) $form_id ?>);})</script><?php
541
-    }
540
+		?><script type="text/javascript">jQuery(document).ready(function(){frmFrontForm.scrollMsg(<?php echo (int) $form_id ?>);})</script><?php
541
+	}
542 542
 
543 543
 	public static function edit_form_link( $form_id ) {
544
-        if ( is_object($form_id) ) {
545
-            $form = $form_id;
546
-            $name = $form->name;
547
-            $form_id = $form->id;
548
-        } else {
549
-            $name = FrmForm::getName($form_id);
550
-        }
551
-
552
-        if ( $form_id ) {
544
+		if ( is_object($form_id) ) {
545
+			$form = $form_id;
546
+			$name = $form->name;
547
+			$form_id = $form->id;
548
+		} else {
549
+			$name = FrmForm::getName($form_id);
550
+		}
551
+
552
+		if ( $form_id ) {
553 553
 			$val = '<a href="' . esc_url( admin_url( 'admin.php' ) . '?page=formidable&frm_action=edit&id=' . $form_id ) . '">' . ( '' == $name ? __( '(no title)' ) : FrmAppHelper::truncate( $name, 40 ) ) . '</a>';
554
-	    } else {
555
-	        $val = '';
556
-	    }
554
+		} else {
555
+			$val = '';
556
+		}
557 557
 
558
-	    return $val;
558
+		return $val;
559 559
 	}
560 560
 
561 561
 	public static function delete_trash_link( $id, $status, $length = 'long' ) {
562
-        $link = '';
563
-        $labels = array(
564
-            'restore' => array(
565
-                'long'  => __( 'Restore from Trash', 'formidable' ),
566
-                'short' => __( 'Restore', 'formidable' ),
567
-            ),
568
-            'trash' => array(
569
-                'long'  => __( 'Move to Trash', 'formidable' ),
570
-                'short' => __( 'Trash', 'formidable' ),
571
-            ),
572
-            'delete' => array(
573
-                'long'  => __( 'Delete Permanently', 'formidable' ),
574
-                'short' => __( 'Delete', 'formidable' ),
575
-            ),
576
-        );
577
-
578
-        $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
579
-        $base_url = '?page=formidable&form_type='. $current_page .'&id='. $id;
580
-        if ( 'trash' == $status ) {
562
+		$link = '';
563
+		$labels = array(
564
+			'restore' => array(
565
+				'long'  => __( 'Restore from Trash', 'formidable' ),
566
+				'short' => __( 'Restore', 'formidable' ),
567
+			),
568
+			'trash' => array(
569
+				'long'  => __( 'Move to Trash', 'formidable' ),
570
+				'short' => __( 'Trash', 'formidable' ),
571
+			),
572
+			'delete' => array(
573
+				'long'  => __( 'Delete Permanently', 'formidable' ),
574
+				'short' => __( 'Delete', 'formidable' ),
575
+			),
576
+		);
577
+
578
+		$current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
579
+		$base_url = '?page=formidable&form_type='. $current_page .'&id='. $id;
580
+		if ( 'trash' == $status ) {
581 581
 			$link = '<a href="'. esc_url( wp_nonce_url( $base_url . '&frm_action=untrash', 'untrash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['restore'][ $length ] . '</a>';
582
-        } else if ( current_user_can('frm_delete_forms') ) {
583
-            if ( EMPTY_TRASH_DAYS ) {
582
+		} else if ( current_user_can('frm_delete_forms') ) {
583
+			if ( EMPTY_TRASH_DAYS ) {
584 584
 				$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=trash', 'trash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['trash'][ $length ] . '</a>';
585
-            } else {
585
+			} else {
586 586
 				$link = '<a href="' . esc_url( wp_nonce_url( $base_url .'&frm_action=destroy', 'destroy_form_' . $id ) ) . '" class="submitdelete deletion" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete this form and all its entries?', 'formidable' ) ) . '\')">' . $labels['delete'][ $length ] . '</a>';
587
-            }
588
-        }
587
+			}
588
+		}
589 589
 
590
-        return $link;
591
-    }
590
+		return $link;
591
+	}
592 592
 
593 593
 	public static function status_nice_name( $status ) {
594
-        $nice_names = array(
595
-            'draft'     => __( 'Draft', 'formidable' ),
596
-            'trash'     => __( 'Trash', 'formidable' ),
597
-            'publish'   => __( 'Published', 'formidable' ),
598
-        );
599
-
600
-        if ( ! in_array($status, array_keys($nice_names)) ) {
601
-            $status = 'publish';
602
-        }
594
+		$nice_names = array(
595
+			'draft'     => __( 'Draft', 'formidable' ),
596
+			'trash'     => __( 'Trash', 'formidable' ),
597
+			'publish'   => __( 'Published', 'formidable' ),
598
+		);
599
+
600
+		if ( ! in_array($status, array_keys($nice_names)) ) {
601
+			$status = 'publish';
602
+		}
603 603
 
604 604
 		$name = $nice_names[ $status ];
605 605
 
606
-        return $name;
607
-    }
606
+		return $name;
607
+	}
608 608
 
609 609
 	public static function get_params() {
610 610
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::list_page_params' );
Please login to merge, or discard this patch.
Spacing   +66 added lines, -66 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
 
@@ -11,8 +11,8 @@  discard block
 block discarded – undo
11 11
 	}
12 12
 
13 13
 	public static function get_direct_link( $key, $form = false ) {
14
-        $target_url = esc_url(admin_url('admin-ajax.php') . '?action=frm_forms_preview&form='. $key);
15
-        $target_url = apply_filters('frm_direct_link', $target_url, $key, $form);
14
+        $target_url = esc_url( admin_url( 'admin-ajax.php' ) . '?action=frm_forms_preview&form=' . $key );
15
+        $target_url = apply_filters( 'frm_direct_link', $target_url, $key, $form );
16 16
 
17 17
         return $target_url;
18 18
     }
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 			$query['id !'] = $args['exclude'];
38 38
         }
39 39
 
40
-        $where = apply_filters('frm_forms_dropdown', $query, $field_name);
40
+        $where = apply_filters( 'frm_forms_dropdown', $query, $field_name );
41 41
 		$forms = FrmForm::get_published_forms( $where, 999, $args['inc_children'] );
42 42
 		$add_html = array();
43 43
 		self::add_html_attr( $args['onchange'], 'onchange', $add_html );
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		<?php } ?>
51 51
 		<?php foreach ( $forms as $form ) { ?>
52 52
 			<option value="<?php echo esc_attr( $form->id ); ?>" <?php selected( $field_value, $form->id ); ?>><?php
53
-				echo ( '' == $form->name ) ? esc_html__( '(no title)', 'formidable' ) : esc_html( FrmAppHelper::truncate( $form->name, 33 ) ) . ( $form->parent_form_id ? esc_html__( ' (child)', 'formidable' ) : '' ) ;
53
+				echo ( '' == $form->name ) ? esc_html__( '(no title)', 'formidable' ) : esc_html( FrmAppHelper::truncate( $form->name, 33 ) ) . ( $form->parent_form_id ? esc_html__( ' (child)', 'formidable' ) : '' );
54 54
 			?></option>
55 55
 		<?php } ?>
56 56
         </select>
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	public static function add_html_attr( $class, $param, &$add_html ) {
68 68
 		if ( ! empty( $class ) ) {
69
-			$add_html[ $param ] = sanitize_title( $param ) . '="' . esc_attr( trim( sanitize_text_field( $class ) ) ) . '"';
69
+			$add_html[$param] = sanitize_title( $param ) . '="' . esc_attr( trim( sanitize_text_field( $class ) ) ) . '"';
70 70
 		}
71 71
 	}
72 72
 
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 		$args = array( 'id' => 0, 'form' => 0 );
78 78
 		if ( isset( $_GET['id'] ) && ! isset( $_GET['form'] ) ) {
79 79
 			unset( $args['form'] );
80
-		} else if ( isset( $_GET['form']) && ! isset( $_GET['id'] ) ) {
80
+		} else if ( isset( $_GET['form'] ) && ! isset( $_GET['id'] ) ) {
81 81
 			unset( $args['id'] );
82 82
         }
83 83
 
@@ -85,11 +85,11 @@  discard block
 block discarded – undo
85 85
 		if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $frm_action, array( 'edit', 'show', 'destroy_all' ) ) ) {
86 86
             $args['frm_action'] = 'list';
87 87
             $args['form'] = 0;
88
-		} else if ( FrmAppHelper::is_admin_page('formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) {
88
+		} else if ( FrmAppHelper::is_admin_page( 'formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) {
89 89
             $args['frm_action'] = 'edit';
90 90
 		} else if ( isset( $_GET['post'] ) ) {
91 91
             $args['form'] = 0;
92
-            $base = admin_url('edit.php?post_type=frm_display');
92
+            $base = admin_url( 'edit.php?post_type=frm_display' );
93 93
         }
94 94
 
95 95
         ?>
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 			        $args['form'] = $form->id;
106 106
 				}
107 107
                 ?>
108
-				<li><a href="<?php echo esc_url( isset( $base ) ? add_query_arg( $args, $base ) : add_query_arg( $args ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)') : FrmAppHelper::truncate( $form->name, 33 ) ); ?></a></li>
108
+				<li><a href="<?php echo esc_url( isset( $base ) ? add_query_arg( $args, $base ) : add_query_arg( $args ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 33 ) ); ?></a></li>
109 109
 			<?php
110 110
 				unset( $form );
111 111
 			} ?>
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
     }
116 116
 
117 117
 	public static function get_sortable_classes( $col, $sort_col, $sort_dir ) {
118
-        echo ($sort_col == $col) ? 'sorted' : 'sortable';
119
-        echo ($sort_col == $col && $sort_dir == 'desc') ? ' asc' : ' desc';
118
+        echo ( $sort_col == $col ) ? 'sorted' : 'sortable';
119
+        echo ( $sort_col == $col && $sort_dir == 'desc' ) ? ' asc' : ' desc';
120 120
     }
121 121
 
122 122
 	public static function get_success_message( $atts ) {
@@ -135,37 +135,37 @@  discard block
 block discarded – undo
135 135
             $post_values = $values;
136 136
         } else {
137 137
             $values = array();
138
-            $post_values = isset($_POST) ? $_POST : array();
138
+            $post_values = isset( $_POST ) ? $_POST : array();
139 139
         }
140 140
 
141 141
 		foreach ( array( 'name' => '', 'description' => '' ) as $var => $default ) {
142
-			if ( ! isset( $values[ $var ] ) ) {
143
-				$values[ $var ] = FrmAppHelper::get_param( $var, $default );
142
+			if ( ! isset( $values[$var] ) ) {
143
+				$values[$var] = FrmAppHelper::get_param( $var, $default );
144 144
             }
145 145
         }
146 146
 
147
-        $values['description'] = FrmAppHelper::use_wpautop($values['description']);
147
+        $values['description'] = FrmAppHelper::use_wpautop( $values['description'] );
148 148
 
149 149
 		foreach ( array( 'form_id' => '', 'logged_in' => '', 'editable' => '', 'default_template' => 0, 'is_template' => 0, 'status' => 'draft', 'parent_form_id' => 0 ) as $var => $default ) {
150
-            if ( ! isset( $values[ $var ] ) ) {
151
-				$values[ $var ] = FrmAppHelper::get_param( $var, $default );
150
+            if ( ! isset( $values[$var] ) ) {
151
+				$values[$var] = FrmAppHelper::get_param( $var, $default );
152 152
             }
153 153
         }
154 154
 
155 155
         if ( ! isset( $values['form_key'] ) ) {
156
-            $values['form_key'] = ($post_values && isset($post_values['form_key'])) ? $post_values['form_key'] : FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_forms', 'form_key');
156
+            $values['form_key'] = ( $post_values && isset( $post_values['form_key'] ) ) ? $post_values['form_key'] : FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_forms', 'form_key' );
157 157
         }
158 158
 
159
-        $values = self::fill_default_opts($values, false, $post_values);
159
+        $values = self::fill_default_opts( $values, false, $post_values );
160 160
 
161
-        if ( $post_values && isset($post_values['options']['custom_style']) ) {
161
+        if ( $post_values && isset( $post_values['options']['custom_style'] ) ) {
162 162
             $values['custom_style'] = $post_values['options']['custom_style'];
163 163
         } else {
164 164
             $frm_settings = FrmAppHelper::get_settings();
165 165
             $values['custom_style'] = ( $frm_settings->load_style != 'none' );
166 166
         }
167 167
 
168
-        return apply_filters('frm_setup_new_form_vars', $values);
168
+        return apply_filters( 'frm_setup_new_form_vars', $values );
169 169
     }
170 170
 
171 171
     /**
@@ -176,42 +176,42 @@  discard block
 block discarded – undo
176 176
 			$post_values = stripslashes_deep( $_POST );
177 177
 		}
178 178
 
179
-        $values['form_key'] = isset($post_values['form_key']) ? $post_values['form_key'] : $record->form_key;
180
-        $values['default_template'] = isset($post_values['default_template']) ? $post_values['default_template'] : $record->default_template;
181
-        $values['is_template'] = isset($post_values['is_template']) ? $post_values['is_template'] : $record->is_template;
179
+        $values['form_key'] = isset( $post_values['form_key'] ) ? $post_values['form_key'] : $record->form_key;
180
+        $values['default_template'] = isset( $post_values['default_template'] ) ? $post_values['default_template'] : $record->default_template;
181
+        $values['is_template'] = isset( $post_values['is_template'] ) ? $post_values['is_template'] : $record->is_template;
182 182
         $values['status'] = $record->status;
183 183
 
184
-        $values = self::fill_default_opts($values, $record, $post_values);
184
+        $values = self::fill_default_opts( $values, $record, $post_values );
185 185
 
186
-        return apply_filters('frm_setup_edit_form_vars', $values);
186
+        return apply_filters( 'frm_setup_edit_form_vars', $values );
187 187
     }
188 188
 
189 189
 	public static function fill_default_opts( $values, $record, $post_values ) {
190 190
 
191 191
         $defaults = self::get_default_opts();
192 192
 		foreach ( $defaults as $var => $default ) {
193
-            if ( is_array($default) ) {
194
-                if ( ! isset( $values[ $var ] ) ) {
195
-					$values[ $var ] = ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : array();
193
+            if ( is_array( $default ) ) {
194
+                if ( ! isset( $values[$var] ) ) {
195
+					$values[$var] = ( $record && isset( $record->options[$var] ) ) ? $record->options[$var] : array();
196 196
                 }
197 197
 
198 198
                 foreach ( $default as $k => $v ) {
199
-					$values[ $var ][ $k ] = ( $post_values && isset( $post_values[ $var ][ $k ] ) ) ? $post_values[ $var ][ $k ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) ) ? $record->options[ $var ][ $k ] : $v);
199
+					$values[$var][$k] = ( $post_values && isset( $post_values[$var][$k] ) ) ? $post_values[$var][$k] : ( ( $record && isset( $record->options[$var] ) && isset( $record->options[$var][$k] ) ) ? $record->options[$var][$k] : $v );
200 200
 
201 201
                     if ( is_array( $v ) ) {
202 202
                         foreach ( $v as $k1 => $v1 ) {
203
-							$values[ $var ][ $k ][ $k1 ] = ( $post_values && isset( $post_values[ $var ][ $k ][ $k1 ] ) ) ? $post_values[ $var ][ $k ][ $k1 ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) && isset( $record->options[ $var ][ $k ][ $k1 ] ) ) ? $record->options[ $var ][ $k ][ $k1 ] : $v1 );
203
+							$values[$var][$k][$k1] = ( $post_values && isset( $post_values[$var][$k][$k1] ) ) ? $post_values[$var][$k][$k1] : ( ( $record && isset( $record->options[$var] ) && isset( $record->options[$var][$k] ) && isset( $record->options[$var][$k][$k1] ) ) ? $record->options[$var][$k][$k1] : $v1 );
204 204
                             unset( $k1, $v1 );
205 205
                         }
206 206
                     }
207 207
 
208
-                    unset($k, $v);
208
+                    unset( $k, $v );
209 209
                 }
210 210
             } else {
211
-				$values[ $var ] = ( $post_values && isset( $post_values['options'][ $var ] ) ) ? $post_values['options'][ $var ] : ( ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : $default );
211
+				$values[$var] = ( $post_values && isset( $post_values['options'][$var] ) ) ? $post_values['options'][$var] : ( ( $record && isset( $record->options[$var] ) ) ? $record->options[$var] : $default );
212 212
             }
213 213
 
214
-            unset($var, $default);
214
+            unset( $var, $default );
215 215
         }
216 216
 
217 217
         return $values;
@@ -224,9 +224,9 @@  discard block
 block discarded – undo
224 224
             'submit_value' => $frm_settings->submit_value, 'success_action' => 'message',
225 225
             'success_msg' => $frm_settings->success_msg, 'show_form' => 0, 'akismet' => '',
226 226
             'no_save' => 0, 'ajax_load' => 0, 'form_class' => '', 'custom_style' => 1,
227
-            'before_html' => self::get_default_html('before'),
227
+            'before_html' => self::get_default_html( 'before' ),
228 228
             'after_html' => '',
229
-            'submit_html' => self::get_default_html('submit'),
229
+            'submit_html' => self::get_default_html( 'submit' ),
230 230
         );
231 231
     }
232 232
 
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 	public static function fill_form_options( &$options, $values ) {
239 239
 		$defaults = self::get_default_opts();
240 240
 		foreach ( $defaults as $var => $default ) {
241
-			$options[ $var ] = isset( $values['options'][ $var ] ) ? $values['options'][ $var ] : $default;
241
+			$options[$var] = isset( $values['options'][$var] ) ? $values['options'][$var] : $default;
242 242
 			unset( $var, $default );
243 243
 		}
244 244
 	}
@@ -278,21 +278,21 @@  discard block
 block discarded – undo
278 278
     }
279 279
 
280 280
 	public static function get_custom_submit( $html, $form, $submit, $form_action, $values ) {
281
-        $button = self::replace_shortcodes($html, $form, $submit, $form_action, $values);
282
-        if ( ! strpos($button, '[button_action]') ) {
281
+        $button = self::replace_shortcodes( $html, $form, $submit, $form_action, $values );
282
+        if ( ! strpos( $button, '[button_action]' ) ) {
283 283
             return;
284 284
         }
285 285
 
286
-        $button_parts = explode('[button_action]', $button);
286
+        $button_parts = explode( '[button_action]', $button );
287 287
         echo $button_parts[0];
288 288
         //echo ' id="frm_submit_"';
289 289
 
290
-        $classes = apply_filters('frm_submit_button_class', array(), $form);
291
-        if ( ! empty($classes) ) {
290
+        $classes = apply_filters( 'frm_submit_button_class', array(), $form );
291
+        if ( ! empty( $classes ) ) {
292 292
 			echo ' class="' . esc_attr( implode( ' ', $classes ) ) . '"';
293 293
         }
294 294
 
295
-        do_action('frm_submit_button_action', $form, $form_action);
295
+        do_action( 'frm_submit_button_action', $form, $form_action );
296 296
         echo $button_parts[1];
297 297
     }
298 298
 
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 		$last_field = false;
314 314
         foreach ( $fields as $field ) {
315 315
 			if ( $prev_order === $field->field_order ) {
316
-				$add_order++;
316
+				$add_order ++;
317 317
 			}
318 318
 
319 319
 			if ( $add_order ) {
@@ -380,21 +380,21 @@  discard block
 block discarded – undo
380 380
             if ( $code == 'form_name' ) {
381 381
                 $replace_with = $form->name;
382 382
             } else if ( $code == 'form_description' ) {
383
-                $replace_with = FrmAppHelper::use_wpautop($form->description);
384
-            } else if ( $code == 'entry_key' && isset($_GET) && isset($_GET['entry']) ) {
383
+                $replace_with = FrmAppHelper::use_wpautop( $form->description );
384
+            } else if ( $code == 'entry_key' && isset( $_GET ) && isset( $_GET['entry'] ) ) {
385 385
                 $replace_with = FrmAppHelper::simple_get( 'entry' );
386 386
             } else {
387 387
                 $replace_with = '';
388 388
             }
389 389
 
390
-            FrmFieldsHelper::remove_inline_conditions( ( FrmAppHelper::is_true($show) && $replace_with != '' ), $code, $replace_with, $html );
390
+            FrmFieldsHelper::remove_inline_conditions( ( FrmAppHelper::is_true( $show ) && $replace_with != '' ), $code, $replace_with, $html );
391 391
         }
392 392
 
393 393
         //replace [form_key]
394
-        $html = str_replace('[form_key]', $form->form_key, $html);
394
+        $html = str_replace( '[form_key]', $form->form_key, $html );
395 395
 
396 396
         //replace [frmurl]
397
-        $html = str_replace('[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html);
397
+        $html = str_replace( '[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html );
398 398
 
399 399
 		if ( strpos( $html, '[button_label]' ) ) {
400 400
 			add_filter( 'frm_submit_button', 'FrmFormsHelper::submit_button_label', 1 );
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 			$html = str_replace( '[button_label]', $replace_with, $html );
403 403
         }
404 404
 
405
-        $html = apply_filters('frm_form_replace_shortcodes', $html, $form, $values);
405
+        $html = apply_filters( 'frm_form_replace_shortcodes', $html, $form, $values );
406 406
 
407 407
 		if ( strpos( $html, '[if back_button]' ) ) {
408 408
 			$html = preg_replace( '/(\[if\s+back_button\])(.*?)(\[\/if\s+back_button\])/mis', '', $html );
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
     }
421 421
 
422 422
 	public static function submit_button_label( $submit ) {
423
-        if ( ! $submit || empty($submit) ) {
423
+        if ( ! $submit || empty( $submit ) ) {
424 424
             $frm_settings = FrmAppHelper::get_settings();
425 425
             $submit = $frm_settings->submit_value;
426 426
         }
@@ -429,11 +429,11 @@  discard block
 block discarded – undo
429 429
     }
430 430
 
431 431
 	public static function get_form_style_class( $form = false ) {
432
-        $style = self::get_form_style($form);
432
+        $style = self::get_form_style( $form );
433 433
         $class = ' with_frm_style';
434 434
 
435
-        if ( empty($style) ) {
436
-            if ( FrmAppHelper::is_admin_page('formidable-entries') ) {
435
+        if ( empty( $style ) ) {
436
+            if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) ) {
437 437
                 return $class;
438 438
             } else {
439 439
                 return;
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
         }
442 442
 
443 443
         //If submit button needs to be inline or centered
444
-        if ( is_object($form) ) {
444
+        if ( is_object( $form ) ) {
445 445
 			$form = $form->options;
446 446
 		}
447 447
 
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 			$class .= ' frm_center_submit';
454 454
 		}
455 455
 
456
-        $class = apply_filters('frm_add_form_style_class', $class, $style);
456
+        $class = apply_filters( 'frm_add_form_style_class', $class, $style );
457 457
 
458 458
         return $class;
459 459
     }
@@ -541,12 +541,12 @@  discard block
 block discarded – undo
541 541
     }
542 542
 
543 543
 	public static function edit_form_link( $form_id ) {
544
-        if ( is_object($form_id) ) {
544
+        if ( is_object( $form_id ) ) {
545 545
             $form = $form_id;
546 546
             $name = $form->name;
547 547
             $form_id = $form->id;
548 548
         } else {
549
-            $name = FrmForm::getName($form_id);
549
+            $name = FrmForm::getName( $form_id );
550 550
         }
551 551
 
552 552
         if ( $form_id ) {
@@ -576,14 +576,14 @@  discard block
 block discarded – undo
576 576
         );
577 577
 
578 578
         $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
579
-        $base_url = '?page=formidable&form_type='. $current_page .'&id='. $id;
579
+        $base_url = '?page=formidable&form_type=' . $current_page . '&id=' . $id;
580 580
         if ( 'trash' == $status ) {
581
-			$link = '<a href="'. esc_url( wp_nonce_url( $base_url . '&frm_action=untrash', 'untrash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['restore'][ $length ] . '</a>';
582
-        } else if ( current_user_can('frm_delete_forms') ) {
581
+			$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=untrash', 'untrash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['restore'][$length] . '</a>';
582
+        } else if ( current_user_can( 'frm_delete_forms' ) ) {
583 583
             if ( EMPTY_TRASH_DAYS ) {
584
-				$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=trash', 'trash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['trash'][ $length ] . '</a>';
584
+				$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=trash', 'trash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['trash'][$length] . '</a>';
585 585
             } else {
586
-				$link = '<a href="' . esc_url( wp_nonce_url( $base_url .'&frm_action=destroy', 'destroy_form_' . $id ) ) . '" class="submitdelete deletion" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete this form and all its entries?', 'formidable' ) ) . '\')">' . $labels['delete'][ $length ] . '</a>';
586
+				$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=destroy', 'destroy_form_' . $id ) ) . '" class="submitdelete deletion" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete this form and all its entries?', 'formidable' ) ) . '\')">' . $labels['delete'][$length] . '</a>';
587 587
             }
588 588
         }
589 589
 
@@ -597,11 +597,11 @@  discard block
 block discarded – undo
597 597
             'publish'   => __( 'Published', 'formidable' ),
598 598
         );
599 599
 
600
-        if ( ! in_array($status, array_keys($nice_names)) ) {
600
+        if ( ! in_array( $status, array_keys( $nice_names ) ) ) {
601 601
             $status = 'publish';
602 602
         }
603 603
 
604
-		$name = $nice_names[ $status ];
604
+		$name = $nice_names[$status];
605 605
 
606 606
         return $name;
607 607
     }
Please login to merge, or discard this patch.
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -375,6 +375,9 @@
 block discarded – undo
375 375
         $reset_fields = true;
376 376
     }
377 377
 
378
+    /**
379
+     * @return string
380
+     */
378 381
     public static function replace_shortcodes( $html, $form, $title = false, $description = false, $values = array() ) {
379 382
 		foreach ( array( 'form_name' => $title, 'form_description' => $description, 'entry_key' => true ) as $code => $show ) {
380 383
             if ( $code == 'form_name' ) {
Please login to merge, or discard this patch.