Make WordPress Core

Opened 4 weeks ago

Last modified 4 days ago

#65272 accepted defect (bug)

Blocks' opinionated styles are not loading on demand in classic themes

Reported by: nidhidhandhukiya's profile nidhidhandhukiya Owned by: westonruter's profile westonruter
Milestone: 7.0.1 Priority: normal
Severity: normal Version: 7.0
Component: Script Loader Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

Steps to Reproduce the issue :-

  1. Install WordPress 7.0 RC4
  2. Activate Twenty Fifteen theme.
  3. Take Quote block.
  4. Choose Text alignment right and align left.

You can able to see editor side it works fine but front side text is aligned right but border remains same left aligned which is not okay if text is aligned right.

Attachments (2)

Screen Recording 2026-05-19 at 8.09.59 PM.mov (6.5 MB) - added by nidhidhandhukiya 4 weeks ago.
I have attached video for better understanding.
65272.patch (466 bytes) - added by nidhidhandhukiya 4 weeks ago.

Change History (15)

@nidhidhandhukiya
4 weeks ago

I have attached video for better understanding.

#1 @sabernhardt
4 weeks ago

  • Summary changed from Twenty Fifteen - Quote block issue with border with latest wordpress update. to Twenty Fifteen: Quote block border is on the left when text is aligned right
  • Version trunk deleted

#2 @audrasjb
4 weeks ago

  • Version set to trunk

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

#3 @audrasjb
4 weeks ago

  • Milestone changed from Awaiting Review to 7.1
  • Version trunk deleted

#4 follow-up: @sabernhardt
4 weeks ago

  • Component changed from Bundled Theme to Script Loader
  • Milestone changed from 7.1 to 7.0.1
  • Summary changed from Twenty Fifteen: Quote block border is on the left when text is aligned right to Blocks' opinionated styles are not loading on demand in classic themes
  • Version set to trunk

This bug is new to 7.0, but not with the theme(s).

The Quote block border issue can happen in Twenty Fifteen and Twenty Nineteen. However, the theme.css for individual blocks such as Quote, Search, etc., are not loading.

I can temporarily correct the behavior by

  1. adding wp_load_classic_theme_block_styles_on_demand on the init action, as it was before [61981], or
  2. disabling the should_load_separate_core_block_assets filter and loading the full wp-block-library-theme stylesheet.

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


4 weeks ago
#5

  • Keywords has-patch has-unit-tests added

## What

Restores the init priority 8 hook for wp_load_classic_theme_block_styles_on_demand() while keeping the wp_default_styles priority 0 hook added in [61981]. Adds guards so filters and actions are not registered twice when the function runs from both hooks.

## Why

In WordPress 7.0, commit 61981 moved wp_load_classic_theme_block_styles_on_demand() from init priority 8 to wp_default_styles priority 0 only. That introduced a regression (#65272):

  1. register_core_block_style_handles() runs at init priority 9.
  2. It checks wp_should_load_separate_core_block_assets() before calling wp_styles().
  3. With only the wp_default_styles hook, those filters are not added until WP_Styles is first constructed.
  4. register_core_block_style_handles() returns early, so per-block opinionated styles (blocks/*/theme.css, e.g. wp-block-quote-theme) are never registered or enqueued on the frontend.

Symptom: In classic themes with wp-block-styles support (e.g. Twenty Fifteen), Quote block right alignment works in the editor but the border stays on the left on the frontend because theme.css never loads.

The wp_default_styles hook remains so filters are still present when WP_Styles is constructed before init priority 9 (#64846).

## How

  • Re-add add_action( 'init', 'wp_load_classic_theme_block_styles_on_demand', 8 ) in default-filters.php.
  • Keep add_action( 'wp_default_styles', 'wp_load_classic_theme_block_styles_on_demand', 0 ).
  • Use has_filter() / has_action() before adding hooks to avoid duplicate registration.
  • Add regression test: Tests_Blocks_ClassicThemeBlockStylesOnDemand::test_register_core_block_style_handles_without_prior_wp_styles.

#6 in reply to: ↑ 4 @westonruter
4 weeks ago

Replying to sabernhardt:

I can temporarily correct the behavior by

  1. adding wp_load_classic_theme_block_styles_on_demand on the init action, as it was before [61981], or

Right, the change in r61981 was done intentionally, so reverting it will break something else. See #64846.

We'll need to figure something else for this.

@westonruter commented on PR #11887:


4 weeks ago
#7

Does this cause a regression in what r61981 was committed to fix Core-64846?

#8 @sabernhardt
4 weeks ago

I was able to get the individual theme.css stylesheets again by changing the priority for register_core_block_style_handles from 9 to the default 10, but I do not know what else that changes.
add_action( 'init', 'register_core_block_style_handles', 10 );

@khokansardar commented on PR #11887:


4 weeks ago
#9

Does this cause a regression in what r61981 was committed to fix Core-64846?

Thanks @westonruter — good catch on has_filter() / has_action() returning priority 0, which is falsy. Updated all four checks to use false ===.

Re #64846: this should not regress r61981 because the wp_default_styles priority 0 hook is retained. That hook ensures filters are present when WP_Styles is constructed before init priority 9, so wp-block-library still registers as common.css.

#10 @westonruter
3 weeks ago

  • Owner set to westonruter
  • Status changed from new to accepted

#11 @westonruter
3 weeks ago

Possible duplicate: #65353

#12 @sabernhardt
3 weeks ago

#65353 was marked as a duplicate.

#13 @miscwp
4 days ago

I would like to ask if you can give an ETA for a fix (https://github.com/WordPress/wordpress-develop/pull/11887 – ?) and update?

Note: See TracTickets for help on using tickets.