Skip to content
This repository was archived by the owner on Nov 21, 2025. It is now read-only.
This repository was archived by the owner on Nov 21, 2025. It is now read-only.

rest_alias property is very limiting - can't use DELETE/PUT #86

@calvinalkan

Description

@calvinalkan

It's not possible to create a rest alias for routes that use DELETE/PUT/PATCH.

For example, this rest_alias: 'rest_alias' => '/wp/v2/posts/(?P<id>[\d]+)',

Will always get matched to the "update route".

But the delete route for a post uses the same route pattern. But with a different method.

I think a feature needs an optional method property, that's also exposed in the rest api under /features

Relevant code parts below:

	/**
	 * Gets the REST method for the feature based on the feature type.
	 *
	 * @since 0.1.0
	 * @return string The REST method.
	 */
	public function get_rest_method() {
                // This would be new.
                if(this->method !== null) {
                   return $this->method;
                }

		if ( self::TYPE_TOOL === $this->type ) {
			return WP_REST_Server::CREATABLE;
		}

		return WP_REST_Server::READABLE;
	}
$method = $this->get_rest_method();

		foreach ( $routes[ $feature_route ] as $route_handler ) {
			$methods = array_keys( $route_handler['methods'] );
			if ( in_array( $method, $methods, true ) ) {
				return $route_handler;
			}
		}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions