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

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

Closed
chad1008 opened this issue Sep 17, 2021 · 1 comment · Fixed by #34955
Assignees
Labels
Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@chad1008
Copy link
Contributor

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

@chad1008 chad1008 changed the title add_theme_support() disabled for some editor options on without theme.json or experimental-link-color suppot add_theme_support() disabled for some editor options on without theme.json or experimental-link-color support Sep 17, 2021
@oandregal oandregal self-assigned this Sep 20, 2021
@oandregal oandregal added [Type] Bug An existing feature does not function as intended Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Sep 20, 2021
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Sep 20, 2021
@oandregal
Copy link
Member

Fix for this at #34955

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants