Make WordPress Core

Changeset 56529

Timestamp:
09/06/2023 09:46:09 PM (11 months ago)
Author:
azaozz
Message:

Editor: Prevent possibility of a fatal error when previewing block themes.

Ensures that preview callbacks attached to the stylesheet and template filters do not run before pluggable.php has been included. These callbacks need functionality from pluggable.php.

Props: scruffian, johnbillion, SergeyBiryukov, okat, okat.
Fixes: #59000.

Location:
trunk
Files:
1 added
2 edited

Legend:

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

    r56500 r56529  
    533533add_action( 'transition_post_status', '_wp_keep_alive_customize_changeset_dependent_auto_drafts', 20, 3 );
    534534
     535
     536
     537
    535538// Calendar widget cache.
    536539add_action( 'save_post', 'delete_get_calendar_cache' );
  • trunk/src/wp-includes/theme-previews.php

    r56218 r56529  
    7676}
    7777
    78 // Attaches filters to enable theme previews in the Site Editor.
    79 if ( ! empty( $_GET['wp_theme_preview'] ) ) {
    80     add_filter( 'stylesheet', 'wp_get_theme_preview_path' );
    81     add_filter( 'template', 'wp_get_theme_preview_path' );
    82     add_action( 'init', 'wp_attach_theme_preview_middleware' );
    83     add_action( 'admin_head', 'wp_block_theme_activate_nonce' );
     78/**
     79 * Add filters and actions to enable Block Theme Previews in the Site Editor.
     80 *
     81 * The filters and actions should be added after `pluggable.php` is included as they may
     82 * trigger code that uses `current_user_can()` which requires functionality from `pluggable.php`.
     83 *
     84 * @since 6.3.2
     85 */
     86function initialize_theme_preview_hooks() {
     87    if ( ! empty( $_GET['wp_theme_preview'] ) ) {
     88        add_filter( 'stylesheet', 'wp_get_theme_preview_path' );
     89        add_filter( 'template', 'wp_get_theme_preview_path' );
     90        add_action( 'init', 'wp_attach_theme_preview_middleware' );
     91        add_action( 'admin_head', 'wp_block_theme_activate_nonce' );
     92    }
    8493}
Note: See TracChangeset for help on using the changeset viewer.