WordPress filter hook · part of WordPress core

rest_json_encode_options

A WordPress core filter that 6 plugins also fire themselves, running on 9,020+ sites between them.

How to use rest_json_encode_options

It's a filter: your callback receives the value and 1 more argument, and must return the (changed) value. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_filter( 'rest_json_encode_options', function( $options, $request ) {
	// Change $options here.
	return $options;
}, 10, 2 );

Argument names come from MapSVG's source. Other plugins may pass different values: check the call in the plugin you're targeting below.

This hook is fired by WordPress core too. Official reference on developer.wordpress.org →

6 plugins that fire rest_json_encode_options

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. ووسلام icon ووسلام7,000+ installs apply_filters( 'rest_json_encode_options', $request->has_param('_pretty') ? JSON_PRETTY_PRINT : 0, $request ) includes/Services/MonitoringDiagnostics.php:38
  2. MapSVG icon MapSVG2,000+ installs apply_filters( 'rest_json_encode_options', $options, $request ) php/Integration/RestResponseJsonEncoder.php:20
  3. WebToffee Universal Commerce Protocol Enabler for Woocommerce icon WebToffee Universal Commerce Protocol Enabler for Woocommerce10+ installs apply_filters( 'rest_json_encode_options', $options, $request ) public/class-webtoffee-ucp-enabler-for-woocommerce-public.php:393
  4. Dropleather for WooCommerce icon Dropleather for WooCommerce10+ installs apply_filters( 'rest_json_encode_options', $flags, $request ) includes/class-dropleather-export-bridge.php:164
  5. Live Visitor Analytics icon Live Visitor AnalyticsFewer than 10 installs apply_filters( 'rest_json_encode_options', 0, $request ) includes/class-pqanalytics-fast.php:206
  6. Kibi Forms icon Kibi FormsFewer than 10 installs apply_filters( 'rest_json_encode_options', $request->has_param( '_pretty' ) ? JSON_PRETTY_PRINT : 0, $request ) includes/class-delivery.php:116

Need a customisation built on this hook?

Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.