Block Editing

Block Registration

For a block to show up in the WP editor, it needs to be registered properly.

/backend/plugins/gravity-platform-core/src/blocks/card/block.json
{
	"apiVersion": 2,
	"name": "gravity-platform-core/card",
	"version": "0.1.0",
	"title": "Card",
	"category": "gravity-platform",
	"icon": "building",
	"description": "Card",
	"supports": {
		"html": false
	},
	"textdomain": "gravity-platform-core",
	"editorScript": "file:../../../build/index.js",
	"editorStyle": "file:../../../build/main.css",
	"style": "file:../../../build/style-main.css"
}

In block.json

And in index.tsx

Adding Block Controls

To check progress on your block controls you will need to run npm run build in gravity/backend/plugins/gravity-platform-core

Block Editor Control Reference

great resource for block controls available from WP Core

Updating Block Attributes

Add attributes to index.tsx in: backend/plugins/gravity-platform-core/src/blocks/promotions/index.tsx

Updating With apiFetch

for the ACF API we have to add the fields attribute before we can get to the actual field attribute

Above is an example of the wp-json endpoint for ACF

Last updated

Was this helpful?