diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 7ba9e884259ea4..a324657fad6f7d 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -82,12 +82,14 @@ /packages/scripts @gziolo @ntwb @nerrad @ajitbohra @ryanwelcher /packages/stylelint-config @ntwb /test/e2e @kevin940726 @Mamaduka +/test/php/gutenberg-coding-standards @anton-vlasenko # UI Components /packages/components @ajitbohra /packages/compose @ajitbohra /packages/element @ajitbohra /packages/notices @ajitbohra +/packages/nux @ajitbohra @peterwilsoncc /packages/viewport @ajitbohra /packages/base-styles /packages/icons diff --git a/changelog.txt b/changelog.txt index 375a1d7199ece0..ede5cff91e4eda 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,299 @@ == Changelog == += 16.3.0-rc.1 = + + + +## Changelog + +### Enhancements + +#### Site Editor +- Edit Site: Add delay and fade-in animation to loading spinner. ([51902](https://github.com/WordPress/gutenberg/pull/51902)) +- Make "My patterns" category permanently visible. ([52531](https://github.com/WordPress/gutenberg/pull/52531)) +- Remove "Theme patterns" heading in Pattern library. ([52570](https://github.com/WordPress/gutenberg/pull/52570)) +- Remove sidebar group descriptions. ([52453](https://github.com/WordPress/gutenberg/pull/52453)) +- Show warning on removal of Post Template block in the site editor. ([52666](https://github.com/WordPress/gutenberg/pull/52666)) +- Swap pattern creation options. ([52726](https://github.com/WordPress/gutenberg/pull/52726)) +- Update Dashboard button tooltips in the site editor. ([52465](https://github.com/WordPress/gutenberg/pull/52465)) +- Update Site Editor frame z-index. ([52180](https://github.com/WordPress/gutenberg/pull/52180)) +- Update descriptions in Pattern library. ([52468](https://github.com/WordPress/gutenberg/pull/52468)) +- Update locked pattern tooltips. ([52497](https://github.com/WordPress/gutenberg/pull/52497)) +- Update navigation menu title size & weight in detail panels. ([52477](https://github.com/WordPress/gutenberg/pull/52477)) +- Update pattern library copy. ([52340](https://github.com/WordPress/gutenberg/pull/52340)) +- Update: Show more intuitive archive titles on Query Title block. ([52521](https://github.com/WordPress/gutenberg/pull/52521)) + +#### Patterns +- Add hint to show template part move. ([52395](https://github.com/WordPress/gutenberg/pull/52395)) +- Add renaming, duplication, and deletion options. ([52270](https://github.com/WordPress/gutenberg/pull/52270)) +- Add sync tooltip. ([52458](https://github.com/WordPress/gutenberg/pull/52458)) +- Display all custom template part areas in sidebar nav. ([52355](https://github.com/WordPress/gutenberg/pull/52355)) +- Don't override the rootClientID in create menu - only set if undefined. ([52713](https://github.com/WordPress/gutenberg/pull/52713)) +- Enable focus mode editing. ([52427](https://github.com/WordPress/gutenberg/pull/52427)) +- Remove `reusable` text from menu once rename hint has been dismissed. ([52664](https://github.com/WordPress/gutenberg/pull/52664)) +- Stop endless snackbars appearing. ([52012](https://github.com/WordPress/gutenberg/pull/52012)) +- Try: Sticky header and pagination on Patterns page. ([52663](https://github.com/WordPress/gutenberg/pull/52663)) +- Update manage pattern links to go to site editor if available. ([52403](https://github.com/WordPress/gutenberg/pull/52403)) +- [Patterns] Separate sync status into a filter control. ([52303](https://github.com/WordPress/gutenberg/pull/52303)) + +#### Components +- Adapt template part hint copy. ([52527](https://github.com/WordPress/gutenberg/pull/52527)) +- Adding support for defined IDs in `TextControl` component. ([52028](https://github.com/WordPress/gutenberg/pull/52028)) +- Updated "position" default value. ([52148](https://github.com/WordPress/gutenberg/pull/52148)) + +#### Interactivity API +- Add filter to turn off Interactivity API for a block. ([52579](https://github.com/WordPress/gutenberg/pull/52579)) +- Add runtime support for the `wp-style` directive. ([52645](https://github.com/WordPress/gutenberg/pull/52645)) + +#### Block Library +- Add back old Navigation and File blocks JavaScript implementation when Gutenberg is not installed. ([52553](https://github.com/WordPress/gutenberg/pull/52553)) +- Home link block: Add 'current-menu-item'. ([51478](https://github.com/WordPress/gutenberg/pull/51478)) + +#### Block Editor +- Add maxLength to LinkControl search item URLs. ([52523](https://github.com/WordPress/gutenberg/pull/52523)) +- i18n: Make the tab labels of `ColorGradientSettingsDropdown` component translatable. ([52669](https://github.com/WordPress/gutenberg/pull/52669)) + +#### NUX +- Restore `@wordpress/nux` to trunk. ([52455](https://github.com/WordPress/gutenberg/pull/52455)) + +#### Block API +- Block Editor: Add support for arrays to `setImmutably` util. ([52280](https://github.com/WordPress/gutenberg/pull/52280)) + +#### Inspector Controls +- Use next40pxDefaultSize on RangeControl components. ([52257](https://github.com/WordPress/gutenberg/pull/52257)) + +#### Fonts API +- Font Face: To generate and print font-face styles for theme.json fonts. ([51770](https://github.com/WordPress/gutenberg/pull/51770)) + + +### New APIs + +#### Nested / Inner Blocks +- Stabilize `defaultBlock`, `directInsert` API's and `getDirectInsertBlock` selector. ([52083](https://github.com/WordPress/gutenberg/pull/52083)) + + +### Bug Fixes + +#### Patterns +- Alternative grid layout to improve keyboard accessibility. ([52357](https://github.com/WordPress/gutenberg/pull/52357)) +- Add handling of sync status to the wp-admin patterns list page. ([52346](https://github.com/WordPress/gutenberg/pull/52346)) +- Add missing decoding entities processing in Patterns and Template/Parts pages. ([52449](https://github.com/WordPress/gutenberg/pull/52449)) +- Add option to set sync status when adding from wp-admin patterns list. ([52352](https://github.com/WordPress/gutenberg/pull/52352)) +- Avoid copying global style presets via the styles compatibility hook. ([52640](https://github.com/WordPress/gutenberg/pull/52640)) +- Command Palette: Update label and icon for Patterns. ([52742](https://github.com/WordPress/gutenberg/pull/52742)) +- Ensure that the unsaved title is not persisted when reopening the modal. ([52473](https://github.com/WordPress/gutenberg/pull/52473)) +- Fix bug with Create Patterns menu not showing in site editor page editing. ([52671](https://github.com/WordPress/gutenberg/pull/52671)) +- Fix renaming in Site View sidebar rename saves all edits for Template Parts and Navigation Menus. ([52373](https://github.com/WordPress/gutenberg/pull/52373)) +- Fix: Patterns & template parts: Remove "apply globally" option from block settings. ([52160](https://github.com/WordPress/gutenberg/pull/52160)) +- Rename edit label to Edit Block Pattern to resolve edge case in Chrome. ([52496](https://github.com/WordPress/gutenberg/pull/52496)) +- Show uncategorized patterns on the Editor > Patterns page. ([52633](https://github.com/WordPress/gutenberg/pull/52633)) +- Site Editor Patterns: Filter out patterns that are not available in the inserter. ([52675](https://github.com/WordPress/gutenberg/pull/52675)) +- Update the title of Pattern block in the block inspector card. ([52010](https://github.com/WordPress/gutenberg/pull/52010)) + +#### Site Editor +- Edit Site: Fix the pattern with the post types becomes the placeholder pattern when editing template part. ([52503](https://github.com/WordPress/gutenberg/pull/52503)) +- Fix "Manage all patterns" link appearance. ([52532](https://github.com/WordPress/gutenberg/pull/52532)) +- Fix document title icon appearance. ([52424](https://github.com/WordPress/gutenberg/pull/52424)) +- Fix entering edit mode in site editor. ([52406](https://github.com/WordPress/gutenberg/pull/52406)) +- Fix missing Add Template Part button in Template Parts page. ([52542](https://github.com/WordPress/gutenberg/pull/52542)) +- Fix undo/redo in site editor code editor's mode. ([52695](https://github.com/WordPress/gutenberg/pull/52695)) +- Remove status icon. ([52457](https://github.com/WordPress/gutenberg/pull/52457)) +- Reset device preview type when exiting the editing mode. ([52566](https://github.com/WordPress/gutenberg/pull/52566)) +- ResizableFrame: Fix styling in Firefox. ([52700](https://github.com/WordPress/gutenberg/pull/52700)) +- Site Editor Pages: Load the appropriate template if posts page set. ([52266](https://github.com/WordPress/gutenberg/pull/52266)) +- Site Editor Patterns: Ensure sidebar does not shrink when long pattern titles are used. ([52547](https://github.com/WordPress/gutenberg/pull/52547)) +- Use lowercase p in in "Manage Patterns". ([52617](https://github.com/WordPress/gutenberg/pull/52617)) +- Do not navigate to the styles pages unless you're in a random listing page. ([52728](https://github.com/WordPress/gutenberg/pull/52728)) +- Fix multiple navigation blocks in pattern template. ([52707](https://github.com/WordPress/gutenberg/pull/52707)) + +#### Block Library +- Fix console warning by improving error handling in Nav block classic menu conversion. ([52591](https://github.com/WordPress/gutenberg/pull/52591)) +- Fix importing classic menus. ([52573](https://github.com/WordPress/gutenberg/pull/52573)) +- Fix: Focus loss on navigation link label editing on Firefox. ([52428](https://github.com/WordPress/gutenberg/pull/52428)) +- List block: Fix selected numbering style option. ([52472](https://github.com/WordPress/gutenberg/pull/52472)) +- Post Title: The changes should be reflected when previewing a post. ([52369](https://github.com/WordPress/gutenberg/pull/52369)) +- Quote block: Add transform to paragraph. ([51809](https://github.com/WordPress/gutenberg/pull/51809)) +- Remove synced blocks from lastBlockInserted. ([52558](https://github.com/WordPress/gutenberg/pull/52558)) +- Rich Text/Footnotes: Fix getRichTextValues for useInnerBlocksProps.save. ([52682](https://github.com/WordPress/gutenberg/pull/52682)) +- Search block: Enqueue view script through block.json. ([52552](https://github.com/WordPress/gutenberg/pull/52552)) +- Use `_get_block_template_file` function and set $area variable. ([52708](https://github.com/WordPress/gutenberg/pull/52708)) + +#### Accessibility +- Change Delete page menu item to Move to trash. ([52641](https://github.com/WordPress/gutenberg/pull/52641)) +- Change password input to type text so contents are visible. ([52622](https://github.com/WordPress/gutenberg/pull/52622)) +- Do not autofocus page title field in the 'Draft a new page' modal dialog. ([52603](https://github.com/WordPress/gutenberg/pull/52603)) +- Fix Shift+Tab to Block Toolbar. ([52613](https://github.com/WordPress/gutenberg/pull/52613)) +- Item: Unify focus style and add default font styles. ([52495](https://github.com/WordPress/gutenberg/pull/52495)) +- Navigation block: Add notice on reduced accessibility. ([52251](https://github.com/WordPress/gutenberg/pull/52251)) +- Password protected field: Remove autofocus and improve placeholder text consistency. ([52634](https://github.com/WordPress/gutenberg/pull/52634)) +- ResizableFrame: Make keyboard accessible. ([52443](https://github.com/WordPress/gutenberg/pull/52443)) +- Site Editor: Fix navigation menu sidebar actions order and label. ([52592](https://github.com/WordPress/gutenberg/pull/52592)) + +#### Block Editor +- Add 'reusable' keyword to Pattern blocks. ([52543](https://github.com/WordPress/gutenberg/pull/52543)) +- Avoid errors in Dimension visualizers when switching between iframed and non-iframed editors. ([52588](https://github.com/WordPress/gutenberg/pull/52588)) +- Ensure synced patterns are accounted for in 'getAllowedBlocks'. ([52546](https://github.com/WordPress/gutenberg/pull/52546)) +- Fix: Remove link action of Link UI for draft pages created from Nav block does not correctly remove link. ([52415](https://github.com/WordPress/gutenberg/pull/52415)) +- LinkControl: Add width to ensure ellipsis truncating works. ([52575](https://github.com/WordPress/gutenberg/pull/52575)) +- LinkControl: Fix mark highlight to bold. ([52517](https://github.com/WordPress/gutenberg/pull/52517)) +- Post Content link color should not be applied to placeholder component links. ([52367](https://github.com/WordPress/gutenberg/pull/52367)) +- Fix highlight change when using transform menu. ([52752](https://github.com/WordPress/gutenberg/pull/52752)) +- Fix: Apply text color selection to link color. ([52379](https://github.com/WordPress/gutenberg/pull/52379)) + +#### Components +- Block Editor: Display variation icon in the 'BlockDraggable' component. ([52502](https://github.com/WordPress/gutenberg/pull/52502)) +- Copy tweak for the reusable block rename hint. ([52581](https://github.com/WordPress/gutenberg/pull/52581)) +- Fix react-dropdown-menu version to avoid breaking change from one of …. ([52356](https://github.com/WordPress/gutenberg/pull/52356)) +- FormTokenField: Fix token overflow when moving cursor left or right. ([52662](https://github.com/WordPress/gutenberg/pull/52662)) +- Site Editor: Make sidebar back button go *back* instead of *up* if possible. ([52456](https://github.com/WordPress/gutenberg/pull/52456)) +- Top Toolbar: Move the preferences selection into the main useSelect. ([52332](https://github.com/WordPress/gutenberg/pull/52332)) + +#### Post Editor +- Editor: Remove a block select button from the multi-entity saving flow. ([52753](https://github.com/WordPress/gutenberg/pull/52753)) +- Fix Site editor page when JS support is disabled. ([52376](https://github.com/WordPress/gutenberg/pull/52376)) +- Fix initial block parsing. ([52417](https://github.com/WordPress/gutenberg/pull/52417)) +- Simplify the code editor of edit-post. ([52751](https://github.com/WordPress/gutenberg/pull/52751)) + +#### Global Styles +- DimensionsPanel: Fix unexpected value decoding/encoding. ([52661](https://github.com/WordPress/gutenberg/pull/52661)) +- Global font sizes: Ensure sizes are unique. ([52483](https://github.com/WordPress/gutenberg/pull/52483)) +- Spacing Sizes: Fix zero size typo and to be output directly. ([52711](https://github.com/WordPress/gutenberg/pull/52711)) + +#### Themes +- Fix admin_url() for preview link of block themes. ([52399](https://github.com/WordPress/gutenberg/pull/52399)) +- Site Editor: Don't allow creating template part on the Patterns page for non-block themes. ([52656](https://github.com/WordPress/gutenberg/pull/52656)) + +#### Fonts API +- Deprecate and make Fonts API non-functional. ([52485](https://github.com/WordPress/gutenberg/pull/52485)) +- Fix font printing regression when metabox exists. ([52343](https://github.com/WordPress/gutenberg/pull/52343)) + +#### Extensibility +- Page Content Focus: Ignore page content within a Query Loop block. ([52351](https://github.com/WordPress/gutenberg/pull/52351)) + +#### Page Content Focus +- Exit template focus when opening the W menu. ([52235](https://github.com/WordPress/gutenberg/pull/52235)) + +#### Block Validation/Deprecation +- Cover Block: Fix block deprecation when fixed background is enabled. ([51612](https://github.com/WordPress/gutenberg/pull/51612)) + + +### Performance + +#### Post Editor +- Fix performance regression for isEditedPostEmpty selector. ([52759](https://github.com/WordPress/gutenberg/pull/52759)) + +#### Patterns +- Add client side pagination to patterns list. ([52538](https://github.com/WordPress/gutenberg/pull/52538)) + +#### Site Editor +- Fix entity cache misses for single posts due to string as recordKey. ([52338](https://github.com/WordPress/gutenberg/pull/52338)) + +#### Block Library +- Experimental: Disable TinyMCE compat with classic editor. ([52325](https://github.com/WordPress/gutenberg/pull/52325)) + + +### Experiments + +#### Project Management +- Github workflow: Add a PHP backport changes action. ([52096](https://github.com/WordPress/gutenberg/pull/52096)) + +#### Interactivity API +- Prevent scripts from loading if behaviors are not used. ([52140](https://github.com/WordPress/gutenberg/pull/52140)) + + +### Documentation + +- (readme.md) Document the new process for releasing point releases for old release branches. ([49968](https://github.com/WordPress/gutenberg/pull/49968)) +- Add layout API documentation. ([52673](https://github.com/WordPress/gutenberg/pull/52673)) +- Added README for the "caption" component. ([52033](https://github.com/WordPress/gutenberg/pull/52033)) +- Added documentation text-transform component #52072. ([52243](https://github.com/WordPress/gutenberg/pull/52243)) +- Block Editor: Add README for `BlockControls`. ([52366](https://github.com/WordPress/gutenberg/pull/52366)) +- Lodash: Remove completely. ([52571](https://github.com/WordPress/gutenberg/pull/52571)) +- Removed line break within the code block. ([46920](https://github.com/WordPress/gutenberg/pull/46920)) +- Theme JSON schema: Add missing block names and unify block properties. ([51293](https://github.com/WordPress/gutenberg/pull/51293)) +- Update layout architecture documentation after stabilisation. ([52316](https://github.com/WordPress/gutenberg/pull/52316)) + + +### Code Quality + +- Add missing `@emotion/react` dep to block-editor. ([52475](https://github.com/WordPress/gutenberg/pull/52475)) +- Code Data: Fix ESLint warning for 'useEntityProp' hook. ([52757](https://github.com/WordPress/gutenberg/pull/52757)) +- Lodash: Deprecate `_.set()`. ([52407](https://github.com/WordPress/gutenberg/pull/52407)) +- Lodash: Remove remaining `_.get()` from block editor and deprecate. ([52561](https://github.com/WordPress/gutenberg/pull/52561)) +- Make use of accessing private APIs from thunks directly. ([52214](https://github.com/WordPress/gutenberg/pull/52214)) + +#### Block Library +- Footnotes: Backport core changes to excerpt trim. ([52709](https://github.com/WordPress/gutenberg/pull/52709)) +- Navigation: Simplify the useSelect for useNavigationMenus. ([51977](https://github.com/WordPress/gutenberg/pull/51977)) +- Query Pagination: Set 'clientId' as useSelect dependency. ([52358](https://github.com/WordPress/gutenberg/pull/52358)) +- Search: Remove unnecessary useEffect. ([52604](https://github.com/WordPress/gutenberg/pull/52604)) +- Template Parts: Set attributes 'area' as useSelect dependency. ([52330](https://github.com/WordPress/gutenberg/pull/52330)) + +#### Global Styles +- Lodash: Refactor away from `_.set()` in `PushChangesToGlobalStylesControl`. ([52404](https://github.com/WordPress/gutenberg/pull/52404)) +- Lodash: Refactor away from `_.set()` in `getNodesWithSettings()`. ([52278](https://github.com/WordPress/gutenberg/pull/52278)) +- Lodash: Refactor away from `_.set()` in global styles. ([52279](https://github.com/WordPress/gutenberg/pull/52279)) +- Lodash: Remove completely from site editor. ([52480](https://github.com/WordPress/gutenberg/pull/52480)) + +#### Post Editor +- EntityRecordItem: Fix ESLint warnings and remove unnecessary memoization. ([52630](https://github.com/WordPress/gutenberg/pull/52630)) +- PostPreviewButton: Rewrite to functional, avoid state transitions in lifecycles. ([44971](https://github.com/WordPress/gutenberg/pull/44971)) +- correct a typo: Sapce -> space. ([52578](https://github.com/WordPress/gutenberg/pull/52578)) + +#### Site Editor +- Fix incorrect 'useSelect' usage. ([52683](https://github.com/WordPress/gutenberg/pull/52683)) +- SiteHub: Combine site data selector hooks. ([52567](https://github.com/WordPress/gutenberg/pull/52567)) + +#### Reusable Blocks +- Update package to use relative path. ([52712](https://github.com/WordPress/gutenberg/pull/52712)) + + +### Tools + +#### Testing +- Iframe: Silence style compat warnings when in a BlockPreview. ([52627](https://github.com/WordPress/gutenberg/pull/52627)) +- Make `query` optional in `visitAdminPage`. ([52413](https://github.com/WordPress/gutenberg/pull/52413)) +- Migrate Adding Inline Token test to Playwright. ([52020](https://github.com/WordPress/gutenberg/pull/52020)) +- Migrate site editor multi-entity save flow tests. ([52372](https://github.com/WordPress/gutenberg/pull/52372)) +- Move request utils reset to global setup. ([52412](https://github.com/WordPress/gutenberg/pull/52412)) +- Nav block: Link text color inheritance fixes and tests. ([51710](https://github.com/WordPress/gutenberg/pull/51710)) +- Refactor and split navigation block end-to-end tests into separate files. ([52647](https://github.com/WordPress/gutenberg/pull/52647)) +- Try fixing block context end-to-end test failure. ([52513](https://github.com/WordPress/gutenberg/pull/52513)) +- Use posts instead of template parts for navigation color tests. ([52654](https://github.com/WordPress/gutenberg/pull/52654)) +- end-to-end Test Utils: Improve test reliability in plugins/themes and login procedures. ([52144](https://github.com/WordPress/gutenberg/pull/52144)) +- test: Enable jest-watch-typeahead for native tests. ([51869](https://github.com/WordPress/gutenberg/pull/51869)) +- test: Expand mobile editor tests. ([52446](https://github.com/WordPress/gutenberg/pull/52446)) + +#### Build Tooling +- Backport tools: Sort PRs to be cherry picked by merged/closed date. ([52667](https://github.com/WordPress/gutenberg/pull/52667)) +- Create block interactive template. ([52612](https://github.com/WordPress/gutenberg/pull/52612)) +- Fix Webpack to watch the `interactivity` package files. ([52642](https://github.com/WordPress/gutenberg/pull/52642)) +- Update caniuse-lite, browserslist and core-js. ([52420](https://github.com/WordPress/gutenberg/pull/52420)) + +#### Project Management +- Update issue gardening automation with new label. ([52173](https://github.com/WordPress/gutenberg/pull/52173)) + +### Various + +- Revert "Update Changelog for 16.1.2". ([52433](https://github.com/WordPress/gutenberg/pull/52433)) + + +## First time contributors + +The following PRs were merged by first time contributors: + +- @andrewhayward: Adding support for defined IDs in `TextControl` component. ([52028](https://github.com/WordPress/gutenberg/pull/52028)) +- @ghorivipul97: Post Content link color should not be applied to placeholder component links. ([52367](https://github.com/WordPress/gutenberg/pull/52367)) +- @sethrubenstein: Stabilize `defaultBlock`, `directInsert` API's and `getDirectInsertBlock` selector. ([52083](https://github.com/WordPress/gutenberg/pull/52083)) + + +## Contributors + +The following contributors merged PRs in this release: + +@aaronrobertshaw @afercia @andrewhayward @andrewserong @anomiex @arthur791004 @BenjaminZekavica @bfintal @carolinan @Clorith @dcalhoun @derekblank @diegohaz @draganescu @ellatrix @fluiddot @fullofcaffeine @geriux @getdave @ghorivipul97 @glendaviesnz @hellofromtonya @jameskoster @jeryj @jorgefilipecosta @jsnajdr @juanmaguitar @kevin940726 @luisherranz @MaggieCabrera @Mamaduka @michalczaplinski @mirka @noisysocks @ntsekouras @peterwilsoncc @pooja-muchandikar @Presskopp @priethor @ramonjd @richtabor @SantosGuillamot @SavPhill @SaxonF @scruffian @sethrubenstein @spacedmonkey @swissspidy @t-hamano @tellthemachines @tyxla @walbo @westonruter @youknowriad + + = 16.2.1 = ## Changelog diff --git a/composer.json b/composer.json index 3f16ba495a94ca..134e366befdb94 100644 --- a/composer.json +++ b/composer.json @@ -32,8 +32,18 @@ "wp-coding-standards/wpcs": "^2.2", "sirbrillig/phpcs-variable-analysis": "^2.8", "spatie/phpunit-watcher": "^1.23", - "yoast/phpunit-polyfills": "^1.0" + "yoast/phpunit-polyfills": "^1.0", + "gutenberg/gutenberg-coding-standards": "@dev" }, + "repositories": [ + { + "type": "path", + "url": "./test/php/gutenberg-coding-standards", + "options": { + "symlink": false + } + } + ], "require": { "composer/installers": "~1.0" }, diff --git a/docs/assets/text-transform-component.png b/docs/assets/text-transform-component.png new file mode 100644 index 00000000000000..2155fbdb8ebef6 Binary files /dev/null and b/docs/assets/text-transform-component.png differ diff --git a/docs/contributors/code/scripts.md b/docs/contributors/code/scripts.md index 5cd7efd2fffdad..1483a409a4d08f 100644 --- a/docs/contributors/code/scripts.md +++ b/docs/contributors/code/scripts.md @@ -31,6 +31,7 @@ The editor includes a number of packages to enable various pieces of functionali | [Is Shallow Equal](/packages/is-shallow-equal/README.md) | wp-is-shallow-equal | A function for performing a shallow comparison between two objects or arrays | | [Keycodes](/packages/keycodes/README.md) | wp-keycodes | Keycodes utilities for WordPress, used to check the key pressed in events like `onKeyDown` | | [List Reusable blocks](/packages/list-reusable-blocks/README.md) | wp-list-reusable-blocks | Package used to add import/export links to the listing page of the reusable blocks | +| [NUX](/packages/nux/README.md) | wp-nux | Components, and wp.data methods useful for onboarding a new user to the WordPress admin interface | | [Plugins](/packages/plugins/README.md) | wp-plugins | Plugins module for WordPress | | [Redux Routine](/packages/redux-routine/README.md) | wp-redux-routine | Redux middleware for generator coroutines | | [Rich Text](/packages/rich-text/README.md) | wp-rich-text | Helper functions to convert HTML or a DOM tree into a rich text value and back | diff --git a/docs/how-to-guides/themes/theme-support.md b/docs/how-to-guides/themes/theme-support.md index eae72f255fac2c..b978ede928b83d 100644 --- a/docs/how-to-guides/themes/theme-support.md +++ b/docs/how-to-guides/themes/theme-support.md @@ -472,6 +472,8 @@ Use this setting to enable the following Global Styles settings: - color: link - spacing: blockGap, margin, padding - typography: lineHeight +- dimensions: minHeight +- position: sticky ```php add_theme_support( 'appearance-tools' ); diff --git a/docs/manifest.json b/docs/manifest.json index ec55132cd7d4b2..5f75e49924f355 100644 --- a/docs/manifest.json +++ b/docs/manifest.json @@ -1757,6 +1757,12 @@ "markdown_source": "../packages/npm-package-json-lint-config/README.md", "parent": "packages" }, + { + "title": "@wordpress/nux", + "slug": "packages-nux", + "markdown_source": "../packages/nux/README.md", + "parent": "packages" + }, { "title": "@wordpress/plugins", "slug": "packages-plugins", @@ -2003,6 +2009,12 @@ "markdown_source": "../docs/reference-guides/data/data-core-notices.md", "parent": "data" }, + { + "title": "The NUX (New User Experience) Data", + "slug": "data-core-nux", + "markdown_source": "../docs/reference-guides/data/data-core-nux.md", + "parent": "data" + }, { "title": "Preferences", "slug": "data-core-preferences", diff --git a/docs/reference-guides/README.md b/docs/reference-guides/README.md index f13c838697f2de..33fdd9aa602414 100644 --- a/docs/reference-guides/README.md +++ b/docs/reference-guides/README.md @@ -63,6 +63,7 @@ - [**core/editor**: The Post Editor’s Data](/docs/reference-guides/data/data-core-editor.md) - [**core/keyboard-shortcuts**: The Keyboard Shortcuts Data](/docs/reference-guides/data/data-core-keyboard-shortcuts.md) - [**core/notices**: Notices Data](/docs/reference-guides/data/data-core-notices.md) + - [**core/nux**: The NUX (New User Experience) Data](/docs/reference-guides/data/data-core-nux.md) - [**core/preferences**: Preferences](/docs/reference-guides/data/data-core-preferences.md) - [**core/reusable-blocks**: Reusable blocks](/docs/reference-guides/data/data-core-reusable-blocks.md) - [**core/rich-text**: Rich Text](/docs/reference-guides/data/data-core-rich-text.md) diff --git a/docs/reference-guides/data/README.md b/docs/reference-guides/data/README.md index 5f4d8d92d4bd49..1134c1d5ddd307 100644 --- a/docs/reference-guides/data/README.md +++ b/docs/reference-guides/data/README.md @@ -12,6 +12,7 @@ - [**core/editor**: The Post Editor’s Data](/docs/reference-guides/data/data-core-editor.md) - [**core/keyboard-shortcuts**: The Keyboard Shortcuts Data](/docs/reference-guides/data/data-core-keyboard-shortcuts.md) - [**core/notices**: Notices Data](/docs/reference-guides/data/data-core-notices.md) +- [**core/nux**: The NUX (New User Experience) Data](/docs/reference-guides/data/data-core-nux.md) - [**core/preferences**: Preferences](/docs/reference-guides/data/data-core-preferences.md) - [**core/reusable-blocks**: Reusable blocks](/docs/reference-guides/data/data-core-reusable-blocks.md) - [**core/rich-text**: Rich Text](/docs/reference-guides/data/data-core-rich-text.md) diff --git a/docs/reference-guides/data/data-core-block-editor.md b/docs/reference-guides/data/data-core-block-editor.md index fd29b1c6e1388c..744b7b2896e26a 100644 --- a/docs/reference-guides/data/data-core-block-editor.md +++ b/docs/reference-guides/data/data-core-block-editor.md @@ -168,29 +168,6 @@ _Returns_ - `Array?`: The list of allowed block types. -### getBehaviors - -Returns the behaviors registered with the editor. - -Behaviors are named, reusable pieces of functionality that can be attached to blocks. They are registered with the editor using the `theme.json` file. - -_Usage_ - -```js -const behaviors = select( blockEditorStore ).getBehaviors(); -if ( behaviors?.lightbox ) { - // Do something with the lightbox. -} -``` - -_Parameters_ - -- _state_ `Object`: Editor state. - -_Returns_ - -- `Object`: The editor behaviors object. - ### getBlock Returns a block given its client ID. This is a parsed copy of the block, containing its `blockName`, `clientId`, and current `attributes` state. This is not the block's registration settings, which must be retrieved from the blocks module registration store. diff --git a/docs/reference-guides/data/data-core-nux.md b/docs/reference-guides/data/data-core-nux.md new file mode 100644 index 00000000000000..eb6a1c3b5c9a5b --- /dev/null +++ b/docs/reference-guides/data/data-core-nux.md @@ -0,0 +1,93 @@ +# The NUX (New User Experience) Data + +Namespace: `core/nux`. + +## Selectors + + + +### areTipsEnabled + +Returns whether or not tips are globally enabled. + +_Parameters_ + +- _state_ `Object`: Global application state. + +_Returns_ + +- `boolean`: Whether tips are globally enabled. + +### getAssociatedGuide + +Returns an object describing the guide, if any, that the given tip is a part of. + +_Parameters_ + +- _state_ `Object`: Global application state. +- _tipId_ `string`: The tip to query. + +_Returns_ + +- `?NUXGuideInfo`: Information about the associated guide. + +### isTipVisible + +Determines whether or not the given tip is showing. Tips are hidden if they are disabled, have been dismissed, or are not the current tip in any guide that they have been added to. + +_Parameters_ + +- _state_ `Object`: Global application state. +- _tipId_ `string`: The tip to query. + +_Returns_ + +- `boolean`: Whether or not the given tip is showing. + + + +## Actions + + + +### disableTips + +Returns an action object that, when dispatched, prevents all tips from showing again. + +_Returns_ + +- `Object`: Action object. + +### dismissTip + +Returns an action object that, when dispatched, dismisses the given tip. A dismissed tip will not show again. + +_Parameters_ + +- _id_ `string`: The tip to dismiss. + +_Returns_ + +- `Object`: Action object. + +### enableTips + +Returns an action object that, when dispatched, makes all tips show again. + +_Returns_ + +- `Object`: Action object. + +### triggerGuide + +Returns an action object that, when dispatched, presents a guide that takes the user through a series of tips step by step. + +_Parameters_ + +- _tipIds_ `string[]`: Which tips to show in the guide. + +_Returns_ + +- `Object`: Action object. + + diff --git a/docs/toc.json b/docs/toc.json index 085bbb536ece2b..1660afdcc29497 100644 --- a/docs/toc.json +++ b/docs/toc.json @@ -284,6 +284,7 @@ "docs/reference-guides/data/data-core-keyboard-shortcuts.md": [] }, { "docs/reference-guides/data/data-core-notices.md": [] }, + { "docs/reference-guides/data/data-core-nux.md": [] }, { "docs/reference-guides/data/data-core-preferences.md": [] }, diff --git a/gutenberg.php b/gutenberg.php index 8a5b9e110a51c6..cb3300bfae0b4f 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.1 * Requires PHP: 5.6 - * Version: 16.2.1 + * Version: 16.3.0-rc.1 * Author: Gutenberg Team * Text Domain: gutenberg * diff --git a/lib/class-wp-duotone-gutenberg.php b/lib/class-wp-duotone-gutenberg.php index 816f7e414ad793..41120a882ed235 100644 --- a/lib/class-wp-duotone-gutenberg.php +++ b/lib/class-wp-duotone-gutenberg.php @@ -32,6 +32,10 @@ * @since 6.3.0 */ +if ( class_exists( 'WP_Duotone_Gutenberg' ) ) { + return; +} + /** * Manages duotone block supports and global styles. * diff --git a/lib/class-wp-theme-json-data-gutenberg.php b/lib/class-wp-theme-json-data-gutenberg.php index 2e5ea474346a92..db0737ebea08b6 100644 --- a/lib/class-wp-theme-json-data-gutenberg.php +++ b/lib/class-wp-theme-json-data-gutenberg.php @@ -6,6 +6,10 @@ * @since 6.1.0 */ +if ( class_exists( 'WP_Theme_JSON_Data_Gutenberg' ) ) { + return; +} + /** * Class to provide access to update a theme.json structure. */ diff --git a/lib/class-wp-theme-json-gutenberg.php b/lib/class-wp-theme-json-gutenberg.php index 0745ee06b84a23..60e69632eedb62 100644 --- a/lib/class-wp-theme-json-gutenberg.php +++ b/lib/class-wp-theme-json-gutenberg.php @@ -6,6 +6,10 @@ * @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. * diff --git a/lib/class-wp-theme-json-resolver-gutenberg.php b/lib/class-wp-theme-json-resolver-gutenberg.php index 1e825e3c6bbe4f..39721742946cd1 100644 --- a/lib/class-wp-theme-json-resolver-gutenberg.php +++ b/lib/class-wp-theme-json-resolver-gutenberg.php @@ -6,6 +6,10 @@ * @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. diff --git a/lib/client-assets.php b/lib/client-assets.php index 99aa7f147ecbfc..891eb05eabdbeb 100644 --- a/lib/client-assets.php +++ b/lib/client-assets.php @@ -368,6 +368,15 @@ function gutenberg_register_packages_styles( $styles ) { ); $styles->add_data( 'wp-edit-blocks', 'rtl', 'replace' ); + gutenberg_override_style( + $styles, + 'wp-nux', + gutenberg_url( 'build/nux/style.css' ), + array( 'wp-components' ), + $version + ); + $styles->add_data( 'wp-nux', 'rtl', 'replace' ); + gutenberg_override_style( $styles, 'wp-block-library-theme', diff --git a/lib/compat/wordpress-6.2/html-api/class-wp-html-attribute-token.php b/lib/compat/wordpress-6.2/html-api/class-wp-html-attribute-token.php index 2c52164a979f02..cc03c1441ee042 100644 --- a/lib/compat/wordpress-6.2/html-api/class-wp-html-attribute-token.php +++ b/lib/compat/wordpress-6.2/html-api/class-wp-html-attribute-token.php @@ -7,6 +7,10 @@ * @since 6.2.0 */ +if ( class_exists( 'WP_HTML_Attribute_Token' ) ) { + return; +} + /** * Data structure for the attribute token that allows to drastically improve performance. * diff --git a/lib/compat/wordpress-6.2/html-api/class-wp-html-span.php b/lib/compat/wordpress-6.2/html-api/class-wp-html-span.php index d92778cd3a2223..e38bc551923170 100644 --- a/lib/compat/wordpress-6.2/html-api/class-wp-html-span.php +++ b/lib/compat/wordpress-6.2/html-api/class-wp-html-span.php @@ -7,6 +7,10 @@ * @since 6.2.0 */ +if ( class_exists( 'WP_HTML_Span' ) ) { + return; +} + /** * Represents a textual span inside an HTML document. * diff --git a/lib/compat/wordpress-6.2/html-api/class-wp-html-tag-processor.php b/lib/compat/wordpress-6.2/html-api/class-wp-html-tag-processor.php index 7edb67f9f0423e..d61180074f608d 100644 --- a/lib/compat/wordpress-6.2/html-api/class-wp-html-tag-processor.php +++ b/lib/compat/wordpress-6.2/html-api/class-wp-html-tag-processor.php @@ -26,6 +26,10 @@ * @since 6.2.0 */ +if ( class_exists( 'WP_HTML_Tag_Processor' ) ) { + return; +} + /** * Modifies attributes in an HTML document for tags matching a query. * diff --git a/lib/compat/wordpress-6.2/html-api/class-wp-html-text-replacement.php b/lib/compat/wordpress-6.2/html-api/class-wp-html-text-replacement.php index 912b4a56a5eb42..b3f70c8e7c57f4 100644 --- a/lib/compat/wordpress-6.2/html-api/class-wp-html-text-replacement.php +++ b/lib/compat/wordpress-6.2/html-api/class-wp-html-text-replacement.php @@ -7,6 +7,10 @@ * @since 6.2.0 */ +if ( class_exists( 'WP_HTML_Text_Replacement' ) ) { + return; +} + /** * Data structure used to replace existing content from start to end that allows to drastically improve performance. * diff --git a/lib/compat/wordpress-6.2/rest-api.php b/lib/compat/wordpress-6.2/rest-api.php index c0f098fa6893ac..97f7daecdff2f7 100644 --- a/lib/compat/wordpress-6.2/rest-api.php +++ b/lib/compat/wordpress-6.2/rest-api.php @@ -91,43 +91,46 @@ function gutenberg_modify_rest_sidebars_response( $response ) { } add_filter( 'rest_prepare_sidebar', 'gutenberg_modify_rest_sidebars_response' ); - -/** - * Add the `block_types` value to the `pattern-directory-item` schema. - * - * @since 6.2.0 Added 'block_types' property. - */ -function add_block_pattern_block_types_schema() { - register_rest_field( - 'pattern-directory-item', - 'block_types', - array( - 'schema' => array( - 'description' => __( 'The block types which can use this pattern.', 'gutenberg' ), - 'type' => 'array', - 'uniqueItems' => true, - 'items' => array( 'type' => 'string' ), - 'context' => array( 'view', 'embed' ), - ), - ) - ); +if ( ! function_exists( 'add_block_pattern_block_types_schema' ) ) { + /** + * Add the `block_types` value to the `pattern-directory-item` schema. + * + * @since 6.2.0 Added 'block_types' property. + */ + function add_block_pattern_block_types_schema() { + register_rest_field( + 'pattern-directory-item', + 'block_types', + array( + 'schema' => array( + 'description' => __( 'The block types which can use this pattern.', 'gutenberg' ), + 'type' => 'array', + 'uniqueItems' => true, + 'items' => array( 'type' => 'string' ), + 'context' => array( 'view', 'embed' ), + ), + ) + ); + } } add_filter( 'rest_api_init', 'add_block_pattern_block_types_schema' ); -/** - * Add the `block_types` value into the API response. - * - * @since 6.2.0 Added 'block_types' property. - * - * @param WP_REST_Response $response The response object. - * @param object $raw_pattern The unprepared pattern. - */ -function filter_block_pattern_response( $response, $raw_pattern ) { - $data = $response->get_data(); - $data['block_types'] = array_map( 'sanitize_text_field', $raw_pattern->meta->wpop_block_types ); - $response->set_data( $data ); - return $response; +if ( ! function_exists( 'filter_block_pattern_response' ) ) { + /** + * Add the `block_types` value into the API response. + * + * @since 6.2.0 Added 'block_types' property. + * + * @param WP_REST_Response $response The response object. + * @param object $raw_pattern The unprepared pattern. + */ + function filter_block_pattern_response( $response, $raw_pattern ) { + $data = $response->get_data(); + $data['block_types'] = array_map( 'sanitize_text_field', $raw_pattern->meta->wpop_block_types ); + $response->set_data( $data ); + return $response; + } } add_filter( 'rest_prepare_block_pattern', 'filter_block_pattern_response', 10, 2 ); diff --git a/lib/compat/wordpress-6.3/class-gutenberg-rest-global-styles-revisions-controller-6-3.php b/lib/compat/wordpress-6.3/class-gutenberg-rest-global-styles-revisions-controller-6-3.php index c45ce23c5d4ea7..e9c73a717d3d0d 100644 --- a/lib/compat/wordpress-6.3/class-gutenberg-rest-global-styles-revisions-controller-6-3.php +++ b/lib/compat/wordpress-6.3/class-gutenberg-rest-global-styles-revisions-controller-6-3.php @@ -21,7 +21,7 @@ class Gutenberg_REST_Global_Styles_Revisions_Controller_6_3 extends WP_REST_Cont * @since 6.3.0 * @var string */ - private $parent_post_type; + protected $parent_post_type; /** * The base of the parent controller's route. @@ -102,7 +102,7 @@ public function get_collection_params() { * @param string $raw_json Encoded JSON from global styles custom post content. * @return Array|WP_Error */ - private function get_decoded_global_styles_json( $raw_json ) { + protected function get_decoded_global_styles_json( $raw_json ) { $decoded_json = json_decode( $raw_json, true ); if ( is_array( $decoded_json ) && isset( $decoded_json['isGlobalStylesUserThemeJSON'] ) && true === $decoded_json['isGlobalStylesUserThemeJSON'] ) { diff --git a/lib/compat/wordpress-6.3/footnotes.php b/lib/compat/wordpress-6.3/footnotes.php index 45f4c74b05e37b..6225b280e1b6c2 100644 --- a/lib/compat/wordpress-6.3/footnotes.php +++ b/lib/compat/wordpress-6.3/footnotes.php @@ -18,8 +18,15 @@ function gutenberg_trim_footnotes( $content ) { return $content; } - static $footnote_pattern = '_\s*\d+\s*_'; - return preg_replace( $footnote_pattern, '', $content ); + if ( ! str_contains( $content, 'data-fn=' ) ) { + return $content; + } + + return preg_replace( + '_\s*\d+\s*_', + '', + $content + ); } add_filter( 'the_content', 'gutenberg_trim_footnotes' ); diff --git a/lib/compat/wordpress-6.3/kses.php b/lib/compat/wordpress-6.3/kses.php index 23eee580f831ab..b0b7356d2dac1c 100644 --- a/lib/compat/wordpress-6.3/kses.php +++ b/lib/compat/wordpress-6.3/kses.php @@ -7,21 +7,23 @@ * @package gutenberg */ -/** - * Mark CSS safe if it contains grid functions - * - * This function should not be backported to core. - * - * @param bool $allow_css Whether the CSS is allowed. - * @param string $css_test_string The CSS to test. - */ -function allow_grid_functions_in_styles( $allow_css, $css_test_string ) { - if ( preg_match( - '/^grid-template-columns:\s*repeat\([0-9,a-z-\s\(\)]*\)$/', - $css_test_string - ) ) { - return true; +if ( ! function_exists( 'allow_grid_functions_in_styles' ) ) { + /** + * Mark CSS safe if it contains grid functions + * + * This function should not be backported to core. + * + * @param bool $allow_css Whether the CSS is allowed. + * @param string $css_test_string The CSS to test. + */ + function allow_grid_functions_in_styles( $allow_css, $css_test_string ) { + if ( preg_match( + '/^grid-template-columns:\s*repeat\([0-9,a-z-\s\(\)]*\)$/', + $css_test_string + ) ) { + return true; + } + return $allow_css; } - return $allow_css; } add_filter( 'safecss_filter_attr_allow_css', 'allow_grid_functions_in_styles', 10, 2 ); diff --git a/lib/compat/wordpress-6.3/rest-api.php b/lib/compat/wordpress-6.3/rest-api.php index 144ad4d50c83f1..ecb8f52392fef9 100644 --- a/lib/compat/wordpress-6.3/rest-api.php +++ b/lib/compat/wordpress-6.3/rest-api.php @@ -52,30 +52,13 @@ function gutenberg_update_templates_template_parts_rest_controller( $args, $post } add_filter( 'register_post_type_args', 'gutenberg_update_templates_template_parts_rest_controller', 10, 2 ); -/** - * Registers the Global Styles Revisions REST API routes. - */ -function gutenberg_register_global_styles_revisions_endpoints() { - $global_styles_revisions_controller = new Gutenberg_REST_Global_Styles_Revisions_Controller_6_3(); - $global_styles_revisions_controller->register_routes(); -} -add_action( 'rest_api_init', 'gutenberg_register_global_styles_revisions_endpoints' ); - -/** - * Registers the Global Styles REST API routes. - */ -function gutenberg_register_global_styles_endpoints() { - $global_styles_controller = new Gutenberg_REST_Global_Styles_Controller_6_3(); - $global_styles_controller->register_routes(); -} -add_action( 'rest_api_init', 'gutenberg_register_global_styles_endpoints' ); - -/** - * Add the `modified` value to the `wp_template` schema. - * - * @since 6.3.0 Added 'modified' property and response value. - */ -function add_modified_wp_template_schema() { +if ( ! function_exists( 'add_modified_wp_template_schema' ) ) { + /** + * Add the `modified` value to the `wp_template` schema. + * + * @since 6.3.0 Added 'modified' property and response value. + */ + function add_modified_wp_template_schema() { register_rest_field( array( 'wp_template', 'wp_template_part' ), 'modified', @@ -98,6 +81,7 @@ function add_modified_wp_template_schema() { }, ) ); + } } add_filter( 'rest_api_init', 'add_modified_wp_template_schema' ); diff --git a/lib/compat/wordpress-6.3/theme-previews.php b/lib/compat/wordpress-6.3/theme-previews.php index 26153d74878b58..e885d389b94fe0 100644 --- a/lib/compat/wordpress-6.3/theme-previews.php +++ b/lib/compat/wordpress-6.3/theme-previews.php @@ -51,14 +51,15 @@ function gutenberg_attach_theme_preview_middleware() { ); } -/** - * Temporary function to add a live preview button to block themes. - * Remove when https://core.trac.wordpress.org/ticket/58190 lands. - */ -function add_live_preview_button() { - global $pagenow; - if ( 'themes.php' === $pagenow ) { - ?> +if ( ! function_exists( 'add_live_preview_button' ) ) { + /** + * Temporary function to add a live preview button to block themes. + * Remove when https://core.trac.wordpress.org/ticket/58190 lands. + */ + function add_live_preview_button() { + global $pagenow; + if ( 'themes.php' === $pagenow ) { + ?> - +if ( ! function_exists( 'block_theme_activate_nonce' ) ) { + /** + * Adds a nonce for the theme activation link. + */ + function block_theme_activate_nonce() { + $nonce_handle = 'switch-theme_' . gutenberg_get_theme_preview_path(); + ?> - schema ) { + return $this->add_additional_fields_schema( $this->schema ); + } + + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => $this->post_type, + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'ID of global styles config.', 'default' ), + 'type' => 'string', + 'context' => array( 'embed', 'view', 'edit' ), + 'readonly' => true, + ), + 'styles' => array( + 'description' => __( 'Global styles.', 'default' ), + 'type' => array( 'object' ), + 'context' => array( 'view', 'edit' ), + ), + 'settings' => array( + 'description' => __( 'Global settings.', 'default' ), + 'type' => array( 'object' ), + 'context' => array( 'view', 'edit' ), + ), + 'behaviors' => array( + 'description' => __( 'Global behaviors.', 'default' ), + 'type' => array( 'object' ), + 'context' => array( 'view', 'edit' ), + ), + 'title' => array( + 'description' => __( 'Title of the global styles variation.', 'default' ), + 'type' => array( 'object', 'string' ), + 'default' => '', + 'context' => array( 'embed', 'view', 'edit' ), + 'properties' => array( + 'raw' => array( + 'description' => __( 'Title for the global styles variation, as it exists in the database.', 'default' ), + 'type' => 'string', + 'context' => array( 'view', 'edit', 'embed' ), + ), + 'rendered' => array( + 'description' => __( 'HTML title for the post, transformed for display.', 'default' ), + 'type' => 'string', + 'context' => array( 'view', 'edit', 'embed' ), + 'readonly' => true, + ), + ), + ), + ), + ); + + $this->schema = $schema; + + return $this->add_additional_fields_schema( $this->schema ); + } + + /** + * Prepare a global styles config output for response. + * + * @since 5.9.0 + * @since 6.2 Handling of style.css was added to WP_Theme_JSON. + * + * @param WP_Post $post Global Styles post object. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response Response object. + */ + public function prepare_item_for_response( $post, $request ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable + $raw_config = json_decode( $post->post_content, true ); + $is_global_styles_user_theme_json = isset( $raw_config['isGlobalStylesUserThemeJSON'] ) && true === $raw_config['isGlobalStylesUserThemeJSON']; + $config = array(); + if ( $is_global_styles_user_theme_json ) { + $config = ( new WP_Theme_JSON_Gutenberg( $raw_config, 'custom' ) )->get_raw_data(); + } + + // Base fields for every post. + $data = array(); + $fields = $this->get_fields_for_response( $request ); + + if ( rest_is_field_included( 'id', $fields ) ) { + $data['id'] = $post->ID; + } + + if ( rest_is_field_included( 'title', $fields ) ) { + $data['title'] = array(); + } + if ( rest_is_field_included( 'title.raw', $fields ) ) { + $data['title']['raw'] = $post->post_title; + } + if ( rest_is_field_included( 'title.rendered', $fields ) ) { + add_filter( 'protected_title_format', array( $this, 'protected_title_format' ) ); + + $data['title']['rendered'] = get_the_title( $post->ID ); + + remove_filter( 'protected_title_format', array( $this, 'protected_title_format' ) ); + } + + if ( rest_is_field_included( 'settings', $fields ) ) { + $data['settings'] = ! empty( $config['settings'] ) && $is_global_styles_user_theme_json ? $config['settings'] : new stdClass(); + } + + if ( rest_is_field_included( 'styles', $fields ) ) { + $data['styles'] = ! empty( $config['styles'] ) && $is_global_styles_user_theme_json ? $config['styles'] : new stdClass(); + } + + if ( rest_is_field_included( 'behaviors', $fields ) ) { + $data['behaviors'] = ! empty( $config['behaviors'] ) && $is_global_styles_user_theme_json ? $config['behaviors'] : new stdClass(); + } + + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + // Wrap the data in a response object. + $response = rest_ensure_response( $data ); + + if ( rest_is_field_included( '_links', $fields ) || rest_is_field_included( '_embedded', $fields ) ) { + $links = $this->prepare_links( $post->ID ); + $response->add_links( $links ); + if ( ! empty( $links['self']['href'] ) ) { + $actions = $this->get_available_actions(); + $self = $links['self']['href']; + foreach ( $actions as $rel ) { + $response->add_link( $rel, $self ); + } + } + } + + return $response; + } + + /** + * Returns the given theme global styles config. + * Duplicated from core. + * The only change is that we call WP_Theme_JSON_Resolver_Gutenberg::get_merged_data( 'theme' ) instead of WP_Theme_JSON_Resolver::get_merged_data( 'theme' ). + * + * @since 6.2.0 + * + * @param WP_REST_Request $request The request instance. + * @return WP_REST_Response|WP_Error + */ + public function get_theme_item( $request ) { + if ( get_stylesheet() !== $request['stylesheet'] ) { + // This endpoint only supports the active theme for now. + return new WP_Error( + 'rest_theme_not_found', + __( 'Theme not found.', 'default' ), + array( 'status' => 404 ) + ); + } + + $theme = WP_Theme_JSON_Resolver_Gutenberg::get_merged_data( 'theme' ); + $data = array(); + $fields = $this->get_fields_for_response( $request ); + + if ( rest_is_field_included( 'settings', $fields ) ) { + $data['settings'] = $theme->get_settings(); + } + + if ( rest_is_field_included( 'styles', $fields ) ) { + $raw_data = $theme->get_raw_data(); + $data['styles'] = isset( $raw_data['styles'] ) ? $raw_data['styles'] : array(); + } + + if ( rest_is_field_included( 'behaviors', $fields ) ) { + $raw_data = $theme->get_raw_data(); + $data['behaviors'] = isset( $raw_data['behaviors'] ) ? $raw_data['behaviors'] : array(); + } + + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + $response = rest_ensure_response( $data ); + + if ( rest_is_field_included( '_links', $fields ) || rest_is_field_included( '_embedded', $fields ) ) { + $links = array( + 'self' => array( + 'href' => rest_url( sprintf( '%s/%s/themes/%s', $this->namespace, $this->rest_base, $request['stylesheet'] ) ), + ), + ); + $response->add_links( $links ); + } + + return $response; + } + + /** + * Prepares a single global styles config for update. + * + * @since 5.9.0 + * @since 6.2.0 Added validation of styles.css property. + * + * @param WP_REST_Request $request Request object. + * @return stdClass Changes to pass to wp_update_post. + */ + protected function prepare_item_for_database( $request ) { + $changes = new stdClass(); + $changes->ID = $request['id']; + $post = get_post( $request['id'] ); + $existing_config = array(); + if ( $post ) { + $existing_config = json_decode( $post->post_content, true ); + $json_decoding_error = json_last_error(); + if ( JSON_ERROR_NONE !== $json_decoding_error || ! isset( $existing_config['isGlobalStylesUserThemeJSON'] ) || + ! $existing_config['isGlobalStylesUserThemeJSON'] ) { + $existing_config = array(); + } + } + if ( isset( $request['styles'] ) || isset( $request['settings'] ) || isset( $request['behaviors'] ) ) { + $config = array(); + if ( isset( $request['styles'] ) ) { + $config['styles'] = $request['styles']; + if ( isset( $request['styles']['css'] ) ) { + $validate_custom_css = $this->validate_custom_css( $request['styles']['css'] ); + if ( is_wp_error( $validate_custom_css ) ) { + return $validate_custom_css; + } + } + } elseif ( isset( $existing_config['styles'] ) ) { + $config['styles'] = $existing_config['styles']; + } + if ( isset( $request['settings'] ) ) { + $config['settings'] = $request['settings']; + } elseif ( isset( $existing_config['settings'] ) ) { + $config['settings'] = $existing_config['settings']; + } + if ( isset( $request['behaviors'] ) ) { + $config['behaviors'] = $request['behaviors']; + } elseif ( isset( $existing_config['behaviors'] ) ) { + $config['behaviors'] = $existing_config['behaviors']; + } + $config['isGlobalStylesUserThemeJSON'] = true; + $config['version'] = WP_Theme_JSON_Gutenberg::LATEST_SCHEMA; + $changes->post_content = wp_json_encode( $config ); + } + // Post title. + if ( isset( $request['title'] ) ) { + if ( is_string( $request['title'] ) ) { + $changes->post_title = $request['title']; + } elseif ( ! empty( $request['title']['raw'] ) ) { + $changes->post_title = $request['title']['raw']; + } + } + return $changes; + } + +} diff --git a/lib/compat/wordpress-6.4/class-gutenberg-rest-global-styles-revisions-controller-6-4.php b/lib/compat/wordpress-6.4/class-gutenberg-rest-global-styles-revisions-controller-6-4.php new file mode 100644 index 00000000000000..42120b44bdcb62 --- /dev/null +++ b/lib/compat/wordpress-6.4/class-gutenberg-rest-global-styles-revisions-controller-6-4.php @@ -0,0 +1,172 @@ +get_parent( $request['parent'] ); + $global_styles_config = $this->get_decoded_global_styles_json( $post->post_content ); + + if ( is_wp_error( $global_styles_config ) ) { + return $global_styles_config; + } + + $fields = $this->get_fields_for_response( $request ); + $data = array(); + + if ( ! empty( $global_styles_config['styles'] ) || ! empty( $global_styles_config['settings'] ) || ! empty( $global_styles_config['behaviors'] ) ) { + $global_styles_config = ( new WP_Theme_JSON_Gutenberg( $global_styles_config, 'custom' ) )->get_raw_data(); + if ( rest_is_field_included( 'settings', $fields ) ) { + $data['settings'] = ! empty( $global_styles_config['settings'] ) ? $global_styles_config['settings'] : new stdClass(); + } + if ( rest_is_field_included( 'styles', $fields ) ) { + $data['styles'] = ! empty( $global_styles_config['styles'] ) ? $global_styles_config['styles'] : new stdClass(); + } + if ( rest_is_field_included( 'behaviors', $fields ) ) { + $data['behaviors'] = ! empty( $global_styles_config['behaviors'] ) ? $global_styles_config['behaviors'] : new stdClass(); + } + } + + if ( rest_is_field_included( 'author', $fields ) ) { + $data['author'] = (int) $post->post_author; + } + + if ( rest_is_field_included( 'date', $fields ) ) { + $data['date'] = $this->prepare_date_response( $post->post_date_gmt, $post->post_date ); + } + + if ( rest_is_field_included( 'date_gmt', $fields ) ) { + $data['date_gmt'] = $this->prepare_date_response( $post->post_date_gmt ); + } + + if ( rest_is_field_included( 'id', $fields ) ) { + $data['id'] = (int) $post->ID; + } + + if ( rest_is_field_included( 'modified', $fields ) ) { + $data['modified'] = $this->prepare_date_response( $post->post_modified_gmt, $post->post_modified ); + } + + if ( rest_is_field_included( 'modified_gmt', $fields ) ) { + $data['modified_gmt'] = $this->prepare_date_response( $post->post_modified_gmt ); + } + + if ( rest_is_field_included( 'parent', $fields ) ) { + $data['parent'] = (int) $parent->ID; + } + + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + return rest_ensure_response( $data ); + } + + /** + * Retrieves the revision's schema, conforming to JSON Schema. + * + * @since 6.3.0 + * + * @return array Item schema data. + */ + public function get_item_schema() { + if ( $this->schema ) { + return $this->add_additional_fields_schema( $this->schema ); + } + + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => "{$this->parent_post_type}-revision", + 'type' => 'object', + // Base properties for every Revision. + 'properties' => array( + + /* + * Adds settings and styles from the WP_REST_Revisions_Controller item fields. + * Leaves out GUID as global styles shouldn't be accessible via URL. + */ + 'author' => array( + 'description' => __( 'The ID for the author of the revision.', 'gutenberg' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit', 'embed' ), + ), + 'date' => array( + 'description' => __( "The date the revision was published, in the site's timezone.", 'gutenberg' ), + 'type' => 'string', + 'format' => 'date-time', + 'context' => array( 'view', 'edit', 'embed' ), + ), + 'date_gmt' => array( + 'description' => __( 'The date the revision was published, as GMT.', 'gutenberg' ), + 'type' => 'string', + 'format' => 'date-time', + 'context' => array( 'view', 'edit' ), + ), + 'id' => array( + 'description' => __( 'Unique identifier for the revision.', 'gutenberg' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit', 'embed' ), + ), + 'modified' => array( + 'description' => __( "The date the revision was last modified, in the site's timezone.", 'gutenberg' ), + 'type' => 'string', + 'format' => 'date-time', + 'context' => array( 'view', 'edit' ), + ), + 'modified_gmt' => array( + 'description' => __( 'The date the revision was last modified, as GMT.', 'gutenberg' ), + 'type' => 'string', + 'format' => 'date-time', + 'context' => array( 'view', 'edit' ), + ), + 'parent' => array( + 'description' => __( 'The ID for the parent of the revision.', 'gutenberg' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit', 'embed' ), + ), + + // Adds settings and styles from the WP_REST_Global_Styles_Controller parent schema. + 'styles' => array( + 'description' => __( 'Global styles.', 'gutenberg' ), + 'type' => array( 'object' ), + 'context' => array( 'view', 'edit' ), + ), + 'settings' => array( + 'description' => __( 'Global settings.', 'gutenberg' ), + 'type' => array( 'object' ), + 'context' => array( 'view', 'edit' ), + ), + 'behaviors' => array( + 'description' => __( 'Global behaviors.', 'gutenberg' ), + 'type' => array( 'object' ), + 'context' => array( 'view', 'edit' ), + ), + ), + ); + + $this->schema = $schema; + + return $this->add_additional_fields_schema( $this->schema ); + } +} diff --git a/lib/compat/wordpress-6.4/rest-api.php b/lib/compat/wordpress-6.4/rest-api.php new file mode 100644 index 00000000000000..53979f832c09a6 --- /dev/null +++ b/lib/compat/wordpress-6.4/rest-api.php @@ -0,0 +1,29 @@ +register_routes(); +} +add_action( 'rest_api_init', 'gutenberg_register_global_styles_revisions_endpoints' ); + +/** + * Registers the Global Styles REST API routes. + */ +function gutenberg_register_global_styles_endpoints() { + $global_styles_controller = new Gutenberg_REST_Global_Styles_Controller_6_4(); + $global_styles_controller->register_routes(); +} +add_action( 'rest_api_init', 'gutenberg_register_global_styles_endpoints' ); diff --git a/lib/experimental/behaviors.php b/lib/experimental/behaviors.php deleted file mode 100644 index 62e7be7a252d49..00000000000000 --- a/lib/experimental/behaviors.php +++ /dev/null @@ -1,20 +0,0 @@ -get_data(); - if ( array_key_exists( 'behaviors', $theme_data ) ) { - $settings['behaviors'] = $theme_data['behaviors']; - } - return $settings; - }, - PHP_INT_MAX -); diff --git a/lib/experimental/class--wp-editors.php b/lib/experimental/class--wp-editors.php index bc49ea80a99421..41062db75c0700 100644 --- a/lib/experimental/class--wp-editors.php +++ b/lib/experimental/class--wp-editors.php @@ -8,6 +8,10 @@ // phpcs:disable PEAR.NamingConventions.ValidClassName.StartWithCapital +if ( class_exists( '_WP_Editors' ) ) { + return; +} + /** * Placeholder class. * Used to disable loading of TinyMCE assets. diff --git a/lib/experimental/class-wp-rest-block-editor-settings-controller.php b/lib/experimental/class-wp-rest-block-editor-settings-controller.php index 52dd328fc7f2db..510ae573e3de8e 100644 --- a/lib/experimental/class-wp-rest-block-editor-settings-controller.php +++ b/lib/experimental/class-wp-rest-block-editor-settings-controller.php @@ -6,6 +6,10 @@ * @subpackage REST_API */ +if ( class_exists( 'WP_REST_Block_Editor_Settings_Controller' ) ) { + return; +} + /** * Core class used to retrieve the block editor settings via the REST API. * diff --git a/lib/experimental/class-wp-rest-customizer-nonces.php b/lib/experimental/class-wp-rest-customizer-nonces.php index 4fc35209ae99de..15c587295557d8 100644 --- a/lib/experimental/class-wp-rest-customizer-nonces.php +++ b/lib/experimental/class-wp-rest-customizer-nonces.php @@ -5,6 +5,10 @@ * @package gutenberg */ +if ( class_exists( 'WP_Rest_Customizer_Nonces' ) ) { + return; +} + /** * Class that returns the customizer "save" nonce that's required for the * batch save operation using the customizer API endpoint. diff --git a/lib/experimental/fonts/bc-layer/class-gutenberg-fonts-api-bc-layer.php b/lib/experimental/fonts/bc-layer/class-gutenberg-fonts-api-bc-layer.php new file mode 100644 index 00000000000000..7cf041148eedd0 --- /dev/null +++ b/lib/experimental/fonts/bc-layer/class-gutenberg-fonts-api-bc-layer.php @@ -0,0 +1,49 @@ +` element for wrapping the `@font-face` CSS. + * + * @since X.X.X + * @deprecated 16.3.0 Get style element is not supported. + * + * @return string Empty string. + */ + protected function get_style_element() { + _deprecated_function( __METHOD__, 'Gutenberg 16.3.0' ); + return ''; + } +} diff --git a/lib/experimental/fonts/bc-layer/class-wp-fonts-resolver.php b/lib/experimental/fonts/bc-layer/class-wp-fonts-resolver.php new file mode 100644 index 00000000000000..c2702348b95232 --- /dev/null +++ b/lib/experimental/fonts/bc-layer/class-wp-fonts-resolver.php @@ -0,0 +1,64 @@ +get_registered_font_families(). + * @deprecated 16.3.0 Register is not supported. + * + * @return array Empty array. + */ + public function get_registered_font_families() { + _deprecated_function( __METHOD__, 'Gutenberg 15.8.0' ); + return array(); + } + + /** + * Gets the list of registered fonts. + * + * @since 6.0.0 + * @deprecated 14.9.1 Use wp_fonts()->get_registered(). + * @deprecated 16.3.0 Register is not supported. + * + * @return array Empty array. + */ + public function get_registered_webfonts() { + _deprecated_function( __METHOD__, 'Gutenberg 14.9.1' ); + + return array(); + } + + /** + * Gets the list of enqueued fonts. + * + * @since 6.0.0 + * @deprecated 14.9.1 Use wp_fonts()->get_enqueued(). + * @deprecated 16.3.0 Enqueue is not supported. + * + * @return array Empty array. + */ + public function get_enqueued_webfonts() { + _deprecated_function( __METHOD__, 'Gutenberg 14.9.1' ); + return array(); + } + + /** + * Gets the list of all fonts. + * + * @since X.X.X + * @deprecated GB 14.9.1 Use wp_fonts()->get_registered(). + * @deprecated 16.3.0 This method is not supported. + * + * @return array[] + */ + public function get_all_webfonts() { + _deprecated_function( __METHOD__, 'Gutenberg 14.9.1', 'wp_fonts()->get_registered()' ); + return array(); + } + + /** + * Registers a webfont. + * + * @since 6.0.0 + * @deprecated GB 14.9.1 Use wp_register_fonts(). + * @deprecated 16.3.0 Register is not supported. + * + * @return bool False. + */ + public function register_webfont() { + _deprecated_function( __METHOD__, 'GB 14.9.1', 'wp_register_fonts()' ); + return false; + } + + /** + * Enqueue a font-family that has been already registered. + * + * @since XX.X + * @deprecated 14.9.1 Use wp_enqueue_fonts(). + * @deprecated 16.3.0 Register is not supported. + * + * @return bool False. + */ + public function enqueue_webfont() { + _deprecated_function( __METHOD__, 'Gutenberg 14.9.1' ); + return false; + } +} diff --git a/lib/experimental/fonts/bc-layer/webfonts-deprecations.php b/lib/experimental/fonts/bc-layer/webfonts-deprecations.php new file mode 100644 index 00000000000000..4de2e6221d50bf --- /dev/null +++ b/lib/experimental/fonts/bc-layer/webfonts-deprecations.php @@ -0,0 +1,291 @@ +get_providers(). + * @deprecated 16.3.0 Providers are not supported. + * + * @return array Empty array. + */ + function wp_get_webfont_providers() { + _deprecated_function( __FUNCTION__, '14.9.1' ); + + return array(); + } +} + +if ( ! function_exists( 'wp_register_webfont_provider' ) ) { + /** + * Registers a custom font service provider. + * + * @since X.X.X + * @deprecated 15.1 Use wp_register_font_provider() instead. + * @deprecated 16.3.0 Providers are not supported. + * + * @return bool False. + */ + function wp_register_webfont_provider() { + _deprecated_function( __FUNCTION__, 'GB 15.1', 'wp_register_font_provider' ); + return false; + } +} + +if ( ! function_exists( 'wp_print_webfonts' ) ) { + /** + * Invokes each provider to process and print its styles. + * + * @since 14.9.1 + * @deprecated 15.1 Use wp_print_fonts() instead. + * @deprecated 16.3.0 Webfonts API is not supported. + * + * @return array Empty array. + */ + function wp_print_webfonts() { + _deprecated_function( __FUNCTION__, 'Gutenberg 15.1', 'wp_print_font_faces' ); + return array(); + } +} + +if ( ! function_exists( 'wp_fonts' ) ) { + /** + * Initialize $wp_fonts if it has not been set. + * + * @since X.X.X + * @deprecated 16.3.0 Use Fonts Library and Font Face. Fonts API is not supported. + * + * @global WP_Fonts $wp_fonts + * + * @return WP_Fonts WP_Fonts instance. + */ + function wp_fonts() { + _deprecated_function( __FUNCTION__, 'Gutenberg 16.3' ); + + global $wp_fonts; + + if ( ! ( $wp_fonts instanceof WP_Fonts ) ) { + $wp_fonts = new WP_Fonts(); + } + + return $wp_fonts; + } +} + +if ( ! function_exists( 'wp_register_fonts' ) ) { + /** + * Registers one or more font-families and each of their variations. + * + * @since X.X.X + * @deprecated 16.3.0 Register is not supported. + * + * @return array Empty array. + */ + function wp_register_fonts() { + _deprecated_function( __FUNCTION__, 'Gutenberg 16.3' ); + return array(); + } +} + +if ( ! function_exists( 'wp_enqueue_fonts' ) ) { + /** + * Enqueues one or more font family and all of its variations. + * + * @since X.X.X + * @deprecated 16.3.0 Enqueue is not supported. + */ + function wp_enqueue_fonts() { + _deprecated_function( __FUNCTION__, 'Gutenberg 16.3' ); + } +} + +if ( ! function_exists( 'wp_enqueue_font_variations' ) ) { + /** + * Enqueues a specific set of font variations. + * + * @since X.X.X + * @deprecated 16.3.0 Enqueue is not supported. + */ + function wp_enqueue_font_variations() { + _deprecated_function( __FUNCTION__, 'Gutenberg 16.3' ); + } +} + +if ( ! function_exists( 'wp_deregister_font_family' ) ) { + /** + * Deregisters a font family and all of its registered variations. + * + * @since X.X.X + * @deprecated 16.3.0 Deregister is not supported. + */ + function wp_deregister_font_family() { + _deprecated_function( __FUNCTION__, 'Gutenberg 16.3' ); + } +} + +if ( ! function_exists( 'wp_deregister_font_variation' ) ) { + /** + * Deregisters a font variation. + * + * @since X.X.X + * @deprecated 16.3.0 Deregister is not supported. + */ + function wp_deregister_font_variation() { + _deprecated_function( __FUNCTION__, 'Gutenberg 16.3' ); + } +} + +if ( ! function_exists( 'wp_register_font_provider' ) ) { + /** + * Registers a custom font service provider. + * + * @since X.X.X + * @deprecated 16.3.0 Providers are not supported. + * + * @return bool False. + */ + function wp_register_font_provider() { + _deprecated_function( __FUNCTION__, 'Gutenberg 16.3' ); + return false; + } +} + +if ( ! function_exists( 'wp_print_fonts' ) ) { + /** + * Invokes each provider to process and print its styles. + * + * @since X.X.X + * @deprecated 16.3.0 For classic themes, use wp_print_font_faces(). For all other sites, + * Font Face will automatically print all fonts in theme.json merged data layer, + * including in theme and user activated fonts from the Fonts Library. + * + * @return array Empty array. + */ + function wp_print_fonts() { + _deprecated_function( __FUNCTION__, 'Gutenberg 16.3', 'wp_print_font_faces' ); + return array(); + } +} diff --git a/lib/experimental/interactivity-api/class-wp-directive-context.php b/lib/experimental/interactivity-api/class-wp-directive-context.php index 7186922d137a89..6e28db83509f52 100644 --- a/lib/experimental/interactivity-api/class-wp-directive-context.php +++ b/lib/experimental/interactivity-api/class-wp-directive-context.php @@ -6,6 +6,10 @@ * @subpackage Interactivity API */ +if ( class_exists( 'WP_Directive_Context' ) ) { + return; +} + /** * This is a data structure to hold the current context. * diff --git a/lib/experimental/interactivity-api/class-wp-directive-processor.php b/lib/experimental/interactivity-api/class-wp-directive-processor.php index 69c72a222fdc71..e57000b3663ce4 100644 --- a/lib/experimental/interactivity-api/class-wp-directive-processor.php +++ b/lib/experimental/interactivity-api/class-wp-directive-processor.php @@ -6,6 +6,10 @@ * @subpackage Interactivity API */ +if ( class_exists( 'WP_Directive_Processor' ) ) { + return; +} + /** * This processor is built on top of the HTML Tag Processor and augments its * capabilities to process the Interactivity API directives. diff --git a/lib/experimental/interactivity-api/class-wp-interactivity-store.php b/lib/experimental/interactivity-api/class-wp-interactivity-store.php index fe96af4786d3bf..8b43dbb6d9e248 100644 --- a/lib/experimental/interactivity-api/class-wp-interactivity-store.php +++ b/lib/experimental/interactivity-api/class-wp-interactivity-store.php @@ -9,6 +9,10 @@ * @subpackage Interactivity API */ +if ( class_exists( 'WP_Interactivity_Store' ) ) { + return; +} + /** * Manages the initial state of the Interactivity API store in the server and * its serialization so it can be restored in the browser upon hydration. diff --git a/lib/experimental/interactivity-api/store.php b/lib/experimental/interactivity-api/store.php index 5e793514e54c90..05c8b35f780d4f 100644 --- a/lib/experimental/interactivity-api/store.php +++ b/lib/experimental/interactivity-api/store.php @@ -6,18 +6,20 @@ * @subpackage Interactivity API */ -/** - * Merge data with the existing store. - * - * @param array $data Data that will be merged with the existing store. - * - * @return $data The current store data. - */ -function wp_store( $data = null ) { - if ( $data ) { - WP_Interactivity_Store::merge_data( $data ); +if ( ! function_exists( 'wp_store' ) ) { + /** + * Merge data with the existing store. + * + * @param array $data Data that will be merged with the existing store. + * + * @return $data The current store data. + */ + function wp_store( $data = null ) { + if ( $data ) { + WP_Interactivity_Store::merge_data( $data ); + } + return WP_Interactivity_Store::get_data(); } - return WP_Interactivity_Store::get_data(); } /** diff --git a/lib/experimental/kses.php b/lib/experimental/kses.php index 115fa3a7d2284c..6fa8ca641772a2 100644 --- a/lib/experimental/kses.php +++ b/lib/experimental/kses.php @@ -66,24 +66,25 @@ function gutenberg_override_core_kses_init_filters() { add_action( 'init', 'gutenberg_override_core_kses_init_filters', 20 ); add_action( 'set_current_user', 'gutenberg_override_core_kses_init_filters' ); -/** - * See https://github.com/WordPress/wordpress-develop/pull/4108 - * - * Mark CSS safe if it contains a "filter: url('#wp-duotone-...')" rule. - * - * This function should not be backported to core. - * - * @param bool $allow_css Whether the CSS is allowed. - * @param string $css_test_string The CSS to test. - */ -function allow_filter_in_styles( $allow_css, $css_test_string ) { - if ( preg_match( - "/^filter:\s*url\((['\"]?)#wp-duotone-[-a-zA-Z0-9]+\\1\)(\s+!important)?$/", - $css_test_string - ) ) { - return true; +if ( ! function_exists( 'allow_filter_in_styles' ) ) { + /** + * See https://github.com/WordPress/wordpress-develop/pull/4108 + * + * Mark CSS safe if it contains a "filter: url('#wp-duotone-...')" rule. + * + * This function should not be backported to core. + * + * @param bool $allow_css Whether the CSS is allowed. + * @param string $css_test_string The CSS to test. + */ + function allow_filter_in_styles( $allow_css, $css_test_string ) { + if ( preg_match( + "/^filter:\s*url\((['\"]?)#wp-duotone-[-a-zA-Z0-9]+\\1\)(\s+!important)?$/", + $css_test_string + ) ) { + return true; + } + return $allow_css; } - return $allow_css; } - add_filter( 'safecss_filter_attr_allow_css', 'allow_filter_in_styles', 10, 2 ); diff --git a/lib/experimental/rest-api.php b/lib/experimental/rest-api.php index 2fc7a7af576f82..7c6a9bf74d7395 100644 --- a/lib/experimental/rest-api.php +++ b/lib/experimental/rest-api.php @@ -102,23 +102,24 @@ function gutenberg_auto_draft_get_sample_permalink( $permalink, $id, $title, $na } add_filter( 'get_sample_permalink', 'gutenberg_auto_draft_get_sample_permalink', 10, 5 ); -/** - * Hook in to the template and template part post types and decorate - * the rest endpoint with the revision count. - * - * When merging to core, this can be removed once Gutenberg_REST_Template_Revision_Count is - * merged with WP_REST_Template_Controller. - * - * @param array $args Current registered post type args. - * @param string $post_type Name of post type. - * - * @return array - */ -function wp_api_template_revision_args( $args, $post_type ) { - if ( 'wp_template' === $post_type || 'wp_template_part' === $post_type ) { - $args['rest_controller_class'] = 'Gutenberg_REST_Template_Revision_Count'; +if ( ! function_exists( 'wp_api_template_revision_args' ) ) { + /** + * Hook in to the template and template part post types and decorate + * the rest endpoint with the revision count. + * + * When merging to core, this can be removed once Gutenberg_REST_Template_Revision_Count is + * merged with WP_REST_Template_Controller. + * + * @param array $args Current registered post type args. + * @param string $post_type Name of post type. + * + * @return array + */ + function wp_api_template_revision_args( $args, $post_type ) { + if ( 'wp_template' === $post_type || 'wp_template_part' === $post_type ) { + $args['rest_controller_class'] = 'Gutenberg_REST_Template_Revision_Count'; + } + return $args; } - - return $args; } add_filter( 'register_post_type_args', 'wp_api_template_revision_args', 10, 2 ); diff --git a/lib/experiments-page.php b/lib/experiments-page.php index de1d3dbce71a14..ea298784aec0c9 100644 --- a/lib/experiments-page.php +++ b/lib/experiments-page.php @@ -5,26 +5,28 @@ * @package gutenberg */ -/** - * The main entry point for the Gutenberg experiments page. - * - * @since 6.3.0 - */ -function the_gutenberg_experiments() { - ?> -