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
<?php
class Papi_Property_Html extends Papi_Property {
public function get_default_settings() {
return [
'html' => '',
'save' => false
];
}
public function html() {
$settings = $this->get_settings();
$html = papi_maybe_get_callable_value( $settings->html );
if ( $settings->save ) {
$value = $this->get_value();
if ( ! empty( $value ) && is_string( $value ) ) {
$html = $value;
}
papi_render_html_tag( 'input', [
'name' => $this->html_name(),
'type' => 'hidden',
'value' => $html
] );
}
papi_render_html_tag( 'div', [
'data-papi-rule' => $this->html_name(),
'class' => 'property-html',
$html
] );
}
}