acf_field_wysiwyg::format_value
This filter is applied to the $value after it is loaded from the db, and before it is returned to the template
Method of the class: acf_field_wysiwyg{}
Hooks from the method
Returns
mixed. $value The modified value
Usage
$acf_field_wysiwyg = new acf_field_wysiwyg(); $acf_field_wysiwyg->format_value( $value, $post_id, $field, $escape_html );
- $value(mixed) (required)
- The value which was loaded from the database.
- $post_id(mixed) (required)
- The
$post_idfrom which the value was loaded. - $field(array) (required)
- The field array holding all the field options.
- $escape_html(true|false) (required)
- Should the field return a HTML safe formatted value.
Changelog
| Since 3.6 | Introduced. |
acf_field_wysiwyg::format_value() acf field wysiwyg::format value code ACF 6.8.8
public function format_value( $value, $post_id, $field, $escape_html ) {
// Bail early if no value or not a string.
if ( empty( $value ) || ! is_string( $value ) ) {
return $value;
}
if ( $escape_html ) {
add_filter( 'acf_the_content', 'acf_esc_html', 1 );
}
$value = apply_filters( 'acf_the_content', $value );
if ( $escape_html ) {
remove_filter( 'acf_the_content', 'acf_esc_html', 1 );
}
// Follow the_content function in /wp-includes/post-template.php
return str_replace( ']]>', ']]>', $value );
}