diff --git a/bin/api-docs/gen-theme-reference.js b/bin/api-docs/gen-theme-reference.js index f638bb708890a8..0ea9e282e5463e 100644 --- a/bin/api-docs/gen-theme-reference.js +++ b/bin/api-docs/gen-theme-reference.js @@ -74,6 +74,42 @@ const keys = ( maybeObject ) => { return Object.keys( maybeObject ); }; +/** + * Get definition from ref. + * + * @param {string} ref + * @return {Object} definition + * @throws {Error} If the referenced definition is not found in 'themejson.definitions'. + * + * @example + * getDefinition( '#/definitions/typographyProperties/properties/fontFamily' ) + * // returns themejson.definitions.typographyProperties.properties.fontFamily + */ +const resolveDefinitionRef = ( ref ) => { + const refParts = ref.split( '/' ); + const definition = refParts[ refParts.length - 1 ]; + if ( ! themejson.definitions[ definition ] ) { + throw new Error( `Can't resolve '${ ref }'. Definition not found` ); + } + return themejson.definitions[ definition ]; +}; + +/** + * Get properties from an array. + * + * @param {Object} items + * @return {Object} properties + */ +const getPropertiesFromArray = ( items ) => { + // if its a $ref resolve it + if ( items.$ref ) { + return resolveDefinitionRef( items.$ref ).properties; + } + + // otherwise just return the properties + return items.properties; +}; + /** * Convert settings properties to markup. * @@ -96,7 +132,9 @@ const getSettingsPropertiesMarkup = ( struct ) => { const def = 'default' in props[ key ] ? props[ key ].default : ''; const ps = props[ key ].type === 'array' - ? keys( props[ key ].items.properties ).sort().join( ', ' ) + ? keys( getPropertiesFromArray( props[ key ].items ) ) + .sort() + .join( ', ' ) : ''; markup += `| ${ key } | ${ props[ key ].type } | ${ def } | ${ ps } |\n`; } ); diff --git a/bin/list-experimental-api-matches.sh b/bin/list-experimental-api-matches.sh index 156464c4e7375e..d9399e63e5cf64 100755 --- a/bin/list-experimental-api-matches.sh +++ b/bin/list-experimental-api-matches.sh @@ -31,7 +31,7 @@ namespace() { awk -F: ' { print module($1), $2 } function module(path) { - n = split(path, parts, "/") + split(path, parts, "/") if (parts[1] == "lib") return "lib" return parts[1] "/" parts[2] }' diff --git a/changelog.txt b/changelog.txt index ba43ddc731d01b..9268dc7edd1fba 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,261 @@ == Changelog == += 17.5.0-rc.1 = + + + +## Changelog + +### Enhancements + +#### Editor Unification +- Editor: Add the show most used blocks preference to the site editor. ([57637](https://github.com/WordPress/gutenberg/pull/57637)) +- Editor: Migrate and unify the panel preferences. ([57529](https://github.com/WordPress/gutenberg/pull/57529)) +- Editor: Unify context text cursor preference. ([57479](https://github.com/WordPress/gutenberg/pull/57479)) +- Editor: Unify list view open preference. ([57504](https://github.com/WordPress/gutenberg/pull/57504)) +- Editor: Unify right click override preference. ([57468](https://github.com/WordPress/gutenberg/pull/57468)) +- Editor: Unify show icon labels preference. ([57480](https://github.com/WordPress/gutenberg/pull/57480)) +- Editor: Unify spotlight mode preference. ([57533](https://github.com/WordPress/gutenberg/pull/57533)) +- Editor: Unify the distraction free preference. ([57590](https://github.com/WordPress/gutenberg/pull/57590)) +- Editor: Unify the show block breadcrumbs preference. ([57506](https://github.com/WordPress/gutenberg/pull/57506)) +- Editor: Unify the top toolbar preference. ([57531](https://github.com/WordPress/gutenberg/pull/57531)) + +#### Components +- Components: Replace `TabPanel` with `Tabs` in inline color picker. ([57292](https://github.com/WordPress/gutenberg/pull/57292) +- Add `compact` size variant to InputControl-based components. ([57398](https://github.com/WordPress/gutenberg/pull/57398)) +- BaseControl: Connect to context system. ([57408](https://github.com/WordPress/gutenberg/pull/57408)) +- Replace `TabPanel` with `Tabs` in the Style Book. ([57287](https://github.com/WordPress/gutenberg/pull/57287)) +- Tooltip: Improve tests. ([57345](https://github.com/WordPress/gutenberg/pull/57345)) +- Update @ariakit/react to v0.3.12 and @ariakit/test to v0.3.7. ([57547](https://github.com/WordPress/gutenberg/pull/57547)) + +#### Font Library +- Font Library: Remove "has_font_mime_type" function. ([57364](https://github.com/WordPress/gutenberg/pull/57364)) +- Font Library: Update font uninstall modal text. ([57368](https://github.com/WordPress/gutenberg/pull/57368)) +- Font Library: Add progress-bar while uploading font assets. ([57463](https://github.com/WordPress/gutenberg/pull/57463)) +- Font Library: Singularize install font families endpoint. ([57569](https://github.com/WordPress/gutenberg/pull/57569)) +- Font Library: Unregister font collection. ([54701](https://github.com/WordPress/gutenberg/pull/54701)) + +#### Site Editor +- Add Template Modal: Update scroll related layout. ([57617](https://github.com/WordPress/gutenberg/pull/57617)) +- Components: Replace `TabPanel` with `Tabs` in the Font Library `Modal`. ([57181](https://github.com/WordPress/gutenberg/pull/57181)) + +#### Interactivity API +- Implement `wp_initial_state()`. ([57556](https://github.com/WordPress/gutenberg/pull/57556)) +- Server directive processing: Stop processing non-interactive blocks. ([56302](https://github.com/WordPress/gutenberg/pull/56302)) +- Interactive template: Use viewModule. ([57712](https://github.com/WordPress/gutenberg/pull/57712)) +- Navigation Block: Use dom.focus for focus control. ([57362](https://github.com/WordPress/gutenberg/pull/57362)) + + +#### Site Editor +- Site editor: Add padding to entity save panel header. ([57471](https://github.com/WordPress/gutenberg/pull/57471)) +- Site editor: Add margin to entity save panel header via a classname. ([57473](https://github.com/WordPress/gutenberg/pull/57473)) + + +#### Block Library +- Post Featured Image: Add a useFirstImageFromPost attribute. ([56573](https://github.com/WordPress/gutenberg/pull/56573)) +- Gallery Block: Add random order setting. ([57477](https://github.com/WordPress/gutenberg/pull/57477)) +- Image Block: Change upload icon label. ([57704](https://github.com/WordPress/gutenberg/pull/57704)) + + +### Bug Fixes + +- Avoid using a memoized selector without dependencies. ([57257](https://github.com/WordPress/gutenberg/pull/57257)) +- Core Data: Pass the 'options' argument to data action shortcuts. ([57383](https://github.com/WordPress/gutenberg/pull/57383)) +- Preferences: Update accessibility scope to "core". ([57563](https://github.com/WordPress/gutenberg/pull/57563)) + +#### Block Editor +- Fix Link UI displaying out of sync results. ([57522](https://github.com/WordPress/gutenberg/pull/57522)) +- Give iframe fallback background color. ([57330](https://github.com/WordPress/gutenberg/pull/57330)) +- Rich text: Add HTML string methods to RichTextData. ([57322](https://github.com/WordPress/gutenberg/pull/57322)) + +#### Block Library +- Footnotes: Fix wrong link when adding more than 9 footnotes. ([57599](https://github.com/WordPress/gutenberg/pull/57599)) +- Table: Remove unnecessary margin override in editor styles. ([57699](https://github.com/WordPress/gutenberg/pull/57699)) +- Template Part block: Fix template part path arg missing from actions. ([56790](https://github.com/WordPress/gutenberg/pull/56790)) + +#### Components +- DuotonePicker: Fix top margin when no duotone options. ([57489](https://github.com/WordPress/gutenberg/pull/57489)) +- NavigatorProvider: Exclude size value from contain CSS rule. ([57498](https://github.com/WordPress/gutenberg/pull/57498)) +- Snackbar: Fix icon positioning. ([57377](https://github.com/WordPress/gutenberg/pull/57377)) + +#### Patterns +- Pattern Overrides: Add `template-lock: All` to pattern inner blocks to prevent deletion/insertion. ([57661](https://github.com/WordPress/gutenberg/pull/57661)) +- Refactor the findOrCreate term method. ([57655](https://github.com/WordPress/gutenberg/pull/57655)) +- Edit source pattern in focus mode in post and site editors. ([57036](https://github.com/WordPress/gutenberg/pull/57036)) + + +#### Site Editor +- Make sure comamnd palette toggle does not disappear while being clicked. ([57420](https://github.com/WordPress/gutenberg/pull/57420)) +- Reinstate iframe CSS for editor canvas container. ([57503](https://github.com/WordPress/gutenberg/pull/57503)) + +#### Global Styles +- Use `is-layout` pattern on layout generated classname. ([57564](https://github.com/WordPress/gutenberg/pull/57564)) +- Global styles revisions: Add individual headings translations, update tests. ([57472](https://github.com/WordPress/gutenberg/pull/57472)) +- Global style revisions: Move change summary code and tests to block editor package. ([57411](https://github.com/WordPress/gutenberg/pull/57411)) +- Reduce specificity of block style variation selectors. ([57659](https://github.com/WordPress/gutenberg/pull/57659)) +- Background image block support: Add tests for size and repeat output. ([57474](https://github.com/WordPress/gutenberg/pull/57474)) + + +#### Post Editor +- Fix Template preview menu item accessibility. ([57456](https://github.com/WordPress/gutenberg/pull/57456)) +- Fullscreen mode description: Use full text instead of abbreviation. ([57518](https://github.com/WordPress/gutenberg/pull/57518)) +- Improve pre-publish checks naming consistency. ([57019](https://github.com/WordPress/gutenberg/pull/57019)) +- Make the Replace featured image button perceivable by assistive technologies. ([57453](https://github.com/WordPress/gutenberg/pull/57453)) + +#### Components +- Label the HeightControl. ([57683](https://github.com/WordPress/gutenberg/pull/57683)) +- NumberControl: Make increment and decrement buttons keyboard accessible. ([57402](https://github.com/WordPress/gutenberg/pull/57402)) + +#### Block Tools +- Update the position of the patterns tab in the inserter menu. ([55688](https://github.com/WordPress/gutenberg/pull/55688)) +- Use full text instead of abbreviation for min height setting. ([57680](https://github.com/WordPress/gutenberg/pull/57680)) +- ResizableEditor: Fix tab order for resize handles. ([57475](https://github.com/WordPress/gutenberg/pull/57475)) +- Keep Lock button it in the toolbar until unmounted. ([57229](https://github.com/WordPress/gutenberg/pull/57229)) +- Custom field connections: Better description on Experiments page. ([57501](https://github.com/WordPress/gutenberg/pull/57501)) + +### Performance + +#### Block Library +- File: Remove 'block-editor' store subscription. ([57511](https://github.com/WordPress/gutenberg/pull/57511)) +- Remove store subscriptions from Audio and Video blocks. ([57449](https://github.com/WordPress/gutenberg/pull/57449)) +- Site Logo: Remove unnecessary 'block-editor' store subscription. ([57513](https://github.com/WordPress/gutenberg/pull/57513)) +- Send numerical post id when uploading image. ([57388](https://github.com/WordPress/gutenberg/pull/57388)) +- PostFeaturedImage: Remove unnecessary 'block-editor' store subscription. ([57554](https://github.com/WordPress/gutenberg/pull/57554)) + +### Experiments + +#### Data Views +- DataViews: Use DropdownMenuRadioItem component when possible. ([57505](https://github.com/WordPress/gutenberg/pull/57505)) +- Align icon size + placement in Patterns data view. ([57548](https://github.com/WordPress/gutenberg/pull/57548)) +- DataViews: Add `duplicate pattern` action in patterns page. ([57592](https://github.com/WordPress/gutenberg/pull/57592)) +- DataViews: Add duplicate template pattern action. ([57638](https://github.com/WordPress/gutenberg/pull/57638)) +- DataViews: Add footer to Pages sidebar. ([57690](https://github.com/WordPress/gutenberg/pull/57690)) +- DataViews: Add new page button in `Pages`. ([57685](https://github.com/WordPress/gutenberg/pull/57685)) +- DataViews: Add sync filter in patterns page. ([57532](https://github.com/WordPress/gutenberg/pull/57532)) +- DataViews: Consolidate CSS selectors naming schema. ([57651](https://github.com/WordPress/gutenberg/pull/57651)) +- DataViews: Fallback to `(no title)` is there's no rendered title. ([57434](https://github.com/WordPress/gutenberg/pull/57434)) +- DataViews: Hide actions menu upon selecting a layout. ([57418](https://github.com/WordPress/gutenberg/pull/57418)) +- DataViews: Make `fields` dependant on `view.type`. ([57450](https://github.com/WordPress/gutenberg/pull/57450)) +- DataViews: Memoize `onSetSelection`. ([57458](https://github.com/WordPress/gutenberg/pull/57458)) +- DataViews: Prevent unnecessary re-renders of Pagination. ([57454](https://github.com/WordPress/gutenberg/pull/57454)) +- DataViews: Prevent unnecessary re-renders. ([57452](https://github.com/WordPress/gutenberg/pull/57452)) +- DataViews: Update names for `DropdownMenuRadioItemCustom`. ([57416](https://github.com/WordPress/gutenberg/pull/57416)) +- DataViews: Use i18n._x to clarify term "Duplicate". ([57686](https://github.com/WordPress/gutenberg/pull/57686)) +- DataViews: Use in patterns page. ([57333](https://github.com/WordPress/gutenberg/pull/57333)) +- Dataview: Change the stacking order of table header. ([57565](https://github.com/WordPress/gutenberg/pull/57565)) +- Dataviews: Add some client side data handling utils. ([57488](https://github.com/WordPress/gutenberg/pull/57488)) +- Make title display in grid views consistent. ([57553](https://github.com/WordPress/gutenberg/pull/57553)) +- Update Table layout design details. ([57644](https://github.com/WordPress/gutenberg/pull/57644)) +- Update pagination spacing in List layout. ([57670](https://github.com/WordPress/gutenberg/pull/57670)) +- Update table header gap. ([57671](https://github.com/WordPress/gutenberg/pull/57671)) +- [Dataviews] Table layout: Ensure focus is not lost on interaction. ([57340](https://github.com/WordPress/gutenberg/pull/57340)) + +#### Patterns +- [Pattern Overrides] Fix duplication of inner blocks. ([57538](https://github.com/WordPress/gutenberg/pull/57538)) +- [Pattern overrides] Allow multiple attributes overrides. ([57573](https://github.com/WordPress/gutenberg/pull/57573)) + + +### Documentation + +- Add links to additional local dev tools in Block Developement Environment readme. ([57682](https://github.com/WordPress/gutenberg/pull/57682)) +- Add new section to the Quick Start Guide about wp-env. ([57559](https://github.com/WordPress/gutenberg/pull/57559)) +- Block JSON schema: Add renaming key to supports definition. ([57373](https://github.com/WordPress/gutenberg/pull/57373)) +- Break out the Curating the Editor Experience doc into its own How-to Guides section. ([57289](https://github.com/WordPress/gutenberg/pull/57289)) +- Change the slug for the theme.json doc to avoid conflicts. ([57410](https://github.com/WordPress/gutenberg/pull/57410)) +- Docs/tutorial: Fix opposite condition for content generation in render.php. ([57445](https://github.com/WordPress/gutenberg/pull/57445)) +- Docs: Fundamentals of Block Development - Static or Dynamic rendering of a block. ([57250](https://github.com/WordPress/gutenberg/pull/57250)) +- Docs: Update sample code to fix React warning error on Tutorial page. ([57412](https://github.com/WordPress/gutenberg/pull/57412)) +- Fix formatting issue due to incorrect link parsing in the Quick Start Guide. ([57693](https://github.com/WordPress/gutenberg/pull/57693)) +- Fix incorrect heading level in Editor curation documentation. ([57409](https://github.com/WordPress/gutenberg/pull/57409)) +- Fix two typos in tutorial.md. ([57627](https://github.com/WordPress/gutenberg/pull/57627)) +- Fix: Create block getting started links. ([57551](https://github.com/WordPress/gutenberg/pull/57551)) +- Improve the static vs dynamic rendering comment in the block tutorial. ([57284](https://github.com/WordPress/gutenberg/pull/57284)) +- Update copyright year to 2024 in `license.md`. ([57481](https://github.com/WordPress/gutenberg/pull/57481)) +- Update the "Build your first block" tutorial based on user feedback. ([57403](https://github.com/WordPress/gutenberg/pull/57403)) +- Update: Material design icons link. ([57550](https://github.com/WordPress/gutenberg/pull/57550)) + + +### Code Quality +- Editor: Unify the DocumentTools component. ([57214](https://github.com/WordPress/gutenberg/pull/57214)) +- Make getLastFocus and setLastFocus private. ([57612](https://github.com/WordPress/gutenberg/pull/57612)) +- Remove deprecated `behaviors` syntax. ([57165](https://github.com/WordPress/gutenberg/pull/57165)) +- Avoid extra `useMarkPersistent` dispatch calls. ([57435](https://github.com/WordPress/gutenberg/pull/57435)) +- Clean up code editor CSS. ([57519](https://github.com/WordPress/gutenberg/pull/57519)) +- Combine selectors in 'useTransformCommands'. ([57424](https://github.com/WordPress/gutenberg/pull/57424)) + +#### Block Library +- Background image: Add has-background classname when background image is applied. ([57495](https://github.com/WordPress/gutenberg/pull/57495)) +- File: Remove unnecessary synchronization effect. ([57585](https://github.com/WordPress/gutenberg/pull/57585)) +- Navigation: Refactor mobile overlay breakpoints to JS. ([57520](https://github.com/WordPress/gutenberg/pull/57520)) +- Search Block: Remove unused `buttonBehavior` attribute. ([53467](https://github.com/WordPress/gutenberg/pull/53467)) + +#### Patterns +- Improve inserter pattern constants. ([57570](https://github.com/WordPress/gutenberg/pull/57570)) +- Remove duplicate setting for `getPostLinkProps` and prefer stable naming. ([57535](https://github.com/WordPress/gutenberg/pull/57535)) +- Rename `patternBlock` to `patternPost`. ([57568](https://github.com/WordPress/gutenberg/pull/57568)) + +#### Post Editor +- Editor: Use hooks instead of HoCs in 'PostVisibilityCheck'. ([57705](https://github.com/WordPress/gutenberg/pull/57705)) +- Quality: Avoid React warning when changing rendering mode. ([57413](https://github.com/WordPress/gutenberg/pull/57413)) + +#### Block Editor +- Editor: Unify the inserter sidebar. ([57466](https://github.com/WordPress/gutenberg/pull/57466)) +- Remove unused parameters from useOnBlockDrop. ([57527](https://github.com/WordPress/gutenberg/pull/57527)) + +#### List View +- Editor: Unify the list view sidebar between the post and site editors. ([57467](https://github.com/WordPress/gutenberg/pull/57467)) +- Add drag cursor to draggable list items. ([57493](https://github.com/WordPress/gutenberg/pull/57493)) + +### Tools + +- Dependency Extraction Webpack Plugin: Use `import` for module externals. ([57577](https://github.com/WordPress/gutenberg/pull/57577)) +- DependencyExtractionWebpackPlugin: Add true shorthand for requestToExternalModule. ([57593](https://github.com/WordPress/gutenberg/pull/57593)) +- DependencyExtractionWebpackPlugin: Use module for @wordpress/interactivity. ([57602](https://github.com/WordPress/gutenberg/pull/57602)) +- Fix webpack not setting environment.module true. ([57714](https://github.com/WordPress/gutenberg/pull/57714)) +- Modules: Load the import map polyfill when needed. ([57256](https://github.com/WordPress/gutenberg/pull/57256)) +- Blocks: Add handling for block.json viewModule. ([57437](https://github.com/WordPress/gutenberg/pull/57437)) + +#### Testing +- Allowed Patterns end-to-end test - move tests that run with a subset of allowed blocks into a group. ([57496](https://github.com/WordPress/gutenberg/pull/57496)) +- Clean up end-to-end tests package. ([57575](https://github.com/WordPress/gutenberg/pull/57575)) +- Fix flaky 'Post publish button' end-to-end test. ([57407](https://github.com/WordPress/gutenberg/pull/57407)) +- Migrate 'allowed patterns' end-to-end tests to Playwright. ([57399](https://github.com/WordPress/gutenberg/pull/57399)) +- Migrate 'block editor keyboard shortcuts' end-to-end tests to Playwright. ([57422](https://github.com/WordPress/gutenberg/pull/57422)) +- Migrate 'core settings' end-to-end tests to Playwright. ([57581](https://github.com/WordPress/gutenberg/pull/57581)) +- Migrate 'datepicker' end-to-end tests to Playwright. ([57545](https://github.com/WordPress/gutenberg/pull/57545)) +- Migrate 'dropdown menu' end-to-end tests to Playwright. ([57663](https://github.com/WordPress/gutenberg/pull/57663)) +- Migrate 'editor modes' end-to-end tests to Playwright. ([57574](https://github.com/WordPress/gutenberg/pull/57574)) +- Migrate 'invalid blocks' end-to-end tests to Playwright. ([57508](https://github.com/WordPress/gutenberg/pull/57508)) +- Migrate 'nux' end-to-end tests to Playwright. ([57542](https://github.com/WordPress/gutenberg/pull/57542)) +- Migrate 'preferences' end-to-end tests to Playwright. ([57446](https://github.com/WordPress/gutenberg/pull/57446)) +- Migrate 'publishing' end-to-end tests to Playwright. ([57521](https://github.com/WordPress/gutenberg/pull/57521)) +- Migrate 'scheduling' end-to-end tests to Playwright. ([57539](https://github.com/WordPress/gutenberg/pull/57539)) +- Migrate 'sidebar' end-to-end tests to Playwright. ([57448](https://github.com/WordPress/gutenberg/pull/57448)) +- Migrate 'taxonomies' end-to-end tests to Playwright. ([57662](https://github.com/WordPress/gutenberg/pull/57662)) +- Migrate `editing-widgets` to Playwright. ([57483](https://github.com/WordPress/gutenberg/pull/57483)) +- Migrate remaining 'publish panel' end-to-end tests to Playwright. ([57432](https://github.com/WordPress/gutenberg/pull/57432)) +- Update 'missing block' end-to-end tests to use the 'setContent' helper. ([57509](https://github.com/WordPress/gutenberg/pull/57509)) + +#### Build Tooling +- Group GitHub Action Dependabot updates. ([57591](https://github.com/WordPress/gutenberg/pull/57591)) +- WP Scripts: Build block.json viewModule. ([57461](https://github.com/WordPress/gutenberg/pull/57461)) +- Dependency Extraction Webpack Plugin: Add Module support. ([57199](https://github.com/WordPress/gutenberg/pull/57199)) + +## First time contributors + +The following PRs were merged by first time contributors: + +- @HrithikDalal: Font Library: Update font uninstall modal text. ([57368](https://github.com/WordPress/gutenberg/pull/57368)) +- @muhme: Fix two typos in tutorial.md. ([57627](https://github.com/WordPress/gutenberg/pull/57627)) + + +## Contributors + +The following contributors merged PRs in this release: + +@afercia @andrewhayward @andrewserong @atachibana @c4rl0sbr4v0 @carolinan @chad1008 @ciampo @DAreRodz @dcalhoun @derekblank @desrosj @ellatrix @fai-sal @fluiddot @geriux @getdave @glendaviesnz @gziolo @hbhalodia @HrithikDalal @jameskoster @jeryj @jorgefilipecosta @jsnajdr @juanmaguitar @kevin940726 @Mamaduka @matiasbenedetto @mcsf @michalczaplinski @mirka @muhme @ndiego @ntsekouras @oandregal @ockham @ramonjd @scruffian @sirreal @Soean @t-hamano @talldan @tellthemachines @youknowriad + + = 17.3.2 = ## Changelog diff --git a/docs/getting-started/devenv/README.md b/docs/getting-started/devenv/README.md index c891490437d431..47113c84d78dac 100644 --- a/docs/getting-started/devenv/README.md +++ b/docs/getting-started/devenv/README.md @@ -48,3 +48,10 @@ Refer to the [Get started with `wp-env`](/docs/getting-started/devenv/get-starte
wp-now
. This is a lightweight tool powered by WordPress Playground that streamlines setting up a simple local WordPress environment. While still experimental, this tool is great for quickly testing WordPress releases, plugins, and themes.
http://localhost:8888
. Log into the WordPress dashboard using username `admin` and password `password`. The plugin will already be installed and activated. Open the Editor or Site Editor, and insert the Copyright Date Block as you would any other block.
Visit the [Getting started](https://developer.wordpress.org/block-editor/getting-started/devenv/get-started-with-wp-env/) guide to learn more about `wp-env`.
diff --git a/docs/reference-guides/data/data-core-block-editor.md b/docs/reference-guides/data/data-core-block-editor.md
index 38a93552bcbef2..7b0bd386daaf48 100644
--- a/docs/reference-guides/data/data-core-block-editor.md
+++ b/docs/reference-guides/data/data-core-block-editor.md
@@ -588,18 +588,6 @@ _Properties_
- _isDisabled_ `boolean`: Whether or not the user should be prevented from inserting this item.
- _frecency_ `number`: Heuristic that combines frequency and recency.
-### getLastFocus
-
-Returns the element of the last element that had focus when focus left the editor canvas.
-
-_Parameters_
-
-- _state_ `Object`: Block editor state.
-
-_Returns_
-
-- `Object`: Element.
-
### getLastMultiSelectedBlockClientId
Returns the client ID of the last block in the multi-selection set, or null if there is no multi-selection.
@@ -1663,18 +1651,6 @@ _Parameters_
- _clientId_ `string`: The block's clientId.
- _hasControlledInnerBlocks_ `boolean`: True if the block's inner blocks are controlled.
-### setLastFocus
-
-Action that sets the element that had focus when focus leaves the editor canvas.
-
-_Parameters_
-
-- _lastFocus_ `Object`: The last focused element.
-
-_Returns_
-
-- `Object`: Action object.
-
### setNavigationMode
Action that enables or disables the navigation mode.
diff --git a/docs/reference-guides/theme-json-reference/theme-json-living.md b/docs/reference-guides/theme-json-reference/theme-json-living.md
index 4baa5a6009ded6..ee88f779ace1ce 100644
--- a/docs/reference-guides/theme-json-reference/theme-json-living.md
+++ b/docs/reference-guides/theme-json-reference/theme-json-living.md
@@ -176,6 +176,7 @@ Settings related to typography.
| Property | Type | Default | Props |
| --- | --- | --- |--- |
+| defaultFontSizes | boolean | true | |
| customFontSize | boolean | true | |
| fontStyle | boolean | true | |
| fontWeight | boolean | true | |
diff --git a/gutenberg.php b/gutenberg.php
index 35e416006bea50..9559f838608da9 100644
--- a/gutenberg.php
+++ b/gutenberg.php
@@ -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.4.1
+ * Version: 17.5.0-rc.1
* Author: Gutenberg Team
* Text Domain: gutenberg
*
diff --git a/lib/block-supports/pattern.php b/lib/block-supports/pattern.php
index a783135c793e3f..2f7717091ff506 100644
--- a/lib/block-supports/pattern.php
+++ b/lib/block-supports/pattern.php
@@ -13,7 +13,7 @@
* @param WP_Block_Type $block_type Block Type.
*/
function gutenberg_register_pattern_support( $block_type ) {
- $pattern_support = property_exists( $block_type, 'supports' ) ? _wp_array_get( $block_type->supports, array( '__experimentalConnections' ), false ) : false;
+ $pattern_support = 'core/paragraph' === $block_type->name ? true : false;
if ( $pattern_support ) {
if ( ! $block_type->uses_context ) {
diff --git a/lib/class-wp-theme-json-gutenberg.php b/lib/class-wp-theme-json-gutenberg.php
index af750fa0599795..a063ab34d9069c 100644
--- a/lib/class-wp-theme-json-gutenberg.php
+++ b/lib/class-wp-theme-json-gutenberg.php
@@ -155,7 +155,7 @@ class WP_Theme_JSON_Gutenberg {
),
array(
'path' => array( 'typography', 'fontSizes' ),
- 'prevent_override' => false,
+ 'prevent_override' => array( 'typography', 'defaultFontSizes' ),
'use_default_names' => true,
'value_func' => 'gutenberg_get_typography_font_size_value',
'css_vars' => '--wp--preset--font-size--$slug',
@@ -411,19 +411,20 @@ class WP_Theme_JSON_Gutenberg {
'defaultPresets' => null,
),
'typography' => array(
- 'fluid' => null,
- 'customFontSize' => null,
- 'dropCap' => null,
- 'fontFamilies' => null,
- 'fontSizes' => null,
- 'fontStyle' => null,
- 'fontWeight' => null,
- 'letterSpacing' => null,
- 'lineHeight' => null,
- 'textColumns' => null,
- 'textDecoration' => null,
- 'textTransform' => null,
- 'writingMode' => null,
+ 'fluid' => null,
+ 'customFontSize' => null,
+ 'defaultFontSizes' => null,
+ 'dropCap' => null,
+ 'fontFamilies' => null,
+ 'fontSizes' => null,
+ 'fontStyle' => null,
+ 'fontWeight' => null,
+ 'letterSpacing' => null,
+ 'lineHeight' => null,
+ 'textColumns' => null,
+ 'textDecoration' => null,
+ 'textTransform' => null,
+ 'writingMode' => null,
),
);
@@ -1021,8 +1022,7 @@ protected static function get_blocks_metadata() {
if ( ! empty( $block_type->styles ) ) {
$style_selectors = array();
foreach ( $block_type->styles as $style ) {
- // The style variation classname is duplicated in the selector to ensure that it overrides core block styles.
- $style_selectors[ $style['name'] ] = static::append_to_selector( '.is-style-' . $style['name'] . '.is-style-' . $style['name'], static::$blocks_metadata[ $block_name ]['selector'] );
+ $style_selectors[ $style['name'] ] = static::append_to_selector( '.is-style-' . $style['name'], static::$blocks_metadata[ $block_name ]['selector'] );
}
static::$blocks_metadata[ $block_name ]['styleVariations'] = $style_selectors;
}
diff --git a/lib/experimental/block-bindings/html-processing.php b/lib/experimental/block-bindings/html-processing.php
new file mode 100644
index 00000000000000..515749d0a8e753
--- /dev/null
+++ b/lib/experimental/block-bindings/html-processing.php
@@ -0,0 +1,110 @@
+get_registered( $block_name );
+ if ( null === $block_type ) {
+ return;
+ }
+
+ // Depending on the attribute source, the processing will be different.
+ switch ( $block_type->attributes[ $block_attr ]['source'] ) {
+ case 'html':
+ case 'rich-text':
+ $block_reader = new WP_HTML_Tag_Processor( $block_content );
+
+ // TODO: Support for CSS selectors whenever they are ready in the HTML API.
+ // In the meantime, support comma-separated selectors by exploding them into an array.
+ $selectors = explode( ',', $block_type->attributes[ $block_attr ]['selector'] );
+ // Add a bookmark to the first tag to be able to iterate over the selectors.
+ $block_reader->next_tag();
+ $block_reader->set_bookmark( 'iterate-selectors' );
+
+ // TODO: This shouldn't be needed when the `set_inner_html` function is ready.
+ // Store the parent tag and its attributes to be able to restore them later in the button.
+ // The button block has a wrapper while the paragraph and heading blocks don't.
+ if ( 'core/button' === $block_name ) {
+ $button_wrapper = $block_reader->get_tag();
+ $button_wrapper_attribute_names = $block_reader->get_attribute_names_with_prefix( '' );
+ $button_wrapper_attrs = array();
+ foreach ( $button_wrapper_attribute_names as $name ) {
+ $button_wrapper_attrs[ $name ] = $block_reader->get_attribute( $name );
+ }
+ }
+
+ foreach ( $selectors as $selector ) {
+ // If the parent tag, or any of its children, matches the selector, replace the HTML.
+ if ( strcasecmp( $block_reader->get_tag( $selector ), $selector ) === 0 || $block_reader->next_tag(
+ array(
+ 'tag_name' => $selector,
+ )
+ ) ) {
+ $block_reader->release_bookmark( 'iterate-selectors' );
+
+ // TODO: Use `set_inner_html` method whenever it's ready in the HTML API.
+ // Until then, it is hardcoded for the paragraph, heading, and button blocks.
+ // Store the tag and its attributes to be able to restore them later.
+ $selector_attribute_names = $block_reader->get_attribute_names_with_prefix( '' );
+ $selector_attrs = array();
+ foreach ( $selector_attribute_names as $name ) {
+ $selector_attrs[ $name ] = $block_reader->get_attribute( $name );
+ }
+ $selector_markup = "<$selector>" . esc_html( $source_value ) . "$selector>";
+ $amended_content = new WP_HTML_Tag_Processor( $selector_markup );
+ $amended_content->next_tag();
+ foreach ( $selector_attrs as $attribute_key => $attribute_value ) {
+ $amended_content->set_attribute( $attribute_key, $attribute_value );
+ }
+ if ( 'core/paragraph' === $block_name || 'core/heading' === $block_name ) {
+ return $amended_content->get_updated_html();
+ }
+ if ( 'core/button' === $block_name ) {
+ $button_markup = "<$button_wrapper>{$amended_content->get_updated_html()}$button_wrapper>";
+ $amended_button = new WP_HTML_Tag_Processor( $button_markup );
+ $amended_button->next_tag();
+ foreach ( $button_wrapper_attrs as $attribute_key => $attribute_value ) {
+ $amended_button->set_attribute( $attribute_key, $attribute_value );
+ }
+ return $amended_button->get_updated_html();
+ }
+ } else {
+ $block_reader->seek( 'iterate-selectors' );
+ }
+ }
+ $block_reader->release_bookmark( 'iterate-selectors' );
+ return $block_content;
+
+ case 'attribute':
+ $amended_content = new WP_HTML_Tag_Processor( $block_content );
+ if ( ! $amended_content->next_tag(
+ array(
+ // TODO: build the query from CSS selector.
+ 'tag_name' => $block_type->attributes[ $block_attr ]['selector'],
+ )
+ ) ) {
+ return $block_content;
+ }
+ $amended_content->set_attribute( $block_type->attributes[ $block_attr ]['attribute'], esc_attr( $source_value ) );
+ return $amended_content->get_updated_html();
+ break;
+
+ default:
+ return $block_content;
+ break;
+ }
+ return;
+ }
+}
diff --git a/lib/experimental/block-bindings/index.php b/lib/experimental/block-bindings/index.php
new file mode 100644
index 00000000000000..cca857e93702f3
--- /dev/null
+++ b/lib/experimental/block-bindings/index.php
@@ -0,0 +1,20 @@
+ $label,
+ 'apply' => $apply,
+ );
+ }
+}
diff --git a/lib/experimental/block-bindings/sources/pattern.php b/lib/experimental/block-bindings/sources/pattern.php
new file mode 100644
index 00000000000000..e3456aa468d3eb
--- /dev/null
+++ b/lib/experimental/block-bindings/sources/pattern.php
@@ -0,0 +1,21 @@
+attributes, array( 'metadata', 'id' ), false ) ) {
+ return null;
+ }
+ $block_id = $block_instance->attributes['metadata']['id'];
+ return _wp_array_get( $block_instance->context, array( 'pattern/overrides', $block_id, $attribute_name ), null );
+ };
+ register_block_bindings_source(
+ 'pattern_attributes',
+ __( 'Pattern Attributes', 'gutenberg' ),
+ $pattern_source_callback
+ );
+}
diff --git a/lib/experimental/block-bindings/sources/post-meta.php b/lib/experimental/block-bindings/sources/post-meta.php
new file mode 100644
index 00000000000000..99b6afc03c0d42
--- /dev/null
+++ b/lib/experimental/block-bindings/sources/post-meta.php
@@ -0,0 +1,25 @@
+context['postId'] but it wasn't available in the image block.
+ $post_id = get_the_ID();
+ }
+
+ return get_post_meta( $post_id, $source_attrs['value'], true );
+ };
+ register_block_bindings_source(
+ 'post_meta',
+ __( 'Post Meta', 'gutenberg' ),
+ $post_meta_source_callback
+ );
+}
diff --git a/lib/experimental/blocks.php b/lib/experimental/blocks.php
index 88e46b478389d2..42663e127870c9 100644
--- a/lib/experimental/blocks.php
+++ b/lib/experimental/blocks.php
@@ -83,118 +83,90 @@ function wp_enqueue_block_view_script( $block_name, $args ) {
$gutenberg_experiments = get_option( 'gutenberg-experiments' );
if ( $gutenberg_experiments && (
- array_key_exists( 'gutenberg-connections', $gutenberg_experiments ) ||
+ array_key_exists( 'gutenberg-block-bindings', $gutenberg_experiments ) ||
array_key_exists( 'gutenberg-pattern-partial-syncing', $gutenberg_experiments )
) ) {
- /**
- * Renders the block meta attributes.
- *
- * @param string $block_content Block Content.
- * @param array $block Block attributes.
- * @param WP_Block $block_instance The block instance.
- */
- function gutenberg_render_block_connections( $block_content, $block, $block_instance ) {
- $connection_sources = require __DIR__ . '/connection-sources/index.php';
- $block_type = $block_instance->block_type;
-
- // Allowlist of blocks that support block connections.
- // Currently, we only allow the following blocks and attributes:
- // - Paragraph: content.
- // - Image: url.
- $blocks_attributes_allowlist = array(
- 'core/paragraph' => array( 'content' ),
- 'core/image' => array( 'url' ),
- );
-
- // Whitelist of the block types that support block connections.
- // Currently, we only allow the Paragraph and Image blocks to use block connections.
- if ( ! in_array( $block['blockName'], array_keys( $blocks_attributes_allowlist ), true ) ) {
- return $block_content;
- }
-
- // If for some reason, the block type is not found, skip it.
- if ( null === $block_type ) {
- return $block_content;
- }
-
- // If the block does not have support for block connections, skip it.
- if ( ! block_has_support( $block_type, array( '__experimentalConnections' ), false ) ) {
- return $block_content;
- }
-
- // Get all the attributes that have a connection.
- $connected_attributes = $block['attrs']['connections']['attributes'] ?? false;
- if ( ! $connected_attributes ) {
- return $block_content;
- }
-
- foreach ( $connected_attributes as $attribute_name => $attribute_value ) {
-
- // If the attribute is not in the allowlist, skip it.
- if ( ! in_array( $attribute_name, $blocks_attributes_allowlist[ $block['blockName'] ], true ) ) {
- continue;
- }
-
- // Skip if the source value is not "meta_fields" or "pattern_attributes".
- if ( 'meta_fields' !== $attribute_value['source'] && 'pattern_attributes' !== $attribute_value['source'] ) {
- continue;
- }
- // If the attribute does not have a source, skip it.
- if ( ! isset( $block_type->attributes[ $attribute_name ]['source'] ) ) {
- continue;
+ require_once __DIR__ . '/block-bindings/index.php';
+ // Allowed blocks that support block bindings.
+ // TODO: Look for a mechanism to opt-in for this. Maybe adding a property to block attributes?
+ global $block_bindings_allowed_blocks;
+ $block_bindings_allowed_blocks = array(
+ 'core/paragraph' => array( 'content' ),
+ 'core/heading' => array( 'content' ),
+ 'core/image' => array( 'url', 'title', 'alt' ),
+ 'core/button' => array( 'url', 'text' ),
+ );
+ if ( ! function_exists( 'process_block_bindings' ) ) {
+ /**
+ * Process the block bindings attribute.
+ *
+ * @param string $block_content Block Content.
+ * @param array $block Block attributes.
+ * @param WP_Block $block_instance The block instance.
+ */
+ function process_block_bindings( $block_content, $block, $block_instance ) {
+ // If the block doesn't have the bindings property, return.
+ if ( ! isset( $block['attrs']['metadata']['bindings'] ) ) {
+ return $block_content;
}
- if ( 'pattern_attributes' === $attribute_value['source'] ) {
- if ( ! _wp_array_get( $block_instance->attributes, array( 'metadata', 'id' ), false ) ) {
+ // Assuming the following format for the bindings property of the "metadata" attribute:
+ //
+ // "bindings": {
+ // "title": {
+ // "source": {
+ // "name": "post_meta",
+ // "attributes": { "value": "text_custom_field" }
+ // }
+ // },
+ // "url": {
+ // "source": {
+ // "name": "post_meta",
+ // "attributes": { "value": "text_custom_field" }
+ // }
+ // }
+ // }
+ //
+ global $block_bindings_allowed_blocks;
+ global $block_bindings_sources;
+ $modified_block_content = $block_content;
+ foreach ( $block['attrs']['metadata']['bindings'] as $binding_attribute => $binding_source ) {
+ // If the block is not in the list, stop processing.
+ if ( ! isset( $block_bindings_allowed_blocks[ $block['blockName'] ] ) ) {
+ return $block_content;
+ }
+ // If the attribute is not in the list, process next attribute.
+ if ( ! in_array( $binding_attribute, $block_bindings_allowed_blocks[ $block['blockName'] ], true ) ) {
continue;
}
-
- $custom_value = $connection_sources[ $attribute_value['source'] ]( $block_instance );
- } else {
- // If the attribute does not specify the name of the custom field, skip it.
- if ( ! isset( $attribute_value['value'] ) ) {
+ // If no source is provided, or that source is not registered, process next attribute.
+ if ( ! isset( $binding_source['source'] ) || ! isset( $binding_source['source']['name'] ) || ! isset( $block_bindings_sources[ $binding_source['source']['name'] ] ) ) {
continue;
}
- // Get the content from the connection source.
- $custom_value = $connection_sources[ $attribute_value['source'] ](
- $block_instance,
- $attribute_value['value']
- );
- }
-
- if ( false === $custom_value ) {
- continue;
- }
+ $source_callback = $block_bindings_sources[ $binding_source['source']['name'] ]['apply'];
+ // Get the value based on the source.
+ if ( ! isset( $binding_source['source']['attributes'] ) ) {
+ $source_args = array();
+ } else {
+ $source_args = $binding_source['source']['attributes'];
+ }
+ $source_value = $source_callback( $source_args, $block_instance, $binding_attribute );
+ // If the value is null, process next attribute.
+ if ( is_null( $source_value ) ) {
+ continue;
+ }
- $tags = new WP_HTML_Tag_Processor( $block_content );
- $found = $tags->next_tag(
- array(
- // TODO: In the future, when blocks other than Paragraph and Image are
- // supported, we should build the full query from CSS selector.
- 'tag_name' => $block_type->attributes[ $attribute_name ]['selector'],
- )
- );
- if ( ! $found ) {
- return $block_content;
+ // Process the HTML based on the block and the attribute.
+ $modified_block_content = block_bindings_replace_html( $modified_block_content, $block['blockName'], $binding_attribute, $source_value );
}
- $tag_name = $tags->get_tag();
- $markup = "<$tag_name>$custom_value$tag_name>";
- $updated_tags = new WP_HTML_Tag_Processor( $markup );
- $updated_tags->next_tag();
-
- // Get all the attributes from the original block and add them to the new markup.
- $names = $tags->get_attribute_names_with_prefix( '' );
- foreach ( $names as $name ) {
- $updated_tags->set_attribute( $name, $tags->get_attribute( $name ) );
- }
-
- return $updated_tags->get_updated_html();
+ return $modified_block_content;
}
- return $block_content;
+ // Add filter only to the blocks in the list.
+ foreach ( $block_bindings_allowed_blocks as $block_name => $attributes ) {
+ add_filter( 'render_block_' . $block_name, 'process_block_bindings', 20, 3 );
+ }
}
-
- add_filter( 'render_block', 'gutenberg_render_block_connections', 10, 3 );
}
diff --git a/lib/experimental/connection-sources/index.php b/lib/experimental/connection-sources/index.php
deleted file mode 100644
index bf89ba177b6e94..00000000000000
--- a/lib/experimental/connection-sources/index.php
+++ /dev/null
@@ -1,19 +0,0 @@
- 'meta',
- 'meta_fields' => function ( $block_instance, $meta_field ) {
- // We should probably also check if the meta field exists but for now it's okay because
- // if it doesn't, `get_post_meta()` will just return an empty string.
- return get_post_meta( $block_instance->context['postId'], $meta_field, true );
- },
- 'pattern_attributes' => function ( $block_instance ) {
- $block_id = $block_instance->attributes['metadata']['id'];
- return _wp_array_get( $block_instance->context, array( 'pattern/overrides', $block_id ), false );
- },
-);
diff --git a/lib/experimental/editor-settings.php b/lib/experimental/editor-settings.php
index 5f61684e8b1342..729376cf030dd9 100644
--- a/lib/experimental/editor-settings.php
+++ b/lib/experimental/editor-settings.php
@@ -26,8 +26,8 @@ function gutenberg_enable_experiments() {
wp_add_inline_script( 'wp-block-editor', 'window.__experimentalEnableGroupGridVariation = true', 'before' );
}
- if ( $gutenberg_experiments && array_key_exists( 'gutenberg-connections', $gutenberg_experiments ) ) {
- wp_add_inline_script( 'wp-block-editor', 'window.__experimentalConnections = true', 'before' );
+ if ( $gutenberg_experiments && array_key_exists( 'gutenberg-block-bindings', $gutenberg_experiments ) ) {
+ wp_add_inline_script( 'wp-block-editor', 'window.__experimentalBlockBindings = true', 'before' );
}
if ( gutenberg_is_experiment_enabled( 'gutenberg-no-tinymce' ) ) {
diff --git a/lib/experimental/fonts/font-library/class-wp-font-collection.php b/lib/experimental/fonts/font-library/class-wp-font-collection.php
index e8cc7c98fe730f..6189da5fa984b1 100644
--- a/lib/experimental/fonts/font-library/class-wp-font-collection.php
+++ b/lib/experimental/fonts/font-library/class-wp-font-collection.php
@@ -35,7 +35,7 @@ class WP_Font_Collection {
* @since 6.5.0
*
* @param array $config Font collection config options.
- * See {@see wp_register_font_collection()} for the supported fields.
+ * See {@see wp_register_font_collection()} for the supported fields.
* @throws Exception If the required parameters are missing.
*/
public function __construct( $config ) {
@@ -43,16 +43,16 @@ public function __construct( $config ) {
throw new Exception( 'Font Collection config options is required as a non-empty array.' );
}
- if ( empty( $config['id'] ) || ! is_string( $config['id'] ) ) {
- throw new Exception( 'Font Collection config ID is required as a non-empty string.' );
+ if ( empty( $config['slug'] ) || ! is_string( $config['slug'] ) ) {
+ throw new Exception( 'Font Collection config slug is required as a non-empty string.' );
}
if ( empty( $config['name'] ) || ! is_string( $config['name'] ) ) {
throw new Exception( 'Font Collection config name is required as a non-empty string.' );
}
- if ( empty( $config['src'] ) || ! is_string( $config['src'] ) ) {
- throw new Exception( 'Font Collection config "src" option is required as a non-empty string.' );
+ if ( ( empty( $config['src'] ) || ! is_string( $config['src'] ) ) && ( empty( $config['data'] ) ) ) {
+ throw new Exception( 'Font Collection config "src" option OR "data" option is required.' );
}
$this->config = $config;
@@ -63,21 +63,59 @@ public function __construct( $config ) {
*
* @since 6.5.0
*
- * @return array An array containing the font collection config.
+ * @return array {
+ * An array of font collection config.
+ *
+ * @type string $slug The font collection's unique slug.
+ * @type string $name The font collection's name.
+ * @type string $description The font collection's description.
+ * }
*/
public function get_config() {
- return $this->config;
+ return array(
+ 'slug' => $this->config['slug'],
+ 'name' => $this->config['name'],
+ 'description' => $this->config['description'] ?? '',
+ );
}
/**
- * Gets the font collection data.
+ * Gets the font collection config and data.
+ *
+ * This function returns an array containing the font collection's unique ID,
+ * name, and its data as a PHP array.
*
* @since 6.5.0
*
- * @return array|WP_Error An array containing the list of font families in theme.json format on success,
+ * @return array {
+ * An array of font collection config and data.
+ *
+ * @type string $slug The font collection's unique ID.
+ * @type string $name The font collection's name.
+ * @type string $description The font collection's description.
+ * @type array $data The font collection's data as a PHP array.
+ * }
+ */
+ public function get_config_and_data() {
+ $config_and_data = $this->get_config();
+ $config_and_data['data'] = $this->load_data();
+ return $config_and_data;
+ }
+
+ /**
+ * Loads the font collection data.
+ *
+ * @since 6.5.0
+ *
+ * @return array|WP_Error An array containing the list of font families in font-collection.json format on success,
* else an instance of WP_Error on failure.
*/
- public function get_data() {
+ public function load_data() {
+
+ if ( ! empty( $this->config['data'] ) ) {
+ return $this->config['data'];
+ }
+
// If the src is a URL, fetch the data from the URL.
if ( str_contains( $this->config['src'], 'http' ) && str_contains( $this->config['src'], '://' ) ) {
if ( ! wp_http_validate_url( $this->config['src'] ) ) {
@@ -104,9 +142,6 @@ public function get_data() {
}
}
- $collection_data = $this->get_config();
- $collection_data['data'] = $data;
- unset( $collection_data['src'] );
- return $collection_data;
+ return $data;
}
}
diff --git a/lib/experimental/fonts/font-library/class-wp-font-family.php b/lib/experimental/fonts/font-library/class-wp-font-family.php
index a4204dfe1fa2c7..f64aebc0c8efa7 100644
--- a/lib/experimental/fonts/font-library/class-wp-font-family.php
+++ b/lib/experimental/fonts/font-library/class-wp-font-family.php
@@ -135,7 +135,7 @@ public function uninstall() {
*/
private static function delete_asset( $src ) {
$filename = basename( $src );
- $file_path = path_join( WP_Font_Library::get_fonts_dir(), $filename );
+ $file_path = path_join( wp_get_font_dir()['path'], $filename );
wp_delete_file( $file_path );
@@ -163,7 +163,6 @@ private static function delete_font_face_assets( $font_face ) {
return true;
}
-
/**
* Gets the overrides for the 'wp_handle_upload' function.
*
@@ -394,7 +393,7 @@ private function download_or_move_font_faces( $files ) {
// If the font face requires the use of the filesystem, create the fonts dir if it doesn't exist.
if ( ! empty( $font_face['downloadFromUrl'] ) && ! empty( $font_face['uploadedFile'] ) ) {
- wp_mkdir_p( WP_Font_Library::get_fonts_dir() );
+ wp_mkdir_p( wp_get_font_dir()['path'] );
}
// If installing google fonts, download the font face assets.
@@ -599,9 +598,9 @@ private function create_or_update_font_post() {
*/
public function install( $files = null ) {
add_filter( 'upload_mimes', array( 'WP_Font_Library', 'set_allowed_mime_types' ) );
- add_filter( 'upload_dir', array( 'WP_Font_Library', 'set_upload_dir' ) );
+ add_filter( 'upload_dir', 'wp_get_font_dir' );
$were_assets_written = $this->download_or_move_font_faces( $files );
- remove_filter( 'upload_dir', array( 'WP_Font_Library', 'set_upload_dir' ) );
+ remove_filter( 'upload_dir', 'wp_get_font_dir' );
remove_filter( 'upload_mimes', array( 'WP_Font_Library', 'set_allowed_mime_types' ) );
if ( ! $were_assets_written ) {
diff --git a/lib/experimental/fonts/font-library/class-wp-font-library.php b/lib/experimental/fonts/font-library/class-wp-font-library.php
index 59ec5e93fa787e..fd36f6ba073c4f 100644
--- a/lib/experimental/fonts/font-library/class-wp-font-library.php
+++ b/lib/experimental/fonts/font-library/class-wp-font-library.php
@@ -63,11 +63,11 @@ public static function get_expected_font_mime_types_per_php_version( $php_versio
*/
public static function register_font_collection( $config ) {
$new_collection = new WP_Font_Collection( $config );
- if ( self::is_collection_registered( $config['id'] ) ) {
+ if ( self::is_collection_registered( $config['slug'] ) ) {
$error_message = sprintf(
- /* translators: %s: Font collection id. */
- __( 'Font collection with id: "%s" is already registered.', 'default' ),
- $config['id']
+ /* translators: %s: Font collection slug. */
+ __( 'Font collection with slug: "%s" is already registered.', 'default' ),
+ $config['slug']
);
_doing_it_wrong(
__METHOD__,
@@ -76,7 +76,7 @@ public static function register_font_collection( $config ) {
);
return new WP_Error( 'font_collection_registration_error', $error_message );
}
- self::$collections[ $config['id'] ] = $new_collection;
+ self::$collections[ $config['slug'] ] = $new_collection;
return $new_collection;
}
@@ -85,20 +85,20 @@ public static function register_font_collection( $config ) {
*
* @since 6.5.0
*
- * @param string $collection_id Font collection ID.
+ * @param string $collection_slug Font collection slug.
* @return bool True if the font collection was unregistered successfully and false otherwise.
*/
- public static function unregister_font_collection( $collection_id ) {
- if ( ! self::is_collection_registered( $collection_id ) ) {
+ public static function unregister_font_collection( $slug ) {
+ if ( ! self::is_collection_registered( $slug ) ) {
_doing_it_wrong(
__METHOD__,
- /* translators: %s: Font collection id. */
- sprintf( __( 'Font collection "%s" not found.', 'default' ), $collection_id ),
+ /* translators: %s: Font collection slug. */
+ sprintf( __( 'Font collection "%s" not found.', 'default' ), $slug ),
'6.5.0'
);
return false;
}
- unset( self::$collections[ $collection_id ] );
+ unset( self::$collections[ $slug ] );
return true;
}
@@ -107,11 +107,11 @@ public static function unregister_font_collection( $collection_id ) {
*
* @since 6.5.0
*
- * @param string $collection_id Font collection ID.
+ * @param string $slug Font collection slug.
* @return bool True if the font collection is registered and false otherwise.
*/
- private static function is_collection_registered( $collection_id ) {
- return array_key_exists( $collection_id, self::$collections );
+ private static function is_collection_registered( $slug ) {
+ return array_key_exists( $slug, self::$collections );
}
/**
@@ -130,52 +130,17 @@ public static function get_font_collections() {
*
* @since 6.5.0
*
- * @param string $id Font collection id.
+ * @param string $slug Font collection slug.
* @return array List of font collections.
*/
- public static function get_font_collection( $id ) {
- if ( array_key_exists( $id, self::$collections ) ) {
- return self::$collections[ $id ];
+ public static function get_font_collection( $slug ) {
+ if ( array_key_exists( $slug, self::$collections ) ) {
+ return self::$collections[ $slug ];
}
return new WP_Error( 'font_collection_not_found', 'Font collection not found.' );
}
- /**
- * Gets the upload directory for fonts.
- *
- * @since 6.5.0
- *
- * @return string Path of the upload directory for fonts.
- */
- public static function get_fonts_dir() {
- return path_join( WP_CONTENT_DIR, 'fonts' );
- }
- /**
- * Sets the upload directory for fonts.
- *
- * @since 6.5.0
- *
- * @param array $defaults {
- * Default upload directory.
- *
- * @type string $path Path to the directory.
- * @type string $url URL for the directory.
- * @type string $subdir Sub-directory of the directory.
- * @type string $basedir Base directory.
- * @type string $baseurl Base URL.
- * }
- * @return array Modified upload directory.
- */
- public static function set_upload_dir( $defaults ) {
- $defaults['basedir'] = WP_CONTENT_DIR;
- $defaults['baseurl'] = content_url();
- $defaults['subdir'] = '/fonts';
- $defaults['path'] = self::get_fonts_dir();
- $defaults['url'] = $defaults['baseurl'] . '/fonts';
-
- return $defaults;
- }
/**
* Sets the allowed mime types for fonts.
diff --git a/lib/experimental/fonts/font-library/class-wp-rest-font-collections-controller.php b/lib/experimental/fonts/font-library/class-wp-rest-font-collections-controller.php
index 2367cba0b870a7..c7595a56413b9b 100644
--- a/lib/experimental/fonts/font-library/class-wp-rest-font-collections-controller.php
+++ b/lib/experimental/fonts/font-library/class-wp-rest-font-collections-controller.php
@@ -50,7 +50,7 @@ public function register_routes() {
register_rest_route(
$this->namespace,
- '/' . $this->rest_base . '/(?PLorem ipsum dolor sit amet, consectetur adipiscing elit. Sed imperdiet ut nibh vitae ornare. Sed auctor nec augue at blandit.
" `; -exports[`{ isLoading ? __( 'Loading…' ) : __( 'No results' ) }
+ ) } +