mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-10-05 23:27:04 +00:00
Editor: Add viewStyle property to block.json for frontend-only block styles
Related issue in Gutenberg: https://github.com/WordPress/gutenberg/issues/54491. For block scripts there was already `script`, `viewScript` and `editorScript`. For block styles there was only `style` and `editorStyle`. This brings the parity. Props gaambo. Fixes #59673. git-svn-id: https://develop.svn.wordpress.org/trunk@57493 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -64,6 +64,7 @@ function generate_block_asset_handle( $block_name, $field_name, $index = 0 ) {
|
||||
'viewScript' => 'view-script',
|
||||
'editorStyle' => 'editor-style',
|
||||
'style' => 'style',
|
||||
'viewStyle' => 'view-style',
|
||||
);
|
||||
$asset_handle = str_replace( '/', '-', $block_name ) .
|
||||
'-' . $field_mappings[ $field_name ];
|
||||
@@ -326,6 +327,7 @@ function get_block_metadata_i18n_schema() {
|
||||
* @since 6.1.0 Added support for `render` field.
|
||||
* @since 6.3.0 Added `selectors` field.
|
||||
* @since 6.4.0 Added support for `blockHooks` field.
|
||||
* @since 6.5.0 Added support for `viewStyle` field.
|
||||
*
|
||||
* @param string $file_or_folder Path to the JSON file with metadata definition for
|
||||
* the block or path to the folder where the `block.json` file is located.
|
||||
@@ -503,6 +505,7 @@ function register_block_type_from_metadata( $file_or_folder, $args = array() ) {
|
||||
$style_fields = array(
|
||||
'editorStyle' => 'editor_style_handles',
|
||||
'style' => 'style_handles',
|
||||
'viewStyle' => 'view_style_handles',
|
||||
);
|
||||
foreach ( $style_fields as $metadata_field_name => $settings_field_name ) {
|
||||
if ( ! empty( $settings[ $metadata_field_name ] ) ) {
|
||||
|
||||
Reference in New Issue
Block a user