graphql_html_entity_decoding_enabled

Given a string, and optional context, this decodes html entities if html_entity_decode is enabled

apply_filters( 'graphql_html_entity_decoding_enabled', boolean $enabled, string $string, string $field_name, \WPGraphQL\Model\Model $model );

Params

  • $enabled (string): Whether html_entity_decode should be applied to the string passed through the \WPGraphQL\Utils::html_entity_decode method.
  • $string (string): The string being passed through for possible decoding
  • $field_name (string): The field name being passed through for posible decoding
  • $model (\WPGraphQL\Model\Model): The Model that is being affected

Examples

Below are some examples showing how to use the graphql_html_entity_decoding_enabled filter.

Disable html_entity_decoding for all fields

This disables decoding for all fields it’s applied to:

add_filter( 'graphql_html_entity_decoding_enabled', '__return_false' );

Enable html_entity_decoding for all fields

This enables decoding for all fields it’s applied to:

add_filter( 'graphql_html_entity_decoding_enabled', '__return_true' );

Enable html_entity_decoding for a specific field

add_filter( 'graphql_html_entity_decoding_enabled', function( $enabled, $string, $field_name, $model ) {
        // Enable for the 'content' field on the 
	if ( $model instanceof \WPGraphQL\Model\Post && 'contentRendered' === $field_name ) {
		return true;
	}
	
	return $enabled;

}, 10, 4 );