Skip to content

Commit

Permalink
Merge branch 'trunk' into try/fix-form-styles
Browse files Browse the repository at this point in the history
  • Loading branch information
aristath committed Feb 1, 2024
2 parents b8474c8 + 23bdd66 commit 6e7c287
Show file tree
Hide file tree
Showing 140 changed files with 8,987 additions and 7,832 deletions.
377 changes: 364 additions & 13 deletions changelog.txt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,9 @@ npm run build

Like scripts, you can enqueue your block's styles using the `block.json` file.

Use the `editorStyle` property to a CSS file you want to load in the editor view, and use the `style` property for a CSS file you want to load on the frontend when the block is used.
Use the `editorStyle` property to a CSS file you want to load in the editor view only, use the `style` property for a CSS file you want to load both in the editor view and on the frontend when the block is used, and use the `viewStyle` property for a CSS file you want to load only on the frontend when the block is used.

It is worth noting that, if the editor content is iframed, both of these will
load in the iframe. `editorStyle` will also load outside the iframe, so it can
be used for editor content as well as UI.
It is worth noting that, if the editor content is iframed, both the `style` and `editorStyle` will load in the iframe. `editorStyle` will also load outside the iframe, so it can be used for editor content as well as UI.

For example:

Expand Down
23 changes: 22 additions & 1 deletion docs/reference-guides/block-api/block-metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Starting in WordPress 5.8 release, we recommend using the `block.json` metadata
"viewScript": [ "file:./view.js", "example-shared-view-script" ],
"editorStyle": "file:./index.css",
"style": [ "file:./style.css", "example-shared-style" ],
"viewStyle": [ "file:./view.css", "example-view-style" ],
"render": "file:./render.php"
}
```
Expand Down Expand Up @@ -560,6 +561,24 @@ It's possible to pass a style handle registered with the [`wp_register_style`](h

_Note: An option to pass also an array of styles exists since WordPress `5.9.0`._

### View Style

- Type: `WPDefinedAsset`|`WPDefinedAsset[]` ([learn more](#wpdefinedasset))
- Optional
- Localized: No
- Property: `viewStyle`
- Since: `WordPress 6.5.0`

```json
{ "viewStyle": [ "file:./view.css", "example-view-style" ] }
```

Block type frontend styles definition. They will be enqueued only when viewing the content on the front of the site.

It's possible to pass a style handle registered with the [`wp_register_style`](https://developer.wordpress.org/reference/functions/wp_register_style/) function, a path to a CSS file relative to the `block.json` file, or a list with a mix of both ([learn more](#wpdefinedasset)).

Frontend-only styles are especially useful for interactive blocks, to style parts that will only be visible after a user performs some action and where those styles will never be needed in the editor. You can start with using the `style` property to put all your common styles in one stylesheet. Only when you need editor-specific styling or frontend-specific styling, you can expand to `editorStyle` and `viewStyle`, but still keep the common part of your styling in the main stylesheet.

### Render

- Type: `WPDefinedPath` ([learn more](#wpdefinedpath))
Expand Down Expand Up @@ -618,7 +637,8 @@ In `block.json`:
"script": "file:./script.js",
"viewScript": [ "file:./view.js", "example-shared-view-script" ],
"editorStyle": "file:./index.css",
"style": [ "file:./style.css", "example-shared-style" ]
"style": [ "file:./style.css", "example-shared-style" ],
"viewStyle": [ "file:./view.css", "example-view-style" ]
}
```

Expand Down Expand Up @@ -670,6 +690,7 @@ Starting in the WordPress 5.8 release, it is possible to instruct WordPress to e
- `script`
- `viewScript`
- `style`
- `viewStyle` (Added in WordPress 6.5.0)

## Internationalization

Expand Down
2 changes: 1 addition & 1 deletion gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Description: Printing since 1440. This is the development plugin for the block editor, site editor, and other future WordPress core functionality.
* Requires at least: 6.3
* Requires PHP: 7.0
* Version: 17.6.0-rc.3
* Version: 17.6.0
* Author: Gutenberg Team
* Text Domain: gutenberg
*
Expand Down
15 changes: 7 additions & 8 deletions lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,15 @@ Or for classes:
* @package WordPress
* @since 6.3.0
*/
if ( class_exists( 'WP_A_Stable_Class' ) ) {
return;
if ( ! class_exists( 'WP_A_Stable_Class' ) ) {
/**
* A very stable class that does something.
*
* @since 6.3.0
*/
class WP_A_Stable_Class { ... }
}

/**
* A very stable class that does something.
*
* @since 6.3.0
*/
class WP_A_Stable_Class { ... }
```

Wrapping code in `class_exists()` and `function_exists()` is usually inappropriate for evergreen code, or any plugin code that we expect to undergo constant change between WordPress releases, because it would prevent the latest versions of the code from being used. For example, the statement `class_exists( 'WP_Theme_JSON' )` would return `true` because the class already exists in Core.
Expand Down
4 changes: 0 additions & 4 deletions lib/class-wp-duotone-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
* @since 6.3.0
*/

if ( class_exists( 'WP_Duotone_Gutenberg' ) ) {
return;
}

/**
* Manages duotone block supports and global styles.
*
Expand Down
4 changes: 0 additions & 4 deletions lib/class-wp-rest-global-styles-controller-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
* @since 5.9.0
*/

if ( class_exists( 'WP_REST_Global_Styles_Controller_Gutenberg' ) ) {
return;
}

/**
* Base Global Styles REST API Controller.
*/
Expand Down
4 changes: 0 additions & 4 deletions lib/class-wp-theme-json-data-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
* @since 6.1.0
*/

if ( class_exists( 'WP_Theme_JSON_Data_Gutenberg' ) ) {
return;
}

/**
* Class to provide access to update a theme.json structure.
*/
Expand Down
4 changes: 0 additions & 4 deletions lib/class-wp-theme-json-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
* @since 5.8.0
*/

if ( class_exists( 'WP_Theme_JSON_Gutenberg' ) ) {
return;
}

/**
* Class that encapsulates the processing of structures that adhere to the theme.json spec.
*
Expand Down
4 changes: 0 additions & 4 deletions lib/class-wp-theme-json-resolver-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
* @since 5.8.0
*/

if ( class_exists( 'WP_Theme_JSON_Resolver_Gutenberg' ) ) {
return;
}

/**
* Class that abstracts the processing of the different data sources
* for site-level config and offers an API to work with them.
Expand Down
Loading

0 comments on commit 6e7c287

Please sign in to comment.