Block Editor: Add a type property to allow Core to identify the source of the editor styles.
Gutenberg plugin need to override the editor styles provided by core selectively, this added property allows it to do so without committing to a public API. Props nosolosw, jorgefilipecosta. See #53175. Built from https://develop.svn.wordpress.org/trunk@51090 git-svn-id: http://core.svn.wordpress.org/trunk@50699 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
1516d05128
commit
446dd1768a
|
@ -131,7 +131,8 @@ $available_templates = ! empty( $available_templates ) ? array_merge(
|
|||
// Editor Styles.
|
||||
$styles = array(
|
||||
array(
|
||||
'css' => 'body { font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif }',
|
||||
'css' => 'body { font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif }',
|
||||
'__unstableType' => 'core',
|
||||
),
|
||||
);
|
||||
if ( $editor_styles && current_theme_supports( 'editor-styles' ) ) {
|
||||
|
@ -140,15 +141,17 @@ if ( $editor_styles && current_theme_supports( 'editor-styles' ) ) {
|
|||
$response = wp_remote_get( $style );
|
||||
if ( ! is_wp_error( $response ) ) {
|
||||
$styles[] = array(
|
||||
'css' => wp_remote_retrieve_body( $response ),
|
||||
'css' => wp_remote_retrieve_body( $response ),
|
||||
'__unstableType' => 'theme',
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$file = get_theme_file_path( $style );
|
||||
if ( is_file( $file ) ) {
|
||||
$styles[] = array(
|
||||
'css' => file_get_contents( $file ),
|
||||
'baseURL' => get_theme_file_uri( $style ),
|
||||
'css' => file_get_contents( $file ),
|
||||
'baseURL' => get_theme_file_uri( $style ),
|
||||
'__unstableType' => 'theme',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -283,10 +283,14 @@ function get_block_editor_settings( array $custom_settings, $block_editor_contex
|
|||
$theme_json = WP_Theme_JSON_Resolver::get_merged_data( $editor_settings );
|
||||
|
||||
if ( WP_Theme_JSON_Resolver::theme_has_support() ) {
|
||||
$editor_settings['styles'][] = array( 'css' => $theme_json->get_stylesheet( 'block_styles' ) );
|
||||
$editor_settings['styles'][] = array(
|
||||
'css' => $theme_json->get_stylesheet( 'block_styles' ),
|
||||
'__unstableType' => 'globalStyles',
|
||||
);
|
||||
$editor_settings['styles'][] = array(
|
||||
'css' => $theme_json->get_stylesheet( 'css_variables' ),
|
||||
'__experimentalNoWrapper' => true,
|
||||
'__unstableType' => 'globalStyles',
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -50,21 +50,25 @@ function render_block_core_legacy_widget( $attributes ) {
|
|||
}
|
||||
|
||||
/**
|
||||
* On application init this does two things:
|
||||
*
|
||||
* - Registers the 'core/legacy-widget' block.
|
||||
* - Intercepts any request with legacy-widget-preview in the query param and,
|
||||
* if set, renders a page containing a preview of the requested Legacy Widget
|
||||
* block.
|
||||
* Registers the 'core/legacy-widget' block.
|
||||
*/
|
||||
function init_legacy_widget_block() {
|
||||
function register_block_core_legacy_widget() {
|
||||
register_block_type_from_metadata(
|
||||
__DIR__ . '/legacy-widget',
|
||||
array(
|
||||
'render_callback' => 'render_block_core_legacy_widget',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
add_action( 'init', 'register_block_core_legacy_widget' );
|
||||
|
||||
/**
|
||||
* Intercepts any request with legacy-widget-preview in the query param and, if
|
||||
* set, renders a page containing a preview of the requested Legacy Widget
|
||||
* block.
|
||||
*/
|
||||
function handle_legacy_widget_preview_iframe() {
|
||||
if ( empty( $_GET['legacy-widget-preview'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
@ -110,4 +114,7 @@ function init_legacy_widget_block() {
|
|||
exit;
|
||||
}
|
||||
|
||||
add_action( 'init', 'init_legacy_widget_block' );
|
||||
// Ensure handle_legacy_widget_preview_iframe() is called after Core's
|
||||
// register_block_core_legacy_widget() (priority = 10) and after Gutenberg's
|
||||
// register_block_core_legacy_widget() (priority = 20).
|
||||
add_action( 'init', 'handle_legacy_widget_preview_iframe', 21 );
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.8-alpha-51089';
|
||||
$wp_version = '5.8-alpha-51090';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue