https://github.com/codeinwp/wp-thememods-api
Helper plugin which allows setting up theme mods via REST API.
https://github.com/codeinwp/wp-thememods-api
Last synced: 10 months ago
JSON representation
Helper plugin which allows setting up theme mods via REST API.
- Host: GitHub
- URL: https://github.com/codeinwp/wp-thememods-api
- Owner: Codeinwp
- License: gpl-3.0
- Created: 2021-02-22T13:59:56.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2023-11-09T15:39:24.000Z (about 2 years ago)
- Last Synced: 2024-04-15T01:19:43.773Z (over 1 year ago)
- Language: PHP
- Size: 43.9 KB
- Stars: 1
- Watchers: 6
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# wp-thememods-api
Helper plugin which allows setting up theme mods via REST API.
#### Configuration
If you would like to restrict access to the endpoint you can define this constant `WPTHEMEMODS_SECRET`
with a passkey which can be sent along with the request as Bearer token.
When the constant is not present the endpoint has public access.
#### How to use
The endpoint is available at `wpthememods/v1/settings` and it receives a POST request with a JSON payload containg the theme mods to set.
#### Sample Code
```js
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({"neve_default_sidebar_layout":"full-width"});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("/wp-json/wpthememods/v1/settings", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
```
#### Disclaimer
**This plugin should not be used on production environments.**