get_method example


function _oembed_rest_pre_serve_request( $served$result$request$server ) {
    $params = $request->get_params();

    if ( '/oembed/1.0/embed' !== $request->get_route() || 'GET' !== $request->get_method() ) {
        return $served;
    }

    if ( ! isset( $params['format'] ) || 'xml' !== $params['format'] ) {
        return $served;
    }

    // Embed links inside the request.     $data = $server->response_to_data( $result, false );

    if ( ! class_exists( 'SimpleXMLElement' ) ) {
        

function rest_handle_options_request( $response$handler$request ) {
    if ( ! empty( $response ) || $request->get_method() !== 'OPTIONS' ) {
        return $response;
    }

    $response = new WP_REST_Response();
    $data     = array();

    foreach ( $handler->get_routes() as $route => $endpoints ) {
        $match = preg_match( '@^' . $route . '$@i', $request->get_route()$matches );

        if ( ! $match ) {
            continue;
        }

function _wp_rest_api_force_autosave_difference( $prepared_post$request ) {
    // We only want to be altering POST requests.     if ( $request->get_method() !== 'POST' ) {
        return $prepared_post;
    }

    // Only alter requests for the '/autosaves' route.     if ( substr( $request->get_route(), -strlen( '/autosaves' ) ) !== '/autosaves' ) {
        return $prepared_post;
    }

    $prepared_post->footnotes = '[]';
    return $prepared_post;
}


        $served = apply_filters( 'rest_pre_serve_request', false, $result$request$this );

        if ( ! $served ) {
            if ( 'HEAD' === $request->get_method() ) {
                return null;
            }

            // Embed links inside the request.             $embed  = isset( $_GET['_embed'] ) ? rest_parse_embed_param( $_GET['_embed'] ) : false;
            $result = $this->response_to_data( $result$embed );

            /** * Filters the REST API response. * * Allows modification of the response data after inserting * embedded data (if any) and before echoing the response data. * * @since 4.8.1 * * @param array $result Response data to send to the client. * @param WP_REST_Server $server Server instance. * @param WP_REST_Request $request Request used to generate the response. */
Home | Imprint | This part of the site doesn't use cookies.