mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@56529 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -75,10 +75,19 @@ function wp_block_theme_activate_nonce() {
|
||||
<?php
|
||||
}
|
||||
|
||||
// Attaches filters to enable theme previews in the Site Editor.
|
||||
if ( ! empty( $_GET['wp_theme_preview'] ) ) {
|
||||
add_filter( 'stylesheet', 'wp_get_theme_preview_path' );
|
||||
add_filter( 'template', 'wp_get_theme_preview_path' );
|
||||
add_action( 'init', 'wp_attach_theme_preview_middleware' );
|
||||
add_action( 'admin_head', 'wp_block_theme_activate_nonce' );
|
||||
/**
|
||||
* Add filters and actions to enable Block Theme Previews in the Site Editor.
|
||||
*
|
||||
* The filters and actions should be added after `pluggable.php` is included as they may
|
||||
* trigger code that uses `current_user_can()` which requires functionality from `pluggable.php`.
|
||||
*
|
||||
* @since 6.3.2
|
||||
*/
|
||||
function initialize_theme_preview_hooks() {
|
||||
if ( ! empty( $_GET['wp_theme_preview'] ) ) {
|
||||
add_filter( 'stylesheet', 'wp_get_theme_preview_path' );
|
||||
add_filter( 'template', 'wp_get_theme_preview_path' );
|
||||
add_action( 'init', 'wp_attach_theme_preview_middleware' );
|
||||
add_action( 'admin_head', 'wp_block_theme_activate_nonce' );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user