Skip to content

get_theme_support('align-wide') does not detect wide layout support when support is declared in theme.json #35330

@skorasaurus

Description

@skorasaurus

I am using block-unit-test; which conditionally outputs blocks on a page based on whether get_theme_support( 'align-wide' ) is true;

I am declaring support for full and wide blocks by defining settings.layout.contentSize and wideSize in theme.json instead of adding add_theme_support( ‘align-wide’ ); in my theme; this is now allowed in WP 5.8.

However, when I remove add_theme_support( ‘align-wide’ ) from my theme and solely rely on theme.json;
the blocks that should conditionally display when `get_theme_support( 'align-wide' ) is true do not display.

I've been able to replicate this on a vanilla wordpress install.
(Within the post editor, I am able to access wide and full widths of a block (e.g. core image block))

If there's another way in PHP to conditionally render blocks based on whether that support is declared in theme.json, that would be suitable.

Step-by-step reproduction instructions

  1. download twentytwentyone theme, comment out https://core.trac.wordpress.org/browser/trunk/src/wp-content/themes/twentytwentyone/functions.php?rev=51881#L124
  2. create a theme.json file - use this as the contents https://gist.github.com/skorasaurus/acda2ea50cf4e4b5581a05968bf7efeb

3a. Download query-monitor plugin and place the following into your theme:
$check_twelve = get_theme_support( 'align-wide' ); do_action( 'qm/debug', $check_twelve);

4a. go to the post editor, open query-monitor panel; the variable is false.

or can do a much longer way of this, skip 3a and 4a:

3b. download and then activate block-unit-test
Activating the plugin will automatically create a page of draft status ;
go to your draft, view the page and search for "Full width"; in the page content. You should find a block with that text content ; but you won't if you follow the above directions
If you use twentytwentyone without any modifications to the theme, and activate the block-unit-test plugin, the full-width blocks will be created as intended. (if you do this and have already activated block-unit-test , first deactivate the plugin, delete the page it drafted (and from trash as well), and then reactivate the plugin.

Screenshots, screen recording, code snippet

No response

Environment info

gutenberg 11.6

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

No one assigned

    Labels

    [Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions