PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 3.0.10.5
Pods – Custom Content Types and Fields v3.0.10.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 / heading.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
heading.php
147 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 . '_wptexturize' => [
61 'label' => __( 'Enable wptexturize', 'pods' ),
62 'default' => 1,
63 'type' => 'boolean',
64 'help' => [
65 __( 'Transforms less-beautiful text characters into stylized equivalents.', 'pods' ),
66 'http://codex.wordpress.org/Function_Reference/wptexturize',
67 ],
68 ],
69 static::$type . '_allow_shortcode' => [
70 'label' => __( 'Allow Shortcodes', 'pods' ),
71 'default' => 0,
72 'type' => 'boolean',
73 'dependency' => true,
74 'help' => [
75 __( 'Embed [shortcodes] that help transform your static content into dynamic content.', 'pods' ),
76 'http://codex.wordpress.org/Shortcode_API',
77 ],
78 ],
79 ],
80 ],
81 ];
82 }
83
84 /**
85 * {@inheritdoc}
86 */
87 public function schema( $options = null ) {
88 return false;
89 }
90
91 /**
92 * {@inheritdoc}
93 */
94 public function input( $name, $value = null, $options = null, $pod = null, $id = null ) {
95 $options = ( is_array( $options ) || is_object( $options ) ) ? $options : (array) $options;
96
97 // Format content.
98 $options[ static::$type . '_content' ] = $this->display( $options[ static::$type . '_content' ], $name, $options, $pod, $id );
99
100 if ( isset( $options['_field_object'] ) && $options['_field_object'] instanceof Field ) {
101 $options['_field_object']->set_arg( static::$type . '_content', $options[ static::$type . '_content' ] );
102 }
103
104 $type = pods_v( 'type', $options, static::$type );
105
106 $args = compact( array_keys( get_defined_vars() ) );
107 $args = (object) $args;
108
109 $this->render_input_script( $args );
110 }
111
112 /**
113 * {@inheritdoc}
114 */
115 public function display( $value = null, $name = null, $options = null, $pod = null, $id = null ) {
116 // Support passing html_content into the options for custom HTML option layouts.
117 if ( empty( $value ) && ! empty( $options[ static::$type . '_content' ] ) ) {
118 $value = $options[ static::$type . '_content' ];
119 }
120
121 $value = $this->strip_html( $value, $options );
122 $value = $this->strip_shortcodes( $value, $options );
123 $value = $this->trim_whitespace( $value, $options );
124
125 if ( 1 === (int) pods_v( static::$type . '_wptexturize', $options, 1 ) ) {
126 $value = wptexturize( $value );
127 }
128
129 if ( 1 === (int) pods_v( static::$type . '_allow_shortcode', $options, 0 ) ) {
130 $value = do_shortcode( $value );
131 }
132
133 return $value;
134 }
135
136 /**
137 * {@inheritdoc}
138 */
139 public function ui( $id, $value, $name = null, $options = null, $fields = null, $pod = null ) {
140 $value = $this->strip_html( $value, $options );
141 $value = $this->strip_shortcodes( $value, $options );
142 $value = $this->trim_whitespace( $value, $options );
143
144 return wp_trim_words( $value );
145 }
146 }
147