Make WordPress Core

Opened 4 months ago

Closed 3 months ago

Last modified 2 months ago

#65166 closed enhancement (fixed)

Editor: Hide Classic Block from the inserter

Reported by: tyxla Owned by: tyxla
Priority: normal Milestone: 7.1
Component: Editor Version:
Severity: normal Keywords: has-patch gutenberg-merge has-unit-tests
Cc: Focuses:

Description

This ticket tracks the backport of PHP files for the following Gutenberg update:

https://github.com/WordPress/gutenberg/pull/77911

We're hiding the Classic block in the block editor inserter by default.

We're also introducing a new wp_classic_block_supports_inserter filter that allows overriding that behavior globally or per post.

See https://github.com/WordPress/gutenberg/pull/77911 for the full context.

Change History (8)

This ticket was mentioned in PR #11712 on WordPress/wordpress-develop by @tyxla.


4 months ago
#1

Trac ticket: https://core.trac.wordpress.org/ticket/65166

This PR brings the changes from the following Gutenberg PR to core:

https://github.com/WordPress/gutenberg/pull/77911

## Description
We're hiding the Classic block in the block editor inserter by default.

We're also introducing a new wp_classic_block_supports_inserter filter that allows overriding that behavior globally or per post.

See: WordPress/gutenberg#74242

## Testing

  • Start writing a new post
  • Verify you don't see the Classic block in the inserter.
  • Open an existing post that contains a classic block (or a block) and confirm the Classic block renders correctly and is editable.
  • Put this in your code: add_filter( 'gutenberg_classic_block_supports_inserter', '__return_true' );. Alternatively, you can use this plugin to test it.
  • Verify you see the Classic block in the inserter.

#2 @audrasjb
4 months ago

Removing trunk version as this is not going to be shipped with WP 7.0 but in the next releases.

#3 @desrosj
4 months ago

  • Version trunk

Since this is an enhancement, there's no first version of WordPress this can be reproduced in. Removing trunk version.

I commented on the PR a suggestion, but the current proposed approach feels like a bit much to me.

@tyxla commented on PR #11712:


4 months ago
#4

Hmm, I'm not really fond of this approach.

Is it possible to add a supports_inserter or show_in_inserter argument for register_block_type()/WP_Block_Type_Registry->register()/WP_Block and register_block_type_from_metadata() instead?

That would:

  • emulate the similar pattern used in register_post_type() and register_taxonomy()
  • eliminating the need for this new function and filter entirely.
  • Still allows filtering through block_type_metadata, register_block_type_args, and other related filters.
  • Make it easier for custom blocks to also disable the inserter behavior.

The parallel to register_post_type() makes sense, but I don't think introducing supports_inserter as a public registration arg is a better alternative. We'd be adding (and committing to maintain) an API that we don't actually want to recommend for general use (especially considering there is already UI for that). The goal here is to phase the Classic block out, not to give every block a first-class "hide me from the inserter" knob.

A filter feels like the lighter touch: it scopes the escape hatch to this specific deprecation, and we can deprecate the filter itself once the Classic block is fully retired. A registration arg is much harder to walk back from.

#5 @tyxla
3 months ago

  • Owner set to tyxla
  • Resolutionfixed
  • Status newclosed

In 62546:

Editor: Hide Classic Block from inserter.

Hide the Classic block in the block editor inserter by default, since classic content is largely a legacy editing path and should not be surfaced as a primary insertion option.

Introduce a new wp_classic_block_supports_inserter filter that allows re-enabling the Classic block in the inserter, either globally or on a per-post basis.

Existing classic content (the core/freeform block) continues to render and remain editable; only its visibility in the inserter is affected.

This ports Gutenberg PR #77911 to Core.

Developed in: https://github.com/WordPress/wordpress-develop/pull/11712

Props desrosj, mamaduka, mukesh27, tyxla, westonruter, wildworks, yuliyan.
Fixes #65166.

This ticket was mentioned in PR #12416 on WordPress/wordpress-develop by @tyxla.


2 months ago
#6

  • Keywords has-unit-tests added

## What?

Reverts the Classic block inserter-hiding work introduced in [62546] (#65166).

The Classic (core/freeform) block is once again available in the inserter by default. This removes:

  • The wp_declare_classic_block_necessary() function and its enqueue_block_editor_assets action hook in script-loader.php / default-filters.php.
  • The wp_classic_block_supports_inserter filter (which never shipped in a WordPress release).
  • The associated PHPUnit tests in tests/phpunit/tests/dependencies/scripts.php.

## Why?

The Classic block deprecation / inserter-gating effort is being reverted. The corresponding Gutenberg change is reverted in https://github.com/WordPress/gutenberg/pull/79894. This PR keeps Core in sync by removing the backported PHP side.

Since the wp_classic_block_supports_inserter filter never made it into a WordPress release, it can be removed cleanly.

## How?

This is a straight revert of [62546] — all 100 added lines across three files are removed. No other code referenced the function or filter.

## Testing Instructions

  1. Open the block editor and open the inserter — the Classic block should be available.
  2. Confirm the window.__needsClassicBlock inline script is no longer printed on enqueue_block_editor_assets.
  3. Run the dependencies/scripts test suite — the removed wp_declare_classic_block_necessary tests should no longer exist and the suite should pass.

See #65166.

🤖 Generated with Claude Code

#7 @tyxla
2 months ago

In 62652:

Editor: Restore Classic block in the inserter.

Revert the Classic block inserter-hiding work introduced in [62546], so the
Classic (core/freeform) block is once again available in the inserter by
default.

This removes:

  • The wp_declare_classic_block_necessary() function and its enqueue_block_editor_assets action hook in script-loader.php and default-filters.php.
  • The wp_classic_block_supports_inserter filter, which never shipped in a WordPress release and can therefore be removed cleanly.
  • The associated PHPUnit tests in tests/phpunit/tests/dependencies/scripts.php.

This keeps Core in sync with the corresponding Gutenberg revert in
https://github.com/WordPress/gutenberg/pull/79894.

Props tyxla, youknowriad, mukesh27.
See #65166.

@tyxla commented on PR #12416:


2 months ago
#8

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 62652
GitHub commit: https://github.com/WordPress/wordpress-develop/commit/76f9763f2c6f0a0e26d96e2e54dccf4849342ff7

Note: See TracTickets for help on using tickets.