Completed
Branch 3.0 (7d679c)
by Stephanie
02:50
created
classes/models/FrmEntry.php 3 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -180,6 +180,7 @@  discard block
 block discarded – undo
180 180
 	*
181 181
 	* @param int $id
182 182
 	* @param array $values
183
+	* @param string $update_type
183 184
 	* @return boolean|int $query_results
184 185
 	*/
185 186
 	private static function update_entry( $id, $values, $update_type ) {
@@ -563,6 +564,9 @@  discard block
 block discarded – undo
563 564
 		return $new_values;
564 565
 	}
565 566
 
567
+	/**
568
+	 * @param string $name
569
+	 */
566 570
 	private static function get_entry_value( $values, $name, $default ) {
567 571
 		return isset( $values[ $name ] ) ? $values[ $name ] : $default;
568 572
 	}
Please login to merge, or discard this patch.
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -55,13 +55,13 @@  discard block
 block discarded – undo
55 55
 		unset( $check_val['is_draft'], $check_val['id'], $check_val['item_key'] );
56 56
 
57 57
         if ( $new_values['item_key'] == $new_values['name'] ) {
58
-            unset($check_val['name']);
58
+            unset( $check_val['name'] );
59 59
         }
60 60
 
61 61
         global $wpdb;
62 62
 		$entry_exists = FrmDb::get_col( $wpdb->prefix . 'frm_items', $check_val, 'id', array( 'order_by' => 'created_at DESC' ) );
63 63
 
64
-        if ( ! $entry_exists || empty($entry_exists) || ! isset($values['item_meta']) ) {
64
+        if ( ! $entry_exists || empty( $entry_exists ) || ! isset( $values['item_meta'] ) ) {
65 65
             return false;
66 66
         }
67 67
 
@@ -70,10 +70,10 @@  discard block
 block discarded – undo
70 70
             $is_duplicate = true;
71 71
 
72 72
             //add more checks here to make sure it's a duplicate
73
-            $metas = FrmEntryMeta::get_entry_meta_info($entry_exist);
73
+            $metas = FrmEntryMeta::get_entry_meta_info( $entry_exist );
74 74
             $field_metas = array();
75 75
             foreach ( $metas as $meta ) {
76
-				$field_metas[ $meta->field_id ] = $meta->meta_value;
76
+				$field_metas[$meta->field_id] = $meta->meta_value;
77 77
             }
78 78
 
79 79
             // If prev entry is empty and current entry is not, they are not duplicates
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
                 return false;
83 83
             }
84 84
 
