1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* ACF Message Field Class |
5
|
|
|
* |
6
|
|
|
* All the logic for this field type |
7
|
|
|
* |
8
|
|
|
* @class acf_field_message |
9
|
|
|
* @extends acf_field |
10
|
|
|
* @package ACF |
11
|
|
|
* @subpackage Fields |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
if( ! class_exists('acf_field_message') ) : |
15
|
|
|
|
16
|
|
|
class acf_field_message extends acf_field { |
17
|
|
|
|
18
|
|
|
|
19
|
|
|
/* |
20
|
|
|
* __construct |
21
|
|
|
* |
22
|
|
|
* This function will setup the field type data |
23
|
|
|
* |
24
|
|
|
* @type function |
25
|
|
|
* @date 5/03/2014 |
26
|
|
|
* @since 5.0.0 |
27
|
|
|
* |
28
|
|
|
* @param n/a |
29
|
|
|
* @return n/a |
30
|
|
|
*/ |
|
|
|
|
31
|
|
|
|
32
|
|
View Code Duplication |
function __construct() { |
|
|
|
|
33
|
|
|
|
34
|
|
|
// vars |
35
|
|
|
$this->name = 'message'; |
36
|
|
|
$this->label = __("Message",'acf'); |
|
|
|
|
37
|
|
|
$this->category = 'layout'; |
38
|
|
|
$this->defaults = array( |
39
|
|
|
'value' => false, // prevents acf_render_fields() from attempting to load value |
40
|
|
|
'message' => '', |
41
|
|
|
'esc_html' => 0, |
42
|
|
|
'new_lines' => 'wpautop', |
43
|
|
|
); |
44
|
|
|
|
45
|
|
|
|
46
|
|
|
// do not delete! |
47
|
|
|
parent::__construct(); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
|
51
|
|
|
/* |
52
|
|
|
* render_field() |
53
|
|
|
* |
54
|
|
|
* Create the HTML interface for your field |
55
|
|
|
* |
56
|
|
|
* @param $field - an array holding all the field's data |
57
|
|
|
* |
58
|
|
|
* @type action |
59
|
|
|
* @since 3.6 |
60
|
|
|
* @date 23/01/13 |
61
|
|
|
*/ |
62
|
|
|
|
63
|
|
|
function render_field( $field ) { |
|
|
|
|
64
|
|
|
|
65
|
|
|
// vars |
66
|
|
|
$m = $field['message']; |
67
|
|
|
|
68
|
|
|
|
69
|
|
|
// wptexturize (improves "quotes") |
70
|
|
|
$m = wptexturize( $m ); |
71
|
|
|
|
72
|
|
|
|
73
|
|
|
// esc_html |
74
|
|
|
if( $field['esc_html'] ) { |
75
|
|
|
|
76
|
|
|
$m = esc_html( $m ); |
77
|
|
|
|
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
|
81
|
|
|
// new lines |
82
|
|
View Code Duplication |
if( $field['new_lines'] == 'wpautop' ) { |
|
|
|
|
83
|
|
|
|
84
|
|
|
$m = wpautop($m); |
85
|
|
|
|
86
|
|
|
} elseif( $field['new_lines'] == 'br' ) { |
87
|
|
|
|
88
|
|
|
$m = nl2br($m); |
89
|
|
|
|
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
|
93
|
|
|
// return |
94
|
|
|
echo $m; |
95
|
|
|
|
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
|
99
|
|
|
/* |
100
|
|
|
* render_field_settings() |
101
|
|
|
* |
102
|
|
|
* Create extra options for your field. This is rendered when editing a field. |
103
|
|
|
* The value of $field['name'] can be used (like bellow) to save extra data to the $field |
104
|
|
|
* |
105
|
|
|
* @param $field - an array holding all the field's data |
106
|
|
|
* |
107
|
|
|
* @type action |
108
|
|
|
* @since 3.6 |
109
|
|
|
* @date 23/01/13 |
110
|
|
|
*/ |
111
|
|
|
|
112
|
|
|
function render_field_settings( $field ) { |
|
|
|
|
113
|
|
|
|
114
|
|
|
// default_value |
115
|
|
|
acf_render_field_setting( $field, array( |
116
|
|
|
'label' => __('Message','acf'), |
117
|
|
|
'instructions' => '', |
118
|
|
|
'type' => 'textarea', |
119
|
|
|
'name' => 'message', |
120
|
|
|
)); |
121
|
|
|
|
122
|
|
|
|
123
|
|
|
// formatting |
124
|
|
|
acf_render_field_setting( $field, array( |
125
|
|
|
'label' => __('New Lines','acf'), |
126
|
|
|
'instructions' => __('Controls how new lines are rendered','acf'), |
127
|
|
|
'type' => 'select', |
128
|
|
|
'name' => 'new_lines', |
129
|
|
|
'choices' => array( |
130
|
|
|
'wpautop' => __("Automatically add paragraphs",'acf'), |
131
|
|
|
'br' => __("Automatically add <br>",'acf'), |
132
|
|
|
'' => __("No Formatting",'acf') |
133
|
|
|
) |
134
|
|
|
)); |
135
|
|
|
|
136
|
|
|
|
137
|
|
|
// HTML |
138
|
|
|
acf_render_field_setting( $field, array( |
139
|
|
|
'label' => __('Escape HTML','acf'), |
140
|
|
|
'instructions' => __('Allow HTML markup to display as visible text instead of rendering','acf'), |
141
|
|
|
'type' => 'radio', |
142
|
|
|
'name' => 'esc_html', |
143
|
|
|
'choices' => array( |
144
|
|
|
1 => __("Yes",'acf'), |
145
|
|
|
0 => __("No",'acf'), |
146
|
|
|
), |
147
|
|
|
'layout' => 'horizontal', |
148
|
|
|
)); |
149
|
|
|
|
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
new acf_field_message(); |
155
|
|
|
|
156
|
|
|
endif; |
157
|
|
|
|
158
|
|
|
?> |
|
|
|
|
159
|
|
|
|
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.