rest_api_default_filters

The timeline below displays how wordpress function rest_api_default_filters has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.5

/**
 * Registers the default REST API filters.
 *
 * Attached to the {@see 'rest_api_init'} action
 * to make testing and disabling these filters easier.
 *
 * @since 4.4.0
 */
function rest_api_default_filters()
{
    if (wp_is_serving_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');
}

WordPress Version: 5.6

/**
 * Registers the default REST API filters.
 *
 * Attached to the {@see 'rest_api_init'} action
 * to make testing and disabling these filters easier.
 *
 * @since 4.4.0
 */
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');
}

WordPress Version: 5.5

/**
 * Registers the default REST API filters.
 *
 * Attached to the {@see 'rest_api_init'} action
 * to make testing and disabling these filters easier.
 *
 * @since 4.4.0
 */
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);
}

WordPress Version: 4.9

/**
 * Registers the default REST API filters.
 *
 * Attached to the {@see 'rest_api_init'} action
 * to make testing and disabling these filters easier.
 *
 * @since 4.4.0
 */
function rest_api_default_filters()
{
    // 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');
    // 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);
}

WordPress Version: 4.4

/**
 * Registers the default REST API filters.
 *
 * Attached to the {@see 'rest_api_init'} action
 * to make testing and disabling these filters easier.
 *
 * @since 4.4.0
 */
function rest_api_default_filters()
{
    // 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');
    // 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_pre_dispatch', 'rest_handle_options_request', 10, 3);
}