-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Block Editor: Allow control over drop cap feature with `useEditorFeat…
…ure` helper (#22291) * Block Editor: Integrate theme config with useEditorFeature * Remove the default value param from useEditorFeature
- Loading branch information
Showing
11 changed files
with
152 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
/** | ||
* Experimental editor features config functionality. | ||
* | ||
* @package gutenberg | ||
*/ | ||
|
||
/** | ||
* Returns the default config for editor features, | ||
* or an empty array if none found. | ||
* | ||
* @return array Default features config for the editor. | ||
*/ | ||
function gutenberg_experimental_get_editor_features_config() { | ||
$empty_config = array(); | ||
$config_path = __DIR__ . '/experimental-default-theme.json'; | ||
if ( ! file_exists( $config_path ) ) { | ||
return $empty_config; | ||
} | ||
|
||
$theme_config = json_decode( | ||
@file_get_contents( $config_path ), | ||
true | ||
); | ||
if ( | ||
empty( $theme_config['global']['features'] ) || | ||
! is_array( $theme_config['global']['features'] ) | ||
) { | ||
return $empty_config; | ||
} | ||
|
||
return $theme_config['global']['features']; | ||
} | ||
|
||
|
||
/** | ||
* Extends editor settings with the features loaded from default config. | ||
* | ||
* @param array $settings Default editor settings. | ||
* | ||
* @return array Filtered editor settings. | ||
*/ | ||
function gutenberg_extend_settings_editor_features( $settings ) { | ||
$editor_features = gutenberg_experimental_get_editor_features_config(); | ||
$settings['__experimentalFeatures'] = $editor_features; | ||
|
||
return $settings; | ||
} | ||
add_filter( 'block_editor_settings', 'gutenberg_extend_settings_editor_features' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 30 additions & 4 deletions
34
packages/block-editor/src/components/use-editor-feature/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters