rest_filter_response_by_context example


    public function filter_response_by_context( $response_data$context ) {

        $schema = $this->get_item_schema();

        return rest_filter_response_by_context( $response_data$schema$context );
    }

    /** * Retrieves the item's schema, conforming to JSON Schema. * * @since 4.7.0 * * @return array Item schema data. */
    public function get_item_schema() {
        return $this->add_additional_fields_schema( array() );
    }

function rest_filter_response_by_context( $response_data$schema$context ) {
    if ( isset( $schema['anyOf'] ) ) {
        $matching_schema = rest_find_any_matching_schema( $response_data$schema, '' );
        if ( ! is_wp_error( $matching_schema ) ) {
            if ( ! isset( $schema['type'] ) ) {
                $schema['type'] = $matching_schema['type'];
            }

            $response_data = rest_filter_response_by_context( $response_data$matching_schema$context );
        }
    }

    if ( isset( $schema['oneOf'] ) ) {
        $matching_schema = rest_find_one_matching_schema( $response_data$schema, '', true );
        if ( ! is_wp_error( $matching_schema ) ) {
            if ( ! isset( $schema['type'] ) ) {
                $schema['type'] = $matching_schema['type'];
            }

            $response_data = rest_filter_response_by_context( $response_data$matching_schema$context );
        }
Home | Imprint | This part of the site doesn't use cookies.