Update to content only editing filter namespace

This dev notedev note Each important change in WordPress Core is documented in a developers note, (usually called dev note). Good dev notes generally include a description of the change, the decision that led to this change, and a description of how developers are supposed to work with that change. Dev notes are published on Make/Core blog during the beta phase of WordPress release cycle. Publishing dev notes is particularly important when plugin/theme authors and WordPress developers need to be aware of those changes.In general, all dev notes are compiled into a Field Guide at the beginning of the release candidate phase. is a follow up to a previous dev note: Content only editing and other locking updates.

The GutenbergGutenberg The Gutenberg project is the new Editor Interface for WordPress. The editor improves the process and experience of creating new content, making writing rich content much simpler. It uses ‘blocks’ to add richness rather than shortcodes, custom HTML etc. https://wordpress.org/gutenberg/ PR, #43037, which introduced the feature, added a filterFilter Filters are one of the two types of Hooks https://codex.wordpress.org/Plugin_API/Hooks. They provide a way for functions to modify data of other functions. They are the counterpart to Actions. Unlike Actions, filters are meant to work in an isolated manner, and should never have side effects such as affecting global variables and output. hook with the same namespace ('core/style/with-block-controls') as an existing filter hook that implements block support style controls.

addFilter(
	'editor.BlockEdit',
	'core/style/with-block-controls',
	withBlockControls
);

The risk of having two hooksHooks In WordPress theme and development, hooks are functions that can be applied to an action or a Filter in WordPress. Actions are functions performed when a certain event occurs in WordPress. Filters allow you to modify certain functions. Arguments used to hook both filters and actions look the same. with the same namespace is that any attempt to remove the filter will, possibly unintentionally, affect them both.

removeFilter( 'editor.BlockEdit', 'core/style/with-block-controls' );

The Block Editor documentation states the following:

One notable difference between the JSJS JavaScript, a web scripting language typically executed in the browser. Often used for advanced user interfaces and behaviors. and PHPPHP The web scripting language in which WordPress is primarily architected. WordPress requires PHP 5.6.20 or higher hooks APIAPI An API or Application Programming Interface is a software intermediary that allows programs to interact with each other and share data in limited, clearly defined ways. is that in the JS version, addAction() and addFilter() also need to include a namespace as the second argument. Namespace uniquely identifies a callback in the form vendor/pluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party/function.

A subsequent Gutenberg PR #46344 has renamed the filter hook namespace for the content lock filter hook to 'core/content-lock-ui/with-block-controls'. This now makes the namespace unique within the context of the BlockBlock Block is the abstract term used to describe units of markup that, composed together, form the content or layout of a webpage using the WordPress editor. The idea combines concepts of what in the past may have achieved with shortcodes, custom HTML, and embed discovery into a single consistent API and user experience. Editor.

addFilter(
	'editor.BlockEdit',
	'core/content-lock-ui/with-block-controls',
	withBlockControls
);

No functionality has been affected. The change will ship with Gutenberg 14.8.

Props to @talldanwp for technical assistance and @milana_cap, @aaronrobertshaw and @andrewserong for reviewing.

#6-2, #dev-notes, #dev-notes-6-2, #gutenberg