Completed
Push — develop ( 5e6af4...e8aa8e )
by Gennady
15:44
created

GravityView_Field_Survey::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @file class-gravityview-field-survey.php
4
 * @package GravityView
5
 * @subpackage includes\fields
6
 */
7
8
class GravityView_Field_Survey extends GravityView_Field {
9
10
	var $name = 'survey';
11
12
	var $_gf_field_class_name = 'GF_Field_Survey';
13
14
	var $is_searchable = false;
15
16
	var $group = 'advanced';
17
18
	public function __construct() {
19
		$this->label = esc_html__( 'Survey', 'gravityview' );
20
		parent::__construct();
21
	}
22
23
	public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) {
24
25
		unset( $field_options['search_filter'] );
26
27
		if ( 'edit' === $context ) {
28
			return $field_options;
29
		}
30
31
		$field = \GV\GF_Field::by_id( \GV\GF_Form::by_id( $form_id ), $field_id );
32
33
		$add_options = array();
34
35
		if ( $field->field->inputType === 'likert' && $field->field->gsurveyLikertEnableScoring ) {
36
			$add_options['score'] = array(
37
				'type' => 'checkbox',
38
				'label' => __( 'Show score', 'gravityview' ),
39
				'desc' => __( 'Display likert score as a simple number.', 'gravityview' ),
40
				'value' => false,
41
				'merge_tags' => false,
42
			);
43
		}
44
45
		return $add_options + $field_options;
46
	}
47
}
48
49
new GravityView_Field_Survey;
50