85
-            $diff = array_diff_assoc($field_metas, array_map('maybe_serialize', $values['item_meta']));
85
+            $diff = array_diff_assoc( $field_metas, array_map( 'maybe_serialize', $values['item_meta'] ) );
86 86
             foreach ( $diff as $field_id => $meta_value ) {
87
-                if ( ! empty($meta_value) ) {
87
+                if ( ! empty( $meta_value ) ) {
88 88
                     $is_duplicate = false;
89 89
                     continue;
90 90
                 }
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 		}
114 114
 
115 115
 		// If CSV is importing, don't check for duplicates
116
-		if ( defined('WP_IMPORTING') && WP_IMPORTING ) {
116
+		if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
117 117
 			return false;
118 118
 		}
119 119
 
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
         $new_values['is_draft'] = $values->is_draft;
137 137
 		$new_values['user_id'] = (int) $values->user_id;
138 138
 		$new_values['updated_by'] = (int) $values->user_id;
139
-        $new_values['form_id'] = $values->form_id ? (int) $values->form_id: null;
139
+        $new_values['form_id'] = $values->form_id ? (int) $values->form_id : null;
140 140
 		$new_values['created_at'] = current_time( 'mysql', 1 );
141 141
 		$new_values['updated_at'] = $new_values['created_at'];
142 142
 
@@ -148,12 +148,12 @@  discard block
 block discarded – undo
148 148
         $entry_id = $wpdb->insert_id;
149 149
 
150 150
         global $frm_vars;
151
-        if ( ! isset($frm_vars['saved_entries']) ) {
151
+        if ( ! isset( $frm_vars['saved_entries'] ) ) {
152 152
             $frm_vars['saved_entries'] = array();
153 153
         }
154 154
         $frm_vars['saved_entries'][] = (int) $entry_id;
155 155
 
156
-        FrmEntryMeta::duplicate_entry_metas($id, $entry_id);
156
+        FrmEntryMeta::duplicate_entry_metas( $id, $entry_id );
157 157
 		self::clear_cache();
158 158
 
159 159
 		do_action( 'frm_after_duplicate_entry', $entry_id, $new_values['form_id'], array( 'old_id' => $id ) );
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 
193 193
 		$new_values = self::package_entry_to_update( $id, $values );
194 194
 
195
-		$query_results = $wpdb->update( $wpdb->prefix . 'frm_items', $new_values, compact('id') );
195
+		$query_results = $wpdb->update( $wpdb->prefix . 'frm_items', $new_values, compact( 'id' ) );
196 196
 
197 197
 		self::after_update_entry( $query_results, $id, $values, $new_values );
198 198
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
             return $result;
210 210
         }
211 211
 
212
-        do_action('frm_before_destroy_entry', $id, $entry);
212
+        do_action( 'frm_before_destroy_entry', $id, $entry );
213 213
 
214 214
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE item_id=%d', $id ) );
215 215
 		$result = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_items WHERE id=%d', $id ) );
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 
222 222
 	public static function update_form( $id, $value, $form_id ) {
223 223
         global $wpdb;
224
-        $form_id = isset($value) ? $form_id : null;
224
+        $form_id = isset( $value ) ? $form_id : null;
225 225
 		$result = $wpdb->update( $wpdb->prefix . 'frm_items', array( 'form_id' => $form_id ), array( 'id' => $id ) );
226 226
 		if ( $result ) {
227 227
 			self::clear_cache();
@@ -268,24 +268,24 @@  discard block
 block discarded – undo
268 268
         $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it
269 269
                   LEFT OUTER JOIN {$wpdb->prefix}frm_forms fr ON it.form_id=fr.id WHERE ";
270 270
 
271
-        $query .= is_numeric($id) ? 'it.id=%d' : 'it.item_key=%s';
271
+        $query .= is_numeric( $id ) ? 'it.id=%d' : 'it.item_key=%s';
272 272
         $query_args = array( $id );
273 273
         $query = $wpdb->prepare( $query, $query_args );
274 274
 
275 275
         if ( ! $meta ) {
276 276
 			$entry = FrmAppHelper::check_cache( $id . '_nometa', 'frm_entry', $query, 'get_row' );
277
-            return stripslashes_deep($entry);
277
+            return stripslashes_deep( $entry );
278 278
         }
279 279
 
280 280
         $entry = FrmAppHelper::check_cache( $id, 'frm_entry' );
281 281
         if ( $entry !== false ) {
282
-            return stripslashes_deep($entry);
282
+            return stripslashes_deep( $entry );
283 283
         }
284 284
 
285 285
         $entry = $wpdb->get_row( $query );
286
-        $entry = self::get_meta($entry);
286
+        $entry = self::get_meta( $entry );
287 287
 
288
-        return stripslashes_deep($entry);
288
+        return stripslashes_deep( $entry );
289 289
     }
290 290
 
291 291
 	public static function get_meta( $entry ) {
@@ -301,23 +301,23 @@  discard block
 block discarded – undo
301 301
 		$include_key = apply_filters( 'frm_include_meta_keys', false, array( 'form_id' => $entry->form_id ) );
302 302
         foreach ( $metas as $meta_val ) {
303 303
             if ( $meta_val->item_id == $entry->id ) {
304
-				$entry->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value );
304
+				$entry->metas[$meta_val->field_id] = maybe_unserialize( $meta_val->meta_value );
305 305
 				if ( $include_key ) {
306
-					$entry->metas[ $meta_val->field_key ] = $entry->metas[ $meta_val->field_id ];
306
+					$entry->metas[$meta_val->field_key] = $entry->metas[$meta_val->field_id];
307 307
 				}
308 308
                  continue;
309 309
             }
310 310
 
311 311
             // include sub entries in an array
312
-			if ( ! isset( $entry_metas[ $meta_val->field_id ] ) ) {
313
-				$entry->metas[ $meta_val->field_id ] = array();
312
+			if ( ! isset( $entry_metas[$meta_val->field_id] ) ) {
313
+				$entry->metas[$meta_val->field_id] = array();
314 314
             }
315 315
 
316
-			$entry->metas[ $meta_val->field_id ][] = maybe_unserialize( $meta_val->meta_value );
316
+			$entry->metas[$meta_val->field_id][] = maybe_unserialize( $meta_val->meta_value );
317 317
 
318
-            unset($meta_val);
318
+            unset( $meta_val );
319 319
         }
320
-        unset($metas);
320
+        unset( $metas );
321 321
 
322 322
 		FrmAppHelper::set_cache( $entry->id, $entry, 'frm_entry' );
323 323
 
@@ -335,24 +335,24 @@  discard block
 block discarded – undo
335 335
             return $exists;
336 336
         }
337 337
 
338
-        if ( is_numeric($id) ) {
338
+        if ( is_numeric( $id ) ) {
339 339
             $where = array( 'id' => $id );
340 340
         } else {
341 341
             $where = array( 'item_key' => $id );
342 342
         }
343 343
 		$id = FrmDb::get_var( $wpdb->prefix . 'frm_items', $where );
344 344
 
345
-        $exists = ($id && $id > 0) ? true : false;
345
+        $exists = ( $id && $id > 0 ) ? true : false;
346 346
         return $exists;
347 347
     }
348 348
 
349 349
     public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) {
350 350
 		global $wpdb;
351 351
 
352
-        $limit = FrmAppHelper::esc_limit($limit);
352
+        $limit = FrmAppHelper::esc_limit( $limit );
353 353
 
354
-        $cache_key = maybe_serialize($where) . $order_by . $limit . $inc_form;
355
-        $entries = wp_cache_get($cache_key, 'frm_entry');
354
+        $cache_key = maybe_serialize( $where ) . $order_by . $limit . $inc_form;
355
+        $entries = wp_cache_get( $cache_key, 'frm_entry' );
356 356
 
357 357
         if ( false === $entries ) {
358 358
             $fields = 'it.id, it.item_key, it.name, it.ip, it.form_id, it.post_id, it.user_id, it.parent_item_id, it.updated_by, it.created_at, it.updated_at, it.is_draft';
@@ -371,25 +371,25 @@  discard block
 block discarded – undo
371 371
 		    }
372 372
 
373 373
 			// prepare the query
374
-			$query = 'SELECT ' . $fields . ' FROM ' . $table . FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
374
+			$query = 'SELECT ' . $fields . ' FROM ' . $table . FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
375 375
 
376
-            $entries = $wpdb->get_results($query, OBJECT_K);
377
-            unset($query);
376
+            $entries = $wpdb->get_results( $query, OBJECT_K );
377
+            unset( $query );
378 378
 
379 379
 			FrmAppHelper::set_cache( $cache_key, $entries, 'frm_entry' );
380 380
         }
381 381
 
382 382
         if ( ! $meta || ! $entries ) {
383
-            return stripslashes_deep($entries);
383
+            return stripslashes_deep( $entries );
384 384
         }
385
-        unset($meta);
385
+        unset( $meta );
386 386
 
387
-        if ( ! is_array( $where ) && preg_match('/^it\.form_id=\d+$/', $where) ) {
387
+        if ( ! is_array( $where ) && preg_match( '/^it\.form_id=\d+$/', $where ) ) {
388 388
 			$where = array( 'it.form_id' => substr( $where, 11 ) );
389 389
         }
390 390
 
391 391
         $meta_where = array( 'field_id !' => 0 );
392
-        if ( $limit == '' && is_array($where) && count($where) == 1 && isset($where['it.form_id']) ) {
392
+        if ( $limit == '' && is_array( $where ) && count( $where ) == 1 && isset( $where['it.form_id'] ) ) {
393 393
             $meta_where['fi.form_id'] = $where['it.form_id'];
394 394
         } else {
395 395
             $meta_where['item_id'] = array_keys( $entries );
@@ -400,21 +400,21 @@  discard block
 block discarded – undo
400 400
         unset( $meta_where );
401 401
 
402 402
         if ( ! $metas ) {
403
-            return stripslashes_deep($entries);
403
+            return stripslashes_deep( $entries );
404 404
         }
405 405
 
406 406
         foreach ( $metas as $m_key => $meta_val ) {
407
-            if ( ! isset( $entries[ $meta_val->item_id ] ) ) {
407
+            if ( ! isset( $entries[$meta_val->item_id] ) ) {
408 408
                 continue;
409 409
             }
410 410
 
411
-            if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) {
412
-				$entries[ $meta_val->item_id ]->metas = array();
411
+            if ( ! isset( $entries[$meta_val->item_id]->metas ) ) {
412
+				$entries[$meta_val->item_id]->metas = array();
413 413
             }
414 414
 
415
-			$entries[ $meta_val->item_id ]->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value );
415
+			$entries[$meta_val->item_id]->metas[$meta_val->field_id] = maybe_unserialize( $meta_val->meta_value );
416 416
 
417
-            unset($m_key, $meta_val);
417
+            unset( $m_key, $meta_val );
418 418
         }
419 419
 
420 420
 		if ( ! FrmAppHelper::prevent_caching() ) {
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 			}
425 425
 		}
426 426
 
427
-        return stripslashes_deep($entries);
427
+        return stripslashes_deep( $entries );
428 428
     }
429 429
 
430 430
     // Pagination Methods
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
         global $wpdb;
433 433
 		$table_join = $wpdb->prefix . 'frm_items it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id';
434 434
 
435
-        if ( is_numeric($where) ) {
435
+        if ( is_numeric( $where ) ) {
436 436
             $table_join = 'frm_items';
437 437
             $where = array( 'form_id' => $where );
438 438
         }
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
 		self::sanitize_entry_post( $values );
475 475
 
476 476
 		if ( $type != 'xml' ) {
477
-			$values = apply_filters('frm_pre_create_entry', $values);
477
+			$values = apply_filters( 'frm_pre_create_entry', $values );
478 478
 		}
479 479
 
480 480
 		$new_values = self::package_entry_data( $values );
@@ -554,17 +554,17 @@  discard block
 block discarded – undo
554 554
 			'user_id' => self::get_entry_user_id( $values ),
555 555
 		);
556 556
 
557
-		if ( is_array($new_values['name']) ) {
558
-			$new_values['name'] = reset($new_values['name']);
557
+		if ( is_array( $new_values['name'] ) ) {
558
+			$new_values['name'] = reset( $new_values['name'] );
559 559
 		}
560 560
 
561
-		$new_values['updated_by'] = isset($values['updated_by']) ? $values['updated_by'] : $new_values['user_id'];
561
+		$new_values['updated_by'] = isset( $values['updated_by'] ) ? $values['updated_by'] : $new_values['user_id'];
562 562
 
563 563
 		return $new_values;
564 564
 	}
565 565
 
566 566
 	private static function get_entry_value( $values, $name, $default ) {
567
-		return isset( $values[ $name ] ) ? $values[ $name ] : $default;
567
+		return isset( $values[$name] ) ? $values[$name] : $default;
568 568
 	}
569 569
 
570 570
 	/**
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
 		}
582 582
 
583 583
 		$ip = FrmAppHelper::get_ip_address();
584
-		if ( defined('WP_IMPORTING') && WP_IMPORTING ) {
584
+		if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
585 585
 			$ip = self::get_entry_value( $values, 'ip', $ip );
586 586
 		}
587 587
 		return $ip;
@@ -694,7 +694,7 @@  discard block
 block discarded – undo
694 694
 	private static function add_new_entry_to_frm_vars( $entry_id ) {
695 695
 		global $frm_vars;
696 696
 
697
-		if ( ! isset($frm_vars['saved_entries']) ) {
697
+		if ( ! isset( $frm_vars['saved_entries'] ) ) {
698 698
 			$frm_vars['saved_entries'] = array();
699 699
 		}
700 700
 
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
 	* @param int $entry_id
710 710
 	*/
711 711
 	private static function maybe_add_entry_metas( $values, $entry_id ) {
712
-		if ( isset($values['item_meta']) ) {
712
+		if ( isset( $values['item_meta'] ) ) {
713 713
 			FrmEntryMeta::update_entry_metas( $entry_id, $values['item_meta'] );
714 714
 		}
715 715
 	}
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
 		$is_child = isset( $values['parent_form_id'] ) && isset( $values['parent_nonce'] ) && ! empty( $values['parent_form_id'] ) && wp_verify_nonce( $values['parent_nonce'], 'parent' );
727 727
 
728 728
 		do_action( 'frm_after_create_entry', $entry_id, $new_values['form_id'], compact( 'is_child' ) );
729
-		do_action( 'frm_after_create_entry_' . $new_values['form_id'], $entry_id , compact( 'is_child' ) );
729
+		do_action( 'frm_after_create_entry_' . $new_values['form_id'], $entry_id, compact( 'is_child' ) );
730 730
 	}
731 731
 
732 732
 	/**
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
 		}
768 768
 
769 769
 		if ( $update && $update_type != 'xml' ) {
770
-			$values = apply_filters('frm_pre_update_entry', $values, $id);
770
+			$values = apply_filters( 'frm_pre_update_entry', $values, $id );
771 771
 		}
772 772
 
773 773
 		return $update;
@@ -788,27 +788,27 @@  discard block
 block discarded – undo
788 788
 			'name'      => self::get_new_entry_name( $values ),
789 789
 			'form_id'   => (int) self::get_entry_value( $values, 'form_id', null ),
790 790
 			'is_draft'  => self::get_is_draft_value( $values ),
791
-			'updated_at' => current_time('mysql', 1),
792
-			'updated_by' => isset($values['updated_by']) ? $values['updated_by'] : get_current_user_id(),
791
+			'updated_at' => current_time( 'mysql', 1 ),
792
+			'updated_by' => isset( $values['updated_by'] ) ? $values['updated_by'] : get_current_user_id(),
793 793
 		);
794 794
 
795
-		if ( isset($values['post_id']) ) {
795
+		if ( isset( $values['post_id'] ) ) {
796 796
 			$new_values['post_id'] = (int) $values['post_id'];
797 797
 		}
798 798
 
799
-		if ( isset($values['item_key']) ) {
799
+		if ( isset( $values['item_key'] ) ) {
800 800
 			$new_values['item_key'] = FrmAppHelper::get_unique_key( $values['item_key'], $wpdb->prefix . 'frm_items', 'item_key', $id );
801 801
 		}
802 802
 
803
-		if ( isset($values['parent_item_id']) ) {
803
+		if ( isset( $values['parent_item_id'] ) ) {
804 804
 			$new_values['parent_item_id'] = (int) $values['parent_item_id'];
805 805
 		}
806 806
 
807
-		if ( isset($values['frm_user_id']) && is_numeric($values['frm_user_id']) ) {
807
+		if ( isset( $values['frm_user_id'] ) && is_numeric( $values['frm_user_id'] ) ) {
808 808
 			$new_values['user_id'] = $values['frm_user_id'];
809 809
 		}
810 810
 
811
-		$new_values = apply_filters('frm_update_entry', $new_values, $id);
811
+		$new_values = apply_filters( 'frm_update_entry', $new_values, $id );
812 812
 
813 813
 		return $new_values;
814 814
 	}
Please login to merge, or discard this patch.
Indentation   +354 added lines, -354 removed lines patch added patch discarded remove patch
@@ -6,11 +6,11 @@  discard block
 block discarded – undo
6 6
 class FrmEntry {
7 7
 
8 8
 	/**
9
-	* Create a new entry
10
-	*
11
-	* @param array $values
12
-	* @return int | boolean $entry_id
13
-	*/
9
+	 * Create a new entry
10
+	 *
11
+	 * @param array $values
12
+	 * @return int | boolean $entry_id
13
+	 */
14 14
 	public static function create( $values ) {
15 15
 		$entry_id = self::create_entry( $values, 'standard' );
16 16
 
@@ -18,12 +18,12 @@  discard block
 block discarded – undo
18 18
 	}
19 19
 
20 20
 	/**
21
-	* Create a new entry with some differences depending on type
22
-	*
23
-	* @param array $values
24
-	* @param string $type
25
-	* @return int | boolean $entry_id
26
-	*/
21
+	 * Create a new entry with some differences depending on type
22
+	 *
23
+	 * @param array $values
24
+	 * @param string $type
25
+	 * @return int | boolean $entry_id
26
+	 */
27 27
 	private static function create_entry( $values, $type ) {
28 28
 		$new_values = self::before_insert_entry_in_database( $values, $type );
29 29
 
@@ -37,10 +37,10 @@  discard block
 block discarded – undo
37 37
 		return $entry_id;
38 38
 	}
39 39
 
40
-    /**
41
-     * check for duplicate entries created in the last minute
42
-     * @return boolean
43
-     */
40
+	/**
41
+	 * check for duplicate entries created in the last minute
42
+	 * @return boolean
43
+	 */
44 44
 	public static function is_duplicate( $new_values, $values ) {
45 45
 		$duplicate_entry_time = apply_filters( 'frm_time_to_check_duplicates', 60, $new_values );
46 46
 
@@ -48,55 +48,55 @@  discard block
 block discarded – undo
48 48
 			return false;
49 49
 		}
50 50
 
51
-        $check_val = $new_values;
51
+		$check_val = $new_values;
52 52
 		$check_val['created_at >'] = date( 'Y-m-d H:i:s', ( strtotime( $new_values['created_at'] ) - absint( $duplicate_entry_time ) ) );
53 53
 
54 54
 		unset( $check_val['created_at'], $check_val['updated_at'] );
55 55
 		unset( $check_val['is_draft'], $check_val['id'], $check_val['item_key'] );
56 56
 
57
-        if ( $new_values['item_key'] == $new_values['name'] ) {
58
-            unset($check_val['name']);
59
-        }
57
+		if ( $new_values['item_key'] == $new_values['name'] ) {
58
+			unset($check_val['name']);
59
+		}
60 60
 
61
-        global $wpdb;
61
+		global $wpdb;
62 62
 		$entry_exists = FrmDb::get_col( $wpdb->prefix . 'frm_items', $check_val, 'id', array( 'order_by' => 'created_at DESC' ) );
63 63
 
64
-        if ( ! $entry_exists || empty($entry_exists) || ! isset($values['item_meta']) ) {
65
-            return false;
66
-        }
64
+		if ( ! $entry_exists || empty($entry_exists) || ! isset($values['item_meta']) ) {
65
+			return false;
66
+		}
67 67
 
68
-        $is_duplicate = false;
69
-        foreach ( $entry_exists as $entry_exist ) {
70
-            $is_duplicate = true;
68
+		$is_duplicate = false;
69
+		foreach ( $entry_exists as $entry_exist ) {
70
+			$is_duplicate = true;
71 71
 
72
-            //add more checks here to make sure it's a duplicate
73
-            $metas = FrmEntryMeta::get_entry_meta_info($entry_exist);
74
-            $field_metas = array();
75
-            foreach ( $metas as $meta ) {
72
+			//add more checks here to make sure it's a duplicate
73
+			$metas = FrmEntryMeta::get_entry_meta_info($entry_exist);
74
+			$field_metas = array();
75
+			foreach ( $metas as $meta ) {
76 76
 				$field_metas[ $meta->field_id ] = $meta->meta_value;
77
-            }
78
-
79
-            // If prev entry is empty and current entry is not, they are not duplicates
80
-            $filtered_vals = array_filter( $values['item_meta'] );
81
-            if ( empty( $field_metas ) && ! empty( $filtered_vals ) ) {
82
-                return false;
83
-            }
84
-
85
-            $diff = array_diff_assoc($field_metas, array_map('maybe_serialize', $values['item_meta']));
86
-            foreach ( $diff as $field_id => $meta_value ) {
87
-                if ( ! empty($meta_value) ) {
88
-                    $is_duplicate = false;
89
-                    continue;
90
-                }
91
-            }
92
-
93
-            if ( $is_duplicate ) {
77
+			}
78
+
79
+			// If prev entry is empty and current entry is not, they are not duplicates
80
+			$filtered_vals = array_filter( $values['item_meta'] );
81
+			if ( empty( $field_metas ) && ! empty( $filtered_vals ) ) {
82
+				return false;
83
+			}
84
+
85
+			$diff = array_diff_assoc($field_metas, array_map('maybe_serialize', $values['item_meta']));
86
+			foreach ( $diff as $field_id => $meta_value ) {
87
+				if ( ! empty($meta_value) ) {
88
+					$is_duplicate = false;
89
+					continue;
90
+				}
91
+			}
92
+
93
+			if ( $is_duplicate ) {
94 94
 				break;
95
-            }
96
-        }
95
+			}
96
+		}
97 97
 
98
-        return $is_duplicate;
99
-    }
98
+		return $is_duplicate;
99
+	}
100 100
 
