I have below code.echo $FileContents;
shows the page which comes the php variable correctly, but the escape function which is <?php esc_html( $FileContents ); ?>
didnt show anything.
How can I escape it correctly and show the page?
<?php global $redux_demo; ?>
<div class="row">
<div class="col-md-12 ulockd-mrgn1210">
<?php $FileContents = file_get_contents($redux_demo['text-location-service-details']); ?>
<?php echo $FileContents; ?>
<?php esc_html( $FileContents ); ?>
</div></div>
I have below code.echo $FileContents;
shows the page which comes the php variable correctly, but the escape function which is <?php esc_html( $FileContents ); ?>
didnt show anything.
How can I escape it correctly and show the page?
<?php global $redux_demo; ?>
<div class="row">
<div class="col-md-12 ulockd-mrgn1210">
<?php $FileContents = file_get_contents($redux_demo['text-location-service-details']); ?>
<?php echo $FileContents; ?>
<?php esc_html( $FileContents ); ?>
</div></div>
Share
Improve this question
asked Jun 16, 2020 at 2:50
Javascript Asking AccountJavascript Asking Account
51 bronze badge
1 Answer
Reset to default 0Well, esc_html()
doesn't echo/display the return value (escaped string), so you need to call echo
manually:
echo esc_html( $FileContents );
Update
If you actually want to filter the list of allowed HTML tags in the variable's value, then you can use the WordPress' KSES functions like wp_kses_post()
and wp_kses_data()
:
echo wp_kses_post( $FileContents );
echo wp_kses_data( $FileContents ); // allows basic HTML by default