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.
composer install
npm install
npm run dev
/ npm run build
I am adding docs to the WIKI
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
Data will be saved in a new database table [prefix]_gutes_arrays
I have included a filter to adda editor_block
to the normal post content response.
Includes 1 new route:
wp-json/gutes-db/v1/[post-id]
- Supports GET & POSTwp-json/gutes-db/v1/[post-id]/revisions
- Supports GET only GET: wp-json/gutes-db/v1/[post-id]
Returns
POST: wp-json/gutes-db/v1/[post-id]
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
clean_data_[hyphenated-block-name]
EXAMPLE
wp.hooks.addFilter( 'clean_data_core-paragraph', 'gutes-array', callback );
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
<?php get_editor_blocks( $post_id ); ?>
- returns array of block dataI 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.
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!