1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
<?php
class Papi_Property_String extends Papi_Property {
public $input_type = 'text';
public function format_value( $value, $slug, $post_id ) {
if ( ! $this->get_setting( 'allow_html' ) && $this->input_type === 'text' ) {
$value = papi_maybe_json_decode( maybe_unserialize( $value ) );
if ( ! is_string( $value ) ) {
$value = '';
}
$value = wp_strip_all_tags( $value );
}
return $value;
}
public function get_default_settings() {
return [
'allow_html' => false,
'placeholder' => ''
];
}
public function get_value() {
return $this->format_value(
parent::get_value(),
$this->get_slug(),
papi_get_post_id()
);
}
public function html() {
papi_render_html_tag( 'input', [
'id' => $this->html_id(),
'name' => $this->html_name(),
'type' => $this->input_type,
'value' => $this->get_value(),
'placeholder' => $this->get_setting( 'placeholder' )
] );
}
}