Skip to content

REST Api ​

The RestApi service provides a way to register REST API routes in WordPress. To register routes you must use the api_routes configuration key in the plugin's configuration file.

Built-in routes ​

The framework provides some built-in routes that you can use to manage your plugin's functionality. These routes are:

  • OptionsRoute - A route to manage plugin options. This is required if you want to use the options panel provided by the framework.

More routes may be added in the future.

Registering routes ​

To register routes you must use the api_routes configuration key in the plugin's configuration file.

php
return [
    'api_routes' => [
        Sematico\Metapress\Api\OptionsRoute::class,
    ],
];

Creating custom routes ​

In order to create custom routes, you must create a class that implements the ApiControllerInterface and PluginAwareInterface interfaces.

The class must then provide a register_routes method. The method must then use the register_rest_route function to register the routes.

Please refer to the built-in routes for examples on how to create custom routes.