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

GravityView_Field_Calculation::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
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