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

GravityView_Field_Source_URL::field_options()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 27
Code Lines 18

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 27
rs 8.8571
cc 2
eloc 18
nc 2
nop 5
1
<?php
2
/**
3
 * @file class-gravityview-field-source-url.php
4
 * @package GravityView
5
 * @subpackage includes\fields
6
 */
7
8
/**
9
 * Add custom options for source_url fields
10
 */
11
class GravityView_Field_Source_URL extends GravityView_Field {
12
13
	var $name = 'source_url';
14
15
	var $search_operators = array( 'is', 'isnot', 'contains', 'starts_with', 'ends_with' );
16
17
	var $group = 'meta';
18
19
	public function __construct() {
20
		$this->label = esc_attr__( 'Source URL', '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
		// Don't link to entry; doesn't make sense.
27
		unset( $field_options['show_as_link'] );
28
29
		if( 'edit' === $context ) {
30
			return $field_options;
31
		}
32
33
		$add_options = array();
34
		$add_options['link_to_source'] = array(
35
			'type' => 'checkbox',
36
			'label' => __( 'Link to URL:', 'gravityview' ),
37
			'desc' => __('Display as a link to the Source URL', 'gravityview'),
38
			'value' => false,
39
			'merge_tags' => false,
40
		);
41
		$add_options['source_link_text'] = array(
42
			'type' => 'text',
43
			'label' => __( 'Link Text:', 'gravityview' ),
44
			'desc' => __('Customize the link text. If empty, the link text will be the the URL.', 'gravityview'),
45
			'value' => NULL,
46
			'merge_tags' => true,
47
		);
48
49
		return $add_options + $field_options;
50
	}
51
52
}
53
54
new GravityView_Field_Source_URL;
55