wordpress-base-plugin icon indicating copy to clipboard operation
wordpress-base-plugin copied to clipboard

Gutenberg solution

Open xeux opened this issue 4 years ago • 0 comments

In case anyone needs to add Gutenbergs blocks to the plugin:

  1. Create the folder "Gutenbergs".
  2. Create a file inside: Gutenbergs_Loader.php
  3. Create a file inside: MyGutenberg.php
  4. Change Plugin.php file.

Gutenbergs_Loader.php content:

<?php

namespace VendorName\PluginName\Gutenbergs;
use VendorName\PluginName\Plugin;

class Gutenbergs_Loader extends Plugin
{
	public function __construct()
	{
		new MyGutenberg();
	}
}

MyGutenberg.php content:

<?php

namespace VendorName\PluginName\Gutenbergs;
use VendorName\PluginName\Plugin;
use Carbon_Fields\Block;
use Carbon_Fields\Field;

class MyGutenberg extends Plugin {

  public function __construct() {
CARBON FIELDS BLOCK CODE

  }
}

https://docs.carbonfields.net/learn/containers/gutenberg-blocks.html

Plugin.php content // Load Gutenbergs new Gutenbergs\Gutenbergs_Loader(); at load_plugin()

xeux avatar Jul 08 '21 04:07 xeux