Completed
Push — master ( 2cdabf...85440e )
by Stephanie
02:59
created
classes/models/FrmField.php 1 patch
Indentation   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 
6 6
 class FrmField {
7 7
 
8
-    static $use_cache = true;
8
+	static $use_cache = true;
9 9
 	static $transient_size = 200;
10 10
 
11 11
 	public static function field_selection() {
@@ -148,41 +148,41 @@  discard block
 block discarded – undo
148 148
 		));
149 149
 	}
150 150
 
151
-    public static function create( $values, $return = true ) {
152
-        global $wpdb, $frm_duplicate_ids;
151
+	public static function create( $values, $return = true ) {
152
+		global $wpdb, $frm_duplicate_ids;
153 153
 
154
-        $new_values = array();
154
+		$new_values = array();
155 155
 		$key = isset( $values['field_key'] ) ? $values['field_key'] : $values['name'];
156 156
 		$new_values['field_key'] = FrmAppHelper::get_unique_key( $key, $wpdb->prefix . 'frm_fields', 'field_key' );
157 157
 
158 158
 		foreach ( array( 'name', 'description', 'type', 'default_value' ) as $col ) {
159 159
 			$new_values[ $col ] = $values[ $col ];
160
-        }
160
+		}
161 161
 
162
-        $new_values['options'] = $values['options'];
162
+		$new_values['options'] = $values['options'];
163 163
 
164 164
 		$new_values['field_order'] = isset( $values['field_order'] ) ? (int) $values['field_order'] : null;
165 165
 		$new_values['required'] = isset( $values['required'] ) ? (int) $values['required'] : 0;
166 166
 		$new_values['form_id'] = isset( $values['form_id'] ) ? (int) $values['form_id'] : null;
167
-        $new_values['field_options'] = $values['field_options'];
167
+		$new_values['field_options'] = $values['field_options'];
168 168
 		$new_values['created_at'] = current_time( 'mysql', 1 );
169 169
 
170 170
 		if ( isset( $values['id'] ) ) {
171 171
 			$frm_duplicate_ids[ $values['field_key'] ] = $new_values['field_key'];
172 172
 			$new_values = apply_filters( 'frm_duplicated_field', $new_values );
173
-        }
173
+		}
174 174
 
175 175
 		self::preserve_format_option_backslashes( $new_values );
176 176
 
177 177
 		foreach ( $new_values as $k => $v ) {
178
-            if ( is_array( $v ) ) {
178
+			if ( is_array( $v ) ) {
179 179
 				$new_values[ $k ] = serialize( $v );
180 180
 			}
181
-            unset( $k, $v );
182
-        }
181
+			unset( $k, $v );
182
+		}
183 183
 
184
-        //if(isset($values['id']) and is_numeric($values['id']))
185
-        //    $new_values['id'] = $values['id'];
184
+		//if(isset($values['id']) and is_numeric($values['id']))
185
+		//    $new_values['id'] = $values['id'];
186 186
 
187 187
 		$query_results = $wpdb->insert( $wpdb->prefix . 'frm_fields', $new_values );
188 188
 		$new_id = 0;
@@ -203,10 +203,10 @@  discard block
 block discarded – undo
203 203
 		} else {
204 204
 			return false;
205 205
 		}
206
-    }
206
+	}
207 207
 
208
-    public static function duplicate( $old_form_id, $form_id, $copy_keys = false, $blog_id = false ) {
209
-        global $frm_duplicate_ids;
208
+	public static function duplicate( $old_form_id, $form_id, $copy_keys = false, $blog_id = false ) {
209
+		global $frm_duplicate_ids;
210 210
 
211 211
 		$where = array(
212 212
 			array(
@@ -217,14 +217,14 @@  discard block
 block discarded – undo
217 217
 		);
218 218
 		$fields = self::getAll( $where, 'field_order', '', $blog_id );
219 219
 
220
-        foreach ( (array) $fields as $field ) {
220
+		foreach ( (array) $fields as $field ) {
221 221
 			$new_key = $copy_keys ? $field->field_key : '';
222 222
 			if ( $copy_keys && substr( $field->field_key, -1 ) == 2 ) {
223 223
 				$new_key = rtrim( $new_key, 2 );
224 224
 			}
225 225
 
226
-            $values = array();
227
-            FrmFieldsHelper::fill_field( $values, $field, $form_id, $new_key );
226
+			$values = array();
227
+			FrmFieldsHelper::fill_field( $values, $field, $form_id, $new_key );
228 228
 
229 229
 			// If this is a repeating section, create new form
230 230
 			if ( self::is_repeating_field( $field ) ) {
@@ -251,11 +251,11 @@  discard block
 block discarded – undo
251 251
 			$frm_duplicate_ids[ $field->id ] = $new_id;
252 252
 			$frm_duplicate_ids[ $field->field_key ] = $new_id;
253 253
 			unset( $field );
254
-        }
255
-    }
254
+		}
255
+	}
256 256
 
257 257
 	public static function update( $id, $values ) {
258
-        global $wpdb;
258
+		global $wpdb;
259 259
 
260 260
 		$id = absint( $id );
261 261
 
@@ -264,8 +264,8 @@  discard block
 block discarded – undo
264 264
 		}
265 265
 
266 266
 		if ( isset( $values['required'] ) ) {
267
-            $values['required'] = (int) $values['required'];
268
-        }
267
+			$values['required'] = (int) $values['required'];
268
+		}
269 269
 
270 270
 		self::preserve_format_option_backslashes( $values );
271 271
 
@@ -287,41 +287,41 @@  discard block
 block discarded – undo
287 287
 
288 288
 		$query_results = $wpdb->update( $wpdb->prefix . 'frm_fields', $values, array( 'id' => $id ) );
289 289
 
290
-        $form_id = 0;
290
+		$form_id = 0;
291 291
 		if ( isset( $values['form_id'] ) ) {
292
-            $form_id = absint( $values['form_id'] );
292
+			$form_id = absint( $values['form_id'] );
293 293
 		} else {
294 294
 			$field = self::getOne( $id );
295
-            if ( $field ) {
296
-                $form_id = $field->form_id;
297
-            }
295
+			if ( $field ) {
296
+				$form_id = $field->form_id;
297
+			}
298 298
 			unset( $field );
299
-        }
299
+		}
300 300
 		unset( $values );
301 301
 
302 302
 		if ( $query_results ) {
303
-            wp_cache_delete( $id, 'frm_field' );
304
-            if ( $form_id ) {
305
-                self::delete_form_transient( $form_id );
306
-            }
307
-        }
303
+			wp_cache_delete( $id, 'frm_field' );
304
+			if ( $form_id ) {
305
+				self::delete_form_transient( $form_id );
306
+			}
307
+		}
308 308
 
309
-        return $query_results;
310
-    }
309
+		return $query_results;
310
+	}
311 311
 
312 312
 	/**
313
-	* Keep backslashes in the phone format option
314
-	*
315
-	* @since 2.0.8
316
-	* @param $values array - pass by reference
317
-	*/
313
+	 * Keep backslashes in the phone format option
314
+	 *
315
+	 * @since 2.0.8
316
+	 * @param $values array - pass by reference
317
+	 */
318 318
 	private static function preserve_format_option_backslashes( &$values ) {
319 319
 		if ( isset( $values['field_options']['format'] ) ) {
320 320
 			$values['field_options']['format'] = FrmAppHelper::preserve_backslashes( $values['field_options']['format'] );
321 321
 		}
322 322
 	}
323 323
 
324
-    public static function destroy( $id ) {
324
+	public static function destroy( $id ) {
325 325
 		global $wpdb;
326 326
 
327 327
 		do_action( 'frm_before_destroy_field', $id );
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 
337 337
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE field_id=%d', $id ) );
338 338
 		return $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_fields WHERE id=%d', $id ) );
339
-    }
339
+	}
340 340
 
341 341
 	public static function delete_form_transient( $form_id ) {
342 342
 		$form_id = absint( $form_id );
@@ -351,10 +351,10 @@  discard block
 block discarded – undo
351 351
 		FrmDb::cache_delete_group( 'frm_field' );
352 352
 
353 353
 		$form = FrmForm::getOne( $form_id );
354
-        if ( $form && $form->parent_form_id && $form->parent_form_id != $form_id ) {
355
-            self::delete_form_transient( $form->parent_form_id );
356
-        }
357
-    }
354
+		if ( $form && $form->parent_form_id && $form->parent_form_id != $form_id ) {
355
+			self::delete_form_transient( $form->parent_form_id );
356
+		}
357
+	}
358 358
 
359 359
 	/**
360 360
 	 * If $field is numeric, get the field object
@@ -370,83 +370,83 @@  discard block
 block discarded – undo
370 370
 			return null;
371 371
 		}
372 372
 
373
-        global $wpdb;
373
+		global $wpdb;
374 374
 
375 375
 		$where = is_numeric( $id ) ? 'id=%d' : 'field_key=%s';
376 376
 		$query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'frm_fields WHERE ' . $where, $id ); // WPCS: unprepared SQL ok.
377 377
 
378
-        $results = FrmDb::check_cache( $id, 'frm_field', $query, 'get_row', 0 );
378
+		$results = FrmDb::check_cache( $id, 'frm_field', $query, 'get_row', 0 );
379 379
 
380 380
 		if ( empty( $results ) ) {
381
-            return $results;
382
-        }
381
+			return $results;
382
+		}
383 383
 
384 384
 		if ( is_numeric( $id ) ) {
385 385
 			FrmDb::set_cache( $results->field_key, $results, 'frm_field' );
386
-        } else if ( $results ) {
386
+		} else if ( $results ) {
387 387
 			FrmDb::set_cache( $results->id, $results, 'frm_field' );
388
-        }
388
+		}
389 389
 
390 390
 		self::prepare_options( $results );
391 391
 
392 392
 		return stripslashes_deep( $results );
393
-    }
393
+	}
394 394
 
395
-    /**
396
-     * Get the field type by key or id
397
-     * @param int|string The field id or key
395
+	/**
396
+	 * Get the field type by key or id
397
+	 * @param int|string The field id or key
398 398
 	 * @param mixed $col The name of the column in the fields database table
399
-     */
400
-    public static function get_type( $id, $col = 'type' ) {
401
-        $field = FrmDb::check_cache( $id, 'frm_field' );
402
-        if ( $field ) {
403
-            $type = $field->{$col};
404
-        } else {
399
+	 */
400
+	public static function get_type( $id, $col = 'type' ) {
401
+		$field = FrmDb::check_cache( $id, 'frm_field' );
402
+		if ( $field ) {
403
+			$type = $field->{$col};
404
+		} else {
405 405
 			$where = array(
406 406
 				'or'        => 1,
407 407
 				'id'        => $id,
408 408
 				'field_key' => $id,
409 409
 			);
410 410
 			$type = FrmDb::get_var( 'frm_fields', $where, $col );
411
-        }
411
+		}
412 412
 
413
-        return $type;
414
-    }
413
+		return $type;
414
+	}
415 415
 
416 416
 	public static function get_all_types_in_form( $form_id, $type, $limit = '', $inc_sub = 'exclude' ) {
417
-        if ( ! $form_id ) {
418
-            return array();
419
-        }
417
+		if ( ! $form_id ) {
418
+			return array();
419
+		}
420 420
 
421 421
 		$results = self::get_fields_from_transients( $form_id, array(
422 422
 			'inc_embed'  => $inc_sub,
423 423
 			'inc_repeat' => $inc_sub,
424 424
 		) );
425 425
 		if ( ! empty( $results ) ) {
426
-            $fields = array();
427
-            $count = 0;
428
-            foreach ( $results as $result ) {
429
-                if ( $type != $result->type ) {
430
-                    continue;
431
-                }
426
+			$fields = array();
427
+			$count = 0;
428
+			foreach ( $results as $result ) {
429
+				if ( $type != $result->type ) {
430
+					continue;
431
+				}
432 432
 
433 433
 				$fields[ $result->id ] = $result;
434
-                $count++;
435
-                if ( $limit == 1 ) {
436
-                    $fields = $result;
437
-                    break;
438
-                }
434
+				$count++;
435
+				if ( $limit == 1 ) {
436
+					$fields = $result;
437
+					break;
438
+				}
439 439
 
440 440
 				if ( ! empty( $limit ) && $count >= $limit ) {
441
-                    break;
442
-                }
441
+					break;
442
+				}
443 443
 
444 444
 				unset( $result );
445 445
 			}
446 446
 			return stripslashes_deep( $fields );
447
-        }
447
+		}
448 448
 
449
-        self::$use_cache = false;
449
+		self::$use_cache = false;
450 450
 
451 451
 		$where = array(
452 452
 			'fi.form_id' => (int) $form_id,
@@ -454,16 +454,16 @@  discard block
 block discarded – undo
454 454
 		);
455 455
 		self::maybe_include_repeating_fields( $inc_sub, $where );
456 456
 		$results = self::getAll( $where, 'field_order', $limit );
457
-        self::$use_cache = true;
457
+		self::$use_cache = true;
458 458
 		self::include_sub_fields( $results, $inc_sub, $type );
459 459
 
460
-        return $results;
461
-    }
460
+		return $results;
461
+	}
462 462
 
463 463
 	public static function get_all_for_form( $form_id, $limit = '', $inc_embed = 'exclude', $inc_repeat = 'include' ) {
464
-        if ( ! (int) $form_id ) {
465
-            return array();
466
-        }
464
+		if ( ! (int) $form_id ) {
465
+			return array();
466
+		}
467 467
 
468 468
 		$results = self::get_fields_from_transients( $form_id, array(
469 469
 			'inc_embed'  => $inc_embed,
@@ -472,28 +472,28 @@  discard block
 block discarded – undo
472 472
 		if ( ! empty( $results ) ) {
473 473
 			if ( empty( $limit ) ) {
474 474
 				return $results;
475
-            }
475
+			}
476 476
 
477
-            $fields = array();
478
-            $count = 0;
479
-            foreach ( $results as $result ) {
477
+			$fields = array();
478
+			$count = 0;
479
+			foreach ( $results as $result ) {
480 480
 				$count++;
481 481
 				$fields[ $result->id ] = $result;
482 482
 				if ( ! empty( $limit ) && $count >= $limit ) {
483
-                    break;
484
-                }
485
-            }
483
+					break;
484
+				}
485
+			}
486 486
 
487 487
 			return $fields;
488
-        }
488
+		}
489 489
 
490
-        self::$use_cache = false;
490
+		self::$use_cache = false;
491 491
 
492 492
 		$where = array( 'fi.form_id' => absint( $form_id ) );
493 493
 		self::maybe_include_repeating_fields( $inc_repeat, $where );
494 494
 		$results = self::getAll( $where, 'field_order', $limit );
495 495
 
496
-        self::$use_cache = true;
496
+		self::$use_cache = true;
497 497
 
498 498
 		self::include_sub_fields( $results, $inc_embed, 'all' );
499 499
 
@@ -502,17 +502,17 @@  discard block
 block discarded – undo
502 502
 				'inc_embed'  => $inc_embed,
503 503
 				'inc_repeat' => $inc_repeat,
504 504
 			) );
505
-        }
505
+		}
506 506
 
507 507
 		return $results;
508
-    }
508
+	}
509 509
 
510 510
 	/**
511
-	* If repeating fields should be included, adjust $where accordingly
512
-	*
513
-	* @param string $inc_repeat
514
-	* @param array $where - pass by reference
515
-	*/
511
+	 * If repeating fields should be included, adjust $where accordingly
512
+	 *
513
+	 * @param string $inc_repeat
514
+	 * @param array $where - pass by reference
515
+	 */
516 516
 	private static function maybe_include_repeating_fields( $inc_repeat, &$where ) {
517 517
 		if ( $inc_repeat == 'include' ) {
518 518
 			$form_id = $where['fi.form_id'];
@@ -527,21 +527,21 @@  discard block
 block discarded – undo
527 527
 
528 528
 	public static function include_sub_fields( &$results, $inc_embed, $type = 'all' ) {
529 529
 		if ( 'include' != $inc_embed || empty( $results ) ) {
530
-            return;
531
-        }
530
+			return;
531
+		}
532 532
 
533
-        $form_fields = $results;
533
+		$form_fields = $results;
534 534
 		$index_offset = 1;
535
-        foreach ( $form_fields as $k => $field ) {
535
+		foreach ( $form_fields as $k => $field ) {
536 536
 			if ( 'form' != $field->type || ! isset( $field->field_options['form_select'] ) ) {
537
-                continue;
538
-            }
537
+				continue;
538
+			}
539 539
 
540
-            if ( $type == 'all' ) {
541
-                $sub_fields = self::get_all_for_form( $field->field_options['form_select'] );
542
-            } else {
540
+			if ( $type == 'all' ) {
541
+				$sub_fields = self::get_all_for_form( $field->field_options['form_select'] );
542
+			} else {
543 543
 				$sub_fields = self::get_all_types_in_form( $field->form_id, $type );
544
-            }
544
+			}
545 545
 
546 546
 			if ( ! empty( $sub_fields ) ) {
547 547
 				$index = $k + $index_offset;
@@ -549,35 +549,35 @@  discard block
 block discarded – undo
549 549
 				array_splice( $results, $index, 0, $sub_fields );
550 550
 			}
551 551
 			unset( $field, $sub_fields );
552
-        }
553
-    }
552
+		}
553
+	}
554 554
 
555 555
 	public static function getAll( $where = array(), $order_by = '', $limit = '', $blog_id = false ) {
556 556
 		$cache_key = maybe_serialize( $where ) . $order_by . 'l' . $limit . 'b' . $blog_id;
557
-        if ( self::$use_cache ) {
558
-            // make sure old cache doesn't get saved as a transient
557
+		if ( self::$use_cache ) {
558
+			// make sure old cache doesn't get saved as a transient
559 559
 			$results = wp_cache_get( $cache_key, 'frm_field' );
560
-            if ( false !== $results ) {
560
+			if ( false !== $results ) {
561 561
 				return stripslashes_deep( $results );
562
-            }
563
-        }
562
+			}
563
+		}
564 564
 
565
-        global $wpdb;
565
+		global $wpdb;
566 566
 
567
-        if ( $blog_id && is_multisite() ) {
568
-            global $wpmuBaseTablePrefix;
569
-            if ( $wpmuBaseTablePrefix ) {
567
+		if ( $blog_id && is_multisite() ) {
568
+			global $wpmuBaseTablePrefix;
569
+			if ( $wpmuBaseTablePrefix ) {
570 570
 				$prefix = $wpmuBaseTablePrefix . $blog_id . '_';
571
-            } else {
572
-                $prefix = $wpdb->get_blog_prefix( $blog_id );
573
-            }
571
+			} else {
572
+				$prefix = $wpdb->get_blog_prefix( $blog_id );
573
+			}
574 574
 
575 575
 			$table_name = $prefix . 'frm_fields';
576 576
 			$form_table_name = $prefix . 'frm_forms';
577 577
 		} else {
578 578
 			$table_name = $wpdb->prefix . 'frm_fields';
579 579
 			$form_table_name = $wpdb->prefix . 'frm_forms';
580
-        }
580
+		}
581 581
 
582 582
 		if ( ! empty( $order_by ) && strpos( $order_by, 'ORDER BY' ) === false ) {
583 583
 			$order_by = ' ORDER BY ' . $order_by;
@@ -585,8 +585,8 @@  discard block
 block discarded – undo
585 585
 
586 586
 		$limit = FrmDb::esc_limit( $limit );
587 587
 
588
-        $query = "SELECT fi.*, fr.name as form_name  FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id";
589
-        $query_type = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'row' : 'results';
588
+		$query = "SELECT fi.*, fr.name as form_name  FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id";
589
+		$query_type = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'row' : 'results';
590 590
 
591 591
 		if ( is_array( $where ) ) {
592 592
 			$args = array(
@@ -600,8 +600,8 @@  discard block
 block discarded – undo
600 600
 
601 601
 			$function_name = ( $query_type == 'row' ) ? 'get_row' : 'get_results';
602 602
 			$results = $wpdb->$function_name( $query );
603
-        }
604
-        unset( $where );
603
+		}
604
+		unset( $where );
605 605
 
606 606
 		self::format_field_results( $results );
607 607
 
@@ -849,8 +849,8 @@  discard block
 block discarded – undo
849 849
 	}
850 850
 
851 851
 	/**
852
-	* @since 2.0.09
853
-	*/
852
+	 * @since 2.0.09
853
+	 */
854 854
 	public static function is_repeating_field( $field ) {
855 855
 		if ( is_array( $field ) ) {
856 856
 			$is_repeating_field = ( 'divider' == $field['type'] );
@@ -860,14 +860,14 @@  discard block
 block discarded – undo
860 860
 		return ( $is_repeating_field && self::is_option_true( $field, 'repeat' ) );
861 861
 	}
862 862
 
863
-    /**
864
-     * @param string $key
865
-     * @return int field id
866
-     */
863
+	/**
864
+	 * @param string $key
865
+	 * @return int field id
866
+	 */
867 867
 	public static function get_id_by_key( $key ) {
868
-        $id = FrmDb::get_var( 'frm_fields', array( 'field_key' => sanitize_title( $key ) ) );
869
-        return $id;
870
-    }
868
+		$id = FrmDb::get_var( 'frm_fields', array( 'field_key' => sanitize_title( $key ) ) );
869
+		return $id;
870
+	}
871 871
 
872 872
 	/**
873 873
 	 * @param string $id
Please login to merge, or discard this patch.
classes/models/FrmMigrate.php 1 patch
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -84,11 +84,11 @@  discard block
 block discarded – undo
84 84
 		return $charset_collate;
85 85
 	}
86 86
 
87
-    private function create_tables() {
88
-        $charset_collate = $this->collation();
89
-        $sql = array();
87
+	private function create_tables() {
88
+		$charset_collate = $this->collation();
89
+		$sql = array();
90 90
 
91
-        /* Create/Upgrade Fields Table */
91
+		/* Create/Upgrade Fields Table */
92 92
 		$sql[] = 'CREATE TABLE ' . $this->fields . ' (
93 93
 				id BIGINT(20) NOT NULL auto_increment,
94 94
 				field_key varchar(100) default NULL,
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
                 UNIQUE KEY field_key (field_key)
108 108
         )';
109 109
 
110
-        /* Create/Upgrade Forms Table */
110
+		/* Create/Upgrade Forms Table */
111 111
 		$sql[] = 'CREATE TABLE ' . $this->forms . ' (
112 112
                 id int(11) NOT NULL auto_increment,
113 113
 				form_key varchar(100) default NULL,
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
                 UNIQUE KEY form_key (form_key)
126 126
         )';
127 127
 
128
-        /* Create/Upgrade Items Table */
128
+		/* Create/Upgrade Items Table */
129 129
 		$sql[] = 'CREATE TABLE ' . $this->entries . ' (
130 130
 				id BIGINT(20) NOT NULL auto_increment,
131 131
 				item_key varchar(100) default NULL,
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
                 UNIQUE KEY item_key (item_key)
149 149
         )';
150 150
 
151
-        /* Create/Upgrade Meta Table */
151
+		/* Create/Upgrade Meta Table */
152 152
 		$sql[] = 'CREATE TABLE ' . $this->entry_metas . ' (
153 153
 				id BIGINT(20) NOT NULL auto_increment,
154 154
 				meta_value longtext default NULL,
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
                 KEY item_id (item_id)
161 161
         )';
162 162
 
163
-        foreach ( $sql as $q ) {
163
+		foreach ( $sql as $q ) {
164 164
 			if ( function_exists( 'dbDelta' ) ) {
165 165
 				dbDelta( $q . $charset_collate . ';' );
166 166
 			} else {
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
 				$wpdb->query( $q . $charset_collate ); // WPCS: unprepared SQL ok.
169 169
 			}
170 170
 			unset( $q );
171
-        }
172
-    }
171
+		}
172
+	}
173 173
 
174 174
 	private function maybe_create_contact_form() {
175 175
 		$template_id = FrmForm::get_id_by_key( 'contact' );
@@ -216,13 +216,13 @@  discard block
 block discarded – undo
216 216
 		}
217 217
 	}
218 218
 
219
-    public function uninstall() {
219
+	public function uninstall() {
220 220
 		if ( ! current_user_can( 'administrator' ) ) {
221
-            $frm_settings = FrmAppHelper::get_settings();
221
+			$frm_settings = FrmAppHelper::get_settings();
222 222
 			wp_die( esc_html( $frm_settings->admin_permission ) );
223
-        }
223
+		}
224 224
 
225
-        global $wpdb, $wp_roles;
225
+		global $wpdb, $wp_roles;
226 226
 
227 227
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->fields ); // WPCS: unprepared SQL ok.
228 228
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->forms ); // WPCS: unprepared SQL ok.
@@ -232,12 +232,12 @@  discard block
 block discarded – undo
232 232
 		delete_option( 'frm_options' );
233 233
 		delete_option( 'frm_db_version' );
234 234
 
235
-        //delete roles
236
-        $frm_roles = FrmAppHelper::frm_capabilities();
237
-        $roles = get_editable_roles();
238
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
239
-            foreach ( $roles as $role => $details ) {
240
-                $wp_roles->remove_cap( $role, $frm_role );
235
+		//delete roles
236
+		$frm_roles = FrmAppHelper::frm_capabilities();
237
+		$roles = get_editable_roles();
238
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
239
+			foreach ( $roles as $role => $details ) {
240
+				$wp_roles->remove_cap( $role, $frm_role );
241 241
 				unset( $role, $details );
242 242
 			}
243 243
 			unset( $frm_role, $frm_role_description );
@@ -265,8 +265,8 @@  discard block
 block discarded – undo
265 265
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) );
266 266
 
267 267
 		do_action( 'frm_after_uninstall' );
268
-        return true;
269
-    }
268
+		return true;
269
+	}
270 270
 
271 271
 	/**
272 272
 	 * Reverse migration 17 -- Divide by 9
@@ -433,44 +433,44 @@  discard block
 block discarded – undo
433 433
 		$size .= 'px';
434 434
 	}
435 435
 
436
-    /**
437
-     * Migrate post and email notification settings into actions
438
-     */
439
-    private function migrate_to_16() {
440
-        $forms = FrmDb::get_results( $this->forms, array(), 'id, options, is_template, default_template' );
441
-
442
-        /**
443
-        * Old email settings format:
444
-        * email_to: Email or field id
445
-        * also_email_to: array of fields ids
446
-        * reply_to: Email, field id, 'custom'
447
-        * cust_reply_to: string
448
-        * reply_to_name: field id, 'custom'
449
-        * cust_reply_to_name: string
450
-        * plain_text: 0|1
451
-        * email_message: string or ''
452
-        * email_subject: string or ''
453
-        * inc_user_info: 0|1
454
-        * update_email: 0, 1, 2
455
-        *
456
-        * Old autoresponder settings format:
457
-        * auto_responder: 0|1
458
-        * ar_email_message: string or ''
459
-        * ar_email_to: field id
460
-        * ar_plain_text: 0|1
461
-        * ar_reply_to_name: string
462
-        * ar_reply_to: string
463
-        * ar_email_subject: string
464
-        * ar_update_email: 0, 1, 2
465
-        *
466
-        * New email settings:
467
-        * post_content: json settings
468
-        * post_title: form id
469
-        * post_excerpt: message
470
-        *
471
-        */
472
-
473
-        foreach ( $forms as $form ) {
436
+	/**
437
+	 * Migrate post and email notification settings into actions
438
+	 */
439
+	private function migrate_to_16() {
440
+		$forms = FrmDb::get_results( $this->forms, array(), 'id, options, is_template, default_template' );
441
+
442
+		/**
443
+		 * Old email settings format:
444
+		 * email_to: Email or field id
445
+		 * also_email_to: array of fields ids
446
+		 * reply_to: Email, field id, 'custom'
447
+		 * cust_reply_to: string
448
+		 * reply_to_name: field id, 'custom'
449
+		 * cust_reply_to_name: string
450
+		 * plain_text: 0|1
451
+		 * email_message: string or ''
452
+		 * email_subject: string or ''
453
+		 * inc_user_info: 0|1
454
+		 * update_email: 0, 1, 2
455
+		 *
456
+		 * Old autoresponder settings format:
457
+		 * auto_responder: 0|1
458
+		 * ar_email_message: string or ''
459
+		 * ar_email_to: field id
460
+		 * ar_plain_text: 0|1
461
+		 * ar_reply_to_name: string
462
+		 * ar_reply_to: string
463
+		 * ar_email_subject: string
464
+		 * ar_update_email: 0, 1, 2
465
+		 *
466
+		 * New email settings:
467
+		 * post_content: json settings
468
+		 * post_title: form id
469
+		 * post_excerpt: message
470
+		 *
471
+		 */
472
+
473
+		foreach ( $forms as $form ) {
474 474
 			if ( $form->is_template && $form->default_template ) {
475 475
 				// don't migrate the default templates since the email will be added anyway
476 476
 				continue;
@@ -479,19 +479,19 @@  discard block
 block discarded – undo
479 479
 			// Format form options
480 480
 			$form_options = maybe_unserialize( $form->options );
481 481
 
482
-            // Migrate settings to actions
483
-            FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id );
484
-        }
485
-    }
482
+			// Migrate settings to actions
483
+			FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id );
484
+		}
485
+	}
486 486
 
487
-    private function migrate_to_11() {
488
-        global $wpdb;
487
+	private function migrate_to_11() {
488
+		global $wpdb;
489 489
 
490 490
 		$forms = FrmDb::get_results( $this->forms, array(), 'id, options' );
491 491
 
492
-        $sending = __( 'Sending', 'formidable' );
492
+		$sending = __( 'Sending', 'formidable' );
493 493
 		$img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif';
494
-        $old_default_html = <<<DEFAULT_HTML
494
+		$old_default_html = <<<DEFAULT_HTML
495 495
 <div class="frm_submit">
496 496
 [if back_button]<input type="submit" value="[back_label]" name="frm_prev_page" formnovalidate="formnovalidate" [back_hook] />[/if back_button]
497 497
 <input type="submit" value="[button_label]" [button_action] />
@@ -501,21 +501,21 @@  discard block
 block discarded – undo
501 501
 		unset( $sending, $img );
502 502
 
503 503
 		$new_default_html = FrmFormsHelper::get_default_html( 'submit' );
504
-        $draft_link = FrmFormsHelper::get_draft_link();
504
+		$draft_link = FrmFormsHelper::get_draft_link();
505 505
 		foreach ( $forms as $form ) {
506 506
 			$form->options = maybe_unserialize( $form->options );
507 507
 			if ( ! isset( $form->options['submit_html'] ) || empty( $form->options['submit_html'] ) ) {
508
-                continue;
509
-            }
508
+				continue;
509
+			}
510 510
 
511
-            if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) {
512
-                $form->options['submit_html'] = $new_default_html;
511
+			if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) {
512
+				$form->options['submit_html'] = $new_default_html;
513 513
 				$wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
514 514
 			} else if ( ! strpos( $form->options['submit_html'], 'save_draft' ) ) {
515 515
 				$form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] );
516 516
 				$wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
517
-            }
517
+			}
518 518
 			unset( $form );
519
-        }
520
-    }
519
+		}
520
+	}
521 521
 }
Please login to merge, or discard this patch.
classes/widgets/FrmShowForm.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 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 FrmAppHelper::kses( $args['before_widget'], 'all' ); // WPCS: XSS ok.
14 14
 
Please login to merge, or discard this patch.
classes/controllers/FrmEntriesController.php 1 patch
Indentation   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -26,55 +26,55 @@  discard block
 block discarded – undo
26 26
 		}
27 27
 	}
28 28
 
29
-    /* Display in Back End */
30
-    public static function route() {
29
+	/* Display in Back End */
30
+	public static function route() {
31 31
 		$action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' );
32 32
 
33
-        switch ( $action ) {
34
-            case 'show':
35
-            case 'destroy':
36
-            case 'destroy_all':
37
-                return self::$action();
33
+		switch ( $action ) {
34
+			case 'show':
35
+			case 'destroy':
36
+			case 'destroy_all':
37
+				return self::$action();
38 38
 
39
-            default:
40
-                do_action( 'frm_entry_action_route', $action );
41
-                if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) {
42
-                    return;
43
-                }
39
+			default:
40
+				do_action( 'frm_entry_action_route', $action );
41
+				if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) {
42
+					return;
43
+				}
44 44
 
45
-                return self::display_list();
46
-        }
47
-    }
45
+				return self::display_list();
46
+		}
47
+	}
48 48
 
49 49
 	public static function contextual_help( $help, $screen_id, $screen ) {
50
-        // Only add to certain screens. add_help_tab was introduced in WordPress 3.3
51
-        if ( ! method_exists( $screen, 'add_help_tab' ) ) {
52
-            return $help;
53
-        }
50
+		// Only add to certain screens. add_help_tab was introduced in WordPress 3.3
51
+		if ( ! method_exists( $screen, 'add_help_tab' ) ) {
52
+			return $help;
53
+		}
54 54
 
55 55
 		$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
56 56
 		$page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
57 57
 		$show_help = ( $page == 'formidable-entries' && ( empty( $action ) || $action == 'list' ) );
58 58
 		if ( ! $show_help ) {
59
-            return $help;
60
-        }
59
+			return $help;
60
+		}
61 61
 
62 62
 		unset( $action, $page );
63 63
 
64
-        $screen->add_help_tab( array(
65
-            'id'      => 'formidable-entries-tab',
66
-            'title'   => __( 'Overview', 'formidable' ),
64
+		$screen->add_help_tab( array(
65
+			'id'      => 'formidable-entries-tab',
66
+			'title'   => __( 'Overview', 'formidable' ),
67 67
 			'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) . '</p> <p>' . esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>',
68
-        ));
68
+		));
69 69
 
70
-        $screen->set_help_sidebar(
70
+		$screen->set_help_sidebar(
71 71
 			'<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' .
72 72
 			'<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/knowledgebase/manage-entries-from-the-back-end/' ) ) . '" target="_blank">' . esc_html__( 'Documentation on Entries', 'formidable' ) . '</a></p>' .
73 73
 			'<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/help-desk/' ) ) . '" target="_blank">' . esc_html__( 'Support', 'formidable' ) . '</a></p>'
74
-    	);
74
+		);
75 75
 
76
-        return $help;
77
-    }
76
+		return $help;
77
+	}
78 78
 
79 79
 	/**
80 80
 	 * Prevent the "screen options" tab from showing when
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	}
93 93
 
94 94
 	public static function manage_columns( $columns ) {
95
-        global $frm_vars;
95
+		global $frm_vars;
96 96
 		$form_id = FrmForm::get_current_form_id();
97 97
 
98 98
 		$columns[ $form_id . '_id' ] = 'ID';
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 		$columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' );
111 111
 		self::maybe_add_ip_col( $form_id, $columns );
112 112
 
113
-        $frm_vars['cols'] = $columns;
113
+		$frm_vars['cols'] = $columns;
114 114
 
115 115
 		$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
116 116
 		if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ) ) ) {
@@ -119,10 +119,10 @@  discard block
 block discarded – undo
119 119
 				'default' => 20,
120 120
 				'option'  => 'formidable_page_formidable_entries_per_page',
121 121
 			) );
122
-        }
122
+		}
123 123
 
124
-        return $columns;
125
-    }
124
+		return $columns;
125
+	}
126 126
 
127 127
 	private static function get_columns_for_form( $form_id, &$columns ) {
128 128
 		$form_cols = FrmField::get_all_for_form( $form_id, '', 'include' );
@@ -187,67 +187,67 @@  discard block
 block discarded – undo
187 187
 	public static function check_hidden_cols( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
188 188
 		$this_page_name = self::hidden_column_key();
189 189
 		if ( $meta_key != $this_page_name || $meta_value == $prev_value ) {
190
-            return $check;
191
-        }
190
+			return $check;
191
+		}
192 192
 
193 193
 		if ( empty( $prev_value ) ) {
194 194
 			$prev_value = get_metadata( 'user', $object_id, $meta_key, true );
195 195
 		}
196 196
 
197
-        global $frm_vars;
197
+		global $frm_vars;
198 198
 		//add a check so we don't create a loop
199 199
 		$frm_vars['prev_hidden_cols'] = ( isset( $frm_vars['prev_hidden_cols'] ) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
200 200
 
201
-        return $check;
202
-    }
201
+		return $check;
202
+	}
203 203
 
204
-    //add hidden columns back from other forms
204
+	//add hidden columns back from other forms
205 205
 	public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) {
206 206
 		$this_page_name = self::hidden_column_key();
207 207
 		if ( $meta_key != $this_page_name ) {
208
-            return;
209
-        }
208
+			return;
209
+		}
210 210
 
211 211
 		global $frm_vars;
212 212
 		if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) {
213 213
 			return; //don't continue if there's no previous value
214 214
 		}
215 215
 
216
-        foreach ( $meta_value as $mk => $mv ) {
217
-            //remove blank values
218
-            if ( empty( $mv ) ) {
219
-                unset( $meta_value[ $mk ] );
220
-            }
221
-        }
216
+		foreach ( $meta_value as $mk => $mv ) {
217
+			//remove blank values
218
+			if ( empty( $mv ) ) {
219
+				unset( $meta_value[ $mk ] );
220
+			}
221
+		}
222 222
 
223 223
 		$cur_form_prefix = reset( $meta_value );
224 224
 		$cur_form_prefix = explode( '_', $cur_form_prefix );
225
-        $cur_form_prefix = $cur_form_prefix[0];
226
-        $save = false;
225
+		$cur_form_prefix = $cur_form_prefix[0];
226
+		$save = false;
227 227
 
228
-        foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) {
228
+		foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) {
229 229
 			if ( empty( $prev_hidden ) || in_array( $prev_hidden, $meta_value ) ) {
230
-                //don't add blank cols or process included cols
231
-                continue;
232
-            }
230
+				//don't add blank cols or process included cols
231
+				continue;
232
+			}
233 233
 
234 234
 			$form_prefix = explode( '_', $prev_hidden );
235
-            $form_prefix = $form_prefix[0];
236
-            if ( $form_prefix == $cur_form_prefix ) {
237
-                //don't add back columns that are meant to be hidden
238
-                continue;
239
-            }
240
-
241
-            $meta_value[] = $prev_hidden;
242
-            $save = true;
235
+			$form_prefix = $form_prefix[0];
236
+			if ( $form_prefix == $cur_form_prefix ) {
237
+				//don't add back columns that are meant to be hidden
238
+				continue;
239
+			}
240
+
241
+			$meta_value[] = $prev_hidden;
242
+			$save = true;
243 243
 			unset( $form_prefix );
244
-        }
244
+		}
245 245
 
246 246
 		if ( $save ) {
247 247
 			$user_id = get_current_user_id();
248 248
 			update_user_option( $user_id, $this_page_name, $meta_value, true );
249
-        }
250
-    }
249
+		}
250
+	}
251 251
 
252 252
 	/**
253 253
 	 * @since 2.05.07
@@ -268,11 +268,11 @@  discard block
 block discarded – undo
268 268
 	}
269 269
 
270 270
 	public static function save_per_page( $save, $option, $value ) {
271
-        if ( $option == 'formidable_page_formidable_entries_per_page' ) {
272
-            $save = (int) $value;
273
-        }
274
-        return $save;
275
-    }
271
+		if ( $option == 'formidable_page_formidable_entries_per_page' ) {
272
+			$save = (int) $value;
273
+		}
274
+		return $save;
275
+	}
276 276
 
277 277
 	public static function sortable_columns() {
278 278
 		$form_id = FrmForm::get_current_form_id();
@@ -372,43 +372,43 @@  discard block
 block discarded – undo
372 372
 	}
373 373
 
374 374
 	public static function display_list( $message = '', $errors = array() ) {
375
-        global $wpdb, $frm_vars;
375
+		global $wpdb, $frm_vars;
376 376
 
377 377
 		$form = FrmForm::maybe_get_current_form();
378 378
 		$params = FrmForm::get_admin_params( $form );
379 379
 
380
-        if ( $form ) {
381
-            $params['form'] = $form->id;
382
-            $frm_vars['current_form'] = $form;
380
+		if ( $form ) {
381
+			$params['form'] = $form->id;
382
+			$frm_vars['current_form'] = $form;
383 383
 
384 384
 			self::get_delete_form_time( $form, $errors );
385 385
 		}
386 386
 
387
-        $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
387
+		$table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
388 388
 
389
-        $wp_list_table = new $table_class( array( 'params' => $params ) );
389
+		$wp_list_table = new $table_class( array( 'params' => $params ) );
390 390
 
391
-        $pagenum = $wp_list_table->get_pagenum();
391
+		$pagenum = $wp_list_table->get_pagenum();
392 392
 
393
-        $wp_list_table->prepare_items();
393
+		$wp_list_table->prepare_items();
394 394
 
395
-        $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
396
-        if ( $pagenum > $total_pages && $total_pages > 0 ) {
395
+		$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
396
+		if ( $pagenum > $total_pages && $total_pages > 0 ) {
397 397
 			$url = add_query_arg( 'paged', $total_pages );
398
-            if ( headers_sent() ) {
398
+			if ( headers_sent() ) {
399 399
 				echo FrmAppHelper::js_redirect( $url ); // WPCS: XSS ok.
400
-            } else {
401
-                wp_redirect( esc_url_raw( $url ) );
402
-            }
403
-            die();
404
-        }
400
+			} else {
401
+				wp_redirect( esc_url_raw( $url ) );
402
+			}
403
+			die();
404
+		}
405 405
 
406 406
 		if ( empty( $message ) && isset( $_GET['import-message'] ) ) {
407
-            $message = __( 'Your import is complete', 'formidable' );
408
-        }
407
+			$message = __( 'Your import is complete', 'formidable' );
408
+		}
409 409
 
410 410
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php' );
411
-    }
411
+	}
412 412
 
413 413
 	private static function get_delete_form_time( $form, &$errors ) {
414 414
 		if ( 'trash' == $form->status ) {
@@ -418,17 +418,17 @@  discard block
 block discarded – undo
418 418
 		}
419 419
 	}
420 420
 
421
-    /* Back End CRUD */
421
+	/* Back End CRUD */
422 422
 	public static function show( $id = 0 ) {
423 423
 		FrmAppHelper::permission_check( 'frm_view_entries' );
424 424
 
425
-        if ( ! $id ) {
425
+		if ( ! $id ) {
426 426
 			$id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
427 427
 
428
-            if ( ! $id ) {
428
+			if ( ! $id ) {
429 429
 				$id = FrmAppHelper::get_param( 'item_id', 0, 'get', 'absint' );
430
-            }
431
-        }
430
+			}
431
+		}
432 432
 
433 433
 		$entry = FrmEntry::getOne( $id, true );
434 434
 		if ( ! $entry ) {
@@ -444,63 +444,63 @@  discard block
 block discarded – undo
444 444
 		}
445 445
 
446 446
 		$fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' );
447
-        $to_emails = array();
447
+		$to_emails = array();
448 448
 		$form = FrmForm::getOne( $entry->form_id );
449 449
 
450 450
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' );
451
-    }
451
+	}
452 452
 
453
-    public static function destroy() {
453
+	public static function destroy() {
454 454
 		FrmAppHelper::permission_check( 'frm_delete_entries' );
455 455
 
456 456
 		$params = FrmForm::get_admin_params();
457 457
 
458 458
 		if ( isset( $params['keep_post'] ) && $params['keep_post'] ) {
459 459
 			self::unlink_post( $params['id'] );
460
-        }
460
+		}
461 461
 
462
-        $message = '';
463
-        if ( FrmEntry::destroy( $params['id'] ) ) {
464
-            $message = __( 'Entry was Successfully Destroyed', 'formidable' );
465
-        }
462
+		$message = '';
463
+		if ( FrmEntry::destroy( $params['id'] ) ) {
464
+			$message = __( 'Entry was Successfully Destroyed', 'formidable' );
465
+		}
466 466
 
467
-        self::display_list( $message );
468
-    }
467
+		self::display_list( $message );
468
+	}
469 469
 
470
-    public static function destroy_all() {
471
-        if ( ! current_user_can( 'frm_delete_entries' ) ) {
472
-            $frm_settings = FrmAppHelper::get_settings();
473
-            wp_die( esc_html( $frm_settings->admin_permission ) );
474
-        }
470
+	public static function destroy_all() {
471
+		if ( ! current_user_can( 'frm_delete_entries' ) ) {
472
+			$frm_settings = FrmAppHelper::get_settings();
473
+			wp_die( esc_html( $frm_settings->admin_permission ) );
474
+		}
475 475
 
476 476
 		$params = FrmForm::get_admin_params();
477
-        $message = '';
478
-        $errors = array();
479
-        $form_id = (int) $params['form'];
477
+		$message = '';
478
+		$errors = array();
479
+		$form_id = (int) $params['form'];
480 480
 
481
-        if ( $form_id ) {
482
-            $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) );
481
+		if ( $form_id ) {
482
+			$entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) );
483 483
 			$action = FrmFormAction::get_action_for_form( $form_id, 'wppost', 1 );
484 484
 
485
-            if ( $action ) {
486
-                // this action takes a while, so only trigger it if there are posts to delete
487
-                foreach ( $entry_ids as $entry_id ) {
488
-                    do_action( 'frm_before_destroy_entry', $entry_id );
489
-                    unset( $entry_id );
490
-                }
491
-            }
485
+			if ( $action ) {
486
+				// this action takes a while, so only trigger it if there are posts to delete
487
+				foreach ( $entry_ids as $entry_id ) {
488
+					do_action( 'frm_before_destroy_entry', $entry_id );
489
+					unset( $entry_id );
490
+				}
491
+			}
492 492
 
493
-            $results = self::delete_form_entries( $form_id );
494
-            if ( $results ) {
493
+			$results = self::delete_form_entries( $form_id );
494
+			if ( $results ) {
495 495
 				FrmEntry::clear_cache();
496
-                $message = __( 'Entries were Successfully Destroyed', 'formidable' );
497
-            }
498
-        } else {
499
-            $errors = __( 'No entries were specified', 'formidable' );
500
-        }
496
+				$message = __( 'Entries were Successfully Destroyed', 'formidable' );
497
+			}
498
+		} else {
499
+			$errors = __( 'No entries were specified', 'formidable' );
500
+		}
501 501
 
502
-        self::display_list( $message, $errors );
503
-    }
502
+		self::display_list( $message, $errors );
503
+	}
504 504
 
505 505
 	/**
506 506
 	 * @since 3.01
@@ -546,47 +546,47 @@  discard block
 block discarded – undo
546 546
 	 * @deprecated 1.07.05
547 547
 	 * @codeCoverageIgnore
548 548
 	 */
549
-    public static function show_form( $id = '', $key = '', $title = false, $description = false ) {
550
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' );
551
-        return FrmFormsController::show_form( $id, $key, $title, $description );
552
-    }
549
+	public static function show_form( $id = '', $key = '', $title = false, $description = false ) {
550
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' );
551
+		return FrmFormsController::show_form( $id, $key, $title, $description );
552
+	}
553 553
 
554 554
 	/**
555 555
 	 * @deprecated 1.07.05
556 556
 	 * @codeCoverageIgnore
557 557
 	 */
558
-    public static function get_form( $filename, $form, $title, $description ) {
559
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' );
560
-        return FrmFormsController::get_form( $form, $title, $description );
561
-    }
558
+	public static function get_form( $filename, $form, $title, $description ) {
559
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' );
560
+		return FrmFormsController::get_form( $form, $title, $description );
561
+	}
562 562
 
563
-    public static function process_entry( $errors = '', $ajax = false ) {
563
+	public static function process_entry( $errors = '', $ajax = false ) {
564 564
 		$form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
565 565
 		if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) {
566
-            return;
567
-        }
566
+			return;
567
+		}
568 568
 
569
-        global $frm_vars;
569
+		global $frm_vars;
570 570
 
571 571
 		$form = FrmForm::getOne( $form_id );
572
-        if ( ! $form ) {
573
-            return;
574
-        }
572
+		if ( ! $form ) {
573
+			return;
574
+		}
575 575
 
576 576
 		$params = FrmForm::get_params( $form );
577 577
 
578
-        if ( ! isset( $frm_vars['form_params'] ) ) {
579
-            $frm_vars['form_params'] = array();
580
-        }
578
+		if ( ! isset( $frm_vars['form_params'] ) ) {
579
+			$frm_vars['form_params'] = array();
580
+		}
581 581
 		$frm_vars['form_params'][ $form->id ] = $params;
582 582
 
583 583
 		if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) {
584
-            return;
585
-        }
584
+			return;
585
+		}
586 586
 
587
-        if ( $errors == '' && ! $ajax ) {
587
+		if ( $errors == '' && ! $ajax ) {
588 588
 			$errors = FrmEntryValidate::validate( $_POST );
589
-        }
589
+		}
590 590
 
