| 1 |
<?php |
| 2 |
/** |
| 3 |
* Loads the default editor styles. |
| 4 |
* |
| 5 |
* @package gutenberg |
| 6 |
*/ |
| 7 |
|
| 8 |
/** |
| 9 |
* Load the default editor styles. |
| 10 |
* These styles are used if the "no theme styles" options is triggered |
| 11 |
* or on themes without their own editor styles. |
| 12 |
* |
| 13 |
* @param array $settings Default editor settings. |
| 14 |
* |
| 15 |
* @return array Filtered editor settings. |
| 16 |
*/ |
| 17 |
function gutenberg_extend_block_editor_settings_with_default_editor_styles( $settings ) { |
| 18 |
$default_editor_styles_file = gutenberg_dir_path() . 'build/block-editor/default-editor-styles.css'; |
| 19 |
$settings['defaultEditorStyles'] = array( |
| 20 |
array( |
| 21 |
'css' => file_get_contents( $default_editor_styles_file ), |
| 22 |
), |
| 23 |
); |
| 24 |
|
| 25 |
// Remove the default font addition from Core Code. |
| 26 |
$styles_without_core_styles = array(); |
| 27 |
if ( isset( $settings['styles'] ) ) { |
| 28 |
foreach ( $settings['styles'] as $style ) { |
| 29 |
if ( |
| 30 |
! isset( $style['__unstableType'] ) || |
| 31 |
'core' !== $style['__unstableType'] |
| 32 |
) { |
| 33 |
$styles_without_core_styles[] = $style; |
| 34 |
} |
| 35 |
} |
| 36 |
} |
| 37 |
$settings['styles'] = $styles_without_core_styles; |
| 38 |
|
| 39 |
return $settings; |
| 40 |
} |
| 41 |
add_filter( 'block_editor_settings_all', 'gutenberg_extend_block_editor_settings_with_default_editor_styles' ); |
| 42 |
|