PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 3.2.2
Pods – Custom Content Types and Fields v3.2.2
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 / heading.php
pods / classes / fields Last commit date
avatar.php 3 years ago boolean.php 3 years ago code.php 2 years ago color.php 3 years ago comment.php 4 years ago currency.php 3 years ago date.php 2 years ago datetime.php 2 years ago email.php 3 years ago file.php 2 years ago heading.php 2 years ago html.php 2 years ago link.php 3 years ago number.php 2 years ago oembed.php 2 years ago paragraph.php 2 years ago password.php 3 years ago phone.php 3 years ago pick.php 2 years ago slug.php 3 years ago taxonomy.php 4 years ago text.php 2 years ago time.php 2 years ago website.php 3 years ago wysiwyg.php 2 years ago
heading.php
154 lines
1 <?php
2
3 use Pods\Whatsit\Field;
4
5 /**
6 * @package Pods\Fields
7 */
8 class PodsField_Heading extends PodsField {
9
10 /**
11 * {@inheritdoc}
12 */
13 public static $group = 'Layout Elements';
14
15 /**
16 * {@inheritdoc}
17 */
18 public static $type = 'heading';
19
20 /**
21 * {@inheritdoc}
22 */
23 public static $label = 'Heading';
24
25 /**
26 * {@inheritdoc}
27 */
28 public static $prepare = '%s';
29
30 /**
31 * {@inheritdoc}
32 */
33 public function setup() {
34 static::$group = __( 'Layout Elements', 'pods' );
35 static::$label = __( 'Heading', 'pods' );
36 }
37
38 /**
39 * {@inheritdoc}
40 */
41 public function options() {
42 return [
43 static::$type . '_tag' => [
44 'label' => __( 'Heading HTML Tag', 'pods' ),
45 'type' => 'text',
46 'default' => '',
47 'description' => __( 'Leave this empty to use the default heading tag for the form context the heading appears in.', 'pods' ),
48 'help' => __( 'This is the heading HTML tag to use for the heading text. Example "h2" will output your heading as <code>&lt;h2&gt;Heading Text&lt;/h2&gt;</code>', 'pods' ),
49 ],
50 'output_options' => [
51 'label' => __( 'Output Options', 'pods' ),
52 'type' => 'boolean_group',
53 'boolean_group' => [
54 static::$type . '_allow_html' => [
55 'label' => __( 'Allow HTML', 'pods' ),
56 'default' => 1,
57 'type' => 'boolean',
58 'dependency' => true,
59 ],
60 static::$type . '_sanitize_html' => [
61 'label' => __( 'Sanitize HTML', 'pods' ),
62 'default' => 1,
63 'help' => __( 'This sanitizes things like script tags and other content not normally allowed in WordPress content. Disable this only if you trust users who will have access to enter content into this field.', 'pods' ),
64 'type' => 'boolean',
65 'dependency' => true,
66 ],
67 static::$type . '_wptexturize' => [
68 'label' => __( 'Enable wptexturize', 'pods' ),
69 'default' => 1,
70 'type' => 'boolean',
71 'help' => [
72 __( 'Transforms less-beautiful text characters into stylized equivalents.', 'pods' ),
73 'http://codex.wordpress.org/Function_Reference/wptexturize',
74 ],
75 ],
76 static::$type . '_allow_shortcode' => [
77 'label' => __( 'Allow Shortcodes', 'pods' ),
78 'default' => 0,
79 'type' => 'boolean',
80 'dependency' => true,
81 'help' => [
82 __( 'Embed [shortcodes] that help transform your static content into dynamic content.', 'pods' ),
83 'http://codex.wordpress.org/Shortcode_API',
84 ],
85 ],
86 ],
87 ],
88 ];
89 }
90
91 /**
92 * {@inheritdoc}
93 */
94 public function schema( $options = null ) {
95 return false;
96 }
97
98 /**
99 * {@inheritdoc}
100 */
101 public function input( $name, $value = null, $options = null, $pod = null, $id = null ) {
102 $options = ( is_array( $options ) || is_object( $options ) ) ? $options : (array) $options;
103
104 // Format content.
105 $options[ static::$type . '_content' ] = $this->display( $options[ static::$type . '_content' ], $name, $options, $pod, $id );
106
107 if ( isset( $options['_field_object'] ) && $options['_field_object'] instanceof Field ) {
108 $options['_field_object']->set_arg( static::$type . '_content', $options[ static::$type . '_content' ] );
109 }
110
111 $type = pods_v( 'type', $options, static::$type );
112
113 $args = compact( array_keys( get_defined_vars() ) );
114 $args = (object) $args;
115
116 $this->render_input_script( $args );
117 }
118
119 /**
120 * {@inheritdoc}
121 */
122 public function display( $value = null, $name = null, $options = null, $pod = null, $id = null ) {
123 // Support passing html_content into the options for custom HTML option layouts.
124 if ( empty( $value ) && ! empty( $options[ static::$type . '_content' ] ) ) {
125 $value = $options[ static::$type . '_content' ];
126 }
127
128 $value = $this->strip_html( $value, $options );
129 $value = $this->strip_shortcodes( $value, $options );
130 $value = $this->trim_whitespace( $value, $options );
131
132 if ( 1 === (int) pods_v( static::$type . '_wptexturize', $options, 1 ) ) {
133 $value = wptexturize( $value );
134 }
135
136 if ( 1 === (int) pods_v( static::$type . '_allow_shortcode', $options, 0 ) ) {
137 $value = do_shortcode( $value );
138 }
139
140 return $value;
141 }
142
143 /**
144 * {@inheritdoc}
145 */
146 public function ui( $id, $value, $name = null, $options = null, $fields = null, $pod = null ) {
147 $value = $this->strip_html( $value, $options );
148 $value = $this->strip_shortcodes( $value, $options );
149 $value = $this->trim_whitespace( $value, $options );
150
151 return wp_trim_words( $value );
152 }
153 }
154