591 591
 		/**
592 592
 		 * Use this filter to add trigger actions and add errors after
@@ -597,24 +597,24 @@  discard block
 block discarded – undo
597 597
 
598 598
 		$frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors );
599 599
 
600
-        if ( empty( $errors ) ) {
600
+		if ( empty( $errors ) ) {
601 601
 			$_POST['frm_skip_cookie'] = 1;
602 602
 			$do_success = false;
603
-            if ( $params['action'] == 'create' ) {
603
+			if ( $params['action'] == 'create' ) {
604 604
 				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
605 605
 					$frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST );
606 606
 					$params['id'] = $frm_vars['created_entries'][ $form_id ]['entry_id'];
607 607
 					$do_success = true;
608
-                }
609
-            }
608
+				}
609
+			}
610 610
 
611
-            do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
611
+			do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
612 612
 			if ( $do_success ) {
613 613
 				FrmFormsController::maybe_trigger_redirect( $form, $params, array( 'ajax' => $ajax ) );
614 614
 			}
615 615
 			unset( $_POST['frm_skip_cookie'] );
616
-        }
617
-    }
616
+		}
617
+	}
618 618
 
619 619
 	/**
620 620
 	 * Escape url entities before redirect
@@ -628,27 +628,27 @@  discard block
 block discarded – undo
628 628
 		return str_replace( array( ' ', '[', ']', '|', '@' ), array( '%20', '%5B', '%5D', '%7C', '%40' ), $url );
629 629
 	}
630 630
 
631
-    public static function delete_entry_before_redirect( $url, $form, $atts ) {
632
-        self::_delete_entry( $atts['id'], $form );
633
-        return $url;
634
-    }
631
+	public static function delete_entry_before_redirect( $url, $form, $atts ) {
632
+		self::_delete_entry( $atts['id'], $form );
633
+		return $url;
634
+	}
635 635
 
636
-    //Delete entry if not redirected
637
-    public static function delete_entry_after_save( $atts ) {
638
-        self::_delete_entry( $atts['entry_id'], $atts['form'] );
639
-    }
636
+	//Delete entry if not redirected
637
+	public static function delete_entry_after_save( $atts ) {
638
+		self::_delete_entry( $atts['entry_id'], $atts['form'] );
639
+	}
640 640
 
641
-    private static function _delete_entry( $entry_id, $form ) {
642
-        if ( ! $form ) {
643
-            return;
644
-        }
641
+	private static function _delete_entry( $entry_id, $form ) {
642
+		if ( ! $form ) {
643
+			return;
644
+		}
645 645
 
646
-        $form->options = maybe_unserialize( $form->options );
647
-        if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
646
+		$form->options = maybe_unserialize( $form->options );
647
+		if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
648 648
 			self::unlink_post( $entry_id );
649
-            FrmEntry::destroy( $entry_id );
650
-        }
651
-    }
649
+			FrmEntry::destroy( $entry_id );
650
+		}
651
+	}
652 652
 
653 653
 	/**
654 654
 	 * unlink entry from post
@@ -720,5 +720,5 @@  discard block
 block discarded – undo
720 720
 		}
721 721
 
722 722
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' );
723
-    }
723
+	}
724 724
 }
Please login to merge, or discard this patch.
classes/controllers/FrmSettingsController.php 1 patch
Indentation   +39 added lines, -39 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
 
@@ -65,47 +65,47 @@  discard block
 block discarded – undo
65 65
 		wp_die();
66 66
 	}
67 67
 
68
-    public static function process_form( $stop_load = false ) {
69
-        global $frm_vars;
68
+	public static function process_form( $stop_load = false ) {
69
+		global $frm_vars;
70 70
 
71
-        $frm_settings = FrmAppHelper::get_settings();
71
+		$frm_settings = FrmAppHelper::get_settings();
72 72
 
73 73
 		$process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' );
74 74
 		if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) {
75 75
 			wp_die( esc_html( $frm_settings->admin_permission ) );
76
-        }
76
+		}
77 77
 
78
-        $errors = array();
79
-        $message = '';
78
+		$errors = array();
79
+		$message = '';
80 80
 
81
-        if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) {
82
-            $errors = $frm_settings->validate( $_POST, array() );
81
+		if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) {
82
+			$errors = $frm_settings->validate( $_POST, array() );
83 83
 
84
-            $frm_settings->update( stripslashes_deep( $_POST ) );
84
+			$frm_settings->update( stripslashes_deep( $_POST ) );
85 85
 
86
-            if ( empty( $errors ) ) {
87
-                $frm_settings->store();
88
-                $message = __( 'Settings Saved', 'formidable' );
89
-            }
90
-        } else {
91
-            $message = __( 'Settings Saved', 'formidable' );
92
-        }
86
+			if ( empty( $errors ) ) {
87
+				$frm_settings->store();
88
+				$message = __( 'Settings Saved', 'formidable' );
89
+			}
90
+		} else {
91
+			$message = __( 'Settings Saved', 'formidable' );
92
+		}
93 93
 
94 94
 		if ( $stop_load == 'stop_load' ) {
95
-            $frm_vars['settings_routed'] = true;
96
-            return;
97
-        }
95
+			$frm_vars['settings_routed'] = true;
96
+			return;
97
+		}
98 98
 
99
-        self::display_form( $errors, $message );
100
-    }
99
+		self::display_form( $errors, $message );
100
+	}
101 101
 
102
-    public static function route( $stop_load = false ) {
103
-        $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
102
+	public static function route( $stop_load = false ) {
103
+		$action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
104 104
 		$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
105
-        if ( $action == 'process-form' ) {
105
+		if ( $action == 'process-form' ) {
106 106
 			self::process_form( $stop_load );
107
-        } else if ( $stop_load != 'stop_load' ) {
107
+		} else if ( $stop_load != 'stop_load' ) {
108 108
 			self::display_form();
109
-        }
110
-    }
109
+		}
110
+	}
111 111
 }
Please login to merge, or discard this patch.
classes/controllers/FrmFieldsController.php 1 patch
Indentation   +179 added lines, -179 removed lines patch added patch discarded remove patch
@@ -2,25 +2,25 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmFieldsController {
4 4
 
5
-    public static function load_field() {
5
+	public static function load_field() {
6 6
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
7
-        check_ajax_referer( 'frm_ajax', 'nonce' );
7
+		check_ajax_referer( 'frm_ajax', 'nonce' );
8 8
 
9
-        $fields = $_POST['field'];
10
-        if ( empty( $fields ) ) {
11
-            wp_die();
12
-        }
9
+		$fields = $_POST['field'];
10
+		if ( empty( $fields ) ) {
11
+			wp_die();
12
+		}
13 13
 
14
-        $_GET['page'] = 'formidable';
15
-        $fields = stripslashes_deep( $fields );
14
+		$_GET['page'] = 'formidable';
15
+		$fields = stripslashes_deep( $fields );
16 16
 
17 17
 		$values = array(
18 18
 			'id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ),
19 19
 			'doing_ajax' => true,
20 20
 		);
21
-        $field_html = array();
21
+		$field_html = array();
22 22
 
23
-        foreach ( $fields as $field ) {
23
+		foreach ( $fields as $field ) {
24 24
 			$field = htmlspecialchars_decode( nl2br( $field ) );
25 25
 			$field = json_decode( $field );
26 26
 			if ( ! isset( $field->id ) || ! is_numeric( $field->id ) ) {
@@ -39,19 +39,19 @@  discard block
 block discarded – undo
39 39
 			self::load_single_field( $field, $values );
40 40
 			$field_html[ absint( $field->id ) ] = ob_get_contents();
41 41
 			ob_end_clean();
42
-        }
42
+		}
43 43
 
44 44
 		echo json_encode( $field_html );
45 45
 
46
-        wp_die();
47
-    }
46
+		wp_die();
47
+	}
48 48
 
49 49
 	/**
50 50
 	 * Create a new field with ajax
51 51
 	 */
52
-    public static function create() {
52
+	public static function create() {
53 53
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
54
-        check_ajax_referer( 'frm_ajax', 'nonce' );
54
+		check_ajax_referer( 'frm_ajax', 'nonce' );
55 55
 
56 56
 		$field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' );
57 57
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
@@ -61,25 +61,25 @@  discard block
 block discarded – undo
61 61
 		// this hook will allow for multiple fields to be added at once
62 62
 		do_action( 'frm_after_field_created', $field, $form_id );
63 63
 
64
-        wp_die();
65
-    }
64
+		wp_die();
65
+	}
66 66
 
67
-    /**
68
-     * Set up and create a new field
69
-     *
70
-     * @param string $field_type
71
-     * @param integer $form_id
72
-     * @return array|bool
73
-     */
67
+	/**
68
+	 * Set up and create a new field
69
+	 *
70
+	 * @param string $field_type
71
+	 * @param integer $form_id
72
+	 * @return array|bool
73
+	 */
74 74
 	public static function include_new_field( $field_type, $form_id ) {
75 75
 		$field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id );
76
-        $field_values = apply_filters( 'frm_before_field_created', $field_values );
76
+		$field_values = apply_filters( 'frm_before_field_created', $field_values );
77 77
 
78
-        $field_id = FrmField::create( $field_values );
78
+		$field_id = FrmField::create( $field_values );
79 79
 
80
-        if ( ! $field_id ) {
81
-            return false;
82
-        }
80
+		if ( ! $field_id ) {
81
+			return false;
82
+		}
83 83
 
84 84
 		$field = self::get_field_array_from_id( $field_id );
85 85
 
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
 
96 96
 		self::load_single_field( $field, $values, $form_id );
97 97
 
98
-        return $field;
99
-    }
98
+		return $field;
99
+	}
100 100
 
101 101
 	/**
102 102
 	 * @deprecated 3.0
@@ -112,29 +112,29 @@  discard block
 block discarded – undo
112 112
 			$field = 'name';
113 113
 		}
114 114
 
115
-        if ( empty( $id ) ) {
115
+		if ( empty( $id ) ) {
116 116
 			$id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
117 117
 			$id = str_replace( 'field_label_', '', $id );
118
-        }
118
+		}
119 119
 
120 120
 		$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' );
121 121
 		$value = trim( $value );
122
-        if ( trim( strip_tags( $value ) ) === '' ) {
123
-            // set blank value if there is no content
124
-            $value = '';
125
-        }
122
+		if ( trim( strip_tags( $value ) ) === '' ) {
123
+			// set blank value if there is no content
124
+			$value = '';
125
+		}
126 126
 
127 127
 		FrmField::update( $id, array( $field => $value ) );
128 128
 
129 129
 		do_action( 'frm_after_update_field_' . $field, compact( 'id', 'value' ) );
130 130
 
131 131
 		echo stripslashes( wp_kses_post( $value ) ); // WPCS: XSS ok.
132
-        wp_die();
133
-    }
132
+		wp_die();
133
+	}
134 134
 
135
-    public static function update_ajax_option() {
135
+	public static function update_ajax_option() {
136 136
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
137
-        check_ajax_referer( 'frm_ajax', 'nonce' );
137
+		check_ajax_referer( 'frm_ajax', 'nonce' );
138 138
 
139 139
 		$field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
140 140
 		if ( ! $field_id ) {
@@ -149,24 +149,24 @@  discard block
 block discarded – undo
149 149
 			unset( $new_val );
150 150
 		}
151 151
 
152
-        FrmField::update( $field_id, array(
153
-            'field_options' => $field->field_options,
152
+		FrmField::update( $field_id, array(
153
+			'field_options' => $field->field_options,
154 154
 			'form_id'       => $field->form_id,
155
-        ) );
156
-        wp_die();
157
-    }
155
+		) );
156
+		wp_die();
157
+	}
158 158
 
159
-    public static function duplicate() {
159
+	public static function duplicate() {
160 160
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
161
-        check_ajax_referer( 'frm_ajax', 'nonce' );
161
+		check_ajax_referer( 'frm_ajax', 'nonce' );
162 162
 
163 163
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
164 164
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
165 165
 
166 166
 		$copy_field = FrmField::getOne( $field_id );
167
-        if ( ! $copy_field ) {
168
-            wp_die();
169
-        }
167
+		if ( ! $copy_field ) {
168
+			wp_die();
169
+		}
170 170
 
171 171
 		do_action( 'frm_duplicate_field', $copy_field, $form_id );
172 172
 		do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id );
@@ -180,8 +180,8 @@  discard block
 block discarded – undo
180 180
 			self::load_single_field( $field_id, $values );
181 181
 		}
182 182
 
183
-        wp_die();
184
-    }
183
+		wp_die();
184
+	}
185 185
 
186 186
 	/**
187 187
 	 * Load a single field in the form builder along with all needed variables
@@ -273,21 +273,21 @@  discard block
 block discarded – undo
273 273
 		return $li_classes;
274 274
 	}
275 275
 
276
-    public static function destroy() {
276
+	public static function destroy() {
277 277
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
278
-        check_ajax_referer( 'frm_ajax', 'nonce' );
278
+		check_ajax_referer( 'frm_ajax', 'nonce' );
279 279
 
280 280
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
281 281
 		FrmField::destroy( $field_id );
282
-        wp_die();
283
-    }
282
+		wp_die();
283
+	}
284 284
 
285
-    /* Field Options */
285
+	/* Field Options */
286 286
 
287
-    //Add Single Option or Other Option
288
-    public static function add_option() {
287
+	//Add Single Option or Other Option
288
+	public static function add_option() {
289 289
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
290
-        check_ajax_referer( 'frm_ajax', 'nonce' );
290
+		check_ajax_referer( 'frm_ajax', 'nonce' );
291 291
 
292 292
 		$id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
293 293
 		$opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' );
@@ -312,69 +312,69 @@  discard block
 block discarded – undo
312 312
 		FrmFieldsHelper::show_single_option( $field );
313 313
 
314 314
 		wp_die();
315
-    }
315
+	}
316 316
 
317 317
 	/**
318 318
 	 * @deprecated 2.3
319 319
 	 * @codeCoverageIgnore
320 320
 	 */
321
-    public static function edit_option() {
321
+	public static function edit_option() {
322 322
 		_deprecated_function( __FUNCTION__, '2.3' );
323
-    }
323
+	}
324 324
 
325 325
 	/**
326 326
 	 * @deprecated 2.3
327 327
 	 * @codeCoverageIgnore
328 328
 	 */
329
-    public static function delete_option() {
329
+	public static function delete_option() {
330 330
 		_deprecated_function( __FUNCTION__, '2.3' );
331
-    }
331
+	}
332 332
 
333
-    public static function import_choices() {
334
-        FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
333
+	public static function import_choices() {
334
+		FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
335 335
 
336 336
 		$field_id = absint( $_REQUEST['field_id'] );
337 337
 
338
-        global $current_screen, $hook_suffix;
338
+		global $current_screen, $hook_suffix;
339 339
 
340
-        // Catch plugins that include admin-header.php before admin.php completes.
341
-        if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) {
342
-            $hook_suffix = '';
343
-        	set_current_screen();
344
-        }
340
+		// Catch plugins that include admin-header.php before admin.php completes.
341
+		if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) {
342
+			$hook_suffix = '';
343
+			set_current_screen();
344
+		}
345 345
 
346
-        if ( function_exists( 'register_admin_color_schemes' ) ) {
347
-            register_admin_color_schemes();
348
-        }
346
+		if ( function_exists( 'register_admin_color_schemes' ) ) {
347
+			register_admin_color_schemes();
348
+		}
349 349
 
350 350
 		$hook_suffix = '';
351 351
 		$admin_body_class = '';
352 352
 
353
-        if ( get_user_setting( 'mfold' ) == 'f' ) {
354
-        	$admin_body_class .= ' folded';
355
-        }
353
+		if ( get_user_setting( 'mfold' ) == 'f' ) {
354
+			$admin_body_class .= ' folded';
355
+		}
356 356
 
357
-        if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) {
358
-        	$admin_body_class .= ' admin-bar';
359
-        }
357
+		if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) {
358
+			$admin_body_class .= ' admin-bar';
359
+		}
360 360
 
361
-        if ( is_rtl() ) {
362
-        	$admin_body_class .= ' rtl';
363
-        }
361
+		if ( is_rtl() ) {
362
+			$admin_body_class .= ' rtl';
363
+		}
364 364
 
365
-        $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
366
-        $prepop = array();
365
+		$admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
366
+		$prepop = array();
367 367
 		FrmFieldsHelper::get_bulk_prefilled_opts( $prepop );
368 368
 
369 369
 		$field = FrmField::getOne( $field_id );
370 370
 
