PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 3.3.9.1
Pods – Custom Content Types and Fields v3.3.9.1
2.7.31.4 2.8.23.5 2.9.19.5 3.0.10.5 3.1.4.3 3.2.8.4 3.3.9.2 2.8.23.4 2.9.19.4 3.0.10.4 3.1.4.2 3.2.8.3 3.3.9.1 trunk 1.14.8 2.7.31.3 2.8.23.3 2.9.19.3 3.0.10.3 3.1.4.1 3.2.0 3.2.1 3.2.1.1 3.2.2 3.2.4 3.2.5 3.2.6 3.2.7 3.2.7.1 3.2.8 3.2.8.1 3.2.8.2 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9
pods / classes / fields / html.php
pods / classes / fields Last commit date
avatar.php 2 weeks ago boolean.php 2 weeks ago code.php 2 weeks ago color.php 2 weeks ago comment.php 2 weeks ago currency.php 2 weeks ago date.php 2 weeks ago datetime.php 2 weeks ago email.php 2 weeks ago file.php 2 weeks ago heading.php 2 weeks ago html.php 2 weeks ago link.php 2 weeks ago number.php 2 weeks ago oembed.php 2 weeks ago paragraph.php 2 weeks ago password.php 2 weeks ago phone.php 2 weeks ago pick.php 2 weeks ago slug.php 2 weeks ago taxonomy.php 2 weeks ago text.php 2 weeks ago time.php 2 weeks ago website.php 2 weeks ago wysiwyg.php 2 weeks ago
html.php
226 lines
1 <?php
2
3 // Don't load directly.
4 if ( ! defined( 'ABSPATH' ) ) {
5 die( '-1' );
6 }
7
8 use Pods\Whatsit\Field;
9
10 /**
11 * @package Pods\Fields
12 */
13 class PodsField_HTML extends PodsField {
14
15 /**
16 * {@inheritdoc}
17 */
18 public static $group = 'Layout Elements';
19
20 /**
21 * {@inheritdoc}
22 */
23 public static $type = 'html';
24
25 /**
26 * {@inheritdoc}
27 */
28 public static $label = 'HTML Content';
29
30 /**
31 * {@inheritdoc}
32 */
33 public static $prepare = '%s';
34
35 /**
36 * {@inheritdoc}
37 */
38 public function setup() {
39 static::$group = __( 'Layout Elements', 'pods' );
40 static::$label = __( 'HTML Content', 'pods' );
41 }
42
43 /**
44 * {@inheritdoc}
45 */
46 public function options() {
47 return [
48 static::$type . '_content' => [
49 'label' => __( 'HTML Content', 'pods' ),
50 'type' => 'code',
51 ],
52 static::$type . '_no_label' => [
53 'label' => __( 'Disable the form label', 'pods' ),
54 'default' => 1,
55 'type' => 'boolean',
56 'help' => __( 'By disabling the form label, the HTML will show as full width without the label text. Only the HTML content will be displayed in the form.', 'pods' ),
57 ],
58 'output_options' => [
59 'label' => __( 'Output Options', 'pods' ),
60 'type' => 'boolean_group',
61 'boolean_group' => [
62 static::$type . '_trim' => [
63 'label' => __( 'Trim extra whitespace before/after contents', 'pods' ),
64 'default' => 1,
65 'type' => 'boolean',
66 ],
67 static::$type . '_trim_lines' => [
68 'label' => __( 'Trim whitespace at the end of lines', 'pods' ),
69 'default' => 0,
70 'type' => 'boolean',
71 ],
72 static::$type . '_trim_p_brs' => [
73 'label' => __( 'Remove blank lines including empty "p" tags and "br" tags', 'pods' ),
74 'default' => 0,
75 'type' => 'boolean',
76 ],
77 static::$type . '_trim_extra_lines' => [
78 'label' => __( 'Remove extra blank lines (when there are 3+ blank lines, replace with a maximum of 2)', 'pods' ),
79 'default' => 0,
80 'type' => 'boolean',
81 ],
82 static::$type . '_oembed' => [
83 'label' => __( 'Enable oEmbed', 'pods' ),
84 'default' => 0,
85 'type' => 'boolean',
86 'help' => [
87 __( 'Embed videos, images, tweets, and other content.', 'pods' ),
88 'http://codex.wordpress.org/Embeds',
89 ],
90 ],
91 static::$type . '_wptexturize' => [
92 'label' => __( 'Enable wptexturize', 'pods' ),
93 'default' => 1,
94 'type' => 'boolean',
95 'help' => [
96 __( 'Transforms less-beautiful text characters into stylized equivalents.', 'pods' ),
97 'http://codex.wordpress.org/Function_Reference/wptexturize',
98 ],
99 ],
100 static::$type . '_convert_chars' => [
101 'label' => __( 'Enable convert_chars', 'pods' ),
102 'default' => 1,
103 'type' => 'boolean',
104 'help' => [
105 __( 'Converts text into valid XHTML and Unicode', 'pods' ),
106 'http://codex.wordpress.org/Function_Reference/convert_chars',
107 ],
108 ],
109 static::$type . '_wpautop' => [
110 'label' => __( 'Enable wpautop', 'pods' ),
111 'default' => 1,
112 'type' => 'boolean',
113 'help' => [
114 __( 'Changes double line-breaks in the text into HTML paragraphs.', 'pods' ),
115 'http://codex.wordpress.org/Function_Reference/wpautop',
116 ],
117 ],
118 static::$type . '_allow_shortcode' => [
119 'label' => __( 'Allow Shortcodes', 'pods' ),
120 'default' => 0,
121 'type' => 'boolean',
122 'dependency' => true,
123 'help' => [
124 __( 'Embed [shortcodes] that help transform your static content into dynamic content.', 'pods' ),
125 'http://codex.wordpress.org/Shortcode_API',
126 ],
127 ],
128 ],
129 ],
130 ];
131 }
132
133 /**
134 * {@inheritdoc}
135 */
136 public function schema( $options = null ) {
137 return false;
138 }
139
140 /**
141 * {@inheritdoc}
142 */
143 public function input( $name, $value = null, $options = null, $pod = null, $id = null ) {
144 $options = ( is_array( $options ) || is_object( $options ) ) ? $options : (array) $options;
145
146 // Enforce boolean.
147 $options[ static::$type . '_no_label' ] = filter_var( pods_v( static::$type . '_no_label', $options, false ), FILTER_VALIDATE_BOOLEAN );
148
149 // Format content.
150 $options[ static::$type . '_content' ] = $this->display( $options[ static::$type . '_content' ], $name, $options, $pod, $id );
151
152 if ( isset( $options['_field_object'] ) && $options['_field_object'] instanceof Field ) {
153 $options['_field_object']->set_arg( static::$type . '_no_label', $options[ static::$type . '_no_label' ] );
154 $options['_field_object']->set_arg( static::$type . '_content', $options[ static::$type . '_content' ] );
155 }
156
157 $type = pods_v( 'type', $options, static::$type );
158
159 $args = compact( array_keys( get_defined_vars() ) );
160 $args = (object) $args;
161
162 $this->render_input_script( $args );
163 }
164
165 /**
166 * {@inheritdoc}
167 */
168 public function display( $value = null, $name = null, $options = null, $pod = null, $id = null ) {
169 // Support passing html_content into the options for custom HTML option layouts.
170 if ( in_array( $value, [ '', null ], true ) ) {
171 $value = pods_v( static::$type . '_content', $options, '' );
172 }
173
174 if ( $options ) {
175 $options[ static::$type . '_allow_html' ] = 1;
176 }
177
178 $value = $this->strip_html( $value, $options );
179 $value = $this->strip_shortcodes( $value, $options );
180 $value = $this->trim_whitespace( $value, $options );
181
182 if ( 1 === (int) pods_v( static::$type . '_oembed', $options, 0 ) ) {
183 $embed = $GLOBALS['wp_embed'];
184 $value = $embed->run_shortcode( $value );
185 $value = $embed->autoembed( $value );
186 }
187
188 if ( 1 === (int) pods_v( static::$type . '_wptexturize', $options, 1 ) ) {
189 $value = wptexturize( $value );
190 }
191
192 if ( 1 === (int) pods_v( static::$type . '_convert_chars', $options, 1 ) ) {
193 $value = convert_chars( $value );
194 }
195
196 if ( 1 === (int) pods_v( static::$type . '_wpautop', $options, 1 ) ) {
197 $value = wpautop( $value );
198 }
199
200 if ( 1 === (int) pods_v( static::$type . '_allow_shortcode', $options, 0 ) ) {
201 if ( 1 === (int) pods_v( static::$type . '_wpautop', $options, 1 ) ) {
202 $value = shortcode_unautop( $value );
203 }
204
205 $value = do_shortcode( $value );
206 }
207
208 return $value;
209 }
210
211 /**
212 * {@inheritdoc}
213 */
214 public function ui( $id, $value, $name = null, $options = null, $fields = null, $pod = null ) {
215 if ( $options ) {
216 $options[ static::$type . '_allow_html' ] = 1;
217 }
218
219 $value = $this->strip_html( $value, $options );
220 $value = $this->strip_shortcodes( $value, $options );
221 $value = $this->trim_whitespace( $value, $options );
222
223 return wp_trim_words( $value );
224 }
225 }
226