|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Add custom options for date fields |
|
5
|
|
|
*/ |
|
6
|
|
|
class GravityView_Field_Website extends GravityView_Field { |
|
7
|
|
|
|
|
8
|
|
|
var $name = 'website'; |
|
9
|
|
|
|
|
10
|
|
|
var $search_operators = array( 'is', 'isnot', 'contains', 'starts_with', 'ends_with' ); |
|
11
|
|
|
|
|
12
|
|
|
var $_gf_field_class_name = 'GF_Field_Website'; |
|
13
|
|
|
|
|
14
|
|
|
var $label = 'Website'; |
|
15
|
|
|
|
|
16
|
|
|
public function __construct() { |
|
17
|
|
|
$this->label = esc_attr__( 'Website', 'gravityview' ); |
|
18
|
|
|
parent::__construct(); |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
function field_options( $field_options, $template_id = '', $field_id = '', $context = '', $input_type = '' ) { |
|
|
|
|
|
|
22
|
|
|
|
|
23
|
|
|
// It makes no sense to use this as the link. |
|
24
|
|
|
unset( $field_options['show_as_link'] ); |
|
25
|
|
|
|
|
26
|
|
|
if( 'edit' === $context ) { |
|
27
|
|
|
return $field_options; |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @since 1.8 |
|
32
|
|
|
*/ |
|
33
|
|
|
$field_options['anchor_text'] = array( |
|
34
|
|
|
'type' => 'text', |
|
35
|
|
|
'label' => __( 'Link Text:', 'gravityview' ), |
|
36
|
|
|
'desc' => __( 'Define custom link text. Leave blank to display the URL', 'gravityview' ), |
|
37
|
|
|
'value' => '', |
|
38
|
|
|
'merge_tags' => 'force', |
|
39
|
|
|
); |
|
40
|
|
|
|
|
41
|
|
|
$field_options['truncatelink'] = array( |
|
42
|
|
|
'type' => 'checkbox', |
|
43
|
|
|
'value' => true, |
|
44
|
|
|
'label' => __( 'Shorten Link Display', 'gravityview' ), |
|
45
|
|
|
'tooltip' => __( 'Only show the domain for a URL instead of the whole link.', 'gravityview' ), |
|
46
|
|
|
'desc' => __( 'Don’t show the full URL, only show the domain.', 'gravityview' ) |
|
47
|
|
|
); |
|
48
|
|
|
|
|
49
|
|
|
$field_options['open_same_window'] = array( |
|
50
|
|
|
'type' => 'checkbox', |
|
51
|
|
|
'value' => false, |
|
52
|
|
|
'label' => __( 'Open link in the same window?', 'gravityview' ), |
|
53
|
|
|
); |
|
54
|
|
|
|
|
55
|
|
|
return $field_options; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
new GravityView_Field_Website; |
|
61
|
|
|
|
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.