Completed
Push — develop ( 7f13c6...c06441 )
by Zack
06:21
created

GravityView_Field_Address   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 38
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A field_options() 0 23 3
1
<?php
2
/**
3
 * @file class-gravityview-field-address.php
4
 * @package GravityView
5
 * @subpackage includes\fields
6
 */
7
8
/**
9
 * Add custom options for address fields
10
 */
11
class GravityView_Field_Address extends GravityView_Field {
12
13
	var $name = 'address';
14
15
	var $group = 'advanced';
16
17
	var $_gf_field_class_name = 'GF_Field_Address';
18
19
	public function __construct() {
20
		$this->label = esc_html__( 'Address', 'gravityview' );
21
		parent::__construct();
22
	}
23
24
	function field_options( $field_options, $template_id = '', $field_id = '', $context = '', $input_type = '' ) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
25
26
		// If this is NOT the full address field, return default options.
27
		if( floor( $field_id ) !== floatval( $field_id ) ) {
28
			return $field_options;
29
		}
30
31
		if( 'edit' === $context ) {
32
			return $field_options;
33
		}
34
35
		$add_options = array();
36
37
		$add_options['show_map_link'] = array(
38
			'type' => 'checkbox',
39
			'label' => __( 'Show Map Link:', 'gravityview' ),
40
			'desc' => __('Display a "Map It" link below the address', 'gravityview'),
41
			'value' => true,
42
			'merge_tags' => false,
43
		);
44
45
		return $add_options + $field_options;
46
	}
47
48
}
49
50
new GravityView_Field_Address;
51