Completed
Push — master ( 3ac4b1...21157a )
by Zack
05:18
created

GravityView_Field_Calculation   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 37
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A blacklist_field_types() 0 9 2
1
<?php
2
/**
3
 * @file class-gravityview-field-calculation.php
4
 * @package GravityView
5
 * @subpackage includes\fields
6
 */
7
8
class GravityView_Field_Calculation extends GravityView_Field {
9
10
	var $name = 'calculation';
11
12
	var $is_searchable = false;
13
14
	var $group = 'pricing';
15
16
	var $_gf_field_class_name = 'GF_Field_Calculation';
17
18
	/**
19
	 * GravityView_Field_Calculation constructor.
20
	 */
21
	public function __construct() {
22
23
		add_filter( 'gravityview_blacklist_field_types', array( $this, 'blacklist_field_types' ), 10, 2 );
24
25
		parent::__construct();
26
	}
27
28
	/**
29
	 * Don't show the Calculation field in field picker
30
	 * @param array $field_types Array of field types
31
	 * @param string $context
32
	 *
33
	 * @return array Field types with calculation added, if not Edit Entry context
34
	 */
35
	public function blacklist_field_types( $field_types = array(), $context = '' ) {
36
37
		// Allow Calculation field in Edit Entry
38
		if( 'edit' !== $context ) {
39
			$field_types[] = $this->name;
40
		}
41
42
		return $field_types;
43
	}
44
}
45
46
new GravityView_Field_Calculation;
47