avatar.php
3 days ago
boolean.php
3 days ago
code.php
3 days ago
color.php
3 days ago
comment.php
3 days ago
currency.php
3 days ago
date.php
3 days ago
datetime.php
3 days ago
email.php
3 days ago
file.php
3 days ago
html.php
3 days ago
link.php
3 days ago
number.php
3 days ago
oembed.php
3 days ago
paragraph.php
3 days ago
password.php
3 days ago
phone.php
3 days ago
pick.php
3 days ago
slug.php
3 days ago
taxonomy.php
3 days ago
text.php
3 days ago
time.php
3 days ago
website.php
3 days ago
wysiwyg.php
3 days ago
html.php
171 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 Blocks'; |
| 12 | |
| 13 | /** |
| 14 | * {@inheritdoc} |
| 15 | */ |
| 16 | public static $type = 'html'; |
| 17 | |
| 18 | /** |
| 19 | * {@inheritdoc} |
| 20 | */ |
| 21 | public static $label = 'HTML'; |
| 22 | |
| 23 | /** |
| 24 | * {@inheritdoc} |
| 25 | */ |
| 26 | public static $prepare = '%s'; |
| 27 | |
| 28 | /** |
| 29 | * {@inheritdoc} |
| 30 | */ |
| 31 | public function setup() { |
| 32 | |
| 33 | self::$label = __( 'HTML', 'pods' ); |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * {@inheritdoc} |
| 38 | */ |
| 39 | public function options() { |
| 40 | |
| 41 | $options = array( |
| 42 | 'output_options' => array( |
| 43 | 'label' => __( 'Output Options', 'pods' ), |
| 44 | 'group' => array( |
| 45 | static::$type . '_allow_html' => array( |
| 46 | 'label' => __( 'Allow HTML?', 'pods' ), |
| 47 | 'default' => 1, |
| 48 | 'type' => 'boolean', |
| 49 | 'dependency' => true, |
| 50 | ), |
| 51 | static::$type . '_oembed' => array( |
| 52 | 'label' => __( 'Enable oEmbed?', 'pods' ), |
| 53 | 'default' => 0, |
| 54 | 'type' => 'boolean', |
| 55 | 'help' => array( |
| 56 | __( 'Embed videos, images, tweets, and other content.', 'pods' ), |
| 57 | 'http://codex.wordpress.org/Embeds', |
| 58 | ), |
| 59 | ), |
| 60 | static::$type . '_wptexturize' => array( |
| 61 | 'label' => __( 'Enable wptexturize?', 'pods' ), |
| 62 | 'default' => 1, |
| 63 | 'type' => 'boolean', |
| 64 | 'help' => array( |
| 65 | __( 'Transforms less-beautfiul text characters into stylized equivalents.', 'pods' ), |
| 66 | 'http://codex.wordpress.org/Function_Reference/wptexturize', |
| 67 | ), |
| 68 | ), |
| 69 | static::$type . '_convert_chars' => array( |
| 70 | 'label' => __( 'Enable convert_chars?', 'pods' ), |
| 71 | 'default' => 1, |
| 72 | 'type' => 'boolean', |
| 73 | 'help' => array( |
| 74 | __( 'Converts text into valid XHTML and Unicode', 'pods' ), |
| 75 | 'http://codex.wordpress.org/Function_Reference/convert_chars', |
| 76 | ), |
| 77 | ), |
| 78 | static::$type . '_wpautop' => array( |
| 79 | 'label' => __( 'Enable wpautop?', 'pods' ), |
| 80 | 'default' => 1, |
| 81 | 'type' => 'boolean', |
| 82 | 'help' => array( |
| 83 | __( 'Changes double line-breaks in the text into HTML paragraphs.', 'pods' ), |
| 84 | 'http://codex.wordpress.org/Function_Reference/wpautop', |
| 85 | ), |
| 86 | ), |
| 87 | static::$type . '_allow_shortcode' => array( |
| 88 | 'label' => __( 'Allow Shortcodes?', 'pods' ), |
| 89 | 'default' => 0, |
| 90 | 'type' => 'boolean', |
| 91 | 'dependency' => true, |
| 92 | 'help' => array( |
| 93 | __( 'Embed [shortcodes] that help transform your static content into dynamic content.', 'pods' ), |
| 94 | 'http://codex.wordpress.org/Shortcode_API', |
| 95 | ), |
| 96 | ), |
| 97 | ), |
| 98 | ), |
| 99 | ); |
| 100 | |
| 101 | return $options; |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * {@inheritdoc} |
| 106 | */ |
| 107 | public function schema( $options = null ) { |
| 108 | |
| 109 | return false; |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * {@inheritdoc} |
| 114 | */ |
| 115 | public function display( $value = null, $name = null, $options = null, $pod = null, $id = null ) { |
| 116 | |
| 117 | $value = $this->strip_html( $value, $options ); |
| 118 | |
| 119 | if ( 1 === (int) pods_v( static::$type . '_oembed', $options, 0 ) ) { |
| 120 | $embed = $GLOBALS['wp_embed']; |
| 121 | $value = $embed->run_shortcode( $value ); |
| 122 | $value = $embed->autoembed( $value ); |
| 123 | } |
| 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 . '_convert_chars', $options, 1 ) ) { |
| 130 | $value = convert_chars( $value ); |
| 131 | } |
| 132 | |
| 133 | if ( 1 === (int) pods_v( static::$type . '_wpautop', $options, 1 ) ) { |
| 134 | $value = wpautop( $value ); |
| 135 | } |
| 136 | |
| 137 | if ( 1 === (int) pods_v( static::$type . '_allow_shortcode', $options, 0 ) ) { |
| 138 | if ( 1 === (int) pods_v( static::$type . '_wpautop', $options, 1 ) ) { |
| 139 | $value = shortcode_unautop( $value ); |
| 140 | } |
| 141 | |
| 142 | $value = do_shortcode( $value ); |
| 143 | } |
| 144 | |
| 145 | return $value; |
| 146 | } |
| 147 | |
| 148 | /** |
| 149 | * {@inheritdoc} |
| 150 | */ |
| 151 | public function input( $name, $value = null, $options = null, $pod = null, $id = null ) { |
| 152 | |
| 153 | $options = (array) $options; |
| 154 | |
| 155 | // @codingStandardsIgnoreLine |
| 156 | echo $this->display( $value, $name, $options, $pod, $id ); |
| 157 | } |
| 158 | |
| 159 | /** |
| 160 | * {@inheritdoc} |
| 161 | */ |
| 162 | public function ui( $id, $value, $name = null, $options = null, $fields = null, $pod = null ) { |
| 163 | |
| 164 | $value = $this->strip_html( $value, $options ); |
| 165 | |
| 166 | $value = wp_trim_words( $value ); |
| 167 | |
| 168 | return $value; |
| 169 | } |
| 170 | } |
| 171 |