371
-        wp_enqueue_script( 'utils' );
371
+		wp_enqueue_script( 'utils' );
372 372
 		wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' );
373
-        FrmAppHelper::load_admin_wide_js();
373
+		FrmAppHelper::load_admin_wide_js();
374 374
 
375 375
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/import_choices.php' );
376
-        wp_die();
377
-    }
376
+		wp_die();
377
+	}
378 378
 
379 379
 	public static function import_options() {
380 380
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
@@ -388,8 +388,8 @@  discard block
 block discarded – undo
388 388
 		$field = FrmField::getOne( $field_id );
389 389
 
390 390
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) {
391
-            return;
392
-        }
391
+			return;
392
+		}
393 393
 
394 394
 		$field = FrmFieldsHelper::setup_edit_vars( $field );
395 395
 		$opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' );
@@ -412,10 +412,10 @@  discard block
 block discarded – undo
412 412
 			}
413 413
 		}
414 414
 
415
-        //Keep other options after bulk update
416
-        if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
417
-            $other_array = array();
418
-            foreach ( $field['options'] as $opt_key => $opt ) {
415
+		//Keep other options after bulk update
416
+		if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
417
+			$other_array = array();
418
+			foreach ( $field['options'] as $opt_key => $opt ) {
419 419
 				if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) {
420 420
 					$other_array[ $opt_key ] = $opt;
421 421
 				}
@@ -426,36 +426,36 @@  discard block
 block discarded – undo
426 426
 			}
427 427
 		}
428 428
 
429
-        $field['options'] = $opts;
429
+		$field['options'] = $opts;
430 430
 
431 431
 		FrmFieldsHelper::show_single_option( $field );
432 432
 
433
-        wp_die();
434
-    }
433
+		wp_die();
434
+	}
435 435
 
436
-    public static function update_order() {
436
+	public static function update_order() {
437 437
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
438
-        check_ajax_referer( 'frm_ajax', 'nonce' );
438
+		check_ajax_referer( 'frm_ajax', 'nonce' );
439 439
 
440 440
 		$fields = FrmAppHelper::get_post_param( 'frm_field_id' );
441 441
 		foreach ( (array) $fields as $position => $item ) {
442 442
 			FrmField::update( absint( $item ), array( 'field_order' => absint( $position ) ) );
443 443
 		}
444
-        wp_die();
445
-    }
444
+		wp_die();
445
+	}
446 446
 
447 447
 	public static function change_type( $type ) {
448
-        $type_switch = array(
449
-            'scale'     => 'radio',
448
+		$type_switch = array(
449
+			'scale'     => 'radio',
450 450
 			'star'      => 'radio',
451
-            '10radio'   => 'radio',
452
-            'rte'       => 'textarea',
453
-            'website'   => 'url',
451
+			'10radio'   => 'radio',
452
+			'rte'       => 'textarea',
453
+			'website'   => 'url',
454 454
 			'image'     => 'url',
455
-        );
456
-        if ( isset( $type_switch[ $type ] ) ) {
457
-            $type = $type_switch[ $type ];
458
-        }
455
+		);
456
+		if ( isset( $type_switch[ $type ] ) ) {
457
+			$type = $type_switch[ $type ];
458
+		}
459 459
 
460 460
 		$pro_fields = FrmField::pro_field_selection();
461 461
 		$types = array_keys( $pro_fields );
@@ -463,8 +463,8 @@  discard block
 block discarded – undo
463 463
 			$type = 'text';
464 464
 		}
465 465
 
466
-        return $type;
467
-    }
466
+		return $type;
467
+	}
468 468
 
469 469
 	/**
470 470
 	 * @param array $settings
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
 		}
480 480
 
481 481
 		return apply_filters( 'frm_display_field_options', $settings );
482
-    }
482
+	}
483 483
 
484 484
 	/**
485 485
 	 * Display the format option
@@ -491,8 +491,8 @@  discard block
 block discarded – undo
491 491
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/value-format.php' );
492 492
 	}
493 493
 
494
-    public static function input_html( $field, $echo = true ) {
495
-        $class = array(); //$field['type'];
494
+	public static function input_html( $field, $echo = true ) {
495
+		$class = array(); //$field['type'];
496 496
 		self::add_input_classes( $field, $class );
497 497
 
498 498
 		$add_html = array();
@@ -511,85 +511,85 @@  discard block
 block discarded – undo
511 511
 		$add_html = apply_filters( 'frm_field_extra_html', $add_html, $field );
512 512
 		$add_html = ' ' . implode( ' ', $add_html ) . '  ';
513 513
 
514
-        if ( $echo ) {
515
-            echo $add_html; // WPCS: XSS ok.
516
-        }
514
+		if ( $echo ) {
515
+			echo $add_html; // WPCS: XSS ok.
516
+		}
517 517
 
518
-        return $add_html;
519
-    }
518
+		return $add_html;
519
+	}
520 520
 
521 521
 	private static function add_input_classes( $field, array &$class ) {
522 522
 		if ( isset( $field['input_class'] ) && ! empty( $field['input_class'] ) ) {
523 523
 			$class[] = $field['input_class'];
524 524
 		}
525 525
 
526
-        if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) {
527
-            return;
528
-        }
526
+		if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) {
527
+			return;
528
+		}
529 529
 
530 530
 		if ( isset( $field['size'] ) && $field['size'] > 0 ) {
531 531
 			$class[] = 'auto_width';
532 532
 		}
533
-    }
533
+	}
534 534
 
535 535
 	private static function add_html_size( $field, array &$add_html ) {
536 536
 		if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden', 'file', 'lookup' ) ) ) {
537
-            return;
538
-        }
537
+			return;
538
+		}
539 539
 
540 540
 		if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
541
-            return;
542
-        }
541
+			return;
542
+		}
543 543
 
544 544
 		if ( is_numeric( $field['size'] ) ) {
545 545
 			$field['size'] .= 'px';
546 546
 		}
547 547
 
548 548
 		$important = apply_filters( 'frm_use_important_width', 1, $field );
549
-        // Note: This inline styling must stay since we cannot realistically set a class for every possible field size
549
+		// Note: This inline styling must stay since we cannot realistically set a class for every possible field size
550 550
 		$add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"';
551 551
 
552 552
 		self::add_html_cols( $field, $add_html );
553
-    }
553
+	}
554 554
 
555 555
 	private static function add_html_cols( $field, array &$add_html ) {
556 556
 		if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) {
557
-            return;
558
-        }
557
+			return;
558
+		}
559 559
 
560
-        // convert to cols for textareas
561
-        $calc = array(
562
-            ''      => 9,
563
-            'px'    => 9,
564
-            'rem'   => 0.444,
565
-            'em'    => 0.544,
566
-        );
560
+		// convert to cols for textareas
561
+		$calc = array(
562
+			''      => 9,
563
+			'px'    => 9,
564
+			'rem'   => 0.444,
565
+			'em'    => 0.544,
566
+		);
567 567
 
568 568
 		// include "col" for valid html
569 569
 		$unit = trim( preg_replace( '/[0-9]+/', '', $field['size'] ) );
570 570
 
571
-        if ( ! isset( $calc[ $unit ] ) ) {
572
-            return;
573
-        }
571
+		if ( ! isset( $calc[ $unit ] ) ) {
572
+			return;
573
+		}
574 574
 
575
-        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
575
+		$size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
576 576
 
577 577
 		$add_html['cols'] = 'cols="' . absint( $size ) . '"';
578
-    }
578
+	}
579 579
 
580 580
 	private static function add_html_length( $field, array &$add_html ) {
581
-        // check for max setting and if this field accepts maxlength
581
+		// check for max setting and if this field accepts maxlength
582 582
 		if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden', 'file' ) ) ) {
583
-            return;
584
-        }
583
+			return;
584
+		}
585 585
 
586 586
 		if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
587
-            // don't load on form builder page
588
-            return;
589
-        }
587
+			// don't load on form builder page
588
+			return;
589
+		}
590 590
 
591 591
 		$add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"';
592
-    }
592
+	}
593 593
 
594 594
 	private static function add_html_placeholder( $field, array &$add_html, array &$class ) {
595 595
 		if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
@@ -691,27 +691,27 @@  discard block
 block discarded – undo
691 691
 		}
692 692
 	}
693 693
 
694
-    private static function add_shortcodes_to_html( $field, array &$add_html ) {
695
-        if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
696
-            return;
697
-        }
694
+	private static function add_shortcodes_to_html( $field, array &$add_html ) {
695
+		if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
696
+			return;
697
+		}
698 698
 
699
-        foreach ( $field['shortcodes'] as $k => $v ) {
700
-            if ( 'opt' === $k ) {
701
-                continue;
702
-            }
699
+		foreach ( $field['shortcodes'] as $k => $v ) {
700
+			if ( 'opt' === $k ) {
701
+				continue;
702
+			}
703 703
 
704 704
 			if ( is_numeric( $k ) && strpos( $v, '=' ) ) {
705
-                $add_html[] = $v;
706
-            } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
705
+				$add_html[] = $v;
706
+			} else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
707 707
 				$add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] );
708
-            } else {
708
+			} else {
709 709
 				$add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
710
-            }
710
+			}
711 711
 
712 712
 			unset( $k, $v );
713
-        }
714
-    }
713
+		}
714
+	}
715 715
 
716 716
 	/**
717 717
 	 * Add pattern attribute
@@ -735,16 +735,16 @@  discard block
 block discarded – undo
735 735
 		}
736 736
 	}
737 737
 
738
-    public static function check_value( $opt, $opt_key, $field ) {
739
-        if ( is_array( $opt ) ) {
740
-            if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
741
-                $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
742
-            } else {
743
-                $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
744
-            }
745
-        }
746
-        return $opt;
747
-    }
738
+	public static function check_value( $opt, $opt_key, $field ) {
739
+		if ( is_array( $opt ) ) {
740
+			if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
741
+				$opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
742
+			} else {
743
+				$opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
744
+			}
745
+		}
746
+		return $opt;
747
+	}
748 748
 
749 749
 	public static function check_label( $opt ) {
750 750
 		if ( is_array( $opt ) ) {
Please login to merge, or discard this patch.
classes/helpers/FrmFormsHelper.php 1 patch
Indentation   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -16,28 +16,28 @@  discard block
 block discarded – undo
16 16
 		$target_url = esc_url( admin_url( 'admin-ajax.php?action=frm_forms_preview&form=' . $key ) );
17 17
 		$target_url = apply_filters( 'frm_direct_link', $target_url, $key, $form );
18 18
 
19
-        return $target_url;
20
-    }
21
-
22
-    public static function forms_dropdown( $field_name, $field_value = '', $args = array() ) {
23
-        $defaults = array(
24
-            'blank'     => true,
25
-            'field_id'  => false,
26
-            'onchange'  => false,
27
-            'exclude'   => false,
28
-            'class'     => '',
19
+		return $target_url;
20
+	}
21
+
22
+	public static function forms_dropdown( $field_name, $field_value = '', $args = array() ) {
23
+		$defaults = array(
24
+			'blank'     => true,
25
+			'field_id'  => false,
26
+			'onchange'  => false,
27
+			'exclude'   => false,
28
+			'class'     => '',
29 29
 			'inc_children' => 'exclude',
30
-        );
31
-        $args = wp_parse_args( $args, $defaults );
30
+		);
31
+		$args = wp_parse_args( $args, $defaults );
32 32
 
33
-        if ( ! $args['field_id'] ) {
34
-            $args['field_id'] = $field_name;
35
-        }
33
+		if ( ! $args['field_id'] ) {
34
+			$args['field_id'] = $field_name;
35
+		}
36 36
 
37 37
 		$query = array();
38
-        if ( $args['exclude'] ) {
38
+		if ( $args['exclude'] ) {
39 39
 			$query['id !'] = $args['exclude'];
40
-        }
40
+		}
41 41
 
42 42
 		$where = apply_filters( 'frm_forms_dropdown', $query, $field_name );
43 43
 		$forms = FrmForm::get_published_forms( $where, 999, $args['inc_children'] );
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 		self::add_html_attr( $args['onchange'], 'onchange', $add_html );
46 46
 		self::add_html_attr( $args['class'], 'class', $add_html );
47 47
 
48
-        ?>
48
+		?>
49 49
 		<select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $args['field_id'] ) ?>" <?php echo esc_html( implode( ' ', $add_html ) ); ?>>
50 50
 		<?php if ( $args['blank'] ) { ?>
51 51
 			<option value=""><?php echo ( $args['blank'] == 1 ) ? ' ' : '- ' . esc_attr( $args['blank'] ) . ' -'; ?></option>
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		<?php } ?>
58 58
         </select>
59 59
         <?php
60
-    }
60
+	}
61 61
 
62 62
 	/**
63 63
 	 * @param string $class
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 		}
73 73
 	}
74 74
 
75
-    public static function form_switcher() {
75
+	public static function form_switcher() {
76 76
 		$where = apply_filters( 'frm_forms_dropdown', array(), '' );
77 77
 		$forms = FrmForm::get_published_forms( $where );
78 78
 
@@ -84,32 +84,32 @@  discard block
 block discarded – undo
84 84
 			unset( $args['form'] );
85 85
 		} elseif ( isset( $_GET['form'] ) && ! isset( $_GET['id'] ) ) {
86 86
 			unset( $args['id'] );
87
-        }
87
+		}
88 88
 
89 89
 		$frm_action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
90 90
 		if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $frm_action, array( 'edit', 'show', 'destroy_all' ) ) ) {
91
-            $args['frm_action'] = 'list';
92
-            $args['form'] = 0;
91
+			$args['frm_action'] = 'list';
92
+			$args['form'] = 0;
93 93
 		} elseif ( FrmAppHelper::is_admin_page( 'formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) {
94
-            $args['frm_action'] = 'edit';
94
+			$args['frm_action'] = 'edit';
95 95
 		} else if ( isset( $_GET['post'] ) ) {
96
-            $args['form'] = 0;
96
+			$args['form'] = 0;
97 97
 			$base = admin_url( 'edit.php?post_type=frm_display' );
98
-        }
98
+		}
99 99
 
100
-        ?>
100
+		?>
101 101
 		<li id="frm_bs_dropdown" class="dropdown <?php echo esc_attr( is_rtl() ? 'pull-right' : 'pull-left' ) ?>">
102 102
 			<a href="#" id="frm-navbarDrop" class="frm-dropdown-toggle" data-toggle="dropdown"><?php esc_html_e( 'Switch Form', 'formidable' ) ?> <b class="caret"></b></a>
103 103
 		    <ul class="frm-dropdown-menu frm-on-top" role="menu" aria-labelledby="frm-navbarDrop">
104 104
 			<?php
105 105
 			foreach ( $forms as $form ) {
106 106
 				if ( isset( $args['id'] ) ) {
107
-			        $args['id'] = $form->id;
107
+					$args['id'] = $form->id;
108 108
 				}
109
-			    if ( isset( $args['form'] ) ) {
110
-			        $args['form'] = $form->id;
109
+				if ( isset( $args['form'] ) ) {
110
+					$args['form'] = $form->id;
111 111
 				}
112
-                ?>
112
+				?>
113 113
 				<li><a href="<?php echo esc_url( isset( $base ) ? add_query_arg( $args, $base ) : add_query_arg( $args ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 60 ) ); ?></a></li>
114 114
 			<?php
115 115
 				unset( $form );
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 			</ul>
119 119
 		</li>
120 120
         <?php
121
-    }
121
+	}
122 122
 
123 123
 	public static function get_sortable_classes( $col, $sort_col, $sort_dir ) {
124 124
 		echo ( $sort_col == $col ) ? 'sorted' : 'sortable';
@@ -169,18 +169,18 @@  discard block
 block discarded – undo
169 169
 		return $message;
170 170
 	}
171 171
 
172
-    /**
173
-     * Used when a form is created
174
-     */
175
-    public static function setup_new_vars( $values = array() ) {
176
-        global $wpdb;
172
+	/**
173
+	 * Used when a form is created
174
+	 */
175
+	public static function setup_new_vars( $values = array() ) {
176
+		global $wpdb;
177 177
 
178
-        if ( ! empty( $values ) ) {
179
-            $post_values = $values;
180
-        } else {
181
-            $values = array();
178
+		if ( ! empty( $values ) ) {
179
+			$post_values = $values;
180
+		} else {
181
+			$values = array();
182 182
 			$post_values = isset( $_POST ) ? $_POST : array();
183
-        }
183
+		}
184 184
 
185 185
 		$defaults = array(
186 186
 			'name' => '',
@@ -189,8 +189,8 @@  discard block
 block discarded – undo
189 189
 		foreach ( $defaults as $var => $default ) {
190 190
 			if ( ! isset( $values[ $var ] ) ) {
191 191
 				$values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
192
-            }
193
-        }
192
+			}
193
+		}
194 194
 
195 195
 		$values['description'] = FrmAppHelper::use_wpautop( $values['description'] );
196 196
 
@@ -210,20 +210,20 @@  discard block
 block discarded – undo
210 210
 		}
211 211
 		unset( $defaults );
212 212
 
213
-        if ( ! isset( $values['form_key'] ) ) {
213
+		if ( ! isset( $values['form_key'] ) ) {
214 214
 			$values['form_key'] = ( $post_values && isset( $post_values['form_key'] ) ) ? $post_values['form_key'] : FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_forms', 'form_key' );
215
-        }
215
+		}
216 216
 
217 217
 		$values = self::fill_default_opts( $values, false, $post_values );
218 218
 		$values['custom_style'] = FrmAppHelper::custom_style_value( $post_values );
219 219
 
220 220
 		return apply_filters( 'frm_setup_new_form_vars', $values );
221
-    }
221
+	}
222 222
 
223
-    /**
224
-     * Used when editing a form
225
-     */
226
-    public static function setup_edit_vars( $values, $record, $post_values = array() ) {
223
+	/**
224
+	 * Used when editing a form
225
+	 */
226
+	public static function setup_edit_vars( $values, $record, $post_values = array() ) {
227 227
 		if ( empty( $post_values ) ) {
228 228
 			$post_values = stripslashes_deep( $_POST );
229 229
 		}
@@ -231,43 +231,43 @@  discard block
 block discarded – undo
231 231
 		$values['form_key'] = isset( $post_values['form_key'] ) ? $post_values['form_key'] : $record->form_key;
232 232
 		$values['default_template'] = isset( $post_values['default_template'] ) ? $post_values['default_template'] : $record->default_template;
233 233
 		$values['is_template'] = isset( $post_values['is_template'] ) ? $post_values['is_template'] : $record->is_template;
234
-        $values['status'] = $record->status;
234
+		$values['status'] = $record->status;
235 235
 
236 236
 		$values = self::fill_default_opts( $values, $record, $post_values );
237 237
 
238 238
 		return apply_filters( 'frm_setup_edit_form_vars', $values );
239
-    }
239
+	}
240 240
 
241 241
 	public static function fill_default_opts( $values, $record, $post_values ) {
242 242
 
243
-        $defaults = self::get_default_opts();
243
+		$defaults = self::get_default_opts();
244 244
 		foreach ( $defaults as $var => $default ) {
245 245
 			if ( is_array( $default ) ) {
246
-                if ( ! isset( $values[ $var ] ) ) {
246
+				if ( ! isset( $values[ $var ] ) ) {
247 247
 					$values[ $var ] = ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : array();
248
-                }
248
+				}
249 249
 
250
-                foreach ( $default as $k => $v ) {
250
+				foreach ( $default as $k => $v ) {
251 251
 					$values[ $var ][ $k ] = ( $post_values && isset( $post_values[ $var ][ $k ] ) ) ? $post_values[ $var ][ $k ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) ) ? $record->options[ $var ][ $k ] : $v );
252 252
 
253
-                    if ( is_array( $v ) ) {
254
-                        foreach ( $v as $k1 => $v1 ) {
253
+					if ( is_array( $v ) ) {
254
+						foreach ( $v as $k1 => $v1 ) {
255 255
 							$values[ $var ][ $k ][ $k1 ] = ( $post_values && isset( $post_values[ $var ][ $k ][ $k1 ] ) ) ? $post_values[ $var ][ $k ][ $k1 ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) && isset( $record->options[ $var ][ $k ][ $k1 ] ) ) ? $record->options[ $var ][ $k ][ $k1 ] : $v1 );
256
-                            unset( $k1, $v1 );
257
-                        }
258
-                    }
256
+							unset( $k1, $v1 );
257
+						}
258
+					}
259 259
 
260 260
 					unset( $k, $v );
261
-                }
262
-            } else {
261
+				}
262
+			} else {
263 263
 				$values[ $var ] = ( $post_values && isset( $post_values['options'][ $var ] ) ) ? $post_values['options'][ $var ] : ( ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : $default );
264
-            }
264
+			}
265 265
 
266 266
 			unset( $var, $default );
267
-        }
267
+		}
268 268
 
269
-        return $values;
270
-    }
269
+		return $values;
270
+	}
271 271
 
272 272
 	public static function get_default_opts() {
273 273
 		$frm_settings = FrmAppHelper::get_settings();
@@ -302,13 +302,13 @@  discard block
 block discarded – undo
302 302
 		}
303 303
 	}
304 304
 
305
-    /**
306
-     * @param string $loc
307
-     */
305
+	/**
306
+	 * @param string $loc
307
+	 */
308 308
 	public static function get_default_html( $loc ) {
309 309
 		if ( $loc == 'submit' ) {
310
-            $draft_link = self::get_draft_link();
311
-            $default_html = <<<SUBMIT_HTML
310
+			$draft_link = self::get_draft_link();
311
+			$default_html = <<<SUBMIT_HTML
312 312
 <div class="frm_submit">
313 313
 [if back_button]<button type="submit" name="frm_prev_page" formnovalidate="formnovalidate" class="frm_prev_page" [back_hook]>[back_label]</button>[/if back_button]
314 314
 <button class="frm_button_submit" type="submit"  [button_action]>[button_label]</button>
@@ -316,22 +316,22 @@  discard block
 block discarded – undo
316 316
 </div>
317 317
 SUBMIT_HTML;
318 318
 		} else if ( $loc == 'before' ) {
319
-            $default_html = <<<BEFORE_HTML
319
+			$default_html = <<<BEFORE_HTML
320 320
 <legend class="frm_screen_reader">[form_name]</legend>
321 321
 [if form_name]<h3 class="frm_form_title">[form_name]</h3>[/if form_name]
322 322
 [if form_description]<div class="frm_description">[form_description]</div>[/if form_description]
323 323
 BEFORE_HTML;
324 324
 		} else {
325
-            $default_html = '';
326
-        }
325
+			$default_html = '';
326
+		}
327 327
 
328
-        return $default_html;
329
-    }
328
+		return $default_html;
329
+	}
330 330
 
331
-    public static function get_draft_link() {
332
-        $link = '[if save_draft]<a href="#" tabindex="0" class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]';
333
-        return $link;
334
-    }
331
+	public static function get_draft_link() {
332
+		$link = '[if save_draft]<a href="#" tabindex="0" class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]';
333
+		return $link;
334
+	}
335 335
 
336 336
 	public static function get_custom_submit( $html, $form, $submit, $form_action, $values ) {
337 337
 		$button = self::replace_shortcodes( $html, $form, $submit, $form_action, $values );
@@ -358,13 +358,13 @@  discard block
 block discarded – undo
358 358
 		echo $button_parts[1]; // WPCS: XSS ok.
359 359
 	}
360 360
 
361
-    /**
362
-     * Automatically add end section fields if they don't exist (2.0 migration)
363
-     * @since 2.0
364
-     *
365
-     * @param boolean $reset_fields
366
-     */
367
-    public static function auto_add_end_section_fields( $form, $fields, &$reset_fields ) {
361
+	/**
362
+	 * Automatically add end section fields if they don't exist (2.0 migration)
363
+	 * @since 2.0
364
+	 *
365
+	 * @param boolean $reset_fields
366
+	 */
367
+	public static function auto_add_end_section_fields( $form, $fields, &$reset_fields ) {
368 368
 		if ( empty( $fields ) ) {
369 369
 			return;
370 370
 		}
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 		$prev_order = false;
375 375
 		$add_order = 0;
376 376
 		$last_field = false;
377
-        foreach ( $fields as $field ) {
377
+		foreach ( $fields as $field ) {
378 378
 			if ( $prev_order === $field->field_order ) {
379 379
 				$add_order++;
380 380
 			}
@@ -385,48 +385,48 @@  discard block
 block discarded – undo
385 385
 				FrmField::update( $field->id, array( 'field_order' => $field->field_order ) );
386 386
 			}
387 387
 
388
-            switch ( $field->type ) {
389
-                case 'divider':
390
-                    // create an end section if open
388
+			switch ( $field->type ) {
389
+				case 'divider':
390
+					// create an end section if open
391 391
 					self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $field, 'move' );
392 392
 
393
-                    // mark it open for the next end section
394
-                    $open = true;
393
+					// mark it open for the next end section
394
+					$open = true;
395 395
 					break;
396
-                case 'break':
396
+				case 'break':
397 397
 					self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $field, 'move' );
398 398
 					break;
399
-                case 'end_divider':
400
-                    if ( ! $open ) {
401
-                        // the section isn't open, so this is an extra field that needs to be removed
402
-                        FrmField::destroy( $field->id );
403
-                        $reset_fields = true;
404
-                    }
405
-
406
-                    // There is already an end section here, so there is no need to create one
407
-                    $open = false;
408
-            }
399
+				case 'end_divider':
400
+					if ( ! $open ) {
401
+						// the section isn't open, so this is an extra field that needs to be removed
402
+						FrmField::destroy( $field->id );
403
+						$reset_fields = true;
404
+					}
405
+
406
+					// There is already an end section here, so there is no need to create one
407
+					$open = false;
408
+			}
409 409
 			$prev_order = $field->field_order;
410 410
 
411 411
 			$last_field = $field;
412 412
 			unset( $field );
413
-        }
413
+		}
414 414
 
415 415
 		self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $last_field );
416
-    }
416
+	}
417 417
 
418 418
 	/**
419 419
 	 * Create end section field if it doesn't exist. This is for migration from < 2.0
420 420
 	 * Fix any ordering that may be messed up
421 421
 	 */
