WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/14/2016 03:49:37 PM (22 months ago)
Author:
joehoyle
Message:

REST API: Enable sanitize_callback to return WP_Error.

Give developers the opportunity to reject incoming data without using the validation callback. It also enables us to do sanitization and validation in one function in instances where this could be useful.

Props websupporter, rmccue.
Fixes #37560.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/class-wp-rest-server.php

    r38037 r38601  
    867867                    if ( is_wp_error( $check_required ) ) {
    868868                        $response = $check_required;
     869                    } else {
     870                        $check_sanitized = $request->sanitize_params();
     871                        if ( is_wp_error( $check_sanitized ) ) {
     872                            $response = $check_sanitized;
     873                        }
    869874                    }
    870 
    871                     $request->sanitize_params();
    872875                }
    873876
Note: See TracChangeset for help on using the changeset viewer.