Add custom classes for blocks in editor based on custom attributes

You can do this with the editor.BlockListBlock filter. More info here. This allows you to do something like the following: const withCustomAttributeClass = createHigherOrderComponent( ( BlockListBlock ) => { return ( props ) => { const { attributes } = props; const { yourCustomAttribute } = attributes; const class = yourCustomAttribute ? ‘my_custom_class’ : ”; … Read more

Would Gutenberg be considered a PlugIn?

It’s slightly complicated. The default editor in WordPress is what’s properly called the “block editor”, but while this editor was being developed it was known as the “Gutenberg” project. The development on Gutenberg was done in the form of a plugin, which people could install for the purposes of testing and contributing. When WordPress 5.0 … Read more

Is it possible (safe) to create custom blocks using ES Next format?

Whatever issues you had that caused a block to be “killed” after editing was entirely unrelated to the two different methods of writing the block that you have outlined. Building a custom block using the following method (https://github.com/WordPress/gutenberg-examples/blob/master/03-editable/block.js) of attributes with the –es5 flag appears to be more stable in terms of backwards compatibility. If … Read more

Block background color not appearing on site

If you’re adding theme support for editor-color-palette then you need to add styles for those colours to your stylesheet. As documented: Themes are responsible for creating the classes that apply the colors in different contexts. Core blocks use “color” and “background-color” contexts. So to correctly apply “strong magenta” to all contexts of core blocks a … Read more

WordPress block editor embeds not working in theme (single.php)

That would be because they’re using oEmbed, not a shortcode. You should use the function the_content() to render the content of a post, as it applies all the things required to make embeds, shortcodes, etc work properly. If for some reason that’s not an option, you can apply the content filter. <?php echo apply_filters( ‘the_content’, … Read more

Block Controls not showing

Your edit function is just missing a [ and ], i.e. you forgot to actually return an array, like so: return ([ // add that [ <InspectorControls key=”lx-authors-block-setting” style={ { marginBottom:’40px’} }> … </InspectorControls>, <div className=”lx-authors-block wp-block” key=”container” style={{ backgroundColor: attributes.bgColor}}> … </div> ]); // and add that ] Or you could instead wrap the … Read more