Skip to content
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

gziolo
Copy link
Member

@gziolo 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 [Feature] Extensibility The ability to extend blocks or the editing experience [Type] Code Quality Issues or PRs that relate to code quality labels Jun 20, 2018
@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 a team June 20, 2018 13:06
@gziolo gziolo added the [Status] In Progress Tracking issues with work in progress label Jun 20, 2018
@gziolo gziolo removed the [Status] In Progress Tracking issues with work in progress label Jun 20, 2018
@gziolo gziolo changed the title [WIP] Editor: Rename all the hooks moved from blocks to editor Editor: Rename all the hooks moved from blocks to editor Jun 20, 2018
Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Extensibility The ability to extend blocks or the editing experience [Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants