Skip to content

[Bug]: Force rewrite title not working with block-library #23150

@pkodicek

Description

@pkodicek

Prerequisites

  • I've read and understood the contribution guidelines.
  • I've searched for any related issues and avoided creating a duplicate issue.

Please give us a description of what happened

There's an issue with the Force_Rewrite_Title class. Gutenberg seems to add inline styles after wp_footer hook, e.g. global-inline-styles-css. In Force_Rewrite_Title class everything between template_redirect hook and wp_footer is considered for ouput, which fails for content included after wp_footer, e.g. gutenberg inline styles.

Possible solution:
replace
\add_action( 'wp_footer', [ $this, 'flush_cache' ], -1 );
with
\add_action( 'shutdown', [ $this, 'flush_cache' ], -1 );
in
register_hooks()

While almost all modern themes have theme_support('title-tag') enabled, this does not need to be with custom themes and might lead to some strange behaviour.

Step-by-step reproduction instructions

  1. Create custom theme without add_theme_support('title-tag')
  2. Enable yoast setting "force rewrite title"
  3. Create a page with a core/columns block with two or more columns
  4. In frontend columns styles are not as supposed

Expected results

  1. yoast should not skip gutenberg's inline styles while replacing title tag

Actual results

  1. yoast "removes" gutenberg's inline styles

Screenshots, screen recording, code snippet

No response

Which editor is affected (or editors)

  • Block Editor
  • Gutenberg Editor
  • Elementor Editor
  • Classic Editor
  • Other (please specify in additional info)

Which browser is affected (or browsers)

  • Chrome
  • Firefox
  • Safari
  • Other (please specify in additional info)

Device you are using

All

Operating system

All

PHP version

All

WordPress version

e.g. 6.9.4

WordPress Theme

Any theme without add_theme_support('title-tag')

Yoast SEO version

e.g. 27.3

Gutenberg plugin version (if relevant)

No response

Elementor plugin version (if relevant)

No response

Classic Editor plugin version (if relevant)

No response

Relevant plugins in case of a bug

Yoast SEO

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions