New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor: Rename all the hooks moved from blocks to editor #7410

Merged
merged 4 commits into from Jun 21, 2018

Conversation

Projects
None yet
2 participants
@gziolo
Member

gziolo commented Jun 20, 2018

Description

We recently moved almost all components from blocks module to `editor module. We didn't update the names of all filters and it looks like we should do it for consistency and easier discoverability.

This PR fixes it by renaming the following filters and expanding documentation:

  • blocks.Autocomplete.completers -> editor.Autocomplete.completers
  • blocks.BlockEdit -> editor.BlockEdit
  • blocks.BlockListBlock -> editor.BlockListBlock
  • blocks.MediaUpload -> editor.MediaUpload

TODO

  • Forwarding and deprecation warnings when someone is using old hooks
  • Update deprecation changelog

How has this been tested?

I made sure that:

  • you are able to use advanced controls for all blocks (custom class name or anchor)
  • blocks that use align feature are still properly aligned in the editor
  • it is still possible to upload media using the library
  • slash autocompleter still works

To test deprecations and doc changes at once. Paste the following snippet which got updated to use old hook:

var el = wp.element.createElement;

var withInspectorControls = wp.element.createHigherOrderComponent( function( BlockEdit ) {
	return function( props ) {
		return el(
			wp.element.Fragment,
			{},
			el(
				BlockEdit,
				props
			),
			el(
				wp.editor.InspectorControls,
				{},
				el(
					wp.components.PanelBody,
					{},
					'My custom control'
				)
			)
		);
	};
}, 'withInspectorControls' );

wp.hooks.addFilter( 'blocks.BlockEdit', 'my-plugin/with-inspector-controls', withInspectorControls );

Made sure it still works and deprecation message appears on the JS console:

screen shot 2018-06-20 at 16 07 24

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

@gziolo gziolo added this to the 3.1 milestone Jun 20, 2018

@gziolo gziolo self-assigned this Jun 20, 2018

@gziolo gziolo requested review from youknowriad, brandonpayton and WordPress/gutenberg-core Jun 20, 2018

@gziolo gziolo changed the title from [WIP] Editor: Rename all the hooks moved from blocks to editor to Editor: Rename all the hooks moved from blocks to editor Jun 20, 2018

@youknowriad

LGTM 👍

@gziolo gziolo merged commit a72a745 into master Jun 21, 2018

2 checks passed

codecov/project 46.87% (+<.01%) compared to 657c368
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@gziolo gziolo deleted the update/editor-hooks branch Jun 21, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment