diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php index 2bc2e61e4a..d143652dd8 100644 --- a/wp-includes/default-filters.php +++ b/wp-includes/default-filters.php @@ -588,6 +588,7 @@ add_action( 'wp_enqueue_scripts', 'wp_common_block_scripts_and_styles' ); add_action( 'wp_enqueue_scripts', 'wp_enqueue_classic_theme_styles' ); add_action( 'admin_enqueue_scripts', 'wp_localize_jquery_ui_datepicker', 1000 ); add_action( 'admin_enqueue_scripts', 'wp_common_block_scripts_and_styles' ); +add_action( 'enqueue_block_assets', 'wp_enqueue_classic_theme_styles' ); add_action( 'enqueue_block_assets', 'wp_enqueue_registered_block_scripts_and_styles' ); add_action( 'enqueue_block_assets', 'enqueue_block_styles_assets', 30 ); /* @@ -612,7 +613,6 @@ add_action( 'wp_print_scripts', 'wp_just_in_time_script_localization' ); add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' ); add_action( 'customize_controls_print_styles', 'wp_resource_hints', 1 ); add_action( 'admin_head', 'wp_check_widget_editor_deps' ); -add_filter( 'block_editor_settings_all', 'wp_add_editor_classic_theme_styles' ); // Global styles can be enqueued in both the header and the footer. See https://core.trac.wordpress.org/ticket/53494. add_action( 'wp_enqueue_scripts', 'wp_enqueue_global_styles' ); diff --git a/wp-includes/deprecated.php b/wp-includes/deprecated.php index a47e7015b1..97183f8647 100644 --- a/wp-includes/deprecated.php +++ b/wp-includes/deprecated.php @@ -6422,3 +6422,42 @@ function wp_create_block_style_variation_instance_name( $block, $variation ) { function current_user_can_for_blog( $blog_id, $capability, ...$args ) { return current_user_can_for_site( $blog_id, $capability, ...$args ); } + +/** + * Loads classic theme styles on classic themes in the editor. + * + * This is used for backwards compatibility for Button and File blocks specifically. + * + * @since 6.1.0 + * @since 6.2.0 Added File block styles. + * @deprecated 6.8.0 Styles are enqueued, not printed in the body element. + * + * @param array $editor_settings The array of editor settings. + * @return array A filtered array of editor settings. + */ +function wp_add_editor_classic_theme_styles( $editor_settings ) { + _deprecated_function( __FUNCTION__, '6.8.0', 'wp_enqueue_classic_theme_styles' ); + + if ( wp_theme_has_theme_json() ) { + return $editor_settings; + } + + $suffix = wp_scripts_get_suffix(); + $classic_theme_styles = ABSPATH . WPINC . "/css/classic-themes$suffix.css"; + + /* + * This follows the pattern of get_block_editor_theme_styles, + * but we can't use get_block_editor_theme_styles directly as it + * only handles external files or theme files. + */ + $classic_theme_styles_settings = array( + 'css' => file_get_contents( $classic_theme_styles ), + '__unstableType' => 'core', + 'isGlobalStyles' => false, + ); + + // Add these settings to the start of the array so that themes can override them. + array_unshift( $editor_settings['styles'], $classic_theme_styles_settings ); + + return $editor_settings; +} \ No newline at end of file diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index 63518ef5f9..f6fe4d648c 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -1662,6 +1662,10 @@ function wp_default_styles( $styles ) { $styles->add( 'wp-block-library-theme', "/$block_library_theme_path" ); $styles->add_data( 'wp-block-library-theme', 'path', ABSPATH . $block_library_theme_path ); + $classic_theme_styles_path = WPINC . "/css/classic-themes$suffix.css"; + $styles->add( 'classic-theme-styles', "/$classic_theme_styles_path" ); + $styles->add_data( 'classic-theme-styles', 'path', ABSPATH . $classic_theme_styles_path ); + $styles->add( 'wp-reset-editor-styles', "/wp-includes/css/dist/block-library/reset$suffix.css", @@ -3351,54 +3355,18 @@ function wp_enqueue_block_style( $block_name, $args ) { /** * Loads classic theme styles on classic themes in the frontend. * - * This is needed for backwards compatibility for button blocks specifically. + * This is used for backwards compatibility for Button and File blocks specifically. * * @since 6.1.0 + * @since 6.2.0 Added File block styles. + * @since 6.8.0 Moved stylesheet registration outside of this function. */ function wp_enqueue_classic_theme_styles() { if ( ! wp_theme_has_theme_json() ) { - $suffix = wp_scripts_get_suffix(); - wp_register_style( 'classic-theme-styles', '/' . WPINC . "/css/classic-themes$suffix.css" ); - wp_style_add_data( 'classic-theme-styles', 'path', ABSPATH . WPINC . "/css/classic-themes$suffix.css" ); wp_enqueue_style( 'classic-theme-styles' ); } } -/** - * Loads classic theme styles on classic themes in the editor. - * - * This is needed for backwards compatibility for button blocks specifically. - * - * @since 6.1.0 - * - * @param array $editor_settings The array of editor settings. - * @return array A filtered array of editor settings. - */ -function wp_add_editor_classic_theme_styles( $editor_settings ) { - if ( wp_theme_has_theme_json() ) { - return $editor_settings; - } - - $suffix = wp_scripts_get_suffix(); - $classic_theme_styles = ABSPATH . WPINC . "/css/classic-themes$suffix.css"; - - /* - * This follows the pattern of get_block_editor_theme_styles, - * but we can't use get_block_editor_theme_styles directly as it - * only handles external files or theme files. - */ - $classic_theme_styles_settings = array( - 'css' => file_get_contents( $classic_theme_styles ), - '__unstableType' => 'core', - 'isGlobalStyles' => false, - ); - - // Add these settings to the start of the array so that themes can override them. - array_unshift( $editor_settings['styles'], $classic_theme_styles_settings ); - - return $editor_settings; -} - /** * Removes leading and trailing _empty_ script tags. * diff --git a/wp-includes/version.php b/wp-includes/version.php index 53f9187a0c..589b5d3b3a 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.8-beta2-59979'; +$wp_version = '6.8-beta2-59980'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.