From 91167c488d23dfaec8cc8305a3178a0b0f67d976 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Wed, 6 Sep 2023 21:48:17 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@56529 git-svn-id: http://core.svn.wordpress.org/trunk@56041 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/default-filters.php | 3 +++ wp-includes/theme-previews.php | 21 +++++++++++++++------ wp-includes/version.php | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php index c08073326c..a3ea1537cb 100644 --- a/wp-includes/default-filters.php +++ b/wp-includes/default-filters.php @@ -532,6 +532,9 @@ add_action( 'admin_enqueue_scripts', '_wp_customize_loader_settings' ); add_action( 'delete_attachment', '_delete_attachment_theme_mod' ); add_action( 'transition_post_status', '_wp_keep_alive_customize_changeset_dependent_auto_drafts', 20, 3 ); +// Block Theme Previews. +add_action( 'plugins_loaded', 'initialize_theme_preview_hooks', 1 ); + // Calendar widget cache. add_action( 'save_post', 'delete_get_calendar_cache' ); add_action( 'delete_post', 'delete_get_calendar_cache' ); diff --git a/wp-includes/theme-previews.php b/wp-includes/theme-previews.php index e8e4a6a8c8..d3f5c631c9 100644 --- a/wp-includes/theme-previews.php +++ b/wp-includes/theme-previews.php @@ -75,10 +75,19 @@ function wp_block_theme_activate_nonce() {