The rest_api_default_filters WordPress PHP function registers the default REST API filters.
Usage
To use the function, simply call it within your WordPress code:
rest_api_default_filters();
Parameters
This function does not have any parameters.
More information
See WordPress Developer Resources: rest_api_default_filters
This function is attached to the rest_api_init
action.
Examples
Register default REST API filters
Register the default REST API filters by calling the rest_api_default_filters function.
// Register default REST API filters rest_api_default_filters();
Remove default REST API filters
To remove the default REST API filters, you can use the remove_action
function.
// Remove default REST API filters remove_action('rest_api_init', 'rest_api_default_filters');
Add custom filter after default REST API filters
Add a custom filter after the default REST API filters have been registered.
// Custom filter function function my_custom_rest_api_filter() { // Your filter code goes here } // Add custom filter after default REST API filters add_action('rest_api_init', 'my_custom_rest_api_filter', 15);
Replace default REST API filters with custom filters
Replace the default REST API filters with your own custom filters.
// Custom filters function function my_custom_rest_api_filters() { // Your custom filters code goes here } // Remove default REST API filters remove_action('rest_api_init', 'rest_api_default_filters'); // Add custom filters add_action('rest_api_init', 'my_custom_rest_api_filters');
Check if default REST API filters are registered
Determine if the default REST API filters are registered using the has_action
function.
// Check if default REST API filters are registered if (has_action('rest_api_init', 'rest_api_default_filters')) { echo "Default REST API filters are registered."; } else { echo "Default REST API filters are NOT registered."; }