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

GravityView_Field_Entry_Link::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 5
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
/**
3
 * @file class-gravityview-field-entry-link.php
4
 * @package GravityView
5
 * @subpackage includes\fields
6
 */
7
8
/**
9
 * Add custom options for entry_link fields
10
 */
11
class GravityView_Field_Entry_Link extends GravityView_Field {
12
13
	var $name = 'entry_link';
14
15
	var $contexts = array( 'multiple' );
16
17
	/**
18
	 * @var bool
19
	 * @since 1.15.3
20
	 */
21
	var $is_sortable = false;
22
23
	/**
24
	 * @var bool
25
	 * @since 1.15.3
26
	 */
27
	var $is_searchable = false;
28
29
	var $group = 'gravityview';
30
31
	public function __construct() {
32
		$this->label = esc_attr__( 'Link to Entry', 'gravityview' );
33
		$this->description = __('A dedicated link to the single entry with customizable text.', 'gravityview');
34
		parent::__construct();
35
	}
36
37
	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...
38
39
		// Always a link!
40
		unset( $field_options['show_as_link'], $field_options['search_filter'] );
41
42
		if( 'edit' === $context ) {
43
			return $field_options;
44
		}
45
46
		$add_options = array();
47
		$add_options['entry_link_text'] = array(
48
			'type' => 'text',
49
			'label' => __( 'Link Text:', 'gravityview' ),
50
			'desc' => NULL,
51
			'value' => __('View Details', 'gravityview'),
52
			'merge_tags' => true,
53
		);
54
55
		return $add_options + $field_options;
56
	}
57
58
}
59
60
new GravityView_Field_Entry_Link;
61