• Stars
    star
    250
  • Rank 162,397 (Top 4 %)
  • Language
    PHP
  • License
    GNU General Publi...
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Saves Gutenberg data as an object / array and allows you to access it via REST API

Gutenberg Object Plugin

The purpose of this plugin is to save Gutenberg (New WordPress Editor) data as an array in the database which is accessible via the REST API.

Installation

  • Clone
  • Run composer install
  • Run npm install
  • npm run dev / npm run build
  • Activate plugin.

WIKI

I am adding docs to the WIKI

WHY

While the new UI for the WordPress Editor is amazing, the data as it is stored lends a lot ot be desired with HTML comments as a basis for data

WHERE

Data will be saved in a new database table [prefix]_gutes_arrays

REST API

I have included a filter to adda editor_block to the normal post content response.

API ENDPOINTS

Includes 1 new route:

  • wp-json/gutes-db/v1/[post-id] - Supports GET & POST
  • wp-json/gutes-db/v1/[post-id]/revisions - Supports GET only

GET

GET: wp-json/gutes-db/v1/[post-id] Returns

  • is_gutes: Is the post created with Gutenberg
  • post_id: Post ID
  • data: Gutenberg Data
  • _embedded['post']: optional with _embed - response from WP REST API for post

SAVE

POST: wp-json/gutes-db/v1/[post-id]

  • id - required - post ID
  • gutes_data - required - Data array

Hooks

To send the data to the API to save we must first transform data. Using wp.hooks You can tie into this process by adding a filter

  • namespace - 'gutes_array'
  • filter name - clean_data_[hyphenated-block-name]
  • data - data sent and returned is an array of the attributes

EXAMPLE
wp.hooks.addFilter( 'clean_data_core-paragraph', 'gutes-array', callback );

Adding editor_blocks to other CPT Responses

V 1.1.0+
Do you have another CPT (post type) that you are using Gutenberg with? Great! all you have to do is define GUTENBERG_OBJECT_PLUGIN_CPTS before rest_api_init with a comma separated list of CPTs.

add_action( 'init', 'my_custom_cpts', 10 );
function my_custom_cpts() {
    if ( ! defined( 'GUTENBERG_OBJECT_PLUGIN_CPTS' ) ) {
        define( 'GUTENBERG_OBJECT_PLUGIN_CPTS', 'product,page,other_cpt' );    
    }
}

Once GUTENBERG_OBJECT_PLUGIN_CPTS is defined as a comma separated list the editor_block data will apaper in that CPT's API response

Helper Functions

  • <?php get_editor_blocks( $post_id ); ?> - returns array of block data

Releases / Built Packages

I will try to create packaged releases if you are not comforatble with using composer, webpack, or npm and just want to try this plugin on your site.

Head over to the Releases to download a packaged zip that is ready to use.

Third Party Block Support

If you have a plugin that adds blocks, just create an issue with a link to the plugin and I'll try to add in support!

More Repositories

1

Angular-Wordpress-Theme

AngularJS Wordpress Theme - used for building single page client side applications using WordPress.
CSS
379
star
2

angularjs-for-wordpress

AngularJS for WordPress is a plugin to help anyone easily leverage AngularJS in their theme
PHP
123
star
3

angular-react-wordpress-theme

A WordPress theme built with AngularJS as the controller and ReactJS as the view layer. Powered by WP-API
JavaScript
70
star
4

wp-api-social-login

Using WP-API and Hello.js to create seamless login and registration via social channels
JavaScript
41
star
5

Stripe-for-WordPress

Manage your Stripe Customers, Subscriptions, and Products from WordPress Admin
PHP
39
star
6

wordpress-firebase-chat

Live Chat powered by Firebase
PHP
25
star
7

My-WordPress-Starter-Theme

A light, minimal, starter theme with bootstrap and gulp
PHP
25
star
8

WP-PHP-to-JS-cheatsheet

A cheat sheet if you are trying to learn JavaScript, starting from WordPress PHP
15
star
9

Guten-Bacon

Bacon Ipsum (www.baconipsum.com) Gutenberg Block for WordPress
JavaScript
13
star
10

Live-Visitor-Tracker

Track where your visitors on from the WordPress dashboard
PHP
11
star
11

live-notify-banner

WordPress plugin that allows for an alert banner that will animate down from the top of the page, and be live using webSockets (firebase)
CSS
9
star
12

gravity-forms-poll-top-picks

Gravity Forms is an awesome Wordpress plugin. Using the polls extension allows for more interaction with users. I wanted to a way to grab (in order) the top (5,10,etc.) results from the poll without looking at all the poll results.
PHP
4
star
13

gutes-object-upstream

Upstream for Gutes, Gutes Object Plugin, and Theme that does nothing but redirect to wp-json
PHP
4
star
14

WP-Rest-API-Taco-Endpoint

Because tacos!
PHP
3
star
15

SG-90

SG-90 Style Guide Creator - Formerly $39.99 - now FREE
CSS
2
star
16

gutenberg-react-quiz

Gutenberg based React build Quiz Plugin
JavaScript
2
star
17

is-today-bens-birthday

Is Today Ben's Birthday
TypeScript
1
star
18

SG-90-Google-Fonts

Google Fonts extension for the SG-90 Style Guide Creator
PHP
1
star
19

SG60-to-SG90-converter

Free SG-90 extension to help you convert your SG-60 styleguides to SG-90
PHP
1
star
20

wprtc-pro

wpRTC Pro WordPress plugin
JavaScript
1
star
21

qwik-supa-todo

Qwik & Supabase (Or localstore) powered To Do
TypeScript
1
star
22

MyHubot

Hubot
CoffeeScript
1
star
23

carl-2020

#Carl2020 - "Work More, Charge Less"
1
star
24

things-i-want-to-build

random ideas, if you take one, let me know! i'll post the link and help on any issues as I have time.
1
star
25

teckokua

A publicly built place where any one in the tech space can be featured for assistance, request assistance, or recommend someone else for assistance
TypeScript
1
star