Skip to content

add_theme_support() disabled for some editor options on without theme.json or experimental-link-color support #34931

@chad1008

Description

@chad1008

Description

Introduced in #34334.

After the above change was merged (specific commit), themes that do not have a theme.json file or declare support for experimental-link-color will fail to load some plugin-based add_theme_support() calls. Calls from within the theme's functions.php file will still work as expected.

This applies specifically to custom-line-height, but may also be true for other options.

Step-by-step reproduction instructions

  1. Install and activate a theme that does not provide a theme.json file, nor declare support for experimental-link-color. I recommend Twenty Twenty for this test.
  2. Create a new post with at least one paragraph block. Select that block and note that the Line height option is not provided in the editor sidebar... this is expected, as the option is disabled by default.
  3. Install a plugin to add support for custom line height. The following bare-bones snippet should suffice as a basic plugin .php file:
<?php
/**
 * Plugin Name: Line Height Test
*/

function test_modify_theme_support() {
	add_theme_support( 'custom-line-height' );
}
add_action( 'after_setup_theme', 'test_modify_theme_support', 11 );

(note the priority of 11. It ensures your plugin is firing after the theme's declarations, which will be important in a minute...)

  1. Activate your plugin and refresh the editor. Note that the Line height option is still not provided.

Confirm your plugin is working:

  1. To confirm your plugin is working, add an image block. Note that option for wide width and full width are included under alignment. This is expected, as support for these options is declared by the theme.
  2. Edit your plugin to also declare remove_theme_support( 'align-wide' );
  3. Make sure you have the priority of your add_action set to 11 as shown above
  4. Reload the editor and confirm that you can no longer apply wide or full width alignments to image blocks.

You now have a plugin that can modify some theme_support parameters like align-wide but fails to modify specific ones like custom-line-height. Note this is theme specific, as described above, and only applies to themes that lack a theme.json file and do not declare support for experimental-link-color.

Expected outcome
Different options should be respected equally. In the above example, line height would activate alongside the removal of align-wide on TwentyTwenty.

Screenshots, screen recording, code snippet

No response

Environment info

WP 5.8.1, Gutenberg 11.5.0, with Twenty Twenty active.

2019 MacBook Pro, MacOS 11.5.2, Chrome 93.0.4577.63

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

Metadata

Metadata

Assignees

Labels

Global StylesAnything related to the broader Global Styles efforts, including Styles Engine and theme.json[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions