class Customise_WordPress {
function __construct($name) {
// Remove the REST API HTML entities.
$post_type = "post";
add_filter( 'rest_prepare_ . $post_type', array( $this, 'decode_rest_api_title' ), 20, 3 );
}
/**
* Decode HTML entities from the website title.
*
* @param string $response Actual response.
* @param Object $request Actual request.
* @param Object $post actual Post object.
*
* @return $response return text with decoded entirties.
*/
public function decode_rest_api_title( $response, $post, $request ) {
if ( isset( $post ) ) {
$decoded_title = html_entity_decode( $response->data['title']['rendered'] );
$response->data['title']['rendered'] = $decoded_title;
}
return $response;
}
}
Created
September 26, 2023 08:50
-
-
Save vanpariyar/95880b458a6110bb9f4d8c588cb4f119 to your computer and use it in GitHub Desktop.
Day to day customisation needed for code so making one plugin to reuse in every plugin
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://vanpariyar.in/blog/how-to-remove-html-entities-from-the-rest-api-title-and-content-in-wordpress/