Skip to content
This repository has been archived by the owner on Jan 26, 2021. It is now read-only.

Commit

Permalink
feat(wp-pwa): add query to disable htmlPurifier
Browse files Browse the repository at this point in the history
  • Loading branch information
DAreRodz committed Oct 19, 2018
1 parent 586e6db commit b515d51
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions wp-pwa.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function add_id_to_gallery_images($html, $attachment_id) {
}

function add_custom_post_types_filters($post_type) {
add_filter('rest_prepare_' . $post_type, array($this, 'purify_html'), 9);
add_filter('rest_prepare_' . $post_type, array($this, 'purify_html'), 9, 3);
add_filter('rest_prepare_' . $post_type, array($this, 'add_latest_to_links'), 10);
add_filter('rest_prepare_' . $post_type, array($this, 'add_image_ids'), 10);
register_rest_field($post_type, 'latest',
Expand Down Expand Up @@ -300,7 +300,11 @@ function add_image_ids($data) {
return $data;
}

function purify_html($data) {
function purify_html($data, $post_type, $request) {
$disableHtmlPurifier = $request->get_param('disableHtmlPurifier');

if ($disableHtmlPurifier === 'true') return $data;

$data->data['title']['text'] =
strip_tags(html_entity_decode($data->data['title']['rendered']));
$data->data['excerpt']['text'] =
Expand Down

0 comments on commit b515d51

Please sign in to comment.