101 101
 	/**
102 102
 	 * Determine if an entry needs to be checked as a possible duplicate
@@ -125,48 +125,48 @@  discard block
 block discarded – undo
125 125
 		return true;
126 126
 	}
127 127
 
128
-    public static function duplicate( $id ) {
129
-        global $wpdb;
128
+	public static function duplicate( $id ) {
129
+		global $wpdb;
130 130
 
131
-        $values = self::getOne( $id );
131
+		$values = self::getOne( $id );
132 132
 
133
-        $new_values = array();
133
+		$new_values = array();
134 134
 		$new_values['item_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_items', 'item_key' );
135
-        $new_values['name'] = $values->name;
136
-        $new_values['is_draft'] = $values->is_draft;
135
+		$new_values['name'] = $values->name;
136
+		$new_values['is_draft'] = $values->is_draft;
137 137
 		$new_values['user_id'] = (int) $values->user_id;
138 138
 		$new_values['updated_by'] = (int) $values->user_id;
139
-        $new_values['form_id'] = $values->form_id ? (int) $values->form_id: null;
139
+		$new_values['form_id'] = $values->form_id ? (int) $values->form_id: null;
140 140
 		$new_values['created_at'] = current_time( 'mysql', 1 );
141 141
 		$new_values['updated_at'] = $new_values['created_at'];
142 142
 
143 143
 		$query_results = $wpdb->insert( $wpdb->prefix . 'frm_items', $new_values );
144
-        if ( ! $query_results ) {
145
-            return false;
146
-        }
144
+		if ( ! $query_results ) {
145
+			return false;
146
+		}
147 147
 
148
-        $entry_id = $wpdb->insert_id;
148
+		$entry_id = $wpdb->insert_id;
149 149
 
150
-        global $frm_vars;
151
-        if ( ! isset($frm_vars['saved_entries']) ) {
152
-            $frm_vars['saved_entries'] = array();
153
-        }
154
-        $frm_vars['saved_entries'][] = (int) $entry_id;
150
+		global $frm_vars;
151
+		if ( ! isset($frm_vars['saved_entries']) ) {
152
+			$frm_vars['saved_entries'] = array();
153
+		}
154
+		$frm_vars['saved_entries'][] = (int) $entry_id;
155 155
 
156
-        FrmEntryMeta::duplicate_entry_metas($id, $entry_id);
156
+		FrmEntryMeta::duplicate_entry_metas($id, $entry_id);
157 157
 		self::clear_cache();
158 158
 
159 159
 		do_action( 'frm_after_duplicate_entry', $entry_id, $new_values['form_id'], array( 'old_id' => $id ) );
160
-        return $entry_id;
161
-    }
160
+		return $entry_id;
161
+	}
162 162
 
163 163
 	/**
164
-	* Update an entry (not via XML)
165
-	*
166
-	* @param int $id
167
-	* @param array $values
168
-	* @return boolean|int $update_results
169
-	*/
164
+	 * Update an entry (not via XML)
165
+	 *
166
+	 * @param int $id
167
+	 * @param array $values
168
+	 * @return boolean|int $update_results
169
+	 */
170 170
 	public static function update( $id, $values ) {
171 171
 		$update_results = self::update_entry( $id, $values, 'standard' );
172 172
 
@@ -174,14 +174,14 @@  discard block
 block discarded – undo
174 174
 	}
175 175
 
176 176
 	/**
177
-	* Update an entry with some differences depending on the update type
178
-	*
179
-	* @since 2.0.16
180
-	*
181
-	* @param int $id
182
-	* @param array $values
183
-	* @return boolean|int $query_results
184
-	*/
177
+	 * Update an entry with some differences depending on the update type
178
+	 *
179
+	 * @since 2.0.16
180
+	 *
181
+	 * @param int $id
182
+	 * @param array $values
183
+	 * @return boolean|int $query_results
184
+	 */
185 185
 	private static function update_entry( $id, $values, $update_type ) {
186 186
 		global $wpdb;
187 187
 
@@ -200,34 +200,34 @@  discard block
 block discarded – undo
200 200
 	}
201 201
 
202 202
 	public static function destroy( $id ) {
203
-        global $wpdb;
204
-        $id = (int) $id;
203
+		global $wpdb;
204
+		$id = (int) $id;
205 205
 
206 206
 		$entry = self::getOne( $id );
207
-        if ( ! $entry ) {
208
-            $result = false;
209
-            return $result;
210
-        }
207
+		if ( ! $entry ) {
208
+			$result = false;
209
+			return $result;
210
+		}
211 211
 
212
-        do_action('frm_before_destroy_entry', $id, $entry);
212
+		do_action('frm_before_destroy_entry', $id, $entry);
213 213
 
214 214
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE item_id=%d', $id ) );
215 215
 		$result = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_items WHERE id=%d', $id ) );
216 216
 
217 217
 		self::clear_cache();
218 218
 
219
-        return $result;
220
-    }
219
+		return $result;
220
+	}
221 221
 
222 222
 	public static function update_form( $id, $value, $form_id ) {
223
-        global $wpdb;
224
-        $form_id = isset($value) ? $form_id : null;
223
+		global $wpdb;
224
+		$form_id = isset($value) ? $form_id : null;
225 225
 		$result = $wpdb->update( $wpdb->prefix . 'frm_items', array( 'form_id' => $form_id ), array( 'id' => $id ) );
226 226
 		if ( $result ) {
227 227
 			self::clear_cache();
228 228
 		}
229
-        return $result;
230
-    }
229
+		return $result;
230
+	}
231 231
 
232 232
 	/**
233 233
 	 * Clear entry caching
@@ -263,159 +263,159 @@  discard block
 block discarded – undo
263 263
 	}
264 264
 
265 265
 	public static function getOne( $id, $meta = false ) {
266
-        global $wpdb;
266
+		global $wpdb;
267 267
 
268
-        $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it
268
+		$query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it
269 269
                   LEFT OUTER JOIN {$wpdb->prefix}frm_forms fr ON it.form_id=fr.id WHERE ";
270 270
 
271
-        $query .= is_numeric($id) ? 'it.id=%d' : 'it.item_key=%s';
272
-        $query_args = array( $id );
273
-        $query = $wpdb->prepare( $query, $query_args );
271
+		$query .= is_numeric($id) ? 'it.id=%d' : 'it.item_key=%s';
272
+		$query_args = array( $id );
273
+		$query = $wpdb->prepare( $query, $query_args );
274 274
 
275
-        if ( ! $meta ) {
275
+		if ( ! $meta ) {
276 276
 			$entry = FrmAppHelper::check_cache( $id . '_nometa', 'frm_entry', $query, 'get_row' );
277
-            return stripslashes_deep($entry);
278
-        }
277
+			return stripslashes_deep($entry);
278
+		}
279 279
 
280
-        $entry = FrmAppHelper::check_cache( $id, 'frm_entry' );
281
-        if ( $entry !== false ) {
282
-            return stripslashes_deep($entry);
283
-        }
280
+		$entry = FrmAppHelper::check_cache( $id, 'frm_entry' );
281
+		if ( $entry !== false ) {
282
+			return stripslashes_deep($entry);
283
+		}
284 284
 
285
-        $entry = $wpdb->get_row( $query );
286
-        $entry = self::get_meta($entry);
285
+		$entry = $wpdb->get_row( $query );
286
+		$entry = self::get_meta($entry);
287 287
 
288
-        return stripslashes_deep($entry);
289
-    }
288
+		return stripslashes_deep($entry);
289
+	}
290 290
 
291 291
 	public static function get_meta( $entry ) {
292
-        if ( ! $entry ) {
293
-            return $entry;
294
-        }
292
+		if ( ! $entry ) {
293
+			return $entry;
294
+		}
295 295
 
296
-        global $wpdb;
296
+		global $wpdb;
297 297
 		$metas = FrmDb::get_results( $wpdb->prefix . 'frm_item_metas m LEFT JOIN ' . $wpdb->prefix . 'frm_fields f ON m.field_id=f.id', array( 'item_id' => $entry->id, 'field_id !' => 0 ), 'field_id, meta_value, field_key, item_id' );
298 298
 
299
-        $entry->metas = array();
299
+		$entry->metas = array();
300 300
 
301 301
 		$include_key = apply_filters( 'frm_include_meta_keys', false, array( 'form_id' => $entry->form_id ) );
302
-        foreach ( $metas as $meta_val ) {
303
-            if ( $meta_val->item_id == $entry->id ) {
302
+		foreach ( $metas as $meta_val ) {
303
+			if ( $meta_val->item_id == $entry->id ) {
304 304
 				$entry->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value );
305 305
 				if ( $include_key ) {
306 306
 					$entry->metas[ $meta_val->field_key ] = $entry->metas[ $meta_val->field_id ];
307 307
 				}
308
-                 continue;
309
-            }
308
+				 continue;
309
+			}
310 310
 
311
-            // include sub entries in an array
311
+			// include sub entries in an array
312 312
 			if ( ! isset( $entry_metas[ $meta_val->field_id ] ) ) {
313 313
 				$entry->metas[ $meta_val->field_id ] = array();
314
-            }
314
+			}
315 315
 
316 316
 			$entry->metas[ $meta_val->field_id ][] = maybe_unserialize( $meta_val->meta_value );
317 317
 
318
-            unset($meta_val);
319
-        }
320
-        unset($metas);
318
+			unset($meta_val);
319
+		}
320
+		unset($metas);
321 321
 
322 322
 		FrmAppHelper::set_cache( $entry->id, $entry, 'frm_entry' );
323 323
 
324
-        return $entry;
325
-    }
324
+		return $entry;
325
+	}
326 326
 
327
-    /**
328
-     * @param string $id
329
-     */
327
+	/**
328
+	 * @param string $id
329
+	 */
330 330
 	public static function exists( $id ) {
331
-        global $wpdb;
332
-
333
-        if ( FrmAppHelper::check_cache( $id, 'frm_entry' ) ) {
334
-            $exists = true;
335
-            return $exists;
336
-        }
337
-
338
-        if ( is_numeric($id) ) {
339
-            $where = array( 'id' => $id );
340
-        } else {
341
-            $where = array( 'item_key' => $id );
342
-        }
331
+		global $wpdb;
332
+
333
+		if ( FrmAppHelper::check_cache( $id, 'frm_entry' ) ) {
334
+			$exists = true;
335
+			return $exists;
336
+		}
337
+
338
+		if ( is_numeric($id) ) {
339
+			$where = array( 'id' => $id );
340
+		} else {
341
+			$where = array( 'item_key' => $id );
342
+		}
343 343
 		$id = FrmDb::get_var( $wpdb->prefix . 'frm_items', $where );
344 344
 
345
-        $exists = ($id && $id > 0) ? true : false;
346
-        return $exists;
347
-    }
345
+		$exists = ($id && $id > 0) ? true : false;
346
+		return $exists;
347
+	}
348 348
 
349
-    public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) {
349
+	public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) {
350 350
 		global $wpdb;
351 351
 
352
-        $limit = FrmAppHelper::esc_limit($limit);
352
+		$limit = FrmAppHelper::esc_limit($limit);
353 353
 
354
-        $cache_key = maybe_serialize($where) . $order_by . $limit . $inc_form;
355
-        $entries = wp_cache_get($cache_key, 'frm_entry');
354
+		$cache_key = maybe_serialize($where) . $order_by . $limit . $inc_form;
355
+		$entries = wp_cache_get($cache_key, 'frm_entry');
356 356
 
357
-        if ( false === $entries ) {
358
-            $fields = 'it.id, it.item_key, it.name, it.ip, it.form_id, it.post_id, it.user_id, it.parent_item_id, it.updated_by, it.created_at, it.updated_at, it.is_draft';
357
+		if ( false === $entries ) {
358
+			$fields = 'it.id, it.item_key, it.name, it.ip, it.form_id, it.post_id, it.user_id, it.parent_item_id, it.updated_by, it.created_at, it.updated_at, it.is_draft';
359 359
 			$table = $wpdb->prefix . 'frm_items it ';
360 360
 
361
-            if ( $inc_form ) {
362
-                $fields = 'it.*, fr.name as form_name,fr.form_key as form_key';
363
-                $table .= 'LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id ';
364
-            }
361
+			if ( $inc_form ) {
362
+				$fields = 'it.*, fr.name as form_name,fr.form_key as form_key';
363
+				$table .= 'LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id ';
364
+			}
365 365
 
366
-            if ( preg_match( '/ meta_([0-9]+)/', $order_by, $order_matches ) ) {
367
-    		    // sort by a requested field
368
-                $field_id = (int) $order_matches[1];
366
+			if ( preg_match( '/ meta_([0-9]+)/', $order_by, $order_matches ) ) {
367
+				// sort by a requested field
368
+				$field_id = (int) $order_matches[1];
369 369
 				$fields .= ', (SELECT meta_value FROM ' . $wpdb->prefix . 'frm_item_metas WHERE field_id = ' . $field_id . ' AND item_id = it.id) as meta_' . $field_id;
370 370
 				unset( $order_matches, $field_id );
371
-		    }
371
+			}
372 372
 
373 373
 			// prepare the query
374 374
 			$query = 'SELECT ' . $fields . ' FROM ' . $table . FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
375 375
 
376
-            $entries = $wpdb->get_results($query, OBJECT_K);
377
-            unset($query);
376
+			$entries = $wpdb->get_results($query, OBJECT_K);
377
+			unset($query);
378 378
 
379 379
 			FrmAppHelper::set_cache( $cache_key, $entries, 'frm_entry' );
380
-        }
380
+		}
381 381
 
382
-        if ( ! $meta || ! $entries ) {
383
-            return stripslashes_deep($entries);
384
-        }
385
-        unset($meta);
382
+		if ( ! $meta || ! $entries ) {
383
+			return stripslashes_deep($entries);
384
+		}
385
+		unset($meta);
386 386
 
387
-        if ( ! is_array( $where ) && preg_match('/^it\.form_id=\d+$/', $where) ) {
387
+		if ( ! is_array( $where ) && preg_match('/^it\.form_id=\d+$/', $where) ) {
388 388
 			$where = array( 'it.form_id' => substr( $where, 11 ) );
389
-        }
389
+		}
390 390
 
391
-        $meta_where = array( 'field_id !' => 0 );
392
-        if ( $limit == '' && is_array($where) && count($where) == 1 && isset($where['it.form_id']) ) {
393
-            $meta_where['fi.form_id'] = $where['it.form_id'];
394
-        } else {
395
-            $meta_where['item_id'] = array_keys( $entries );
396
-        }
391
+		$meta_where = array( 'field_id !' => 0 );
392
+		if ( $limit == '' && is_array($where) && count($where) == 1 && isset($where['it.form_id']) ) {
393
+			$meta_where['fi.form_id'] = $where['it.form_id'];
394
+		} else {
395
+			$meta_where['item_id'] = array_keys( $entries );
396
+		}
397 397
 
398
-        $metas = FrmDb::get_results( $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON (it.field_id = fi.id)', $meta_where, 'item_id, meta_value, field_id, field_key, form_id' );
398
+		$metas = FrmDb::get_results( $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON (it.field_id = fi.id)', $meta_where, 'item_id, meta_value, field_id, field_key, form_id' );
399 399
 
400
-        unset( $meta_where );
400
+		unset( $meta_where );
401 401
 
402
-        if ( ! $metas ) {
403
-            return stripslashes_deep($entries);
404
-        }
402
+		if ( ! $metas ) {
403
+			return stripslashes_deep($entries);
404
+		}
405 405
 
406
-        foreach ( $metas as $m_key => $meta_val ) {
407
-            if ( ! isset( $entries[ $meta_val->item_id ] ) ) {
408
-                continue;
409
-            }
406
+		foreach ( $metas as $m_key => $meta_val ) {
407
+			if ( ! isset( $entries[ $meta_val->item_id ] ) ) {
408
+				continue;
409
+			}
410 410
 
411
-            if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) {
411
+			if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) {
412 412
 				$entries[ $meta_val->item_id ]->metas = array();
413
-            }
413
+			}
414 414
 
415 415
 			$entries[ $meta_val->item_id ]->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value );
416 416
 
417
-            unset($m_key, $meta_val);
418
-        }
417
+			unset($m_key, $meta_val);
418
+		}
419 419
 
420 420
 		if ( ! FrmAppHelper::prevent_caching() ) {
421 421
 			foreach ( $entries as $entry ) {
@@ -424,31 +424,31 @@  discard block
 block discarded – undo
424 424
 			}
425 425
 		}
426 426
 
427
-        return stripslashes_deep($entries);
428
-    }
427
+		return stripslashes_deep($entries);
428
+	}
429 429
 
430
-    // Pagination Methods
431
-    public static function getRecordCount( $where = '' ) {
432
-        global $wpdb;
430
+	// Pagination Methods
431
+	public static function getRecordCount( $where = '' ) {
432
+		global $wpdb;
433 433
 		$table_join = $wpdb->prefix . 'frm_items it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id';
434 434
 
435
-        if ( is_numeric($where) ) {
436
-            $table_join = 'frm_items';
437
-            $where = array( 'form_id' => $where );
438
-        }
435
+		if ( is_numeric($where) ) {
436
+			$table_join = 'frm_items';
437
+			$where = array( 'form_id' => $where );
438
+		}
439 439
 
440
-        if ( is_array( $where ) ) {
441
-            $count = FrmDb::get_count( $table_join, $where );
442
-        } else {
440
+		if ( is_array( $where ) ) {
441
+			$count = FrmDb::get_count( $table_join, $where );
442
+		} else {
443 443
 			$cache_key = 'count_' . maybe_serialize( $where );
444 444
 			$query = 'SELECT COUNT(*) FROM ' . $table_join . FrmAppHelper::prepend_and_or_where( ' WHERE ', $where );
445 445
 			$count = FrmAppHelper::check_cache( $cache_key, 'frm_entry', $query, 'get_var' );
446
-        }
446
+		}
447 447
 
448
-        return $count;
449
-    }
448
+		return $count;
449
+	}
450 450
 
451
-    public static function getPageCount( $p_size, $where = '' ) {
451
+	public static function getPageCount( $p_size, $where = '' ) {
452 452
 		$p_size = (int) $p_size;
453 453
 		$count = 1;
454 454
 		if ( $p_size ) {
@@ -459,16 +459,16 @@  discard block
 block discarded – undo
459 459
 		}
460 460
 
461 461
 		return $count;
462
-    }
462
+	}
463 463
 
464 464
 	/**
465
-	* Prepare the data before inserting it into the database
466
-	*
467
-	* @since 2.0.16
468
-	* @param array $values
469
-	* @param string $type
470
-	* @return array $new_values
471
-	*/
465
+	 * Prepare the data before inserting it into the database
466
+	 *
467
+	 * @since 2.0.16
468
+	 * @param array $values
469
+	 * @param string $type
470
+	 * @return array $new_values
471
+	 */
472 472
 	private static function before_insert_entry_in_database( &$values, $type ) {
473 473
 
474 474
 		self::sanitize_entry_post( $values );
@@ -483,13 +483,13 @@  discard block
 block discarded – undo
483 483
 	}
484 484
 
485 485
 	/**
486
-	* Create an entry and perform after create actions
487
-	*
488
-	* @since 2.0.16
489
-	* @param array $values
490
-	* @param array $new_values
491
-	* @return boolean|int $entry_id
492
-	*/
486
+	 * Create an entry and perform after create actions
487
+	 *
488
+	 * @since 2.0.16
489
+	 * @param array $values
490
+	 * @param array $new_values
491
+	 * @return boolean|int $entry_id
492
+	 */
493 493
 	private static function continue_to_create_entry( $values, $new_values ) {
494 494
 		$entry_id = self::insert_entry_into_database( $new_values );
495 495
 		if ( ! $entry_id ) {
@@ -501,37 +501,37 @@  discard block
 block discarded – undo
501 501
 		return $entry_id;
502 502
 	}
503 503
 
504
-    /**
505
-     * Sanitize the POST values before we use them
506
-     *
507
-     * @since 2.0
508
-     * @param array $values The POST values by reference
509
-     */
510
-    public static function sanitize_entry_post( &$values ) {
511
-        $sanitize_method = array(
512
-            'form_id'       => 'absint',
513
-            'frm_action'    => 'sanitize_title',
514
-            'form_key'      => 'sanitize_title',
515
-            'item_key'      => 'sanitize_title',
516
-            'item_name'     => 'sanitize_text_field',
517
-            'frm_saving_draft' => 'absint',
518
-            'is_draft'      => 'absint',
519
-            'post_id'       => 'absint',
520
-            'parent_item_id' => 'absint',
521
-            'created_at'    => 'sanitize_text_field',
522
-            'updated_at'    => 'sanitize_text_field',
523
-        );
524
-
525
-        FrmAppHelper::sanitize_request( $sanitize_method, $values );
526
-    }
504
+	/**
505
+	 * Sanitize the POST values before we use them
506
+	 *
507
+	 * @since 2.0
508
+	 * @param array $values The POST values by reference
509
+	 */
510
+	public static function sanitize_entry_post( &$values ) {
511
+		$sanitize_method = array(
512
+			'form_id'       => 'absint',
513
+			'frm_action'    => 'sanitize_title',
514
+			'form_key'      => 'sanitize_title',
515
+			'item_key'      => 'sanitize_title',
516
+			'item_name'     => 'sanitize_text_field',
517
+			'frm_saving_draft' => 'absint',
518
+			'is_draft'      => 'absint',
519
+			'post_id'       => 'absint',
520
+			'parent_item_id' => 'absint',
521
+			'created_at'    => 'sanitize_text_field',
522
+			'updated_at'    => 'sanitize_text_field',
523
+		);
524
+
525
+		FrmAppHelper::sanitize_request( $sanitize_method, $values );
526
+	}
527 527
 
528 528
 	/**
529
-	* Prepare the new values for inserting into the database
530
-	*
531
-	* @since 2.0.16
532
-	* @param array $values
533
-	* @return array $new_values
534
-	*/
529
+	 * Prepare the new values for inserting into the database
530
+	 *
531
+	 * @since 2.0.16
532
+	 * @param array $values
533
+	 * @return array $new_values
534
+	 */
535 535
 	private static function package_entry_data( &$values ) {
536 536
 		global $wpdb;
537 537
 
@@ -588,34 +588,34 @@  discard block
 block discarded – undo
588 588
 	}
589 589
 
590 590
 	/**
591
-	* Get the is_draft value for a new entry
592
-	*
593
-	* @since 2.0.16
594
-	* @param array $values
595
-	* @return int
596
-	*/
591
+	 * Get the is_draft value for a new entry
592
+	 *
593
+	 * @since 2.0.16
594
+	 * @param array $values
595
+	 * @return int
596
+	 */
597 597
 	private static function get_is_draft_value( $values ) {
598 598
 		return ( ( isset( $values['frm_saving_draft'] ) && $values['frm_saving_draft'] == 1 ) || ( isset( $values['is_draft'] ) && $values['is_draft'] == 1 ) ) ? 1 : 0;
599 599
 	}
600 600
 
601 601
 	/**
602
-	* Get the created_at value for a new entry
603
-	*
604
-	* @since 2.0.16
605
-	* @param array $values
606
-	* @return string
607
-	*/
602
+	 * Get the created_at value for a new entry
603
+	 *
604
+	 * @since 2.0.16
605
+	 * @param array $values
606
+	 * @return string
607
+	 */
608 608
 	private static function get_created_at( $values ) {
609 609
 		return self::get_entry_value( $values, 'created_at', current_time( 'mysql', 1 ) );
610 610
 	}
611 611
 
612 612
 	/**
613
-	* Get the updated_at value for a new entry
614
-	*
615
-	* @since 2.0.16
616
-	* @param array $values
617
-	* @return string
618
-	*/
613
+	 * Get the updated_at value for a new entry
614
+	 *
615
+	 * @since 2.0.16
616
+	 * @param array $values
617
+	 * @return string
618
+	 */
619 619
 	private static function get_updated_at( $values ) {
620 620
 		if ( isset( $values['updated_at'] ) ) {
621 621
 			$updated_at = $values['updated_at'];
@@ -627,12 +627,12 @@  discard block
 block discarded – undo
627 627
 	}
628 628
 
629 629
 	/**
630
-	* Get the description value for a new entry
631
-	*
632
-	* @since 2.0.16
633
-	* @param array $values
634
-	* @return string
635
-	*/
630
+	 * Get the description value for a new entry
631
+	 *
632
+	 * @since 2.0.16
633
+	 * @param array $values
634
+	 * @return string
635
+	 */
636 636
 	private static function get_entry_description( $values ) {
637 637
 		if ( isset( $values['description'] ) && ! empty( $values['description'] ) ) {
638 638
 			$description = maybe_serialize( $values['description'] );
@@ -647,12 +647,12 @@  discard block
 block discarded – undo
647 647
 	}
648 648
 
649 649
 	/**
650
-	* Get the user_id value for a new entry
651
-	*
652
-	* @since 2.0.16
653
-	* @param array $values
654
-	* @return int
655
-	*/
650
+	 * Get the user_id value for a new entry
651
+	 *
652
+	 * @since 2.0.16
653
+	 * @param array $values
654
+	 * @return int
655
+	 */
656 656
 	private static function get_entry_user_id( $values ) {
657 657
 		if ( isset( $values['frm_user_id'] ) && ( is_numeric( $values['frm_user_id'] ) || FrmAppHelper::is_admin() ) ) {
658 658
 			$user_id = $values['frm_user_id'];
@@ -665,12 +665,12 @@  discard block
 block discarded – undo
665 665
 	}
666 666
 
667 667
 	/**
668
-	* Insert new entry into the database
669
-	*
670
-	* @since 2.0.16
671
-	* @param array $new_values
672
-	* @return int | boolean $entry_id
673
-	*/
668
+	 * Insert new entry into the database
669
+	 *
670
+	 * @since 2.0.16
671
+	 * @param array $new_values
672
+	 * @return int | boolean $entry_id
673
+	 */
674 674
 	private static function insert_entry_into_database( $new_values ) {
675 675
 		global $wpdb;
676 676
 
@@ -686,11 +686,11 @@  discard block
 block discarded – undo
686 686
 	}
687 687
 
688 688
 	/**
689
-	* Add the new entry to global $frm_vars
690
-	*
691
-	* @since 2.0.16
692
-	* @param int $entry_id
693
-	*/
689
+	 * Add the new entry to global $frm_vars
690
+	 *
691
+	 * @since 2.0.16
692
+	 * @param int $entry_id
693
+	 */
694 694
 	private static function add_new_entry_to_frm_vars( $entry_id ) {
695 695
 		global $frm_vars;
696 696
 
@@ -702,12 +702,12 @@  discard block
 block discarded – undo
702 702
 	}
703 703
 
704 704
 	/**
705
-	* Add entry metas, if there are any
706
-	*
707
-	* @since 2.0.16
708
-	* @param array $values
709
-	* @param int $entry_id
710
-	*/
705
+	 * Add entry metas, if there are any
706
+	 *
707
+	 * @since 2.0.16
708
+	 * @param array $values
709
+	 * @param int $entry_id
710
+	 */
711 711
 	private static function maybe_add_entry_metas( $values, $entry_id ) {
712 712
 		if ( isset($values['item_meta']) ) {
713 713
 			FrmEntryMeta::update_entry_metas( $entry_id, $values['item_meta'] );
@@ -715,12 +715,12 @@  discard block
 block discarded – undo
715 715
 	}
716 716
 
717 717
 	/**
718
-	* Trigger frm_after_create_entry hooks
719
-	*
720
-	* @since 2.0.16
721
-	* @param int $entry_id
722
-	* @param array $new_values
723
-	*/
718
+	 * Trigger frm_after_create_entry hooks
719
+	 *
720
+	 * @since 2.0.16
721
+	 * @param int $entry_id
722
+	 * @param array $new_values
723
+	 */
724 724
 	private static function after_entry_created_actions( $entry_id, $values, $new_values ) {
725 725
 		// this is a child entry
726 726
 		$is_child = isset( $values['parent_form_id'] ) && isset( $values['parent_nonce'] ) && ! empty( $values['parent_form_id'] ) && wp_verify_nonce( $values['parent_nonce'], 'parent' );
@@ -730,13 +730,13 @@  discard block
 block discarded – undo
730 730
 	}
731 731
 
732 732
 	/**
733
-	* Actions to perform immediately after an entry is inserted in the frm_items database
734
-	*
735
-	* @since 2.0.16
736
-	* @param array $values
737
-	* @param array $new_values
738
-	* @param int $entry_id
739
-	*/
733
+	 * Actions to perform immediately after an entry is inserted in the frm_items database
734
+	 *
735
+	 * @since 2.0.16
736
+	 * @param array $values
737
+	 * @param array $new_values
738
+	 * @param int $entry_id
739
+	 */
740 740
 	private static function after_insert_entry_in_database( $values, $new_values, $entry_id ) {
741 741
 
742 742
 		self::add_new_entry_to_frm_vars( $entry_id );
@@ -749,14 +749,14 @@  discard block
 block discarded – undo
749 749
 	}
750 750
 
751 751
 	/**
752
-	* Perform some actions right before updating an entry
753
-	*
754
-	* @since 2.0.16
755
-	* @param int $id
756
-	* @param array $values
757
-	* @param string $update_type
758
-	* @return boolean $update
759
-	*/
752
+	 * Perform some actions right before updating an entry
753
+	 *
754
+	 * @since 2.0.16
755
+	 * @param int $id
756
+	 * @param array $values
757
+	 * @param string $update_type
758
+	 * @return boolean $update
759
+	 */
760 760
 	private static function before_update_entry( $id, &$values, $update_type ) {
761 761
 		$update = true;
762 762
 
@@ -774,13 +774,13 @@  discard block
 block discarded – undo
774 774
 	}
775 775
 
776 776
 	/**
777
-	* Package the entry data for updating
778
-	*
779
-	* @since 2.0.16
780
-	* @param int $id
781
-	* @param array $values
782
-	* @return array $new_values
783
-	*/
777
+	 * Package the entry data for updating
778
+	 *
779
+	 * @since 2.0.16
780
+	 * @param int $id
781
+	 * @param array $values
782
+	 * @return array $new_values
783
+	 */
784 784
 	private static function package_entry_to_update( $id, $values ) {
785 785
 		global $wpdb;
786 786
 
@@ -814,14 +814,14 @@  discard block
 block discarded – undo
814 814
 	}
815 815
 
816 816
 	/**
817
-	* Perform some actions right after updating an entry
818
-	*
819
-	* @since 2.0.16
820
-	* @param boolean|int $query_results
821
-	* @param int $id
822
-	* @param array $values
823
-	* @param array $new_values
824
-	*/
817
+	 * Perform some actions right after updating an entry
818
+	 *
819
+	 * @since 2.0.16
820
+	 * @param boolean|int $query_results
821
+	 * @param int $id
822
+	 * @param array $values
823
+	 * @param array $new_values
824
+	 */
825 825
 	private static function after_update_entry( $query_results, $id, $values, $new_values ) {
826 826
 		if ( $query_results ) {
827 827
 			self::clear_cache();
@@ -843,13 +843,13 @@  discard block
 block discarded – undo
843 843
 	}
844 844
 
845 845
 	/**
846
-	* Create entry from an XML import
847
-	* Certain actions aren't necessary when importing (like saving sub entries, checking for duplicates, etc.)
848
-	*
849
-	* @since 2.0.16
850
-	* @param array $values
851
-	* @return int | boolean $entry_id
852
-	*/
846
+	 * Create entry from an XML import
847
+	 * Certain actions aren't necessary when importing (like saving sub entries, checking for duplicates, etc.)
848
+	 *
849
+	 * @since 2.0.16
850
+	 * @param array $values
851
+	 * @return int | boolean $entry_id
852
+	 */
853 853
 	public static function create_entry_from_xml( $values ) {
854 854
 		$entry_id = self::create_entry( $values, 'xml' );
855 855
 
@@ -857,26 +857,26 @@  discard block
 block discarded – undo
857 857
 	}
858 858
 
859 859
 	/**
860
-	* Update entry from an XML import
861
-	* Certain actions aren't necessary when importing (like saving sub entries and modifying other vals)
862
-	*
863
-	* @since 2.0.16
864
-	* @param int $id
865
-	* @param array $values
866
-	* @return int | boolean $updated
867
-	*/
860
+	 * Update entry from an XML import
861
+	 * Certain actions aren't necessary when importing (like saving sub entries and modifying other vals)
862
+	 *
863
+	 * @since 2.0.16
864
+	 * @param int $id
865
+	 * @param array $values
866
+	 * @return int | boolean $updated
867
+	 */
868 868
 	public static function update_entry_from_xml( $id, $values ) {
869 869
 		$updated = self::update_entry( $id, $values, 'xml' );
870 870
 
871 871
 		return $updated;
872 872
 	}
873 873
 
874
-    /**
875
-     * @param string $key
876
-     * @return int entry_id
877
-     */
874
+	/**
875
+	 * @param string $key
876
+	 * @return int entry_id
877
+	 */
878 878
 	public static function get_id_by_key( $key ) {
879
-        $entry_id = FrmDb::get_var( 'frm_items', array( 'item_key' => sanitize_title( $key ) ) );
880
-        return $entry_id;
881
-    }
879
+		$entry_id = FrmDb::get_var( 'frm_items', array( 'item_key' => sanitize_title( $key ) ) );
880
+		return $entry_id;
881
+	}
882 882
 }
Please login to merge, or discard this patch.
classes/views/frm-settings/license_box.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<div class="general_settings metabox-holder tabs-panel frm_license_box <?php echo ($a == 'general_settings') ? 'frm_block' : 'frm_hidden'; ?>">
1
+<div class="general_settings metabox-holder tabs-panel frm_license_box <?php echo ( $a == 'general_settings' ) ? 'frm_block' : 'frm_hidden'; ?>">
2 2
 <?php if ( ! is_multisite() || current_user_can( 'setup_network' ) ) { ?>
3 3
     <div class="postbox">
4 4
         <div class="inside">
Please login to merge, or discard this patch.
classes/views/frm-entries/new.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@
 block discarded – undo
1
-<div class="frm_forms <?php echo FrmFormsHelper::get_form_style_class($values); ?>" id="frm_form_<?php echo esc_attr( $form->id ) ?>_container" <?php echo apply_filters( 'frm_form_div_attributes', '', $form ); ?>>
1
+<div class="frm_forms <?php echo FrmFormsHelper::get_form_style_class( $values ); ?>" id="frm_form_<?php echo esc_attr( $form->id ) ?>_container" <?php echo apply_filters( 'frm_form_div_attributes', '', $form ); ?>>
2 2
 <?php
3 3
 if ( ! isset( $include_form_tag ) || $include_form_tag ) {
4 4
 ?>
5
-<form enctype="<?php echo esc_attr( apply_filters( 'frm_form_enctype', 'multipart/form-data', $form ) ) ?>" method="post" class="frm-show-form <?php do_action('frm_form_classes', $form) ?>" id="form_<?php echo esc_attr( $form->form_key ) ?>" <?php echo $frm_settings->use_html ? '' : 'action=""'; ?> <?php echo apply_filters( 'frm_form_attributes', '', $form ); ?>>
5
+<form enctype="<?php echo esc_attr( apply_filters( 'frm_form_enctype', 'multipart/form-data', $form ) ) ?>" method="post" class="frm-show-form <?php do_action( 'frm_form_classes', $form ) ?>" id="form_<?php echo esc_attr( $form->form_key ) ?>" <?php echo $frm_settings->use_html ? '' : 'action=""'; ?> <?php echo apply_filters( 'frm_form_attributes', '', $form ); ?>>
6 6
 <?php
7 7
 } else { ?>
8
-<div id="form_<?php echo esc_attr( $form->form_key ) ?>" class="frm-show-form <?php do_action('frm_form_classes', $form) ?>" >
8
+<div id="form_<?php echo esc_attr( $form->form_key ) ?>" class="frm-show-form <?php do_action( 'frm_form_classes', $form ) ?>" >
9 9
 <?php
10 10
 }
11 11
 
Please login to merge, or discard this patch.
classes/widgets/FrmShowForm.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 	}
9 9
 
10 10
 	public function widget( $args, $instance ) {
11
-        $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
11
+		$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
12 12
 
13 13
 		echo $args['before_widget'];
14 14
 
@@ -34,9 +34,9 @@  discard block
 block discarded – undo
34 34
 	}
35 35
 
36 36
 	public function form( $instance ) {
37
-	    //Defaults
37
+		//Defaults
38 38
 		$instance = wp_parse_args( (array) $instance, array(
39
-		    'title' => false, 'form' => false, 'description' => false,
39
+			'title' => false, 'form' => false, 'description' => false,
40 40
 		) );
41 41
 ?>
42 42
 	<p><label for="<?php echo esc_attr( $this->get_field_id('title') ); ?>"><?php _e( 'Title', 'formidable' ) ?>:</label><br/>
@@ -44,10 +44,10 @@  discard block
 block discarded – undo
44 44
 
45 45
 	<p><label for="<?php echo esc_attr( $this->get_field_id('form') ); ?>"><?php _e( 'Form', 'formidable' ) ?>:</label><br/>
46 46
 <?php
47
-	    FrmFormsHelper::forms_dropdown( $this->get_field_name('form'), $instance['form'], array(
48
-	        'blank' => false, 'field_id' => $this->get_field_id('form'),
49
-            'class' => 'widefat',
50
-	    ) );
47
+		FrmFormsHelper::forms_dropdown( $this->get_field_name('form'), $instance['form'], array(
48
+			'blank' => false, 'field_id' => $this->get_field_id('form'),
49
+			'class' => 'widefat',
50
+		) );
51 51
 ?>
52 52
 	</p>
53 53
 
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 	public function __construct() {
6 6
 		$widget_ops = array( 'description' => __( 'Display a Formidable Form', 'formidable' ) );
7
-		parent::__construct('frm_show_form', __( 'Formidable Form', 'formidable' ), $widget_ops);
7
+		parent::__construct( 'frm_show_form', __( 'Formidable Form', 'formidable' ), $widget_ops );
8 8
 	}
9 9
 
10 10
 	public function widget( $args, $instance ) {
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
 		echo '<div class="frm_form_widget">';
16 16
 		if ( $title ) {
17
-			echo $args['before_title'] . stripslashes($title) . $args['after_title'];
17
+			echo $args['before_title'] . stripslashes( $title ) . $args['after_title'];
18 18
 		}
19 19
 
20 20
 		$form_atts = array(
@@ -39,19 +39,19 @@  discard block
 block discarded – undo
39 39
 		    'title' => false, 'form' => false, 'description' => false,
40 40
 		) );
41 41
 ?>
42
-	<p><label for="<?php echo esc_attr( $this->get_field_id('title') ); ?>"><?php _e( 'Title', 'formidable' ) ?>:</label><br/>
43
-	<input type="text" class="widefat" id="<?php echo esc_attr( $this->get_field_id('title') ); ?>" name="<?php echo esc_attr( $this->get_field_name('title') ); ?>" value="<?php echo esc_attr( stripslashes($instance['title']) ); ?>" /></p>
42
+	<p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title', 'formidable' ) ?>:</label><br/>
43
+	<input type="text" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" value="<?php echo esc_attr( stripslashes( $instance['title'] ) ); ?>" /></p>
44 44
 
45
-	<p><label for="<?php echo esc_attr( $this->get_field_id('form') ); ?>"><?php _e( 'Form', 'formidable' ) ?>:</label><br/>
45
+	<p><label for="<?php echo esc_attr( $this->get_field_id( 'form' ) ); ?>"><?php _e( 'Form', 'formidable' ) ?>:</label><br/>
46 46
 <?php
47
-	    FrmFormsHelper::forms_dropdown( $this->get_field_name('form'), $instance['form'], array(
48
-	        'blank' => false, 'field_id' => $this->get_field_id('form'),
47
+	    FrmFormsHelper::forms_dropdown( $this->get_field_name( 'form' ), $instance['form'], array(
48
+	        'blank' => false, 'field_id' => $this->get_field_id( 'form' ),
49 49
             'class' => 'widefat',
50 50
 	    ) );
51 51
 ?>
52 52
 	</p>
53 53
 
54
-	<p><label for="<?php echo esc_attr( $this->get_field_id('description') ); ?>"><input class="checkbox" type="checkbox" <?php checked($instance['description'], true) ?> id="<?php echo esc_attr( $this->get_field_id('description') ); ?>" name="<?php echo esc_attr( $this->get_field_name('description') ); ?>" value="1" />
54
+	<p><label for="<?php echo esc_attr( $this->get_field_id( 'description' ) ); ?>"><input class="checkbox" type="checkbox" <?php checked( $instance['description'], true ) ?> id="<?php echo esc_attr( $this->get_field_id( 'description' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'description' ) ); ?>" value="1" />
55 55
 	<?php _e( 'Show Description', 'formidable' ) ?></label></p>
56 56
 <?php
57 57
 	}
Please login to merge, or discard this patch.
classes/controllers/FrmAddonsController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -194,7 +194,7 @@
 block discarded – undo
194 194
 			}
195 195
 			$addon['link'] = FrmAppHelper::make_affiliate_url( $addon['link'] );
196 196
 
197
-			$addons[ $slug ] = $addon;
197
+			$addons[$slug] = $addon;
198 198
 		}
199 199
 	}
200 200
 
Please login to merge, or discard this patch.
classes/controllers/FrmSettingsController.php 2 patches
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -2,26 +2,26 @@  discard block
 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 = self::get_settings_tabs();
27 27
 
@@ -64,47 +64,47 @@  discard block
 block discarded – undo
64 64
 		wp_die();
65 65
 	}
66 66
 
67
-    public static function process_form( $stop_load = false ) {
68
-        global $frm_vars;
67
+	public static function process_form( $stop_load = false ) {
68
+		global $frm_vars;
69 69
 
70
-        $frm_settings = FrmAppHelper::get_settings();
70
+		$frm_settings = FrmAppHelper::get_settings();
71 71
 
72 72
 		$process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' );
73 73
 		if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) {
74
-            wp_die( $frm_settings->admin_permission );
75
-        }
74
+			wp_die( $frm_settings->admin_permission );
75
+		}
76 76
 
77
-        $errors = array();
78
-        $message = '';
77
+		$errors = array();
78
+		$message = '';
79 79
 
80
-        if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) {
81
-            $errors = $frm_settings->validate( $_POST, array() );
80
+		if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) {
81
+			$errors = $frm_settings->validate( $_POST, array() );
82 82
 
83
-            $frm_settings->update( stripslashes_deep( $_POST ) );
83
+			$frm_settings->update( stripslashes_deep( $_POST ) );
84 84
 
85
-            if ( empty( $errors ) ) {
86
-                $frm_settings->store();
87
-                $message = __( 'Settings Saved', 'formidable' );
88
-            }
89
-        } else {
90
-            $message = __( 'Settings Saved', 'formidable' );
91
-        }
85
+			if ( empty( $errors ) ) {
86
+				$frm_settings->store();
87
+				$message = __( 'Settings Saved', 'formidable' );
88
+			}
89
+		} else {
90
+			$message = __( 'Settings Saved', 'formidable' );
91
+		}
92 92
 
93 93
 		if ( $stop_load == 'stop_load' ) {
94
-            $frm_vars['settings_routed'] = true;
95
-            return;
96
-        }
94
+			$frm_vars['settings_routed'] = true;
95
+			return;
96
+		}
97 97
 
98
-        self::display_form( $errors, $message );
99
-    }
98
+		self::display_form( $errors, $message );
99
+	}
100 100
 
101
-    public static function route( $stop_load = false ) {
102
-        $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
101
+	public static function route( $stop_load = false ) {
102
+		$action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
103 103
 		$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
104
-        if ( $action == 'process-form' ) {
104
+		if ( $action == 'process-form' ) {
105 105
 			self::process_form( $stop_load );
106
-        } else if ( $stop_load != 'stop_load' ) {
106
+		} else if ( $stop_load != 'stop_load' ) {
107 107
 			self::display_form();
108
-        }
109
-    }
108
+		}
109
+	}
110 110
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -45,16 +45,16 @@
 block discarded – undo
45 45
 	}
46 46
 
47 47
 	public static function load_settings_tab() {
48
-		FrmAppHelper::permission_check('frm_change_settings');
48
+		FrmAppHelper::permission_check( 'frm_change_settings' );
49 49
 		check_ajax_referer( 'frm_ajax', 'nonce' );
50 50
 
51 51
 		$section = FrmAppHelper::get_post_param( 'tab', '', 'sanitize_text_field' );
52 52
 		$sections = self::get_settings_tabs();
53
-		if ( ! isset( $sections[ $section ] ) ) {
53
+		if ( ! isset( $sections[$section] ) ) {
54 54
 			wp_die();
55 55
 		}
56 56
 
57
-		$section = $sections[ $section ];
57
+		$section = $sections[$section];
58 58
 
59 59
 		if ( isset( $section['class'] ) ) {
60 60
 			call_user_func( array( $section['class'], $section['function'] ) );
Please login to merge, or discard this patch.
classes/views/frm-settings/form.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -191,10 +191,10 @@
 block discarded – undo
191 191
 					} else {
192 192
 						call_user_func( ( isset( $section['function'] ) ? $section['function'] : $section ) );
193 193
 					}
194
-                } ?>
194
+				} ?>
195 195
             </div>
196 196
         <?php
197
-        } ?>
197
+		} ?>
198 198
 
199 199
         <p class="alignright frm_uninstall">
200 200
             <a href="javascript:void(0)" id="frm_uninstall_now"><?php _e( 'Uninstall Formidable', 'formidable' ) ?></a>
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -27,14 +27,14 @@  discard block
 block discarded – undo
27 27
         </ul>
28 28
         </div>
29 29
 
30
-    <?php do_action('frm_before_settings'); ?>
30
+    <?php do_action( 'frm_before_settings' ); ?>
31 31
 
32 32
 	<form name="frm_settings_form" method="post" class="frm_settings_form" action="?page=formidable-settings<?php echo ( $a ? '&amp;t=' . $a : '' ); ?>">
33 33
         <input type="hidden" name="frm_action" value="process-form" />
34 34
         <input type="hidden" name="action" value="process-form" />
35
-        <?php wp_nonce_field('process_form_nonce', 'process_form'); ?>
35
+        <?php wp_nonce_field( 'process_form_nonce', 'process_form' ); ?>
36 36
 
37
-        <div class="general_settings tabs-panel <?php echo ($a == 'general_settings') ? 'frm_block' : 'frm_hidden'; ?>">
37
+        <div class="general_settings tabs-panel <?php echo ( $a == 'general_settings' ) ? 'frm_block' : 'frm_hidden'; ?>">
38 38
             <p class="submit">
39 39
 				<input class="button-primary" type="submit" value="<?php esc_attr_e( 'Update Options', 'formidable' ) ?>" />
40 40
             </p>
@@ -43,20 +43,20 @@  discard block
 block discarded – undo
43 43
 
44 44
             <p><label class="frm_left_label"><?php _e( 'Load form styling', 'formidable' ) ?></label>
45 45
                 <select id="frm_load_style" name="frm_load_style">
46
-                <option value="all" <?php selected($frm_settings->load_style, 'all') ?>><?php _e( 'on every page of your site', 'formidable' ) ?></option>
47
-                <option value="dynamic" <?php selected($frm_settings->load_style, 'dynamic') ?>><?php _e( 'only on applicable pages', 'formidable' ) ?></option>
48
-                <option value="none" <?php selected($frm_settings->load_style, 'none') ?>><?php _e( 'Don\'t use form styling on any page', 'formidable' ) ?></option>
46
+                <option value="all" <?php selected( $frm_settings->load_style, 'all' ) ?>><?php _e( 'on every page of your site', 'formidable' ) ?></option>
47
+                <option value="dynamic" <?php selected( $frm_settings->load_style, 'dynamic' ) ?>><?php _e( 'only on applicable pages', 'formidable' ) ?></option>
48
+                <option value="none" <?php selected( $frm_settings->load_style, 'none' ) ?>><?php _e( 'Don\'t use form styling on any page', 'formidable' ) ?></option>
49 49
                 </select>
50 50
             </p>
51 51
 
52 52
             <p>
53 53
 				<label for="frm_use_html">
54
-					<input type="checkbox" id="frm_use_html" name="frm_use_html" value="1" <?php checked($frm_settings->use_html, 1) ?>	> <?php _e( 'Use HTML5 in forms', 'formidable' ) ?>
54
+					<input type="checkbox" id="frm_use_html" name="frm_use_html" value="1" <?php checked( $frm_settings->use_html, 1 ) ?>	> <?php _e( 'Use HTML5 in forms', 'formidable' ) ?>
55 55
 				</label>
56 56
 				<span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'We recommend using HTML 5 for your forms. It adds some nifty options like placeholders, patterns, and autocomplete.', 'formidable' ) ?>"></span>
57 57
             </p>
58 58
 
59
-            <?php do_action('frm_style_general_settings', $frm_settings); ?>
59
+            <?php do_action( 'frm_style_general_settings', $frm_settings ); ?>
60 60
 
61 61
 			<h3><?php _e( 'User Permissions', 'formidable' ); ?>
62 62
 				<span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'Select users that are allowed access to Formidable. Without access to View Forms, users will be unable to see the Formidable menu.', 'formidable' ) ?>"></span>
@@ -80,10 +80,10 @@  discard block
 block discarded – undo
80 80
 			</p>
81 81
 
82 82
 			<p><label class="frm_left_label"><?php _e( 'Site Key', 'formidable' ) ?></label>
83
-			<input type="text" name="frm_pubkey" id="frm_pubkey" size="42" value="<?php echo esc_attr($frm_settings->pubkey) ?>" placeholder="<?php esc_attr_e( 'Optional', 'formidable' ) ?>" /></p>
83
+			<input type="text" name="frm_pubkey" id="frm_pubkey" size="42" value="<?php echo esc_attr( $frm_settings->pubkey ) ?>" placeholder="<?php esc_attr_e( 'Optional', 'formidable' ) ?>" /></p>
84 84
 
85 85
 			<p><label class="frm_left_label"><?php _e( 'Secret Key', 'formidable' ) ?></label>
86
-			<input type="text" name="frm_privkey" id="frm_privkey" size="42" value="<?php echo esc_attr($frm_settings->privkey) ?>" placeholder="<?php esc_attr_e( 'Optional', 'formidable' ) ?>" /></p>
86
+			<input type="text" name="frm_privkey" id="frm_privkey" size="42" value="<?php echo esc_attr( $frm_settings->privkey ) ?>" placeholder="<?php esc_attr_e( 'Optional', 'formidable' ) ?>" /></p>
87 87
 
88 88
 		    <p><label class="frm_left_label"><?php _e( 'reCAPTCHA Type', 'formidable' ) ?></label>
89 89
 			<select name="frm_re_type" id="frm_re_type">
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 			<select name="frm_re_lang" id="frm_re_lang">
100 100
 				<option value="" <?php selected( $frm_settings->re_lang, '' ) ?>><?php esc_html_e( 'Browser Default', 'formidable' ); ?></option>
101 101
 			    <?php foreach ( $captcha_lang as $lang => $lang_name ) { ?>
102
-				<option value="<?php echo esc_attr($lang) ?>" <?php selected($frm_settings->re_lang, $lang) ?>><?php echo esc_html( $lang_name ) ?></option>
102
+				<option value="<?php echo esc_attr( $lang ) ?>" <?php selected( $frm_settings->re_lang, $lang ) ?>><?php echo esc_html( $lang_name ) ?></option>
103 103
                 <?php } ?>
104 104
             </select></p>
105 105
 
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 			<label class="frm_left_label"><?php _e( 'Success Message', 'formidable' ); ?>
153 153
 				<span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'The default message seen after a form is submitted.', 'formidable' ) ?>" ></span>
154 154
 			</label>
155
-            <input type="text" id="frm_success_msg" name="frm_success_msg" class="frm_with_left_label" value="<?php echo esc_attr($frm_settings->success_msg) ?>" />
155
+            <input type="text" id="frm_success_msg" name="frm_success_msg" class="frm_with_left_label" value="<?php echo esc_attr( $frm_settings->success_msg ) ?>" />
156 156
 		</p>
157 157
 
158 158
 		<p>
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 			<input type="text" value="<?php echo esc_attr( $frm_settings->submit_value ) ?>" id="frm_submit_value" name="frm_submit_value" class="frm_with_left_label" />
161 161
 		</p>
162 162
 
163
-        <?php do_action('frm_settings_form', $frm_settings); ?>
163
+        <?php do_action( 'frm_settings_form', $frm_settings ); ?>
164 164
 
165 165
         <?php if ( ! FrmAppHelper::pro_is_installed() ) { ?>
166 166
 			<div class="clear"></div>
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 		<?php } ?>
171 171
 
172 172
         <p><label class="frm_left_label"><?php _e( 'Preview Page', 'formidable' ); ?></label>
173
-        <?php FrmAppHelper::wp_pages_dropdown('frm-preview-page-id', $frm_settings->preview_page_id ) ?>
173
+        <?php FrmAppHelper::wp_pages_dropdown( 'frm-preview-page-id', $frm_settings->preview_page_id ) ?>
174 174
         </p>
175 175
 
176 176
 		<p>
Please login to merge, or discard this patch.
classes/models/fields/FrmFieldEmail.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
 	protected function field_settings_for_type() {
15 15
 		return array(
16 16
 			'size'           => true,
17
-            'clear_on_focus' => true,
17
+			'clear_on_focus' => true,
18 18
 			'invalid'        => true,
19 19
 		);
20 20
 	}
Please login to merge, or discard this patch.
classes/controllers/FrmAppController.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
             return;
102 102
         }
103 103
 
104
-		if ( get_site_option( 'frmpro-authorized' ) && ! is_callable('load_formidable_pro') ) {
104
+		if ( get_site_option( 'frmpro-authorized' ) && ! is_callable( 'load_formidable_pro' ) ) {
105 105
             FrmAppHelper::load_admin_wide_js();
106 106
 
107 107
             // user is authorized, but running free version
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 <div class="update-nag frm-update-to-pro">
139 139
 	<?php echo FrmAppHelper::kses( $tip['tip'] ) ?>
140 140
 	<span><?php echo FrmAppHelper::kses( $tip['call'] ) ?></span>
141
-	<a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidableforms.com?banner=1&tip=' . absint( $tip['num'] ) ) ) ?>" class="button">Upgrade to Pro</a>
141
+	<a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com?banner=1&tip=' . absint( $tip['num'] ) ) ) ?>" class="button">Upgrade to Pro</a>
142 142
 </div>
143 143
 <?php
144 144
 		}
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
     }
372 372
 
373 373
     public static function uninstall() {
374
-		FrmAppHelper::permission_check('administrator');
374
+		FrmAppHelper::permission_check( 'administrator' );
375 375
         check_ajax_referer( 'frm_ajax', 'nonce' );
376 376
 
377 377
 		$frmdb = new FrmDb();
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
     }
407 407
 
408 408
     public static function deauthorize() {
409
-		FrmAppHelper::permission_check('frm_change_settings');
409
+		FrmAppHelper::permission_check( 'frm_change_settings' );
410 410
         check_ajax_referer( 'frm_ajax', 'nonce' );
411 411
 
412 412
         delete_option( 'frmpro-credentials' );
Please login to merge, or discard this patch.
Indentation   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -3,14 +3,14 @@  discard block
 block discarded – undo
3 3
 class FrmAppController {
4 4
 
5 5
 	public static function menu() {
6
-        FrmAppHelper::maybe_add_permissions();
7
-        if ( ! current_user_can( 'frm_view_forms' ) ) {
8
-            return;
9
-        }
6
+		FrmAppHelper::maybe_add_permissions();
7
+		if ( ! current_user_can( 'frm_view_forms' ) ) {
8
+			return;
9
+		}
10 10
 
11 11
 		$menu_name = FrmAppHelper::get_menu_name();
12 12
 		add_menu_page( 'Formidable', $menu_name, 'frm_view_forms', 'formidable', 'FrmFormsController::route', '', self::get_menu_position() );
13
-    }
13
+	}
14 14
 
15 15
 	private static function get_menu_position() {
16 16
 		$count = count( get_post_types( array( 'show_ui' => true, '_builtin' => false, 'show_in_menu' => true ) ) );
@@ -19,15 +19,15 @@  discard block
 block discarded – undo
19 19
 		return $pos;
20 20
 	}
21 21
 
22
-    public static function load_wp_admin_style() {
23
-        FrmAppHelper::load_font_style();
24
-    }
22
+	public static function load_wp_admin_style() {
23
+		FrmAppHelper::load_font_style();
24
+	}
25 25
 
26 26
 	public static function get_form_nav( $form, $show_nav = false, $title = 'show' ) {
27 27
 		$show_nav = FrmAppHelper::get_param( 'show_nav', $show_nav, 'get', 'absint' );
28
-        if ( empty( $show_nav ) || ! $form ) {
29
-            return;
30
-        }
28
+		if ( empty( $show_nav ) || ! $form ) {
29
+			return;
30
+		}
31 31
 
32 32
 		FrmForm::maybe_get_form( $form );
33 33
 		if ( ! is_object( $form ) ) {
@@ -85,28 +85,28 @@  discard block
 block discarded – undo
85 85
 		return $nav_items;
86 86
 	}
87 87
 
88
-    // Adds a settings link to the plugins page
89
-    public static function settings_link( $links ) {
88
+	// Adds a settings link to the plugins page
89
+	public static function settings_link( $links ) {
90 90
 		$settings = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-settings' ) ) . '">' . __( 'Settings', 'formidable' ) . '</a>';
91
-        array_unshift( $links, $settings );
91
+		array_unshift( $links, $settings );
92 92
 
93
-        return $links;
94
-    }
93
+		return $links;
94
+	}
95 95
 
96
-    public static function pro_get_started_headline() {
96
+	public static function pro_get_started_headline() {
97 97
 		self::maybe_show_upgrade_bar();
98 98
 
99
-        // Don't display this error as we're upgrading the thing, or if the user shouldn't see the message
100
-        if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) {
101
-            return;
102
-        }
99
+		// Don't display this error as we're upgrading the thing, or if the user shouldn't see the message
100
+		if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) {
101
+			return;
102
+		}
103 103
 
104 104
 		if ( get_site_option( 'frmpro-authorized' ) && ! is_callable('load_formidable_pro') ) {
105
-            FrmAppHelper::load_admin_wide_js();
105
+			FrmAppHelper::load_admin_wide_js();
106 106
 
107
-            // user is authorized, but running free version
108
-            $inst_install_url = 'https://formidableforms.com/knowledgebase/install-formidable-forms/';
109
-        ?>
107
+			// user is authorized, but running free version
108
+			$inst_install_url = 'https://formidableforms.com/knowledgebase/install-formidable-forms/';
109
+		?>
110 110
 <div class="error" class="frm_previous_install">
111 111
 		<?php
112 112
 		echo wp_kses_post( apply_filters( 'frm_pro_update_msg',
@@ -118,8 +118,8 @@  discard block
 block discarded – undo
118 118
 		) ); ?>
119 119
 </div>
120 120
 <?php
121
-        }
122
-    }
121
+		}
122
+	}
123 123
 
124 124
 	private static function maybe_show_upgrade_bar() {
125 125
 		$page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 		}
225 225
 	}
226 226
 
227
-    public static function admin_js() {
227
+	public static function admin_js() {
228 228
 		$version = FrmAppHelper::plugin_version();
229 229
 		FrmAppHelper::load_admin_wide_js( false );
230 230
 
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 			'bootstrap_tooltip', 'bootstrap-multiselect',
236 236
 		), $version, true );
237 237
 		wp_register_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css', array(), $version );
238
-        wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' );
238
+		wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' );
239 239
 		wp_register_style( 'formidable-grids', FrmAppHelper::plugin_url() . '/css/frm_grids.css', array(), $version );
240 240
 
241 241
 		// load multselect js
@@ -247,54 +247,54 @@  discard block
 block discarded – undo
247 247
 		global $pagenow;
248 248
 		if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow == 'edit.php' && $post_type == 'frm_display' ) ) {
249 249
 
250
-            wp_enqueue_script( 'admin-widgets' );
251
-            wp_enqueue_style( 'widgets' );
252
-            wp_enqueue_script( 'formidable' );
253
-            wp_enqueue_script( 'formidable_admin' );
250
+			wp_enqueue_script( 'admin-widgets' );
251
+			wp_enqueue_style( 'widgets' );
252
+			wp_enqueue_script( 'formidable' );
253
+			wp_enqueue_script( 'formidable_admin' );
254 254
 			FrmAppHelper::localize_script( 'admin' );
255 255
 
256
-            wp_enqueue_style( 'formidable-admin' );
256
+			wp_enqueue_style( 'formidable-admin' );
257 257
 			wp_enqueue_style( 'formidable-grids' );
258 258
 			wp_enqueue_style( 'formidable-dropzone' );
259
-            add_thickbox();
259
+			add_thickbox();
260 260
 
261
-            wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' );
261
+			wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' );
262 262
 
263
-        } else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) {
264
-            if ( isset( $_REQUEST['post_type'] ) ) {
265
-                $post_type = sanitize_title( $_REQUEST['post_type'] );
263
+		} else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) {
264
+			if ( isset( $_REQUEST['post_type'] ) ) {
265
+				$post_type = sanitize_title( $_REQUEST['post_type'] );
266 266
 			} else if ( isset( $_REQUEST['post'] ) && absint( $_REQUEST['post'] ) ) {
267 267
 				$post = get_post( absint( $_REQUEST['post'] ) );
268
-                if ( ! $post ) {
269
-                    return;
270
-                }
271
-                $post_type = $post->post_type;
272
-            } else {
273
-                return;
274
-            }
275
-
276
-            if ( $post_type == 'frm_display' ) {
277
-                wp_enqueue_script( 'jquery-ui-draggable' );
278
-                wp_enqueue_script( 'formidable_admin' );
279
-                wp_enqueue_style( 'formidable-admin' );
268
+				if ( ! $post ) {
269
+					return;
270
+				}
271
+				$post_type = $post->post_type;
272
+			} else {
273
+				return;
274
+			}
275
+
276
+			if ( $post_type == 'frm_display' ) {
277
+				wp_enqueue_script( 'jquery-ui-draggable' );
278
+				wp_enqueue_script( 'formidable_admin' );
279
+				wp_enqueue_style( 'formidable-admin' );
280 280
 				FrmAppHelper::localize_script( 'admin' );
281
-            }
282
-        } else if ( $pagenow == 'widgets.php' ) {
283
-            FrmAppHelper::load_admin_wide_js();
284
-        }
285
-    }
286
-
287
-    public static function load_lang() {
288
-        load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' );
289
-    }
290
-
291
-    /**
292
-     * Filter shortcodes in text widgets
293
-     */
294
-    public static function widget_text_filter( $content ) {
295
-    	$regex = '/\[\s*(formidable|display-frm-data|frm-stats|frm-graph|frm-entry-links|formresults|frm-search)\s+.*\]/';
296
-    	return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content );
297
-    }
281
+			}
282
+		} else if ( $pagenow == 'widgets.php' ) {
283
+			FrmAppHelper::load_admin_wide_js();
284
+		}
285
+	}
286
+
287
+	public static function load_lang() {
288
+		load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' );
289
+	}
290
+
291
+	/**
292
+	 * Filter shortcodes in text widgets
293
+	 */
294
+	public static function widget_text_filter( $content ) {
295
+		$regex = '/\[\s*(formidable|display-frm-data|frm-stats|frm-graph|frm-entry-links|formresults|frm-search)\s+.*\]/';
296
+		return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content );
297
+	}
298 298
 
299 299
 	/**
300 300
 	 * Deprecated in favor of wpmu_upgrade_site
@@ -344,23 +344,23 @@  discard block
 block discarded – undo
344 344
 		wp_die();
345 345
 	}
346 346
 
347
-    public static function activation_install() {
348
-        FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' );
349
-        FrmFormActionsController::actions_init();
347
+	public static function activation_install() {
348
+		FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' );
349
+		FrmFormActionsController::actions_init();
350 350
 		if ( ! self::needs_update() ) {
351 351
 			FrmAppHelper::save_combined_js();
352 352
 		}
353
-        self::install();
354
-    }
353
+		self::install();
354
+	}
355 355
 
356
-    public static function install( $old_db_version = false ) {
357
-        $frmdb = new FrmDb();
358
-        $frmdb->upgrade( $old_db_version );
359
-    }
356
+	public static function install( $old_db_version = false ) {
357
+		$frmdb = new FrmDb();
358
+		$frmdb->upgrade( $old_db_version );
359
+	}
360 360
 
361
-    public static function uninstall() {
361
+	public static function uninstall() {
362 362
 		FrmAppHelper::permission_check('administrator');
363
-        check_ajax_referer( 'frm_ajax', 'nonce' );
363
+		check_ajax_referer( 'frm_ajax', 'nonce' );
364 364
 
365 365
 		$frmdb = new FrmDb();
366 366
 		$frmdb->uninstall();
@@ -369,43 +369,43 @@  discard block
 block discarded – undo
369 369
 		deactivate_plugins( FrmAppHelper::plugin_folder() . '/formidable.php', false, false );
370 370
 		echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) );
371 371
 
372
-        wp_die();
373
-    }
372
+		wp_die();
373
+	}
374 374
 
375
-    public static function drop_tables( $tables ) {
376
-        global $wpdb;
377
-        $tables[] = $wpdb->prefix . 'frm_fields';
378
-        $tables[] = $wpdb->prefix . 'frm_forms';
379
-        $tables[] = $wpdb->prefix . 'frm_items';
380
-        $tables[] = $wpdb->prefix . 'frm_item_metas';
381
-        return $tables;
382
-    }
375
+	public static function drop_tables( $tables ) {
376
+		global $wpdb;
377
+		$tables[] = $wpdb->prefix . 'frm_fields';
378
+		$tables[] = $wpdb->prefix . 'frm_forms';
379
+		$tables[] = $wpdb->prefix . 'frm_items';
380
+		$tables[] = $wpdb->prefix . 'frm_item_metas';
381
+		return $tables;
382
+	}
383 383
 
384
-    // Routes for wordpress pages -- we're just replacing content here folks.
385
-    public static function page_route( $content ) {
386
-        global $post;
384
+	// Routes for wordpress pages -- we're just replacing content here folks.
385
+	public static function page_route( $content ) {
386
+		global $post;
387 387
 
388
-        $frm_settings = FrmAppHelper::get_settings();
389
-        if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) {
390
-            $content = FrmFormsController::page_preview();
391
-        }
388
+		$frm_settings = FrmAppHelper::get_settings();
389
+		if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) {
390
+			$content = FrmFormsController::page_preview();
391
+		}
392 392
 
393
-        return $content;
394
-    }
393
+		return $content;
394
+	}
395 395
 
396
-    public static function deauthorize() {
396
+	public static function deauthorize() {
397 397
 		FrmAppHelper::permission_check('frm_change_settings');
398
-        check_ajax_referer( 'frm_ajax', 'nonce' );
399
-
400
-        delete_option( 'frmpro-credentials' );
401
-        delete_option( 'frmpro-authorized' );
402
-        delete_site_option( 'frmpro-credentials' );
403
-        delete_site_option( 'frmpro-authorized' );
404
-        wp_die();
405
-    }
406
-
407
-    public static function get_form_shortcode( $atts ) {
408
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' );
409
-        return FrmFormsController::get_form_shortcode( $atts );
410
-    }
398
+		check_ajax_referer( 'frm_ajax', 'nonce' );
399
+
400
+		delete_option( 'frmpro-credentials' );
401
+		delete_option( 'frmpro-authorized' );
402
+		delete_site_option( 'frmpro-credentials' );
403
+		delete_site_option( 'frmpro-authorized' );
404
+		wp_die();
405
+	}
406
+
407
+	public static function get_form_shortcode( $atts ) {
408
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' );
409
+		return FrmFormsController::get_form_shortcode( $atts );
410
+	}
411 411
 }
Please login to merge, or discard this patch.