422 422
 	public static function maybe_create_end_section( &$open, &$reset_fields, &$add_order, $end_section_values, $field, $move = 'no' ) {
423
-        if ( ! $open ) {
424
-            return;
425
-        }
423
+		if ( ! $open ) {
424
+			return;
425
+		}
426 426
 
427 427
 		$end_section_values['field_order'] = $field->field_order + 1;
428 428
 
429
-        FrmField::create( $end_section_values );
429
+		FrmField::create( $end_section_values );
430 430
 
431 431
 		if ( $move == 'move' ) {
432 432
 			// bump the order of current field unless we're at the end of the form
@@ -434,9 +434,9 @@  discard block
 block discarded – undo
434 434
 		}
435 435
 
436 436
 		$add_order += 2;
437
-        $open = false;
438
-        $reset_fields = true;
439
-    }
437
+		$open = false;
438
+		$reset_fields = true;
439
+	}
440 440
 
441 441
 	public static function replace_shortcodes( $html, $form, $title = false, $description = false, $values = array() ) {
442 442
 		$codes = array(
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
 			}
457 457
 
458 458
 			FrmShortcodeHelper::remove_inline_conditions( ( FrmAppHelper::is_true( $show ) && $replace_with != '' ), $code, $replace_with, $html );
459
-        }
459
+		}
460 460
 
461 461
 		//replace [form_key]
462 462
 		$html = str_replace( '[form_key]', $form->form_key, $html );
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 			$submit_label = apply_filters( 'frm_submit_button', $title, $form );
470 470
 			$submit_label = esc_attr( do_shortcode( $submit_label ) );
471 471
 			$html = str_replace( '[button_label]', $submit_label, $html );
472
-        }
472
+		}
473 473
 
474 474
 		$html = apply_filters( 'frm_form_replace_shortcodes', $html, $form, $values );
475 475
 
@@ -485,17 +485,17 @@  discard block
 block discarded – undo
485 485
 			$html = do_shortcode( $html );
486 486
 		}
487 487
 
488
-        return $html;
489
-    }
488
+		return $html;
489
+	}
490 490
 
491 491
 	public static function submit_button_label( $submit ) {
492 492
 		if ( ! $submit || empty( $submit ) ) {
493
-            $frm_settings = FrmAppHelper::get_settings();
494
-            $submit = $frm_settings->submit_value;
495
-        }
493
+			$frm_settings = FrmAppHelper::get_settings();
494
+			$submit = $frm_settings->submit_value;
495
+		}
496 496
 
497
-        return $submit;
498
-    }
497
+		return $submit;
498
+	}
499 499
 
500 500
 	/**
501 501
 	 * If the Formidable styling isn't being loaded,
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 			}
524 524
 		}
525 525
 
526
-        //If submit button needs to be inline or centered
526
+		//If submit button needs to be inline or centered
527 527
 		if ( is_object( $form ) ) {
528 528
 			$form = $form->options;
529 529
 		}
@@ -539,8 +539,8 @@  discard block
 block discarded – undo
539 539
 
540 540
 		$class = apply_filters( 'frm_add_form_style_class', $class, $style );
541 541
 
542
-        return $class;
543
-    }
542
+		return $class;
543
+	}
544 544
 
545 545
 	/**
546 546
 	 * Returns appropriate class if form has top labels
@@ -595,12 +595,12 @@  discard block
 block discarded – undo
595 595
 		return in_array( $label_position, array( 'top', 'inside', 'hidden' ) );
596 596
 	}
597 597
 
598
-    /**
599
-     * @param string|boolean $form
600
-     *
601
-     * @return string
602
-     */
603
-    public static function get_form_style( $form ) {
598
+	/**
599
+	 * @param string|boolean $form
600
+	 *
601
+	 * @return string
602
+	 */
603
+	public static function get_form_style( $form ) {
604 604
 		$style = 1;
605 605
 		if ( empty( $form ) || 'default' == 'form' ) {
606 606
 			return $style;
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
 		$style = ( $form && is_object( $form ) && isset( $form->options['custom_style'] ) ) ? $form->options['custom_style'] : $style;
621 621
 
622 622
 		return $style;
623
-    }
623
+	}
624 624
 
625 625
 	/**
626 626
 	 * Display the validation error messages when an entry is submitted
@@ -689,8 +689,8 @@  discard block
 block discarded – undo
689 689
 	}
690 690
 
691 691
 	public static function get_scroll_js( $form_id ) {
692
-        echo '<script type="text/javascript">document.addEventListener(\'DOMContentLoaded\',function(){frmFrontForm.scrollMsg(' . (int) $form_id . ');})</script>';
693
-    }
692
+		echo '<script type="text/javascript">document.addEventListener(\'DOMContentLoaded\',function(){frmFrontForm.scrollMsg(' . (int) $form_id . ');})</script>';
693
+	}
694 694
 
695 695
 	/**
696 696
 	 * @since 3.0
@@ -745,20 +745,20 @@  discard block
 block discarded – undo
745 745
 
746 746
 	public static function edit_form_link( $form_id ) {
747 747
 		if ( is_object( $form_id ) ) {
748
-            $form = $form_id;
749
-            $name = $form->name;
750
-            $form_id = $form->id;
751
-        } else {
748
+			$form = $form_id;
749
+			$name = $form->name;
750
+			$form_id = $form->id;
751
+		} else {
752 752
 			$name = FrmForm::getName( $form_id );
753
-        }
753
+		}
754 754
 
755
-        if ( $form_id ) {
755
+		if ( $form_id ) {
756 756
 			$val = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ) ) . '">' . ( '' == $name ? __( '(no title)' ) : FrmAppHelper::truncate( $name, 40 ) ) . '</a>';
757
-	    } else {
758
-	        $val = '';
759
-	    }
757
+		} else {
758
+			$val = '';
759
+		}
760 760
 
761
-	    return $val;
761
+		return $val;
762 762
 	}
763 763
 
764 764
 	public static function delete_trash_link( $id, $status, $length = 'label' ) {
@@ -939,18 +939,18 @@  discard block
 block discarded – undo
939 939
 	}
940 940
 
941 941
 	public static function status_nice_name( $status ) {
942
-        $nice_names = array(
943
-            'draft'     => __( 'Draft', 'formidable' ),
944
-            'trash'     => __( 'Trash', 'formidable' ),
945
-            'publish'   => __( 'Published', 'formidable' ),
946
-        );
942
+		$nice_names = array(
943
+			'draft'     => __( 'Draft', 'formidable' ),
944
+			'trash'     => __( 'Trash', 'formidable' ),
945
+			'publish'   => __( 'Published', 'formidable' ),
946
+		);
947 947
 
948 948
 		if ( ! in_array( $status, array_keys( $nice_names ) ) ) {
949
-            $status = 'publish';
950
-        }
949
+			$status = 'publish';
950
+		}
951 951
 
952 952
 		$name = $nice_names[ $status ];
953 953
 
954
-        return $name;
955
-    }
954
+		return $name;
955
+	}
956 956
 }
Please login to merge, or discard this patch.
classes/helpers/FrmListHelper.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -204,8 +204,8 @@  discard block
 block discarded – undo
204 204
 			return $this->get_pagenum();
205 205
 		}
206 206
 
207
-		if ( isset( $this->_pagination_args[ $key ] ) ) {
208
-			return $this->_pagination_args[ $key ];
207
+		if ( isset( $this->_pagination_args[$key] ) ) {
208
+			return $this->_pagination_args[$key];
209 209
 		}
210 210
 	}
211 211
 
@@ -260,8 +260,8 @@  discard block
 block discarded – undo
260 260
 	}
261 261
 
262 262
 	private function hidden_search_inputs( $param_name ) {
263
-		if ( ! empty( $_REQUEST[ $param_name ] ) ) {
264
-			echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $_REQUEST[ $param_name ] ) . '" />';
263
+		if ( ! empty( $_REQUEST[$param_name] ) ) {
264
+			echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $_REQUEST[$param_name] ) . '" />';
265 265
 		}
266 266
 	}
267 267
 
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 
305 305
 		echo "<ul class='subsubsub'>\n";
306 306
 		foreach ( $views as $class => $view ) {
307
-			$views[ $class ] = "\t" . '<li class="' . esc_attr( $class ) . '">' . $view;
307
+			$views[$class] = "\t" . '<li class="' . esc_attr( $class ) . '">' . $view;
308 308
 		}
309 309
 		echo implode( " |</li>\n", $views ) . "</li>\n"; // WPCS: XSS ok.
310 310
 		echo '</ul>';
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 
430 430
 		$out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
431 431
 		foreach ( $actions as $action => $link ) {
432
-			++$i;
432
+			++ $i;
433 433
 			( $i == $action_count ) ? $sep = '' : $sep = ' | ';
434 434
 			$out .= "<span class='$action'>$link$sep</span>";
435 435
 		}
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
 			'prev'  => __( 'Previous page' ),
643 643
 			'next'  => __( 'Next page' ),
644 644
 		);
645
-		return $labels[ $link ];
645
+		return $labels[$link];
646 646
 	}
647 647
 
648 648
 	private function current_url() {
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
 
731 731
 		// If the primary column doesn't exist fall back to the
732 732
 		// first non-checkbox column.
733
-		if ( ! isset( $columns[ $default ] ) ) {
733
+		if ( ! isset( $columns[$default] ) ) {
734 734
 			$default = FrmListHelper::get_default_primary_column_name();
735 735
 		}
736 736
 
@@ -744,7 +744,7 @@  discard block
 block discarded – undo
744 744
 		 */
745 745
 		$column  = apply_filters( 'list_table_primary_column', $default, $this->screen->id );
746 746
 
747
-		if ( empty( $column ) || ! isset( $columns[ $column ] ) ) {
747
+		if ( empty( $column ) || ! isset( $columns[$column] ) ) {
748 748
 			$column = $default;
749 749
 		}
750 750
 
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
 			// In 4.3, we added a fourth argument for primary column.
767 767
 			$column_headers = array( array(), array(), array(), $this->get_primary_column_name() );
768 768
 			foreach ( $this->_column_headers as $key => $value ) {
769
-				$column_headers[ $key ] = $value;
769
+				$column_headers[$key] = $value;
770 770
 			}
771 771
 
772 772
 			return $column_headers;
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
 				$data[1] = false;
800 800
 			}
801 801
 
802
-			$sortable[ $id ] = $data;
802
+			$sortable[$id] = $data;
803 803
 		}
804 804
 
805 805
 		$primary = $this->get_primary_column_name();
@@ -854,7 +854,7 @@  discard block
 block discarded – undo
854 854
 			static $cb_counter = 1;
855 855
 			$columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All' ) . '</label>'
856 856
 				. '<input id="cb-select-all-' . esc_attr( $cb_counter ) . '" type="checkbox" />';
857
-			$cb_counter++;
857
+			$cb_counter ++;
858 858
 		}
859 859
 
860 860
 		foreach ( $columns as $column_key => $column_display_name ) {
@@ -874,8 +874,8 @@  discard block
 block discarded – undo
874 874
 				$class[] = 'column-primary';
875 875
 			}
876 876
 
877
-			if ( isset( $sortable[ $column_key ] ) ) {
878
-				list( $orderby, $desc_first ) = $sortable[ $column_key ];
877
+			if ( isset( $sortable[$column_key] ) ) {
878
+				list( $orderby, $desc_first ) = $sortable[$column_key];
879 879
 
880 880
 				if ( $current_orderby == $orderby ) {
881 881
 					$order = 'asc' == $current_order ? 'desc' : 'asc';
Please login to merge, or discard this patch.
classes/views/frm-entries/errors.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 <?php
5 5
 }
6 6
 if ( isset( $message ) && $message != '' ) {
7
-    if ( FrmAppHelper::is_admin() ) {
7
+	if ( FrmAppHelper::is_admin() ) {
8 8
 ?>
9 9
 <div id="message" class="frm_updated_message updated"><?php echo wp_kses_post( $message ) ?></div>
10 10
 <?php
@@ -13,13 +13,13 @@  discard block
 block discarded – undo
13 13
 
14 14
 		// we need to allow scripts here for javascript in the success message
15 15
 		echo $message; // WPCS: XSS ok.
16
-    }
16
+	}
17 17
 }
18 18
 
19 19
 if ( isset( $errors ) && is_array( $errors ) && ! empty( $errors ) ) {
20 20
 
21 21
 	if ( isset( $form ) && is_object( $form ) ) {
22
-    	FrmFormsHelper::get_scroll_js( $form->id );
22
+		FrmFormsHelper::get_scroll_js( $form->id );
23 23
 	}
24 24
 	?>
25 25
 <div class="<?php echo esc_attr( FrmFormsHelper::form_error_class() ) ?>">
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
 if ( ! FrmAppHelper::is_admin() ) {
29 29
 	$img = apply_filters( 'frm_error_icon', $img );
30 30
 	if ( $img && ! empty( $img ) ) {
31
-    	echo '<img src="' . esc_url( $img ) . '" alt="" />';
32
-    }
31
+		echo '<img src="' . esc_url( $img ) . '" alt="" />';
32
+	}
33 33
 }
34 34
 
35 35
 FrmFormsHelper::show_errors( compact( 'img', 'errors', 'form' ) );
Please login to merge, or discard this patch.