-
Notifications
You must be signed in to change notification settings - Fork 1
Getting Started
Ben Moore edited this page Jun 19, 2017
·
8 revisions
Once you have the WAR API plugin downloaded & activated you will want to start creating your own custom data models, and configuring the default options.
You must create a new plugin which will house all of your custom data model definitions, as well as configuration.
return [
'api_name' => 'war', // This is the namespace
'api_prefix' => 'wp-json', // Used to determine if request is a REST API request
'admin_toolbar' => false, // Turn off admin toolbar when user is logged in
'user_roles' => [], // TODO: associate user roles that have access to this data / api
'version' => 1, // Version which comes after the namespace in URL route
'permalink' => '/posts/%postname%/', // permalink for return
'default_access' => false // Default Access level for each endpoint (including CRUD endpoints),
'war_jwt_expire' => ( time() + ( DAY_IN_SECONDS * 30 ) ), // JSON Web Token will expire every 30 days
'isolate_user_data' => true // Only allow the user who created an item to see and edit that item
];
To change the config just pass an array back to the add_config
method.
This array only adjusts the default configurations specified, everything else will be left as default
$war_api = new War_Api();
$war_api->add_config( [
'api_prefix' => 'api',
'api_name' => 'new_name',
'version' => 1
]);
// API endpoint will be /api/new_name/v1