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
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><h2>Heading Text</h2></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 |