Check for Gutenberg

This snippet is useful when you are updating an older plugin and don’t want to break backwards compatibility for users on older versions of WordPress. This allows you to conditionally include Gutenberg blocks only if the appropriate Gutenberg core files are available.

* Checks to see if Gutenberg is set up on the site before attempting to load blocks
function myplugin_setup_blocks() {
   if(function_exists('register_block_type')) {
       require_once( plugin_dir_path( __FILE__ ) . 'blocks/my-block-slug.php');
add_action( 'plugins_loaded', 'myplugin_setup_blocks' );

In this example, blocks/my-block-slug.php is your block’s (or blocks’, if multiple) PHP loader file.

Above: Shiny Code ( )