Completed
Push — master ( 21157a...9cf7be )
by Zack
84:58 queued 65:12
created

GravityView_Field_Website::field_options()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 36
Code Lines 21

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 36
rs 8.8571
cc 2
eloc 21
nc 2
nop 5
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 11 and the first side effect is on line 65.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * @file class-gravityview-field-website.php
4
 * @package GravityView
5
 * @subpackage includes\fields
6
 */
7
8
/**
9
 * Add custom options for date fields
10
 */
11
class GravityView_Field_Website extends GravityView_Field {
12
13
	var $name = 'website';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
14
15
	var $search_operators = array( 'is', 'isnot', 'contains', 'starts_with', 'ends_with' );
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $search_operators.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
16
17
	var $_gf_field_class_name = 'GF_Field_Website';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $_gf_field_class_name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
18
19
	var $group = 'advanced';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $group.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
20
21
	public function __construct() {
22
		$this->label = esc_html__( 'Website', 'gravityview' );
23
		parent::__construct();
24
	}
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
		// It makes no sense to use this as the link.
29
		unset( $field_options['show_as_link'] );
30
31
		if( 'edit' === $context ) {
0 ignored issues
show
introduced by
Space after opening control structure is required
Loading history...
32
			return $field_options;
33
		}
34
35
		/**
36
		 * @since 1.8
37
		 */
38
		$field_options['anchor_text'] = array(
39
			'type' => 'text',
40
			'label' => __( 'Link Text:', 'gravityview' ),
41
			'desc' => __( 'Define custom link text. Leave blank to display the URL', 'gravityview' ),
42
			'value' => '',
43
			'merge_tags' => 'force',
44
		);
45
46
		$field_options['truncatelink'] = array(
47
			'type' => 'checkbox',
48
			'value' => true,
49
			'label' => __( 'Shorten Link Display', 'gravityview' ),
50
			'tooltip' => __( 'Only show the domain for a URL instead of the whole link.', 'gravityview' ),
51
			'desc' => __( 'Don&rsquo;t show the full URL, only show the domain.', 'gravityview' )
52
		);
53
54
		$field_options['open_same_window'] = array(
55
			'type' => 'checkbox',
56
			'value' => false,
57
			'label' => __( 'Open link in the same window?', 'gravityview' ),
58
		);
59
60
		return $field_options;
61
	}
62
63
}
64
65
new GravityView_Field_Website;
66