1
|
|
|
<?php |
|
|
|
|
2
|
|
|
/** |
3
|
|
|
* @file class-gravityview-field-email.php |
4
|
|
|
* @package GravityView |
5
|
|
|
* @subpackage includes\fields |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Add custom options for email fields |
10
|
|
|
*/ |
11
|
|
|
class GravityView_Field_Email extends GravityView_Field { |
12
|
|
|
|
13
|
|
|
var $name = 'email'; |
|
|
|
|
14
|
|
|
|
15
|
|
|
var $search_operators = array( 'is', 'isnot', 'contains', 'starts_with', 'ends_with' ); |
|
|
|
|
16
|
|
|
|
17
|
|
|
var $_gf_field_class_name = 'GF_Field_Email'; |
|
|
|
|
18
|
|
|
|
19
|
|
|
var $group = 'advanced'; |
|
|
|
|
20
|
|
|
|
21
|
|
|
public function __construct() { |
22
|
|
|
$this->label = esc_html__( 'Email', 'gravityview' ); |
23
|
|
|
parent::__construct(); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
function field_options( $field_options, $template_id = '', $field_id = '', $context = '', $input_type = '' ) { |
|
|
|
|
27
|
|
|
|
28
|
|
|
// It makes no sense to use this as the link. |
29
|
|
|
unset( $field_options['show_as_link'] ); |
30
|
|
|
|
31
|
|
|
if( 'edit' === $context ) { |
|
|
|
|
32
|
|
|
return $field_options; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
$email_options = array( |
36
|
|
|
'emailmailto' => array( |
37
|
|
|
'type' => 'checkbox', |
38
|
|
|
'value' => true, |
39
|
|
|
'label' => __( 'Link the Email Address', 'gravityview' ), |
40
|
|
|
'desc' => __( 'Clicking the link will generate a new email.', 'gravityview' ), |
41
|
|
|
), |
42
|
|
|
'emailsubject' => array( |
43
|
|
|
'type' => 'text', |
44
|
|
|
'label' => __( 'Email Subject', 'gravityview' ), |
45
|
|
|
'value' => '', |
46
|
|
|
'desc' => __( 'Set the default email subject line.', 'gravityview' ), |
47
|
|
|
'merge_tags' => 'force', |
48
|
|
|
), |
49
|
|
|
'emailbody' => array( |
50
|
|
|
'type' => 'textarea', |
51
|
|
|
'label' => __( 'Email Body', 'gravityview' ), |
52
|
|
|
'value' => '', |
53
|
|
|
'desc' => __( 'Set the default email content.', 'gravityview' ), |
54
|
|
|
'merge_tags' => 'force', |
55
|
|
|
'class' => 'widefat', |
56
|
|
|
), |
57
|
|
|
'emailencrypt' => array( |
58
|
|
|
'type' => 'checkbox', |
59
|
|
|
'value' => true, |
60
|
|
|
'label' => __( 'Encrypt Email Address', 'gravityview' ), |
61
|
|
|
'desc' => __( 'Make it harder for spammers to get email addresses from your entries. Email addresses will not be visible with Javascript disabled.', 'gravityview' ) |
62
|
|
|
) |
63
|
|
|
); |
64
|
|
|
|
65
|
|
|
return $email_options + $field_options; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
new GravityView_Field_Email; |
71
|
|
|
|
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.