Make WordPress Core

Opened 5 months ago

Last modified 2 months ago

#65272 accepted defect (bug)

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

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

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 5 months ago.
I have attached video for better understanding.
65272.patch​ (466 bytes ) - added by nidhidhandhukiya 5 months ago.

Change History (23)

@nidhidhandhukiya
5 months ago

I have attached video for better understanding.

#1 @sabernhardt
5 months ago

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

#2 @audrasjb
5 months ago

  • Version → trunk

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

#3 @audrasjb
5 months ago

  • Milestone Awaiting Review → 7.1
  • Version trunk

#4 follow-up: @sabernhardt
5 months ago

  • Component Bundled Theme → Script Loader
  • Milestone 7.1 → 7.0.1
  • Summary Twenty Fifteen: Quote block border is on the left when text is aligned right → Blocks' opinionated styles are not loading on demand in classic themes
  • Version → 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.


5 months 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
5 months 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:


5 months ago
#7

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

#8 @sabernhardt
5 months 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:


5 months 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
4 months ago

  • Owner set to westonruter
  • Status new → accepted

#11 @westonruter
4 months ago

Possible duplicate: #65353

#12 @sabernhardt
4 months ago

#65353 was marked as a duplicate.

#13 @miscwp
4 months 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?

#14 @sabernhardt
3 months ago

#65547 was marked as a duplicate.

#15 @masteradhoc
3 months ago

  • Milestone 7.0.1 → 7.0.2

As the RC for WP 7.0.1 is expected to land tomorrow we'll have to punt this to 7.0.2.

#16 @sabernhardt
3 months ago

  • Milestone 7.0.2 → 7.1

I'm switching this to the major release cycle. If it is completed in time and appropriate to backport, it can go back to 7.0.x.

#17 @westonruter
2 months ago

This is still on my radar. I haven't been able to dive into it yet.

This ticket was mentioned in ​Slack in #core by adrianduffell. ​View the logs.


2 months ago

#19 @adrianduffell
2 months ago

@westonruter Do you still plan for this in 7.1?

#20 @westonruter
2 months ago

Unfortunately, since we're up against the RC1 I think this has to be punted to 7.2 or at least a 7.1.x minor release. However, given that there is a workaround which can be enabled via the ​Load Combined Core Block Assets plugin, I think this is not critical.

#21 @westonruter
2 months ago

  • Milestone 7.1 → 7.2

And given the complexity of the stylesheet loading, this should land earlier in a cycle to soak longer.

Note: See TracTickets for help on using tickets.