PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 2.8.23.5
Pods – Custom Content Types and Fields v2.8.23.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
134 lines
1 <?php
2
3 /**
4 * @package Pods\Fields
5 */
6 class PodsField_Heading extends PodsField {
7
8 /**
9 * {@inheritdoc}
10 */
11 public static $group = 'Layout Elements';
12
13 /**
14 * {@inheritdoc}
15 */
16 public static $type = 'heading';
17
18 /**
19 * {@inheritdoc}
20 */
21 public static $label = 'Heading';
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 = __( 'Heading', 'pods' );
34 }
35
36 /**
37 * {@inheritdoc}
38 */
39 public function options() {
40 return [
41 static::$type . '_tag' => [
42 'label' => __( 'Heading HTML Tag', 'pods' ),
43 'type' => 'text',
44 'default' => '',
45 'description' => __( 'Leave this empty to use the default heading tag for the form context the heading appears in.', 'pods' ),
46 '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' ),
47 ],
48 'output_options' => [
49 'label' => __( 'Output Options', 'pods' ),
50 'type' => 'boolean_group',
51 'boolean_group' => [
52 static::$type . '_allow_html' => [
53 'label' => __( 'Allow HTML', 'pods' ),
54 'default' => 1,
55 'type' => 'boolean',
56 'dependency' => true,
57 ],
58 static::$type . '_wptexturize' => [
59 'label' => __( 'Enable wptexturize', 'pods' ),
60 'default' => 1,
61 'type' => 'boolean',
62 'help' => [
63 __( 'Transforms less-beautiful text characters into stylized equivalents.', 'pods' ),
64 'http://codex.wordpress.org/Function_Reference/wptexturize',
65 ],
66 ],
67 static::$type . '_allow_shortcode' => [
68 'label' => __( 'Allow Shortcodes', 'pods' ),
69 'default' => 0,
70 'type' => 'boolean',
71 'dependency' => true,
72 'help' => [
73 __( 'Embed [shortcodes] that help transform your static content into dynamic content.', 'pods' ),
74 'http://codex.wordpress.org/Shortcode_API',
75 ],
76 ],
77 ],
78 ],
79 ];
80 }
81
82 /**
83 * {@inheritdoc}
84 */
85 public function schema( $options = null ) {
86 return false;
87 }
88
89 /**
90 * {@inheritdoc}
91 */
92 public function input( $name, $value = null, $options = null, $pod = null, $id = null ) {
93 $options = ( is_array( $options ) || is_object( $options ) ) ? $options : (array) $options;
94
95 // @codingStandardsIgnoreLine
96 echo $this->display( $value, $name, $options, $pod, $id );
97 }
98
99 /**
100 * {@inheritdoc}
101 */
102 public function display( $value = null, $name = null, $options = null, $pod = null, $id = null ) {
103 // Support passing html_content into the options for custom HTML option layouts.
104 if ( empty( $value ) && ! empty( $options[ static::$type . '_content' ] ) ) {
105 $value = $options[ static::$type . '_content' ];
106 }
107
108 $value = $this->strip_html( $value, $options );
109 $value = $this->strip_shortcodes( $value, $options );
110 $value = $this->trim_whitespace( $value, $options );
111
112 if ( 1 === (int) pods_v( static::$type . '_wptexturize', $options, 1 ) ) {
113 $value = wptexturize( $value );
114 }
115
116 if ( 1 === (int) pods_v( static::$type . '_allow_shortcode', $options, 0 ) ) {
117 $value = do_shortcode( $value );
118 }
119
120 return $value;
121 }
122
123 /**
124 * {@inheritdoc}
125 */
126 public function ui( $id, $value, $name = null, $options = null, $fields = null, $pod = null ) {
127 $value = $this->strip_html( $value, $options );
128 $value = $this->strip_shortcodes( $value, $options );
129 $value = $this->trim_whitespace( $value, $options );
130
131 return wp_trim_words( $value );
132 }
133 }
134