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

GravityView_Field_Entry_Link   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 48
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A field_options() 0 20 2
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