From f89fefe070bb3532c31f2e96a7c9d94248f66c29 Mon Sep 17 00:00:00 2001 From: Raymond Rutjes Date: Mon, 17 Jul 2017 13:32:46 +0200 Subject: [PATCH] fix(indexing): send un-escaped content to Algolia Closes: #615 --- includes/indices/class-algolia-posts-index.php | 7 +++++++ includes/indices/class-algolia-searchable-posts-index.php | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/includes/indices/class-algolia-posts-index.php b/includes/indices/class-algolia-posts-index.php index 3ad1703e..d4146f96 100644 --- a/includes/indices/class-algolia-posts-index.php +++ b/includes/indices/class-algolia-posts-index.php @@ -87,7 +87,14 @@ protected function get_records( $item ) { private function get_post_records( WP_Post $post ) { $shared_attributes = $this->get_post_shared_attributes( $post ); + $removed = remove_filter( 'the_content', 'wptexturize', 10 ); + $post_content = apply_filters( 'the_content', $post->post_content ); + + if ( $removed === true ) { + add_filter( 'the_content', 'wptexturize', 10 ); + } + $post_content = Algolia_Utils::prepare_content( $post_content ); $parts = Algolia_Utils::explode_content( $post_content ); diff --git a/includes/indices/class-algolia-searchable-posts-index.php b/includes/indices/class-algolia-searchable-posts-index.php index 491f0082..2e16baeb 100644 --- a/includes/indices/class-algolia-searchable-posts-index.php +++ b/includes/indices/class-algolia-searchable-posts-index.php @@ -77,7 +77,14 @@ protected function get_records( $item ) { private function get_post_records( WP_Post $post ) { $shared_attributes = $this->get_post_shared_attributes( $post ); + $removed = remove_filter( 'the_content', 'wptexturize', 10 ); + $post_content = apply_filters( 'the_content', $post->post_content ); + + if ( $removed === true ) { + add_filter( 'the_content', 'wptexturize', 10 ); + } + $post_content = Algolia_Utils::prepare_content( $post_content ); $parts = Algolia_Utils::explode_content( $post_content );