wp-kit/rest-kit

A micro RAD solution for Wordpress REST API themes

1.1.1 2021-01-31 22:40 UTC

This package is not auto-updated.

Last update: 2024-12-16 17:17:00 UTC


README

rest-kit is a micro RAD solution for using Wordpress as a Headless CMS.

Installation

Download Composer and install using this command

cd wp-content/themes
composer create-project wp-kit/rest-kit rest-kit --prefer-dist

Working with Bedrock?

Firstly, install Bedrock, then;

composer require wp-kit/rest-kit
cp -r vendor/wp-kit/rest-kit web/app/themes
(rm ./package.json || true) && mv web/app/themes/rest-kit/package.json ./package.json
(rm ./webpack.config.js || true) && mv web/app/themes/rest-kit/webpack.config.js ./webpack.config.js

// inside webpack.config.js change the following
const themeFolder = './web/app/themes/rest-kit';

npm i
npm run build

When should you use wp-kit/rest-kit?

If you're looking for a framework to be able to build and manage custom Gutenberg blocks (both React style or with ACF Blocks) and want to manage how blocks looks and are styled in the editor and want to consume Gutenberg block data via Wordpress Rest API, and would like to easily register Post Types and Taxonomies and organise your code contextually within Controller and PostType/Taxonomy classes then this is a the perfect framework. Features include;

  • Webpack configuration to easily create / edit and style React-style Gutenberg blocks for the editor
  • Gutenberg Blocks are JSONified and send in WP REST API response for Posts (CPT) and Pages
  • ACF Blocks are easily registered via config and managed via view files for the editor
  • ServiceProvider Config
  • PostType Registration
  • Taxonomy Registration
  • Invoke Controllers on Conditions

Just want to get Blocks in WP REST Response?

One of the key features on rest-kit is that it outputs JSON Blocks, including ACF Blocks, for Posts and Pages in the API response under a property gblocks. This framework is great when you want to also add custom React-style blocks or register and manage ACF Blocks but if you don't need those features or feel rest-kit is too overkill for you, we have abstracted the JSON Blocks feature away into it's own plugin:

WP ACF Rest API Blocks

Recommended Plugins

We recommend the following plugins depending your use case:

Gists

Menu Endpoint

We have recently removed the Menu endpoint by default from the boilerplate code in favour of using WP Rest API V2 Menus. You can easily add this back:

Add Menu endpoint in wp-kit/rest-kit, if you don't want to use plugins/wp-rest-api-v2-menus

Adjusting Gutenberg JSON

We have recently pruned the transformation code right back so the schema of blocks received in the response is exactly the schema provided by parse_blocks(). You can change and transform this however you wish:

Adjusting Gutenberg Block output in REST Response

Get Involved

Any help is appreciated. The project is open-source and we encourage you to participate. You can contribute to the project in multiple ways by:

  • Reporting a bug issue
  • Suggesting features
  • Sending a pull request with code fix or feature
  • Following the project on GitHub
  • Sharing the project around your community

Requirements

Wordpress 5+

PHP 7.4+

Composer

Node

NPM

Security Vulnerabilities

If you discover a security vulnerability within wp-kit/rest-kit, please send an e-mail to tech@creativelittledots.co.uk or raise an issue on this repo. All security vulnerabilities will be promptly addressed.

License

wp-kit/rest-kit is open-sourced software licensed under the MIT License.