PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 2.9.19.5
Pods – Custom Content Types and Fields v2.9.19.5
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 days ago boolean.php 2 days ago code.php 2 days ago color.php 2 days ago comment.php 2 days ago currency.php 2 days ago date.php 2 days ago datetime.php 2 days ago email.php 2 days ago file.php 2 days ago heading.php 2 days ago html.php 2 days ago link.php 2 days ago number.php 2 days ago oembed.php 2 days ago paragraph.php 2 days ago password.php 2 days ago phone.php 2 days ago pick.php 2 days ago slug.php 2 days ago taxonomy.php 2 days ago text.php 2 days ago time.php 2 days ago website.php 2 days ago wysiwyg.php 2 days ago
html.php
193 lines
1 <?php
2
3 /**
4 * @package Pods\Fields
5 */
6 class PodsField_HTML extends PodsField {
7
8 /**
9 * {@inheritdoc}
10 */
11 public static $group = 'Layout Elements';
12
13 /**
14 * {@inheritdoc}
15 */
16 public static $type = 'html';
17
18 /**
19 * {@inheritdoc}
20 */
21 public static $label = 'HTML Content';
22
23 /**
24 * {@inheritdoc}
25 */
26 public static $prepare = '%s';
27
28 /**
29 * {@inheritdoc}
30 */
31 public function setup() {
32 static::$group = __( 'Layout Elements', 'pods' );
33 static::$label = __( 'HTML Content', 'pods' );
34 }
35
36 /**
37 * {@inheritdoc}
38 */
39 public function options() {
40 return [
41 static::$type . '_content' => [
42 'label' => __( 'HTML Content', 'pods' ),
43 'type' => 'code',
44 ],
45 static::$type . '_no_label' => [
46 'label' => __( 'Disable the form label', 'pods' ),
47 'default' => 1,
48 'type' => 'boolean',
49 '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' ),
50 ],
51 'output_options' => [
52 'label' => __( 'Output Options', 'pods' ),
53 'type' => 'boolean_group',
54 'boolean_group' => [
55 static::$type . '_trim' => array(
56 'label' => __( 'Trim extra whitespace before/after contents', 'pods' ),
57 'default' => 1,
58 'type' => 'boolean',
59 'dependency' => true,
60 ),
61 static::$type . '_oembed' => [
62 'label' => __( 'Enable oEmbed', 'pods' ),
63 'default' => 0,
64 'type' => 'boolean',
65 'help' => [
66 __( 'Embed videos, images, tweets, and other content.', 'pods' ),
67 'http://codex.wordpress.org/Embeds',
68 ],
69 ],
70 static::$type . '_wptexturize' => [
71 'label' => __( 'Enable wptexturize', 'pods' ),
72 'default' => 1,
73 'type' => 'boolean',
74 'help' => [
75 __( 'Transforms less-beautiful text characters into stylized equivalents.', 'pods' ),
76 'http://codex.wordpress.org/Function_Reference/wptexturize',
77 ],
78 ],
79 static::$type . '_convert_chars' => [
80 'label' => __( 'Enable convert_chars', 'pods' ),
81 'default' => 1,
82 'type' => 'boolean',
83 'help' => [
84 __( 'Converts text into valid XHTML and Unicode', 'pods' ),
85 'http://codex.wordpress.org/Function_Reference/convert_chars',
86 ],
87 ],
88 static::$type . '_wpautop' => [
89 'label' => __( 'Enable wpautop', 'pods' ),
90 'default' => 1,
91 'type' => 'boolean',
92 'help' => [
93 __( 'Changes double line-breaks in the text into HTML paragraphs.', 'pods' ),
94 'http://codex.wordpress.org/Function_Reference/wpautop',
95 ],
96 ],
97 static::$type . '_allow_shortcode' => [
98 'label' => __( 'Allow Shortcodes', 'pods' ),
99 'default' => 0,
100 'type' => 'boolean',
101 'dependency' => true,
102 'help' => [
103 __( 'Embed [shortcodes] that help transform your static content into dynamic content.', 'pods' ),
104 'http://codex.wordpress.org/Shortcode_API',
105 ],
106 ],
107 ],
108 ],
109 ];
110 }
111
112 /**
113 * {@inheritdoc}
114 */
115 public function schema( $options = null ) {
116 return false;
117 }
118
119 /**
120 * {@inheritdoc}
121 */
122 public function input( $name, $value = null, $options = null, $pod = null, $id = null ) {
123 $options = ( is_array( $options ) || is_object( $options ) ) ? $options : (array) $options;
124
125 // Enforce boolean.
126 $options[ static::$type . '_no_label' ] = filter_var( pods_v( static::$type . '_no_label', $options, false ), FILTER_VALIDATE_BOOLEAN );
127
128 // @codingStandardsIgnoreLine
129 echo $this->display( $value, $name, $options, $pod, $id );
130 }
131
132 /**
133 * {@inheritdoc}
134 */
135 public function display( $value = null, $name = null, $options = null, $pod = null, $id = null ) {
136 // Support passing html_content into the options for custom HTML option layouts.
137 if ( in_array( $value, [ '', null ], true ) ) {
138 $value = pods_v( static::$type . '_content', $options, '' );
139 }
140
141 if ( $options ) {
142 $options[ static::$type . '_allow_html' ] = 1;
143 }
144
145 $value = $this->strip_html( $value, $options );
146 $value = $this->strip_shortcodes( $value, $options );
147 $value = $this->trim_whitespace( $value, $options );
148
149 if ( 1 === (int) pods_v( static::$type . '_oembed', $options, 0 ) ) {
150 $embed = $GLOBALS['wp_embed'];
151 $value = $embed->run_shortcode( $value );
152 $value = $embed->autoembed( $value );
153 }
154
155 if ( 1 === (int) pods_v( static::$type . '_wptexturize', $options, 1 ) ) {
156 $value = wptexturize( $value );
157 }
158
159 if ( 1 === (int) pods_v( static::$type . '_convert_chars', $options, 1 ) ) {
160 $value = convert_chars( $value );
161 }
162
163 if ( 1 === (int) pods_v( static::$type . '_wpautop', $options, 1 ) ) {
164 $value = wpautop( $value );
165 }
166
167 if ( 1 === (int) pods_v( static::$type . '_allow_shortcode', $options, 0 ) ) {
168 if ( 1 === (int) pods_v( static::$type . '_wpautop', $options, 1 ) ) {
169 $value = shortcode_unautop( $value );
170 }
171
172 $value = do_shortcode( $value );
173 }
174
175 return $value;
176 }
177
178 /**
179 * {@inheritdoc}
180 */
181 public function ui( $id, $value, $name = null, $options = null, $fields = null, $pod = null ) {
182 if ( $options ) {
183 $options[ static::$type . '_allow_html' ] = 1;
184 }
185
186 $value = $this->strip_html( $value, $options );
187 $value = $this->strip_shortcodes( $value, $options );
188 $value = $this->trim_whitespace( $value, $options );
189
190 return wp_trim_words( $value );
191 }
192 }
193