What’s new in Gutenberg? (28th November)

1.8 🐝

This release introduces several under the hood improvements to support more plugin opportunities — extending existing blocks, limiting blocks available, preventing a given meta-box from appearing in Gutenberg, etc — as well as allowing developers to specify templates, a list of predefined blocks. It also includes design iterations, mobile improvements, and initial work on a more rewarding publishing flow.

  • Introduce block-templates as a list of blocks specification. Allows a custom post type to define a pre-configured set of blocks to be render upon creation of a new item.
  • New tools menu design, preparing the way for more extensibility options.
  • Block API change: use simpler JS object notation for declaring attribute sources.
  • Add function to allow filtering allowed block types.
  • Show popovers full screen on mobile, improving several mobile interactions.
  • Began work on publishing flow improvements with an indication of publishing (or updating a published post) action by introducing a button state and label updates.
  • Made toolbar-by-block the default after different rounds of feedback and testing. Both options are still present.

Other changes

Example for how to provide a template in a CPT:

function register_book_type() {
	$args = array(
		'public' => true,
		'label'  => 'Books',
		'show_in_rest' => true,
		'template' => array(
			array( 'core/image' ),
			array( 'core/heading', array(
				'placeholder' => 'Author...',
			) ),
			array( 'core/paragraph', array(
				'placeholder' => 'Add book description...',
			) ),
	register_post_type( 'book', $args );
add_action( 'init', 'register_book_type' );

Coming to a WP-CLI near you

Soon you'll be able to quickly create a block using a command like wp scaffold block my-block --theme with WP-CLI. It'll setup a new block registration with the passed slug and theme (or plugin) as the namespace. This will all be added to the handbook.

#core-editor, #editor, #gutenberg