Completed
Push — develop ( fc0354...e2ac27 )
by Zack
11:27 queued 07:24
created

GravityView_Field_Other_Entries::__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
 * A field that displays other entries by the entry_creator for the same View in a list format
5
 *
6
 * @since 1.7.2
7
 */
8
class GravityView_Field_Other_Entries extends GravityView_Field {
9
10
	var $name = 'other_entries';
11
12
	var $label = 'Other Entries';
13
14
	var $group = 'gravityview';
15
16
	public function __construct() {
17
		$this->label = esc_attr__( 'Other Entries', 'gravityview' );
18
		$this->description = __('Display other entries created by the entry creator.', '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...
19
		parent::__construct();
20
	}
21
22
	/**
23
	 * @inheritDoc
24
	 * @since 1.7.2
25
	 */
26
	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...
27
28
		if( 'edit' === $context ) {
29
			return $field_options;
30
		}
31
32
		// No "Link to single entry"; all the items will be links to entries!
33
		unset( $field_options['show_as_link'] );
34
35
		$new_options = array();
36
37
		$new_options['link_format'] = array(
38
			'type'  => 'text',
39
			'label' => __( 'Entry link text (required)', 'gravityview' ),
40
			'value' => __('Entry #{entry_id}', 'gravityview'),
41
			'merge_tags' => 'force',
42
		);
43
44
		$new_options['after_link'] = array(
45
			'type'  => 'textarea',
46
			'label' => __( 'Text or HTML to display after the link (optional)', 'gravityview' ),
47
			'desc'  => __('This content will be displayed below each entry link.', 'gravityview'),
48
			'value' => '',
49
			'merge_tags' => 'force',
50
			'class' => 'widefat code',
51
		);
52
53
		$new_options['page_size'] = array(
54
			'type'  => 'number',
55
			'label' => __( 'Entries to Display', 'gravityview' ),
56
			'desc'  => __( 'What is the maximum number of entries that should be shown?', 'gravityview' ),
57
			'value' => '10',
58
			'merge_tags' => false,
59
		);
60
61
		$new_options['no_entries_hide'] = array(
62
			'type'  => 'checkbox',
63
			'label' => __( 'Hide if no entries', 'gravityview' ),
64
			'desc'  => __( 'Don\'t display this field if the entry creator has no other entries', 'gravityview' ),
65
			'value' => false,
66
		);
67
68
		$new_options['no_entries_text'] = array(
69
			'type'  => 'text',
70
			'label' => __( 'No Entries Text', 'gravityview' ),
71
			'desc'  => __( 'The text that is shown if the entry creator has no other entries (and "Hide if no entries" is disabled).', 'gravityview' ),
72
			'value' => __( 'This user has no other entries.', 'gravityview' ),
73
		);
74
75
		return $new_options + $field_options;
76
	}
77
78
}
79
80
new GravityView_Field_Other_Entries;
81