Completed
Push — develop ( fc0354...e2ac27 )
by Zack
11:27 queued 07:24
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.4286
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
/**
4
 * Add custom options for entry_link fields
5
 */
6
class GravityView_Field_Entry_Link extends GravityView_Field {
7
8
	var $name = 'entry_link';
9
10
	var $contexts = array( 'multiple' );
11
12
	/**
13
	 * @var bool
14
	 * @since 1.15.3
15
	 */
16
	var $is_sortable = false;
17
18
	/**
19
	 * @var bool
20
	 * @since 1.15.3
21
	 */
22
	var $is_searchable = false;
23
24
	public function __construct() {
25
		$this->label = esc_attr__( 'Link to Entry', 'gravityview' );
0 ignored issues
show
Bug introduced by
The property label cannot be accessed from this context as it is declared private in class GravityView_Field.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
26
		$this->description = __('A dedicated link to the single entry with customizable text.', 'gravityview');
0 ignored issues
show
Bug introduced by
The property description cannot be accessed from this context as it is declared private in class GravityView_Field.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
27
		parent::__construct();
28
	}
29
30
	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...
31
32
		// Always a link!
33
		unset( $field_options['show_as_link'], $field_options['search_filter'] );
34
35
		if( 'edit' === $context ) {
36
			return $field_options;
37
		}
38
39
		$add_options = array();
40
		$add_options['entry_link_text'] = array(
41
			'type' => 'text',
42
			'label' => __( 'Link Text:', 'gravityview' ),
43
			'desc' => NULL,
44
			'value' => __('View Details', 'gravityview'),
45
			'merge_tags' => true,
46
		);
47
48
		return $add_options + $field_options;
49
	}
50
51
}
52
53
new GravityView_Field_Entry_Link;
54