Make WordPress Core


Ignore:
Timestamp:
03/11/2025 12:31:07 PM (14 months ago)
Author:
joemcgill
Message:

Themes: Fix resolution of parent themes.

This fixes an issue introduced in [59885] whereby calling WP_Theme:is_block_theme() before themes are set up resulted in the parent theme to not be resolved. To address this, post support for editor default-mode has been moved to a standalone callback, wp_set_editor_default_mode(), which is called on the after_setup_theme hook. In addition, if WP_Theme::is_block_theme is called too early, a _doing_it_wrong() error will now be thrown.

Props fabiankaegy, joemcgill, peterwilsoncc, jorbin, krupajnanda, riddhidave, ugyensupport, navi161, manojmaharrshi, Ankit K Gupta, narenin, shailu25, pooja1210.
Fixes #63062.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post.php

    r59885 r59968  
    6969        )
    7070    );
    71 
    72     // Enhance page editor for block themes by rendering template and content blocks.
    73     if ( wp_is_block_theme() && current_theme_supports( 'block-templates' ) ) {
    74         add_post_type_support( 'page', 'editor', array( 'default-mode' => 'template-locked' ) );
    75     }
    7671
    7772    register_post_type(
     
    85308525    );
    85318526}
     8527
     8528/**
     8529 * Sets the default editor mode based on support for block templates.
     8530 *
     8531 * @since 6.8.0
     8532 */
     8533function wp_set_editor_default_mode() {
     8534    if ( wp_is_block_theme() && current_theme_supports( 'block-templates' ) ) {
     8535        add_post_type_support( 'page', 'editor', array( 'default-mode' => 'template-locked' ) );
     8536    }
     8537}
Note: See TracChangeset for help on using the changeset viewer.