rest_api_default_filters() WordPress Function
The rest_api_default_filters() function allows you to specify which filters should be applied to the data returned by the WordPress REST API. By default, the REST API will return all public data for a given resource. However, if you want to restrict the data that is returned, you can use this function to specify which filters should be applied.
rest_api_default_filters() #
Registers the default REST API filters.
Description
Attached to the ‘rest_api_init’ action to make testing and disabling these filters easier.
Source
File: wp-includes/rest-api.php
function rest_api_default_filters() { if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) { // Deprecated reporting. add_action( 'deprecated_function_run', 'rest_handle_deprecated_function', 10, 3 ); add_filter( 'deprecated_function_trigger_error', '__return_false' ); add_action( 'deprecated_argument_run', 'rest_handle_deprecated_argument', 10, 3 ); add_filter( 'deprecated_argument_trigger_error', '__return_false' ); add_action( 'doing_it_wrong_run', 'rest_handle_doing_it_wrong', 10, 3 ); add_filter( 'doing_it_wrong_trigger_error', '__return_false' ); } // Default serving. add_filter( 'rest_pre_serve_request', 'rest_send_cors_headers' ); add_filter( 'rest_post_dispatch', 'rest_send_allow_header', 10, 3 ); add_filter( 'rest_post_dispatch', 'rest_filter_response_fields', 10, 3 ); add_filter( 'rest_pre_dispatch', 'rest_handle_options_request', 10, 3 ); add_filter( 'rest_index', 'rest_add_application_passwords_to_index' ); }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
4.4.0 | Introduced. |