diff --git a/.eslintrc.js b/.eslintrc.js index 53e8cf888a18ed..18763807cb36be 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -110,6 +110,7 @@ const restrictedImports = [ 'maxBy', 'memoize', 'merge', + 'mergeWith', 'negate', 'noop', 'nth', diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index c29a18dcee2e04..37d1abb5256f2a 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -78,7 +78,7 @@ /packages/prettier-config @ntwb @gziolo /packages/scripts @gziolo @ntwb @nerrad @ajitbohra @ryanwelcher /packages/stylelint-config @ntwb -/test/e2e @kevin940726 +/test/e2e @kevin940726 @Mamaduka # UI Components /packages/components @ajitbohra diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index 7a5c523c8324b6..bf8545f2c16d65 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -59,13 +59,13 @@ jobs: - name: Compare performance with base branch if: github.event_name == 'push' # The base hash used here need to be a commit that is compatible with the current WP version - # The current one is debd225d007f4e441ceec80fbd6fa96653f94737 and it needs to be updated every WP major release. + # The current one is 843a3053aca918bb10b939be28e676f8e71b751b and it needs to be updated every WP major release. # It is used as a base comparison point to avoid fluctuation in the performance metrics. run: | WP_VERSION=$(awk -F ': ' '/^Tested up to/{print $2}' readme.txt) IFS=. read -ra WP_VERSION_ARRAY <<< "$WP_VERSION" WP_MAJOR="${WP_VERSION_ARRAY[0]}.${WP_VERSION_ARRAY[1]}" - ./bin/plugin/cli.js perf $GITHUB_SHA debd225d007f4e441ceec80fbd6fa96653f94737 --tests-branch $GITHUB_SHA --wp-version "$WP_MAJOR" + ./bin/plugin/cli.js perf $GITHUB_SHA 843a3053aca918bb10b939be28e676f8e71b751b --tests-branch $GITHUB_SHA --wp-version "$WP_MAJOR" - name: Compare performance with custom branches if: github.event_name == 'workflow_dispatch' @@ -88,7 +88,7 @@ jobs: CODEHEALTH_PROJECT_TOKEN: ${{ secrets.CODEHEALTH_PROJECT_TOKEN }} run: | COMMITTED_AT=$(git show -s $GITHUB_SHA --format="%ct") - ./bin/log-performance-results.js $CODEHEALTH_PROJECT_TOKEN trunk $GITHUB_SHA debd225d007f4e441ceec80fbd6fa96653f94737 $COMMITTED_AT + ./bin/log-performance-results.js $CODEHEALTH_PROJECT_TOKEN trunk $GITHUB_SHA 843a3053aca918bb10b939be28e676f8e71b751b $COMMITTED_AT - name: Archive debug artifacts (screenshots, HTML snapshots) uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 diff --git a/README.md b/README.md index 8ac17b8574c52f..5ba112319b405c 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Welcome to the development hub for the WordPress Gutenberg project! The block editor introduces a modular approach to pages and posts: each piece of content in the editor, from a paragraph to an image gallery to a headline, is its own block. And just like physical blocks, WordPress blocks can be added, arranged, and rearranged, allowing WordPress users to create media-rich pages in a visually intuitive way -- and without work-arounds like shortcodes or custom HTML. -The block editor first became available in December 2018, and we're still hard at work refining the experience, creating more and better blocks, and laying the groundwork for the next three phases of work. The Gutenberg plugin gives you the latest version of the block editor so you can join us in testing bleeding-edge features, start playing with blocks, and maybe get inspired to build your own. +The block editor first became available in December 2018, and we're still hard at work refining the experience, creating more and better blocks, and laying the groundwork for the next three phases of work. The Gutenberg plugin gives you the latest version of the block editor, so you can join us in testing bleeding-edge features, start playing with blocks, and maybe get inspired to build your own. Check out the [Ways to keep up with Gutenberg & Full Site Editing (FSE)](https://make.wordpress.org/core/2020/05/20/ways-to-keep-up-with-full-site-editing-fse/) @@ -31,7 +31,7 @@ Get hands on: check out the [block editor live demo](https://wordpress.org/guten - **User Documentation:** See the [WordPress Editor documentation](https://wordpress.org/documentation/article/wordpress-block-editor/) for detailed docs on using the editor as an author creating posts and pages. -- **User Support:** If you have run into an issue, you should check the [Support Forums first](https://wordpress.org/support/forums/). The forums are a great place to get help. If you have a bug to report, please [submit it to the Gutenberg repository](https://github.com/wordpress/gutenberg/issues). Please search prior to creating a new bug to confirm its not a duplicate. +- **User Support:** If you have run into an issue, you should check the [Support Forums first](https://wordpress.org/support/forums/). The forums are a great place to get help. If you have a bug to report, please [submit it to the Gutenberg repository](https://github.com/wordpress/gutenberg/issues). Please search prior to creating a new bug to confirm it's not a duplicate. ### Developing for Gutenberg @@ -41,7 +41,7 @@ Review the [Create a Block tutorial](/docs/getting-started/create-block/README.m ### Contribute to Gutenberg -Gutenberg is an open-source project and welcomes all contributors from code to design, and from documentation to triage. The project is built by many contributors and volunteers and we'd love your help building it. +Gutenberg is an open-source project and welcomes all contributors from code to design, and from documentation to triage. The project is built by many contributors and volunteers, and we'd love your help building it. See the [Contributors Handbook](https://developer.wordpress.org/block-editor/contributors/) for all the details on how you can contribute. diff --git a/bin/list-experimental-api-matches.sh b/bin/list-experimental-api-matches.sh new file mode 100755 index 00000000000000..156464c4e7375e --- /dev/null +++ b/bin/list-experimental-api-matches.sh @@ -0,0 +1,65 @@ +#!/bin/sh + +# Generate a Markdown-formatted list of experimental APIs found across our +# packages and lib, providing GitHub search links for each match. +# +# Experimental APIs must be regularly audited, particularly in the context of +# major WordPress releases. This script allows release leads to generate a list +# to share in release issues. +# +# @see example audit issue for WordPress 6.2: +# https://github.com/WordPress/gutenberg/issues/47196 + +# Exit if any command fails. +set -e + +# Change to the root directory. +cd "$(dirname "$0")" +cd .. + +# POSIX: prefer standard grep over rg. Git is assumed present (ls-files), but +# could be replaced with find. +grep_experimental_apis() { + git ls-files packages/* lib \ + | grep -E '\.(js|ts|jsx|tsx|php)$' \ + | grep -v __tests__ \ + | xargs grep -Eo '__experimental\w+' +} + +# For each line as `:`, rewrite as ` `. +namespace() { + awk -F: ' + { print module($1), $2 } + function module(path) { + n = split(path, parts, "/") + if (parts[1] == "lib") return "lib" + return parts[1] "/" parts[2] + }' +} + +# Like uniq, but applied across packages: if `__experimentalFoo` appears in +# packages A and B, only keep the occurrence under A. +compact() { + sort | uniq | awk '{ + if (known_api[$2]) next + known_api[$2] = 1 + print + }' +} + +# Output a heading for each package and a link for each experimental API. +format() { + awk '{ + if (prev_dir != $1) { + if (NR > 1) print "" + printf "## `%s`\n", $1 + prev_dir = $1 + } + printf "[`%s`](/WordPress/gutenberg/search?q=%s)\n", $2, $2 + }' +} + +grep_experimental_apis \ + | namespace \ + | compact \ + | format diff --git a/changelog.txt b/changelog.txt index 4cdd8690b3740f..2ed1a1d8e62edb 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,239 @@ == Changelog == += 16.0.0 = + +## Changelog + +### Enhancements + +#### Block Editor +- Block Controls SlotFill: Refactor to allow passing multiple contexts, including internal components context. ([51264](https://github.com/WordPress/gutenberg/pull/51264)) +- Block Toolbar: Update the 'Unlock' button label. ([51083](https://github.com/WordPress/gutenberg/pull/51083)) +- Iframe Editor if all blocks are v3. ([48286](https://github.com/WordPress/gutenberg/pull/48286)) +- Improve (and relax) search vs direct URL entry detection in Link Control. ([51011](https://github.com/WordPress/gutenberg/pull/51011)) +- Link Control require user to manually submit any changes. ([50668](https://github.com/WordPress/gutenberg/pull/50668)) +- List View: Allow dragging outside the immediate area by passing down a dropZoneElement. ([50726](https://github.com/WordPress/gutenberg/pull/50726)) +- List View: Append when dragging into collapsed blocks. ([50936](https://github.com/WordPress/gutenberg/pull/50936)) +- Reinstate Text control outside of settings in Link Control. ([50957](https://github.com/WordPress/gutenberg/pull/50957)) +- Update the document title in the template mode of the post editor. ([50864](https://github.com/WordPress/gutenberg/pull/50864)) +- Use "Save" instead of "Apply" in Link Control. ([50964](https://github.com/WordPress/gutenberg/pull/50964)) +- Use checkbox for `Open in new tab` within Link Control. ([50961](https://github.com/WordPress/gutenberg/pull/50961)) +- Visually hide the LinkControl initial/results heading. ([50977](https://github.com/WordPress/gutenberg/pull/50977)) + +#### Site Editor +- Add `delete` action for pages in navigation sidebar. ([51101](https://github.com/WordPress/gutenberg/pull/51101)) +- Add page details to the Site Editor sidebar. ([50767](https://github.com/WordPress/gutenberg/pull/50767)) +- Add Paragraph prompt to Post Content when empty. ([50623](https://github.com/WordPress/gutenberg/pull/50623)) +- Add template actions in site editor navigation sidebar. ([51054](https://github.com/WordPress/gutenberg/pull/51054)) +- Add the ability to create a new page in the Site Editor. ([50565](https://github.com/WordPress/gutenberg/pull/50565)) +- Add the ability to focus on editing a page's content vs the page's template. ([50857](https://github.com/WordPress/gutenberg/pull/50857)) +- Directly save if only changing current context. ([50567](https://github.com/WordPress/gutenberg/pull/50567)) +- Disable block supports derived design tools when Blocking Editing Mode is not `default`. ([50912](https://github.com/WordPress/gutenberg/pull/50912)) +- DocumentActions: Animate between page and template mode. ([51224](https://github.com/WordPress/gutenberg/pull/51224)) +- Site Editor sidebar: Refactor page details. ([51093](https://github.com/WordPress/gutenberg/pull/51093)) +- Styles Screen: Add link to global styles revisions. ([51149](https://github.com/WordPress/gutenberg/pull/51149)) +- Try adding dynamic page templates to pages section. ([50630](https://github.com/WordPress/gutenberg/pull/50630)) +- Tweak edit site resizable frame handle. ([50878](https://github.com/WordPress/gutenberg/pull/50878)) +- Update the bottom sticky section in the site editor details panel. ([51274](https://github.com/WordPress/gutenberg/pull/51274)) + +#### Block Library +- Details Block: Remove experimental flag and stabilize. ([50997](https://github.com/WordPress/gutenberg/pull/50997)) +- Post Excerpt: Improve preview on the editor site. ([50167](https://github.com/WordPress/gutenberg/pull/50167)) +- Post Title: Improve preview on the editor site. ([50147](https://github.com/WordPress/gutenberg/pull/50147)) +- Query Pagination: Address feedback from #50779. ([51165](https://github.com/WordPress/gutenberg/pull/51165)) +- Query Pagination: Allow hiding the label text. ([50779](https://github.com/WordPress/gutenberg/pull/50779)) +- Search Block: Add button only with expandable input. ([50487](https://github.com/WordPress/gutenberg/pull/50487)) +- Search block: Refactor to use HTML Tag Processor. ([51273](https://github.com/WordPress/gutenberg/pull/51273)) +- Post Link: Update block variation icon to match the one used in the Link UI results. ([50190](https://github.com/WordPress/gutenberg/pull/50190)) +- Post Template: Add block spacing and layout. ([49050](https://github.com/WordPress/gutenberg/pull/49050)) + +#### Components +- Button: Add opt-in prop for larger `isSmall` size. ([51012](https://github.com/WordPress/gutenberg/pull/51012)) +- ListView: Converted additional content render into a component. ([51163](https://github.com/WordPress/gutenberg/pull/51163)) +- ColorPalette: Improve color name readability. ([50450](https://github.com/WordPress/gutenberg/pull/50450)) +- Spacing: Optimize and condense unlinked spacing controls. ([50660](https://github.com/WordPress/gutenberg/pull/50660)) + +#### Data Layer +- Merge selector-binding code (except resolvers) into a new bindSelector function. ([51176](https://github.com/WordPress/gutenberg/pull/51176)) +- Move action-binding code to a bindAction function. ([51161](https://github.com/WordPress/gutenberg/pull/51161)) + +#### Accessibility +- Add TabPanel to document overview replacing fake tabs. ([50199](https://github.com/WordPress/gutenberg/pull/50199)) +- BorderControl: Improve color code readability in aria-label. ([51197](https://github.com/WordPress/gutenberg/pull/51197)) +- Handle isDraft or isInvalid Enter keypress via onKeyDown instead of a Keyboard Shortcut. ([51021](https://github.com/WordPress/gutenberg/pull/51021)) +- ListView: Allow deleting blocks using keyboard. ([50422](https://github.com/WordPress/gutenberg/pull/50422)) +- Site Editor: Add view site link to site editor nav. ([50420](https://github.com/WordPress/gutenberg/pull/50420)) +- Use generic `div` instead of nav for the SidebarNavigationScreen component. ([51111](https://github.com/WordPress/gutenberg/pull/51111)) + +### New APIs + +- Command Center: Marks the selectors and actions of the commands store as a public API. ([51169](https://github.com/WordPress/gutenberg/pull/51169)) + +### Bug Fixes + +#### Block Editor +- Add inert attribute to disabled blocks that have only disabled descendants. ([51079](https://github.com/WordPress/gutenberg/pull/51079)) +- Fix multi-entity multi-property undo redo. ([50911](https://github.com/WordPress/gutenberg/pull/50911)) +- Hide the save draft button for published posts. ([51193](https://github.com/WordPress/gutenberg/pull/51193)) +- Iframe enqueuing: Add editorStyle and warning. ([50091](https://github.com/WordPress/gutenberg/pull/50091)) +- Improvements to how blocks with a 'disabled' editing mode behave. ([51148](https://github.com/WordPress/gutenberg/pull/51148)) +- Link Control: Add missing translation. ([51081](https://github.com/WordPress/gutenberg/pull/51081)) +- Make sure post content always has correct layout. ([51431](https://github.com/WordPress/gutenberg/pull/51431)) +- Navigation: Memoize link value passed to the LinkControl. ([51155](https://github.com/WordPress/gutenberg/pull/51155)) + +#### Site Editor +- Browse Mode: Remove horizontal scrollbar during screen transitions. ([51189](https://github.com/WordPress/gutenberg/pull/51189)) +- Fix styling of actions in site editor navigation sidebar. ([51153](https://github.com/WordPress/gutenberg/pull/51153)) +- Properly decode new template title in snackbar. ([51057](https://github.com/WordPress/gutenberg/pull/51057)) +- Site Editor: Update untitled copy and rendering. ([51074](https://github.com/WordPress/gutenberg/pull/51074)) + +#### Widgets Editor +- Update the settings icon in Widgets Editor. ([51029](https://github.com/WordPress/gutenberg/pull/51029)) + +#### Block Library +- Freeform/Shortcode: Prevent blocks from converting HTML entities. ([51123](https://github.com/WordPress/gutenberg/pull/51123)) +- Navigation: Apply color classes to the navigation container element. ([50968](https://github.com/WordPress/gutenberg/pull/50968)) +- Post Template: Set block context via filter. ([50313](https://github.com/WordPress/gutenberg/pull/50313)) +- Post Template: Output number of columns as classname for backwards compatibility. ([51358](https://github.com/WordPress/gutenberg/pull/51358)) +- Post Title: Fix autofocus when iframed. ([51331](https://github.com/WordPress/gutenberg/pull/51331), [51367](https://github.com/WordPress/gutenberg/pull/51367)) +- Query: Fix deprecation error when migrating layout. ([51311](https://github.com/WordPress/gutenberg/pull/51311)) +- Term Description: Handle default margin styles. ([51137](https://github.com/WordPress/gutenberg/pull/51137)) + +#### Global Styles +- DimensionsPanel: Fix site editor error on Columns block level screen. ([51252](https://github.com/WordPress/gutenberg/pull/51252)) +- Fluid typography: Ensure max viewport width is used in the editor. ([51146](https://github.com/WordPress/gutenberg/pull/51146)) +- Global styles revisions: Ensure redirect runs once for back button. ([51316](https://github.com/WordPress/gutenberg/pull/51316)) +- SpacingSizesControl: Fix problem with the slider position being reset when saving global styles. ([50956](https://github.com/WordPress/gutenberg/pull/50956)) +- Styles Screen: Ensure variations previews will render in mobile viewports. ([51080](https://github.com/WordPress/gutenberg/pull/51080)) + +#### Components +- Fix: Can't type space if `RichText` component is inside button/summary in Firefox. ([50540](https://github.com/WordPress/gutenberg/pull/50540)) +- FontSizePicker: Fix control header spacing. ([50855](https://github.com/WordPress/gutenberg/pull/50855)) + +#### Themes +- Avoid changing non-theme-preview requests. ([51221](https://github.com/WordPress/gutenberg/pull/51221)) + +#### Data Layer +- Data: Fix a bug where private selectors on a store with resolvers are inaccessible. ([51166](https://github.com/WordPress/gutenberg/pull/51166)) + +#### Accessibility +- Add aria labels to the focal point picker component. ([50993](https://github.com/WordPress/gutenberg/pull/50993)) +- Block Toolbar: Fix text only label for locked blocks. ([50944](https://github.com/WordPress/gutenberg/pull/50944)) +- Fix Navigable Toolbar initialIndex. ([51181](https://github.com/WordPress/gutenberg/pull/51181)) +- Fix screen readers not announcing updated `aria-describedby` in Firefox. ([51035](https://github.com/WordPress/gutenberg/pull/51035)) +- Link Control: Fix the 'Save' button's disabled state. ([51117](https://github.com/WordPress/gutenberg/pull/51117)) +- Social Icons: Manually set Snapchat label color. ([51237](https://github.com/WordPress/gutenberg/pull/51237)) + +### Performance + +- Make getBlockEditingMode() return 'default' when parent is 'contentOnly'. ([51185](https://github.com/WordPress/gutenberg/pull/51185)) +- Use static closures when not using $this. ([50723](https://github.com/WordPress/gutenberg/pull/50723)) +- Add `removeAllNotices` action to allow all notices to be removed from a given context. ([44059](https://github.com/WordPress/gutenberg/pull/44059)) +- Add a new action `removeNotices` which allows bulk removal of notices. ([39940](https://github.com/WordPress/gutenberg/pull/39940)) + +### Experiments + +#### Interactivity API +- Change label and description for the `gutenberg-interactivity-api-core-blocks` experiments setting. ([51059](https://github.com/WordPress/gutenberg/pull/51059)) +- Disable Lightbox UI if link has an image. ([51180](https://github.com/WordPress/gutenberg/pull/51180)) +- Experiment: Put directives on
element and insert lightbox as its child. ([51089](https://github.com/WordPress/gutenberg/pull/51089)) +- Image Lightbox: Add a reset button. ([51239](https://github.com/WordPress/gutenberg/pull/51239)) +- Image Lightbox: Add support for external urls in the lightbox. ([51278](https://github.com/WordPress/gutenberg/pull/51278)) +- Image Lightbox: Fix design of close button for the lightbox (correct PR). ([51206](https://github.com/WordPress/gutenberg/pull/51206)) +- Image Lightbox: Improve image block lightbox escaping. ([51061](https://github.com/WordPress/gutenberg/pull/51061)) +- Move the directives and markup needed for the lightbox to block supports. ([51232](https://github.com/WordPress/gutenberg/pull/51232)) +- Navigation block: Set correct aria-expanded on hover. ([50953](https://github.com/WordPress/gutenberg/pull/50953)) +- Remove experimental flag from navigation and file blocks to use the Interactivity API (as private). ([51266](https://github.com/WordPress/gutenberg/pull/51266)) +- Rename directives suffix character and island directive in the Interactivity API. ([51152](https://github.com/WordPress/gutenberg/pull/51152)) +- Remove not needed aria-hidden attribute in navigation block experiment. ([51044](https://github.com/WordPress/gutenberg/pull/51044)) + +#### DropdownMenu v2 +- Change default placement to match the legacy DropdownMenu component. ([51133](https://github.com/WordPress/gutenberg/pull/51133)) +- Render in the default Popover.Slot. ([51046](https://github.com/WordPress/gutenberg/pull/51046)) +- Style tweaks. ([50967](https://github.com/WordPress/gutenberg/pull/50967)) +- Tweak styles, add toolbar-specific styles. ([51097](https://github.com/WordPress/gutenberg/pull/51097)) + +### Documentation + +- Add documentation about the entities abstraction and the undo/redo stack. ([51052](https://github.com/WordPress/gutenberg/pull/51052)) +- Fix code example error in the Curating the Editor doc. ([51070](https://github.com/WordPress/gutenberg/pull/51070)) +- Fix formatting and use sentence case for titles in Scripts doc. ([51069](https://github.com/WordPress/gutenberg/pull/51069)) +- Fix headings in the View component readme. ([51157](https://github.com/WordPress/gutenberg/pull/51157)) +- Fix text in readme. ([51268](https://github.com/WordPress/gutenberg/pull/51268)) +- Remove Block Grammar doc and all corresponding internal links. ([51106](https://github.com/WordPress/gutenberg/pull/51106)) +- Remove Roadmap doc. ([51062](https://github.com/WordPress/gutenberg/pull/51062)) +- Undo/Redo: Minor edits. ([51085](https://github.com/WordPress/gutenberg/pull/51085)) +- Update README.md on SlotFills to add info + example about the prop `fillProps`. ([51013](https://github.com/WordPress/gutenberg/pull/51013)) +- Update React documentation link for propTypes. ([51208](https://github.com/WordPress/gutenberg/pull/51208)) + +### Code Quality +- Extract BlockThemePreviews-related code from the editor package. ([50863](https://github.com/WordPress/gutenberg/pull/50863)) +- Fluid typography: Extract logic to derive fluid typography settings. ([51188](https://github.com/WordPress/gutenberg/pull/51188)) +- Fonts API: Refactor Theme JSON global functions into WP_Fonts_Resolver. ([50811](https://github.com/WordPress/gutenberg/pull/50811)) +- Iframe: Clarify how dependencies related to inline styles work. ([51199](https://github.com/WordPress/gutenberg/pull/51199)) +- Iframe: Fix blob cleanup. ([51004](https://github.com/WordPress/gutenberg/pull/51004)) +- Iframe: Remove obsolete readyState checks. ([51003](https://github.com/WordPress/gutenberg/pull/51003)) +- Iframe: Remove obsolete styles HTML parsing. ([51136](https://github.com/WordPress/gutenberg/pull/51136)) +- Lodash: Remove `_.isEmpty()`. ([51096](https://github.com/WordPress/gutenberg/pull/51096), [50974](https://github.com/WordPress/gutenberg/pull/50974), [51098](https://github.com/WordPress/gutenberg/pull/51098), [50917](https://github.com/WordPress/gutenberg/pull/50917), [51168](https://github.com/WordPress/gutenberg/pull/51168)) +- mapSelectorsWithResolvers: Don't init hasResolver, mapSelectors already did it. ([51160](https://github.com/WordPress/gutenberg/pull/51160)) +- mapValues: Use fromEntries, avoid re-creating object in each reducer call. ([51159](https://github.com/WordPress/gutenberg/pull/51159)) +- Refactor code that adds resolver fulfillment to selector calls. ([51009](https://github.com/WordPress/gutenberg/pull/51009)) +- Remove legacy logic for `__unstableResolvedAssets`. ([51100](https://github.com/WordPress/gutenberg/pull/51100)) +- Remove outdated Babel spread optimization from selectors. ([50987](https://github.com/WordPress/gutenberg/pull/50987)) +- Remove the insert.ref field from insertUsage data. ([51130](https://github.com/WordPress/gutenberg/pull/51130)) +- Rename 'page content lock' to 'page content focus'. ([51280](https://github.com/WordPress/gutenberg/pull/51280)) +- Separate template screens in the Site Editor. ([51040](https://github.com/WordPress/gutenberg/pull/51040)) +- Writing flow: Fix tab into iframe. ([50955](https://github.com/WordPress/gutenberg/pull/50955)) + +#### Block Editor +- Refactor Link Control Settings Drawer to avoid unnecessary prop drilling. ([50963](https://github.com/WordPress/gutenberg/pull/50963)) +- ListView: Remove unused 'useSelect' dependency. ([51134](https://github.com/WordPress/gutenberg/pull/51134)) + +#### Components +- BlockDraggable: Use the getBlockType selector. ([51174](https://github.com/WordPress/gutenberg/pull/51174)) +- PreferenceToggleMenuItem: Add missing useSelect dependency. ([51158](https://github.com/WordPress/gutenberg/pull/51158)) + +### Tools + +#### wp-env +- Fixed Docker Image Size Ballooning. ([51034](https://github.com/WordPress/gutenberg/pull/51034)) +- Preferentially Execute Local `wp-env`. ([50980](https://github.com/WordPress/gutenberg/pull/50980)) + +#### Scripts +- Scripts: Optimize updating render paths when developing blocks. ([51162](https://github.com/WordPress/gutenberg/pull/51162)) +- Fix: Build render.php when webpack watch in progress. ([50939](https://github.com/WordPress/gutenberg/pull/50939)) + +#### Testing +- Add tests to `useIsDirty`. ([51036](https://github.com/WordPress/gutenberg/pull/51036)) +- Button: Add basic visual regression tests. ([51000](https://github.com/WordPress/gutenberg/pull/51000)) +- Comment Template Block: Add test coverage for context setting. ([50879](https://github.com/WordPress/gutenberg/pull/50879)) +- Comment Template Block: Retain inner blocks inserted via render_block_data filter. ([50883](https://github.com/WordPress/gutenberg/pull/50883)) +- Fix flaky Behaviors UI end-to-end tests. ([50954](https://github.com/WordPress/gutenberg/pull/50954)) +- Ignore framer-motion warning when running end-to-end tests locally. ([50938](https://github.com/WordPress/gutenberg/pull/50938)) +- Link Control test migration: Should contain a label when it should open in a new tab. ([51001](https://github.com/WordPress/gutenberg/pull/51001)) +- Link control: Migrate tests to Playwright. Can be created by selecting text and using keyboard shortcuts. ([50996](https://github.com/WordPress/gutenberg/pull/50996)) +- End-to-end tests: Add an assertion to confirm that the URL changed. ([50835](https://github.com/WordPress/gutenberg/pull/50835)) + +#### Build Tooling +- babel-preset-default: Enable the bugfixes option for preset-env. ([50994](https://github.com/WordPress/gutenberg/pull/50994)) + +## First time contributors + +The following PRs were merged by first time contributors: + +- @okmttdhr: Extract BlockThemePreviews-related code from the editor package. ([50863](https://github.com/WordPress/gutenberg/pull/50863)) +- @SaxonF: Directly save if only changing current context. ([50567](https://github.com/WordPress/gutenberg/pull/50567)) +- @Takshil-Kunadia: fix: Build render.php when webpack watch in progress. ([50939](https://github.com/WordPress/gutenberg/pull/50939)) +- @wayheming: Docs: Fix text in readme. ([51268](https://github.com/WordPress/gutenberg/pull/51268)) + + +## Contributors + +The following contributors merged PRs in this release: + +@aaronrobertshaw @afercia @alexstine @andrewserong @anton-vlasenko @artemiomorales @benlk @c4rl0sbr4v0 @carolinan @chad1008 @ciampo @derekblank @ellatrix @fluiddot @geriux @getdave @gigitux @glendaviesnz @gziolo @jameskoster @jeryj @jffng @jsnajdr @juanfra @kevin940726 @luisherranz @MaggieCabrera @Mamaduka @mcsf @michalczaplinski @mikachan @mirka @ndiego @noisysocks @ntsekouras @oandregal @ObliviousHarmony @ockham @okmttdhr @opr @ramonjd @richtabor @rmorse @SantosGuillamot @SaxonF @scruffian @SiobhyB @t-hamano @Takshil-Kunadia @tellthemachines @tyxla @wayheming @westonruter @youknowriad + + = 15.9.1 = diff --git a/docs/contributors/code/coding-guidelines.md b/docs/contributors/code/coding-guidelines.md index ac89ef7f7dc873..e7ff0a40843060 100644 --- a/docs/contributors/code/coding-guidelines.md +++ b/docs/contributors/code/coding-guidelines.md @@ -211,7 +211,7 @@ import { privateHasContentRoleAttribute, ...selectors } from './selectors'; import { privateToggleFeature, ...actions } from './selectors'; // The `lock` function is exported from the internal private-apis.js file where // the opt-in function was called. -import { lock, unlock } from './private-apis'; +import { lock, unlock } from './lock-unlock'; export const store = registerStore(/* ... */); // Attach a private action to the exported store: @@ -230,7 +230,7 @@ import { store } from '@wordpress/package1'; import { useSelect } from '@wordpress/data'; // The `unlock` function is exported from the internal private-apis.js file where // the opt-in function was called. -import { unlock } from './private-apis'; +import { unlock } from './lock-unlock'; function MyComponent() { const hasRole = useSelect( ( select ) => ( @@ -251,7 +251,7 @@ function MyComponent() { ```js // In packages/package1/index.js: -import { lock } from './private-apis'; +import { lock } from './lock-unlock'; export const privateApis = {}; /* Attach private data to the exported object */ @@ -266,7 +266,7 @@ lock( privateApis, { // In packages/package2/index.js: import { privateApis } from '@wordpress/package1'; -import { unlock } from './private-apis'; +import { unlock } from './lock-unlock'; const { privateCallback, @@ -314,7 +314,7 @@ inside it: ```js // In @wordpress/package1/index.js: -import { lock } from './private-apis'; +import { lock } from './lock-unlock'; // A private function contains all the logic function privateValidateBlocks( formula, privateIsStrict ) { @@ -339,7 +339,7 @@ lock( privateApis, { privateValidateBlocks } ); // In @wordpress/package2/index.js: import { privateApis as package1PrivateApis } from '@wordpress/package1'; -import { unlock } from './private-apis'; +import { unlock } from './lock-unlock'; // The private function may be "unlocked" given the stable function: const { privateValidateBlocks } = unlock( package1PrivateApis ); @@ -355,7 +355,7 @@ inside it: ```js // In @wordpress/package1/index.js: -import { lock } from './private-apis'; +import { lock } from './lock-unlock'; // The private component contains all the logic const PrivateMyButton = ( { title, privateShowIcon = true } ) => { @@ -379,7 +379,7 @@ lock( privateApis, { PrivateMyButton } ); // In @wordpress/package2/index.js: import { privateApis } from '@wordpress/package1'; -import { unlock } from './private-apis'; +import { unlock } from './lock-unlock'; // The private component may be "unlocked" given the stable component: const { PrivateMyButton } = unlock(privateApis); diff --git a/docs/contributors/code/react-native/getting-started-react-native.md b/docs/contributors/code/react-native/getting-started-react-native.md index e5c8fdd4eaf2c1..96338af7a6f2f7 100644 --- a/docs/contributors/code/react-native/getting-started-react-native.md +++ b/docs/contributors/code/react-native/getting-started-react-native.md @@ -111,7 +111,7 @@ This project is set up to use [jest](https://facebook.github.io/jest/) for tests This repository uses Appium to run UI tests. The tests live in `__device-tests__` and are written using Appium to run tests against simulators and real devices. To run these you'll need to check off a few things: - When running the tests, you'll need to ensure the Metro bundler (`npm run native start`) is not running. -- [Appium CLI](https://appium.io/docs/en/about-appium/getting-started/) installed and available globally. We also recommend using [appium-doctor](https://github.com/appium/appium-doctor) to ensure all of Appium's dependencies are good to go. You don't have to worry about starting the server yourself, the tests handle starting the server on port 4723, just be sure that the port is free or feel free to change the port number in the test file. +- [Appium CLI](https://github.com/appium/appium/blob/1.x/docs/en/about-appium/getting-started.md) installed and available globally. We also recommend using [appium-doctor](https://github.com/appium/appium-doctor) to ensure all of Appium's dependencies are good to go. You don't have to worry about starting the server yourself, the tests handle starting the server on port 4723, just be sure that the port is free or feel free to change the port number in the test file. - For iOS a simulator should automatically launch but for Android you'll need to have an emulator _with at least platform version 8.0_ fired up and running. Then, to run the UI tests on iOS: diff --git a/docs/explanations/architecture/entities.md b/docs/explanations/architecture/entities.md index 1e037ed5b2824f..13e6eaca08b5a0 100644 --- a/docs/explanations/architecture/entities.md +++ b/docs/explanations/architecture/entities.md @@ -15,7 +15,7 @@ The editor keeps track of all these modifications and orchestrates the saving of To be able to edit an entity, you need to first fetch it and load it into the `core-data` store. For example, the following code loads the post with ID 1 into the store. (The entity is the post, the post 1 is the entity record). ````js -wp.data.dispatch( 'core' ).getEntityRecord( 'postType', 'post', 1 ); +wp.data.select( 'core' ).getEntityRecord( 'postType', 'post', 1 ); ```` Once the entity is loaded, you can edit it. For example, the following code sets the title of the post to "Hello World". For each fetched entity record, the `core-data` store keeps track of: diff --git a/docs/explanations/architecture/styles.md b/docs/explanations/architecture/styles.md index a1ed2c33054bc9..faf2649efd13ab 100644 --- a/docs/explanations/architecture/styles.md +++ b/docs/explanations/architecture/styles.md @@ -513,7 +513,7 @@ In addition to styles at the individual block level and in global styles, there The layout block support is an experimental approach for outputting common layout styles that are shared between blocks that are used for creating layouts. Layout styles are useful for providing common styling for any block that is a container for other blocks. Examples of blocks that depend on these layout styles include Group, Row, Columns, Buttons, and Social Icons. -While the feature is part of WordPress core, it is still flagged as experimental in the sense that the features and output are still undergoing active development. It is therefore not yet a stable feature from the perspective of 3rd party blocks, as the API is likely to change. The feature is enabled in core blocks via the `__experimentalLayout` setting under `supports` in a block's `block.json` file. +While the feature is part of WordPress core, it is still flagged as experimental in the sense that the features and output are still undergoing active development. It is therefore not yet a stable feature from the perspective of 3rd party blocks, as the API is likely to change. The feature is enabled in core blocks via the `layout` setting under `supports` in a block's `block.json` file. There are two primary places where Layout styles are output: diff --git a/docs/getting-started/devenv/docker-ubuntu.md b/docs/getting-started/devenv/docker-ubuntu.md index f26ca0826140ef..680798d74f4e8c 100644 --- a/docs/getting-started/devenv/docker-ubuntu.md +++ b/docs/getting-started/devenv/docker-ubuntu.md @@ -34,7 +34,7 @@ If docker is not running, try to start the service using: sudo systemctl start docker.service ``` -If docker is running, then it is not listening how the WordPress environment is trying to communicate. Try adding the following service override file to include listening on tcp. See docker documentation, [How do I enable the remote API for dockerd](https://success.docker.com/article/how-do-i-enable-the-remote-api-for-dockerd) +If docker is running, then it is not listening how the WordPress environment is trying to communicate. Try adding the following service override file to include listening on tcp. See [this Docker documentation](https://docs.docker.com/config/daemon/remote-access/) on how to configure remote access for Docker daemon. ``` # /etc/systemd/system/docker.service.d/override.conf diff --git a/docs/reference-guides/block-api/block-supports.md b/docs/reference-guides/block-api/block-supports.md index 683e4f134d9877..7e68e18eb14bf8 100644 --- a/docs/reference-guides/block-api/block-supports.md +++ b/docs/reference-guides/block-api/block-supports.md @@ -48,7 +48,7 @@ function render_block() { - Type: `boolean` - Default value: `false` -Anchors let you link directly to a specific block on a page. This property adds a field to define an id for the block and a button to copy the direct link. +Anchors let you link directly to a specific block on a page. This property adds a field to define an id for the block and a button to copy the direct link. _Important: It doesn't work with dynamic blocks yet._ ```js // Declare support for anchor links. @@ -232,7 +232,7 @@ When the block declares support for `color.background`, the attributes definitio _**Note:** Deprecated since WordPress 6.3._ -This property has been replaced by [`filter.duotone`](#filter-duotone). +This property has been replaced by [`filter.duotone`](#filter-duotone). ### color.gradients diff --git a/docs/reference-guides/core-blocks.md b/docs/reference-guides/core-blocks.md index 43aabae2aca086..dec943d4bb7905 100644 --- a/docs/reference-guides/core-blocks.md +++ b/docs/reference-guides/core-blocks.md @@ -15,7 +15,7 @@ Display a date archive of your posts. ([Source](https://github.com/WordPress/gut - **Name:** core/archives - **Category:** widgets -- **Supports:** align, anchor, spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ +- **Supports:** align, spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ - **Attributes:** displayAsDropdown, showLabel, showPostCounts, type ## Audio @@ -33,7 +33,7 @@ Add a user’s avatar. ([Source](https://github.com/WordPress/gutenberg/tree/tru - **Name:** core/avatar - **Category:** theme -- **Supports:** align, anchor, color (~~background~~, ~~text~~), spacing (margin, padding), ~~alignWide~~, ~~html~~ +- **Supports:** align, color (~~background~~, ~~text~~), spacing (margin, padding), ~~alignWide~~, ~~html~~ - **Attributes:** isLink, linkTarget, size, userId ## Reusable block @@ -61,7 +61,7 @@ Prompt visitors to take action with a group of button-style links. ([Source](htt - **Name:** core/buttons - **Category:** design -- **Supports:** align (full, wide), anchor, spacing (blockGap, margin), typography (fontSize, lineHeight), ~~html~~ +- **Supports:** align (full, wide), anchor, layout (default, ~~allowInheriting~~, ~~allowSwitching~~), spacing (blockGap, margin), typography (fontSize, lineHeight), ~~html~~ - **Attributes:** ## Calendar @@ -70,7 +70,7 @@ A calendar of your site’s posts. ([Source](https://github.com/WordPress/gutenb - **Name:** core/calendar - **Category:** widgets -- **Supports:** align, anchor, color (background, link, text), typography (fontSize, lineHeight) +- **Supports:** align, color (background, link, text), typography (fontSize, lineHeight) - **Attributes:** month, year ## Categories List @@ -79,7 +79,7 @@ Display a list of all categories. ([Source](https://github.com/WordPress/gutenbe - **Name:** core/categories - **Category:** widgets -- **Supports:** align, anchor, spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ +- **Supports:** align, spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ - **Attributes:** displayAsDropdown, showEmpty, showHierarchy, showOnlyTopLevel, showPostCounts ## Code @@ -98,7 +98,7 @@ A single column within a columns block. ([Source](https://github.com/WordPress/g - **Name:** core/column - **Category:** design - **Parent:** core/columns -- **Supports:** anchor, color (background, gradients, link, text), spacing (blockGap, padding), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ +- **Supports:** anchor, color (background, gradients, link, text), layout, spacing (blockGap, padding), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ - **Attributes:** allowedBlocks, templateLock, verticalAlignment, width ## Columns @@ -107,7 +107,7 @@ Display content in multiple columns, with blocks added to each column. ([Source] - **Name:** core/columns - **Category:** design -- **Supports:** align (full, wide), anchor, color (background, gradients, link, text), spacing (blockGap, margin, padding), typography (fontSize, lineHeight), ~~html~~ +- **Supports:** align (full, wide), anchor, color (background, gradients, link, text), layout (default, ~~allowEditing~~, ~~allowInheriting~~, ~~allowSwitching~~), spacing (blockGap, margin, padding), typography (fontSize, lineHeight), ~~html~~ - **Attributes:** isStackedOnMobile, templateLock, verticalAlignment ## Comment Author Avatar (deprecated) @@ -117,7 +117,7 @@ This block is deprecated. Please use the Avatar block instead. ([Source](https:/ - **Name:** core/comment-author-avatar - **Experimental:** fse - **Category:** theme -- **Supports:** anchor, color (background, ~~text~~), spacing (margin, padding), ~~html~~, ~~inserter~~ +- **Supports:** color (background, ~~text~~), spacing (margin, padding), ~~html~~, ~~inserter~~ - **Attributes:** height, width ## Comment Author Name @@ -126,7 +126,7 @@ Displays the name of the author of the comment. ([Source](https://github.com/Wor - **Name:** core/comment-author-name - **Category:** theme -- **Supports:** anchor, color (background, gradients, link, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ +- **Supports:** color (background, gradients, link, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ - **Attributes:** isLink, linkTarget, textAlign ## Comment Content @@ -135,7 +135,7 @@ Displays the contents of a comment. ([Source](https://github.com/WordPress/guten - **Name:** core/comment-content - **Category:** theme -- **Supports:** anchor, color (background, gradients, link, text), spacing (padding), typography (fontSize, lineHeight), ~~html~~ +- **Supports:** color (background, gradients, link, text), spacing (padding), typography (fontSize, lineHeight), ~~html~~ - **Attributes:** textAlign ## Comment Date @@ -144,7 +144,7 @@ Displays the date on which the comment was posted. ([Source](https://github.com/ - **Name:** core/comment-date - **Category:** theme -- **Supports:** anchor, color (background, gradients, link, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ +- **Supports:** color (background, gradients, link, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ - **Attributes:** format, isLink ## Comment Edit Link @@ -153,7 +153,7 @@ Displays a link to edit the comment in the WordPress Dashboard. This link is onl - **Name:** core/comment-edit-link - **Category:** theme -- **Supports:** anchor, color (background, gradients, link, ~~text~~), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ +- **Supports:** color (background, gradients, link, ~~text~~), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ - **Attributes:** linkTarget, textAlign ## Comment Reply Link @@ -162,7 +162,7 @@ Displays a link to reply to a comment. ([Source](https://github.com/WordPress/gu - **Name:** core/comment-reply-link - **Category:** theme -- **Supports:** anchor, color (background, gradients, link, ~~text~~), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ +- **Supports:** color (background, gradients, link, ~~text~~), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ - **Attributes:** textAlign ## Comment Template @@ -172,7 +172,7 @@ Contains the block elements used to display a comment, like the title, date, aut - **Name:** core/comment-template - **Category:** design - **Parent:** core/comments -- **Supports:** align, anchor, spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ +- **Supports:** align, spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ - **Attributes:** ## Comments @@ -181,7 +181,7 @@ An advanced block that allows displaying post comments using different visual co - **Name:** core/comments - **Category:** theme -- **Supports:** align (full, wide), anchor, color (background, gradients, link, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ +- **Supports:** align (full, wide), color (background, gradients, link, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ - **Attributes:** legacy, tagName ## Comments Pagination @@ -191,7 +191,7 @@ Displays a paginated navigation to next/previous set of comments, when applicabl - **Name:** core/comments-pagination - **Category:** theme - **Parent:** core/comments -- **Supports:** align, anchor, color (background, gradients, link, text), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ +- **Supports:** align, color (background, gradients, link, text), layout (default, ~~allowInheriting~~, ~~allowSwitching~~), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ - **Attributes:** paginationArrow ## Comments Next Page @@ -201,7 +201,7 @@ Displays the next comment's page link. ([Source](https://github.com/WordPress/gu - **Name:** core/comments-pagination-next - **Category:** theme - **Parent:** core/comments-pagination -- **Supports:** anchor, color (background, gradients, ~~text~~), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ +- **Supports:** color (background, gradients, ~~text~~), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ - **Attributes:** label ## Comments Page Numbers @@ -211,7 +211,7 @@ Displays a list of page numbers for comments pagination. ([Source](https://githu - **Name:** core/comments-pagination-numbers - **Category:** theme - **Parent:** core/comments-pagination -- **Supports:** anchor, color (background, gradients, ~~text~~), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ +- **Supports:** color (background, gradients, ~~text~~), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ - **Attributes:** ## Comments Previous Page @@ -221,7 +221,7 @@ Displays the previous comment's page link. ([Source](https://github.com/WordPres - **Name:** core/comments-pagination-previous - **Category:** theme - **Parent:** core/comments-pagination -- **Supports:** anchor, color (background, gradients, ~~text~~), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ +- **Supports:** color (background, gradients, ~~text~~), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ - **Attributes:** label ## Comments Title @@ -239,7 +239,7 @@ Add an image or video with a text overlay. ([Source](https://github.com/WordPres - **Name:** core/cover - **Category:** media -- **Supports:** align, anchor, color (text, ~~background~~), spacing (blockGap, margin, padding), typography (fontSize, lineHeight), ~~html~~ +- **Supports:** align, anchor, color (text, ~~background~~), layout (~~allowJustification~~), spacing (blockGap, margin, padding), typography (fontSize, lineHeight), ~~html~~ - **Attributes:** allowedBlocks, alt, backgroundType, contentPosition, customGradient, customOverlayColor, dimRatio, focalPoint, gradient, hasParallax, id, isDark, isRepeated, minHeight, minHeightUnit, overlayColor, tagName, templateLock, url, useFeaturedImage ## Details @@ -284,7 +284,7 @@ Display multiple images in a rich gallery. ([Source](https://github.com/WordPres - **Name:** core/gallery - **Category:** media -- **Supports:** align, anchor, color (background, gradients, ~~text~~), spacing (blockGap, margin, padding), units (em, px, rem, vh, vw), ~~html~~ +- **Supports:** align, anchor, color (background, gradients, ~~text~~), layout (default, ~~allowEditing~~, ~~allowInheriting~~, ~~allowSwitching~~), spacing (blockGap, margin, padding), units (em, px, rem, vh, vw), ~~html~~ - **Attributes:** allowResize, caption, columns, fixedHeight, ids, imageCrop, images, linkTarget, linkTo, shortCodeTransforms, sizeSlug ## Group @@ -293,7 +293,7 @@ Gather blocks in a layout container. ([Source](https://github.com/WordPress/gute - **Name:** core/group - **Category:** design -- **Supports:** align (full, wide), anchor, ariaLabel, color (background, gradients, link, text), dimensions (minHeight), position (sticky), spacing (blockGap, margin, padding), typography (fontSize, lineHeight), ~~html~~ +- **Supports:** align (full, wide), anchor, ariaLabel, color (background, gradients, link, text), dimensions (minHeight), layout (allowSizingOnChildren), position (sticky), spacing (blockGap, margin, padding), typography (fontSize, lineHeight), ~~html~~ - **Attributes:** allowedBlocks, tagName, templateLock ## Heading @@ -312,7 +312,7 @@ Create a link that always points to the homepage of the site. Usually not necess - **Name:** core/home-link - **Category:** design - **Parent:** core/navigation -- **Supports:** anchor, typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ +- **Supports:** typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ - **Attributes:** label ## Custom HTML @@ -330,8 +330,8 @@ Insert an image to make a visual statement. ([Source](https://github.com/WordPre - **Name:** core/image - **Category:** media -- **Supports:** anchor, color (~~background~~, ~~text~~), filter (duotone) -- **Attributes:** align, alt, behaviors, caption, height, href, id, linkClass, linkDestination, linkTarget, rel, sizeSlug, title, url, width +- **Supports:** anchor, behaviors (lightbox), color (~~background~~, ~~text~~), filter (duotone) +- **Attributes:** align, alt, caption, height, href, id, linkClass, linkDestination, linkTarget, rel, sizeSlug, title, url, width ## Latest Comments @@ -339,7 +339,7 @@ Display a list of your most recent comments. ([Source](https://github.com/WordPr - **Name:** core/latest-comments - **Category:** widgets -- **Supports:** align, anchor, spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ +- **Supports:** align, spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ - **Attributes:** commentsToShow, displayAvatar, displayDate, displayExcerpt ## Latest Posts @@ -348,7 +348,7 @@ Display a list of your most recent posts. ([Source](https://github.com/WordPress - **Name:** core/latest-posts - **Category:** widgets -- **Supports:** align, anchor, color (background, gradients, link, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ +- **Supports:** align, color (background, gradients, link, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ - **Attributes:** addLinkToFeaturedImage, categories, columns, displayAuthor, displayFeaturedImage, displayPostContent, displayPostContentRadio, displayPostDate, excerptLength, featuredImageAlign, featuredImageSizeHeight, featuredImageSizeSlug, featuredImageSizeWidth, order, orderBy, postLayout, postsToShow, selectedAuthor ## List @@ -376,7 +376,7 @@ Show login & logout links. ([Source](https://github.com/WordPress/gutenberg/tree - **Name:** core/loginout - **Category:** theme -- **Supports:** anchor, className, typography (fontSize, lineHeight) +- **Supports:** className, typography (fontSize, lineHeight) - **Attributes:** displayLoginAsForm, redirectToCurrent ## Media & Text @@ -412,7 +412,7 @@ A collection of blocks that allow visitors to get around your site. ([Source](ht - **Name:** core/navigation - **Category:** theme -- **Supports:** align (full, wide), anchor, inserter, spacing (blockGap, units), typography (fontSize, lineHeight), ~~html~~ +- **Supports:** align (full, wide), inserter, layout (allowSizingOnChildren, default, ~~allowInheriting~~, ~~allowSwitching~~, ~~allowVerticalAlignment~~), spacing (blockGap, units), typography (fontSize, lineHeight), ~~html~~ - **Attributes:** __unstableLocation, backgroundColor, customBackgroundColor, customOverlayBackgroundColor, customOverlayTextColor, customTextColor, hasIcon, icon, maxNestingLevel, openSubmenusOnClick, overlayBackgroundColor, overlayMenu, overlayTextColor, ref, rgbBackgroundColor, rgbTextColor, showSubmenuIcon, templateLock, textColor ## Custom Link @@ -451,7 +451,7 @@ Display a list of all pages. ([Source](https://github.com/WordPress/gutenberg/tr - **Name:** core/page-list - **Category:** widgets -- **Supports:** anchor, typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ +- **Supports:** typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ - **Attributes:** isNested, parentPageID ## Page List Item @@ -488,7 +488,7 @@ Display post author details such as name, avatar, and bio. ([Source](https://git - **Name:** core/post-author - **Category:** theme -- **Supports:** anchor, color (background, gradients, link, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ +- **Supports:** color (background, gradients, link, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ - **Attributes:** avatarSize, byline, isLink, linkTarget, showAvatar, showBio, textAlign ## Post Author Biography @@ -497,7 +497,7 @@ The author biography. ([Source](https://github.com/WordPress/gutenberg/tree/trun - **Name:** core/post-author-biography - **Category:** theme -- **Supports:** anchor, color (background, gradients, link, text), spacing (margin, padding), typography (fontSize, lineHeight) +- **Supports:** color (background, gradients, link, text), spacing (margin, padding), typography (fontSize, lineHeight) - **Attributes:** textAlign ## Post Author Name @@ -506,7 +506,7 @@ The author name. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/pac - **Name:** core/post-author-name - **Category:** theme -- **Supports:** anchor, color (background, gradients, link, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ +- **Supports:** color (background, gradients, link, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ - **Attributes:** isLink, linkTarget, textAlign ## Post Comment (deprecated) @@ -526,7 +526,7 @@ Display a post's comments count. ([Source](https://github.com/WordPress/gutenber - **Name:** core/post-comments-count - **Experimental:** fse - **Category:** theme -- **Supports:** anchor, color (background, gradients, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ +- **Supports:** color (background, gradients, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ - **Attributes:** textAlign ## Post Comments Form @@ -535,7 +535,7 @@ Display a post's comments form. ([Source](https://github.com/WordPress/gutenberg - **Name:** core/post-comments-form - **Category:** theme -- **Supports:** anchor, color (background, gradients, link, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ +- **Supports:** color (background, gradients, link, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ - **Attributes:** textAlign ## Post Comments Link @@ -545,7 +545,7 @@ Displays the link to the current post comments. ([Source](https://github.com/Wor - **Name:** core/post-comments-link - **Experimental:** fse - **Category:** theme -- **Supports:** anchor, color (background, link, ~~text~~), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ +- **Supports:** color (background, link, ~~text~~), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ - **Attributes:** textAlign ## Post Content @@ -554,7 +554,7 @@ Displays the contents of a post or page. ([Source](https://github.com/WordPress/ - **Name:** core/post-content - **Category:** theme -- **Supports:** align (full, wide), anchor, dimensions (minHeight), typography (fontSize, lineHeight), ~~html~~ +- **Supports:** align (full, wide), dimensions (minHeight), layout, typography (fontSize, lineHeight), ~~html~~ - **Attributes:** ## Post Date @@ -563,16 +563,16 @@ Add the date of this post. ([Source](https://github.com/WordPress/gutenberg/tree - **Name:** core/post-date - **Category:** theme -- **Supports:** anchor, color (background, gradients, link, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ +- **Supports:** color (background, gradients, link, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ - **Attributes:** displayType, format, isLink, textAlign -## Post Excerpt +## Excerpt -Display a post's excerpt. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/post-excerpt)) +Display the excerpt. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/post-excerpt)) - **Name:** core/post-excerpt - **Category:** theme -- **Supports:** anchor, color (background, gradients, link, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ +- **Supports:** color (background, gradients, link, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ - **Attributes:** excerptLength, moreText, showMoreOnNewLine, textAlign ## Post Featured Image @@ -581,7 +581,7 @@ Display a post's featured image. ([Source](https://github.com/WordPress/gutenber - **Name:** core/post-featured-image - **Category:** theme -- **Supports:** align (center, full, left, right, wide), anchor, color (~~background~~, ~~text~~), spacing (margin, padding), ~~html~~ +- **Supports:** align (center, full, left, right, wide), color (~~background~~, ~~text~~), spacing (margin, padding), ~~html~~ - **Attributes:** aspectRatio, customGradient, customOverlayColor, dimRatio, gradient, height, isLink, linkTarget, overlayColor, rel, scale, sizeSlug, width ## Post Navigation Link @@ -590,7 +590,7 @@ Displays the next or previous post link that is adjacent to the current post. ([ - **Name:** core/post-navigation-link - **Category:** theme -- **Supports:** anchor, color (background, link, text), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ +- **Supports:** color (background, link, text), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ - **Attributes:** arrow, label, linkLabel, showTitle, textAlign, type ## Post Template @@ -600,7 +600,7 @@ Contains the block elements used to render a post, like the title, date, feature - **Name:** core/post-template - **Category:** theme - **Parent:** core/query -- **Supports:** align (full, wide), anchor, color (background, gradients, link, text), spacing (blockGap), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ +- **Supports:** align (full, wide), color (background, gradients, link, text), layout, spacing (blockGap), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ - **Attributes:** ## Post Terms @@ -609,7 +609,7 @@ Post terms. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages - **Name:** core/post-terms - **Category:** theme -- **Supports:** anchor, color (background, gradients, link, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ +- **Supports:** color (background, gradients, link, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ - **Attributes:** prefix, separator, suffix, term, textAlign ## Time To Read @@ -628,7 +628,7 @@ Displays the title of a post, page, or any other content-type. ([Source](https:/ - **Name:** core/post-title - **Category:** theme -- **Supports:** align (full, wide), anchor, color (background, gradients, link, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ +- **Supports:** align (full, wide), color (background, gradients, link, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ - **Attributes:** isLink, level, linkTarget, rel, textAlign ## Preformatted @@ -655,7 +655,7 @@ An advanced block that allows displaying post types based on different query par - **Name:** core/query - **Category:** theme -- **Supports:** align (full, wide), anchor, ~~html~~ +- **Supports:** align (full, wide), layout, ~~html~~ - **Attributes:** namespace, query, queryId, tagName ## No results @@ -665,7 +665,7 @@ Contains the block elements used to render content when no query results are fou - **Name:** core/query-no-results - **Category:** theme - **Parent:** core/query -- **Supports:** align, anchor, color (background, gradients, link, text), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ +- **Supports:** align, color (background, gradients, link, text), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ - **Attributes:** ## Pagination @@ -675,7 +675,7 @@ Displays a paginated navigation to next/previous set of posts, when applicable. - **Name:** core/query-pagination - **Category:** theme - **Parent:** core/query -- **Supports:** align, anchor, color (background, gradients, link, text), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ +- **Supports:** align, color (background, gradients, link, text), layout (default, ~~allowInheriting~~, ~~allowSwitching~~), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ - **Attributes:** paginationArrow, showLabel ## Next Page @@ -685,7 +685,7 @@ Displays the next posts page link. ([Source](https://github.com/WordPress/gutenb - **Name:** core/query-pagination-next - **Category:** theme - **Parent:** core/query-pagination -- **Supports:** anchor, color (background, gradients, ~~text~~), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ +- **Supports:** color (background, gradients, ~~text~~), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ - **Attributes:** label ## Page Numbers @@ -695,7 +695,7 @@ Displays a list of page numbers for pagination ([Source](https://github.com/Word - **Name:** core/query-pagination-numbers - **Category:** theme - **Parent:** core/query-pagination -- **Supports:** anchor, color (background, gradients, ~~text~~), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ +- **Supports:** color (background, gradients, ~~text~~), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ - **Attributes:** ## Previous Page @@ -705,7 +705,7 @@ Displays the previous posts page link. ([Source](https://github.com/WordPress/gu - **Name:** core/query-pagination-previous - **Category:** theme - **Parent:** core/query-pagination -- **Supports:** anchor, color (background, gradients, ~~text~~), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ +- **Supports:** color (background, gradients, ~~text~~), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ - **Attributes:** label ## Query Title @@ -714,7 +714,7 @@ Display the query title. ([Source](https://github.com/WordPress/gutenberg/tree/t - **Name:** core/query-title - **Category:** theme -- **Supports:** align (full, wide), anchor, color (background, gradients, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ +- **Supports:** align (full, wide), color (background, gradients, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ - **Attributes:** level, showPrefix, showSearchTerm, textAlign, type ## Quote @@ -732,7 +732,7 @@ Displays the link of a post, page, or any other content-type. ([Source](https:// - **Name:** core/read-more - **Category:** theme -- **Supports:** anchor, color (background, gradients, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ +- **Supports:** color (background, gradients, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ - **Attributes:** content, linkTarget ## RSS @@ -741,7 +741,7 @@ Display entries from any RSS or Atom feed. ([Source](https://github.com/WordPres - **Name:** core/rss - **Category:** widgets -- **Supports:** align, anchor, ~~html~~ +- **Supports:** align, ~~html~~ - **Attributes:** blockLayout, columns, displayAuthor, displayDate, displayExcerpt, excerptLength, feedURL, itemsToShow ## Search @@ -750,7 +750,7 @@ Help visitors find your content. ([Source](https://github.com/WordPress/gutenber - **Name:** core/search - **Category:** widgets -- **Supports:** align (center, left, right), anchor, color (background, gradients, text), typography (fontSize, lineHeight), ~~html~~ +- **Supports:** align (center, left, right), color (background, gradients, text), typography (fontSize, lineHeight), ~~html~~ - **Attributes:** buttonBehavior, buttonPosition, buttonText, buttonUseIcon, isSearchFieldHidden, label, placeholder, query, showLabel, width, widthUnit ## Separator @@ -777,7 +777,7 @@ Display an image to represent this site. Update this block and the changes apply - **Name:** core/site-logo - **Category:** theme -- **Supports:** align, anchor, color (~~background~~, ~~text~~), spacing (margin, padding), ~~alignWide~~, ~~html~~ +- **Supports:** align, color (~~background~~, ~~text~~), spacing (margin, padding), ~~alignWide~~, ~~html~~ - **Attributes:** isLink, linkTarget, shouldSyncIcon, width ## Site Tagline @@ -786,7 +786,7 @@ Describe in a few words what the site is about. The tagline can be used in searc - **Name:** core/site-tagline - **Category:** theme -- **Supports:** align (full, wide), anchor, color (background, gradients, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ +- **Supports:** align (full, wide), color (background, gradients, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ - **Attributes:** textAlign ## Site Title @@ -795,7 +795,7 @@ Displays the name of this site. Update the block, and the changes apply everywhe - **Name:** core/site-title - **Category:** theme -- **Supports:** align (full, wide), anchor, color (background, gradients, link, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ +- **Supports:** align (full, wide), color (background, gradients, link, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ - **Attributes:** isLink, level, linkTarget, textAlign ## Social Icon @@ -805,7 +805,7 @@ Display an icon linking to a social media profile or site. ([Source](https://git - **Name:** core/social-link - **Category:** widgets - **Parent:** core/social-links -- **Supports:** anchor, ~~html~~, ~~reusable~~ +- **Supports:** ~~html~~, ~~reusable~~ - **Attributes:** label, rel, service, url ## Social Icons @@ -814,7 +814,7 @@ Display icons linking to your social media profiles or sites. ([Source](https:// - **Name:** core/social-links - **Category:** widgets -- **Supports:** align (center, left, right), anchor, color (background, gradients, ~~enableContrastChecker~~, ~~text~~), spacing (blockGap, margin, padding, units) +- **Supports:** align (center, left, right), anchor, color (background, gradients, ~~enableContrastChecker~~, ~~text~~), layout (default, ~~allowInheriting~~, ~~allowSwitching~~, ~~allowVerticalAlignment~~), spacing (blockGap, margin, padding, units) - **Attributes:** customIconBackgroundColor, customIconColor, iconBackgroundColor, iconBackgroundColorValue, iconColor, iconColorValue, openInNewTab, showLabels, size ## Spacer @@ -851,7 +851,7 @@ A cloud of your most used tags. ([Source](https://github.com/WordPress/gutenberg - **Name:** core/tag-cloud - **Category:** widgets -- **Supports:** align, anchor, spacing (margin, padding), typography (lineHeight), ~~html~~ +- **Supports:** align, spacing (margin, padding), typography (lineHeight), ~~html~~ - **Attributes:** largestFontSize, numberOfTags, showTagCounts, smallestFontSize, taxonomy ## Template Part @@ -860,7 +860,7 @@ Edit the different global regions of your site, like the header, footer, sidebar - **Name:** core/template-part - **Category:** theme -- **Supports:** align, anchor, ~~html~~, ~~reusable~~ +- **Supports:** align, ~~html~~, ~~reusable~~ - **Attributes:** area, slug, tagName, theme ## Term Description @@ -869,7 +869,7 @@ Display the description of categories, tags and custom taxonomies when viewing a - **Name:** core/term-description - **Category:** theme -- **Supports:** align (full, wide), anchor, color (background, link, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ +- **Supports:** align (full, wide), color (background, link, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ - **Attributes:** textAlign ## Text Columns (deprecated) diff --git a/docs/reference-guides/data/data-core-edit-site.md b/docs/reference-guides/data/data-core-edit-site.md index 523bb8d2bbff5f..a2610c2647c65d 100644 --- a/docs/reference-guides/data/data-core-edit-site.md +++ b/docs/reference-guides/data/data-core-edit-site.md @@ -131,9 +131,9 @@ _Returns_ - `Object`: Settings. -### hasPageContentLock +### hasPageContentFocus -Whether or not the editor is locked so that only page content can be edited. +Whether or not the editor allows only page content to be edited. _Parameters_ @@ -141,7 +141,7 @@ _Parameters_ _Returns_ -- `boolean`: Whether or not the editor is locked. +- `boolean`: Whether or not focus is on editing page content. ### isFeatureActive @@ -280,13 +280,13 @@ _Returns_ - `number`: The resolved template ID for the page route. -### setHasPageContentLock +### setHasPageContentFocus -Sets whether or not the editor is locked so that only page content can be edited. +Sets whether or not the editor allows only page content to be edited. _Parameters_ -- _hasPageContentLock_ `boolean`: True to enable lock, false to disable. +- _hasPageContentFocus_ `boolean`: True to allow only page content to be edited, false to allow template to be edited. ### setHomeTemplateId @@ -328,6 +328,18 @@ _Parameters_ - _isOpen_ `boolean`: If true, opens the save view. If false, closes it. It does not toggle the state, but sets it directly. +### setNavigationMenu + +Action that sets a navigation menu. + +_Parameters_ + +- _navigationMenuId_ `string`: The Navigation Menu Post ID. + +_Returns_ + +- `Object`: Action object. + ### setNavigationPanelActiveMenu > **Deprecated** diff --git a/gutenberg.php b/gutenberg.php index 08813fbb24fee1..917e4ba503a6e2 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: 15.9.1 + * Version: 16.0.0 * Author: Gutenberg Team * Text Domain: gutenberg * diff --git a/lib/block-supports/anchor.php b/lib/block-supports/anchor.php deleted file mode 100644 index 8f704a5019b365..00000000000000 --- a/lib/block-supports/anchor.php +++ /dev/null @@ -1,67 +0,0 @@ -supports, array( 'anchor' ), true ); - if ( ! $has_anchor_support ) { - return; - } - - if ( ! $block_type->attributes ) { - $block_type->attributes = array(); - } - - if ( ! array_key_exists( 'anchor', $block_type->attributes ) ) { - $block_type->attributes['anchor'] = array( - 'type' => 'string', - ); - } -} - -/** - * Add the anchor to the output. - * - * @param WP_Block_Type $block_type Block Type. - * @param array $block_attributes Block attributes. - * - * @return array Block anchor. - */ -function gutenberg_apply_anchor_support( $block_type, $block_attributes ) { - if ( ! $block_attributes ) { - return array(); - } - - if ( wp_should_skip_block_supports_serialization( $block_type, 'anchor' ) ) { - return array(); - } - - $has_anchor_support = _wp_array_get( $block_type->supports, array( 'anchor' ), true ); - if ( ! $has_anchor_support ) { - return array(); - } - - $has_anchor = array_key_exists( 'anchor', $block_attributes ); - if ( ! $has_anchor ) { - return array(); - } - - return array( 'id' => $block_attributes['anchor'] ); -} - -// Register the block support. -WP_Block_Supports::get_instance()->register( - 'anchor', - array( - 'register_attribute' => 'gutenberg_register_anchor_support', - 'apply' => 'gutenberg_apply_anchor_support', - ) -); diff --git a/lib/block-supports/behaviors.php b/lib/block-supports/behaviors.php new file mode 100644 index 00000000000000..27e5faeb8e8a42 --- /dev/null +++ b/lib/block-supports/behaviors.php @@ -0,0 +1,155 @@ +attributes ) { + $block_type->attributes = array(); + } + + $block_type->attributes['behaviors'] = array( + 'type' => 'object', + ); + + // If it supports the lightbox behavior, add the hook to that block. + // In the future, this should be a loop with all the behaviors. + $has_lightbox_support = block_has_support( $block_type, array( 'behaviors', 'lightbox' ), false ); + if ( $has_lightbox_support ) { + // Use priority 15 to run this hook after other hooks/plugins. + // They could use the `render_block_{$this->name}` filter to modify the markup. + add_filter( 'render_block_' . $block_type->name, 'gutenberg_render_behaviors_support_lightbox', 15, 2 ); + } +} + +/** + * Add the directives and layout needed for the lightbox behavior. + * This functions shouldn't be in this file. It should be moved to a package (or somewhere else), where all the behaviors logic is defined. + * + * @param string $block_content Rendered block content. + * @param array $block Block object. + * @return string Filtered block content. + */ +function gutenberg_render_behaviors_support_lightbox( $block_content, $block ) { + $experiments = get_option( 'gutenberg-experiments' ); + $link_destination = isset( $block['attrs']['linkDestination'] ) ? $block['attrs']['linkDestination'] : 'none'; + // Get the lightbox setting from the block attributes. + if ( isset( $block['attrs']['behaviors']['lightbox'] ) ) { + $lightbox_settings = $block['attrs']['behaviors']['lightbox']; + // If the lightbox setting is not set in the block attributes, get it from the theme.json file. + } else { + $theme_data = WP_Theme_JSON_Resolver_Gutenberg::get_merged_data()->get_data(); + if ( isset( $theme_data['behaviors']['blocks'][ $block['blockName'] ]['lightbox'] ) ) { + $lightbox_settings = $theme_data['behaviors']['blocks'][ $block['blockName'] ]['lightbox']; + } else { + $lightbox_settings = null; + } + } + + if ( ! $lightbox_settings || 'none' !== $link_destination || empty( $experiments['gutenberg-interactivity-api-core-blocks'] ) ) { + return $block_content; + } + + $processor = new WP_HTML_Tag_Processor( $block_content ); + + $aria_label = __( 'Enlarge image', 'gutenberg' ); + + $alt_attribute = trim( $processor->get_attribute( 'alt' ) ); + + if ( $alt_attribute ) { + /* translators: %s: Image alt text. */ + $aria_label = sprintf( __( 'Enlarge image: %s', 'gutenberg' ), $alt_attribute ); + } + $content = $processor->get_updated_html(); + + $lightbox_animation = ''; + if ( isset( $lightbox_settings['animation'] ) ) { + $lightbox_animation = $lightbox_settings['animation']; + } + + // We want to store the src in the context so we can set it dynamically when the lightbox is opened. + $z = new WP_HTML_Tag_Processor( $content ); + $z->next_tag( 'img' ); + if ( isset( $block['attrs']['id'] ) ) { + $img_src = wp_get_attachment_url( $block['attrs']['id'] ); + } else { + $img_src = $z->get_attribute( 'src' ); + } + + $w = new WP_HTML_Tag_Processor( $content ); + $w->next_tag( 'figure' ); + $w->add_class( 'wp-lightbox-container' ); + $w->set_attribute( 'data-wp-interactive', true ); + $w->set_attribute( + 'data-wp-context', + sprintf( '{ "core":{ "image": { "initialized": false, "imageSrc": "%s", "lightboxEnabled": false, "lightboxAnimation": "%s", "hideAnimationEnabled": false } } }', $img_src, $lightbox_animation ) + ); + $body_content = $w->get_updated_html(); + + // Wrap the image in the body content with a button. + $img = null; + preg_match( '/]+>/', $content, $img ); + $button = '
+ ' + . $img[0] . + '
'; + $body_content = preg_replace( '/]+>/', $button, $body_content ); + + // Add src to the modal image. + $m = new WP_HTML_Tag_Processor( $content ); + $m->next_tag( 'img' ); + $m->set_attribute( 'data-wp-bind--src', 'selectors.core.image.imageSrc' ); + $modal_content = $m->get_updated_html(); + + $background_color = esc_attr( wp_get_global_styles( array( 'color', 'background' ) ) ); + + $close_button_icon = ''; + $close_button_color = esc_attr( wp_get_global_styles( array( 'color', 'text' ) ) ); + $dialog_label = $alt_attribute ? esc_attr( $alt_attribute ) : esc_attr__( 'Image', 'gutenberg' ); + $close_button_label = esc_attr__( 'Close', 'gutenberg' ); + + $lightbox_html = << + + $modal_content +
+ +HTML; + + return str_replace( '
', $lightbox_html . '', $body_content ); +} + +// Register the block support. +WP_Block_Supports::get_instance()->register( + 'behaviors', + array( + 'register_attribute' => 'gutenberg_register_behaviors_support', + ) +); diff --git a/lib/block-supports/layout.php b/lib/block-supports/layout.php index fb3098d06f7432..d61a09f4e8927e 100644 --- a/lib/block-supports/layout.php +++ b/lib/block-supports/layout.php @@ -5,13 +5,196 @@ * @package gutenberg */ +/** + * Returns layout definitions, keyed by layout type. + * + * Provides a common definition of slugs, classnames, base styles, and spacing styles for each layout type. + * When making changes or additions to layout definitions, the corresponding JavaScript definitions should + * also be updated. + * + * @return array[] Layout definitions. + */ +function gutenberg_get_layout_definitions() { + $layout_definitions = array( + 'default' => array( + 'name' => 'default', + 'slug' => 'flow', + 'className' => 'is-layout-flow', + 'baseStyles' => array( + array( + 'selector' => ' > .alignleft', + 'rules' => array( + 'float' => 'left', + 'margin-inline-start' => '0', + 'margin-inline-end' => '2em', + ), + ), + array( + 'selector' => ' > .alignright', + 'rules' => array( + 'float' => 'right', + 'margin-inline-start' => '2em', + 'margin-inline-end' => '0', + ), + ), + array( + 'selector' => ' > .aligncenter', + 'rules' => array( + 'margin-left' => 'auto !important', + 'margin-right' => 'auto !important', + ), + ), + ), + 'spacingStyles' => array( + array( + 'selector' => ' > :first-child:first-child', + 'rules' => array( + 'margin-block-start' => '0', + ), + ), + array( + 'selector' => ' > :last-child:last-child', + 'rules' => array( + 'margin-block-end' => '0', + ), + ), + array( + 'selector' => ' > *', + 'rules' => array( + 'margin-block-start' => null, + 'margin-block-end' => '0', + ), + ), + ), + ), + 'constrained' => array( + 'name' => 'constrained', + 'slug' => 'constrained', + 'className' => 'is-layout-constrained', + 'baseStyles' => array( + array( + 'selector' => ' > .alignleft', + 'rules' => array( + 'float' => 'left', + 'margin-inline-start' => '0', + 'margin-inline-end' => '2em', + ), + ), + array( + 'selector' => ' > .alignright', + 'rules' => array( + 'float' => 'right', + 'margin-inline-start' => '2em', + 'margin-inline-end' => '0', + ), + ), + array( + 'selector' => ' > .aligncenter', + 'rules' => array( + 'margin-left' => 'auto !important', + 'margin-right' => 'auto !important', + ), + ), + array( + 'selector' => ' > :where(:not(.alignleft):not(.alignright):not(.alignfull))', + 'rules' => array( + 'max-width' => 'var(--wp--style--global--content-size)', + 'margin-left' => 'auto !important', + 'margin-right' => 'auto !important', + ), + ), + array( + 'selector' => ' > .alignwide', + 'rules' => array( + 'max-width' => 'var(--wp--style--global--wide-size)', + ), + ), + ), + 'spacingStyles' => array( + array( + 'selector' => ' > :first-child:first-child', + 'rules' => array( + 'margin-block-start' => '0', + ), + ), + array( + 'selector' => ' > :last-child:last-child', + 'rules' => array( + 'margin-block-end' => '0', + ), + ), + array( + 'selector' => ' > *', + 'rules' => array( + 'margin-block-start' => null, + 'margin-block-end' => '0', + ), + ), + ), + ), + 'flex' => array( + 'name' => 'flex', + 'slug' => 'flex', + 'className' => 'is-layout-flex', + 'displayMode' => 'flex', + 'baseStyles' => array( + array( + 'selector' => '', + 'rules' => array( + 'flex-wrap' => 'wrap', + 'align-items' => 'center', + ), + ), + array( + 'selector' => ' > *', + 'rules' => array( + 'margin' => '0', + ), + ), + ), + 'spacingStyles' => array( + array( + 'selector' => '', + 'rules' => array( + 'gap' => null, + ), + ), + ), + ), + 'grid' => array( + 'name' => 'grid', + 'slug' => 'grid', + 'className' => 'is-layout-grid', + 'displayMode' => 'grid', + 'baseStyles' => array( + array( + 'selector' => ' > *', + 'rules' => array( + 'margin' => '0', + ), + ), + ), + 'spacingStyles' => array( + array( + 'selector' => '', + 'rules' => array( + 'gap' => null, + ), + ), + ), + ), + ); + + return $layout_definitions; +} + /** * Registers the layout block attribute for block types that support it. * * @param WP_Block_Type $block_type Block Type. */ function gutenberg_register_layout_support( $block_type ) { - $support_layout = block_has_support( $block_type, array( '__experimentalLayout' ), false ); + $support_layout = block_has_support( $block_type, array( 'layout' ), false ) || block_has_support( $block_type, array( '__experimentalLayout' ), false ); if ( $support_layout ) { if ( ! $block_type->attributes ) { $block_type->attributes = array(); @@ -347,7 +530,7 @@ function gutenberg_get_layout_style( $selector, $layout, $has_block_gap_support */ function gutenberg_render_layout_support_flag( $block_content, $block ) { $block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] ); - $support_layout = block_has_support( $block_type, array( '__experimentalLayout' ), false ); + $support_layout = block_has_support( $block_type, array( 'layout' ), false ) || block_has_support( $block_type, array( '__experimentalLayout' ), false ); $has_child_layout = isset( $block['attrs']['style']['layout']['selfStretch'] ); if ( ! $support_layout @@ -400,16 +583,12 @@ function gutenberg_render_layout_support_flag( $block_content, $block ) { return (string) $content; } - $global_settings = gutenberg_get_global_settings(); - $global_layout_settings = _wp_array_get( $global_settings, array( 'layout' ), null ); - $used_layout = isset( $block['attrs']['layout'] ) ? $block['attrs']['layout'] : _wp_array_get( $block_type->supports, array( '__experimentalLayout', 'default' ), array() ); - - if ( isset( $used_layout['inherit'] ) && $used_layout['inherit'] && ! $global_layout_settings ) { - return $block_content; - } + $global_settings = gutenberg_get_global_settings(); + $fallback_layout = ! empty( _wp_array_get( $block_type->supports, array( 'layout', 'default' ), array() ) ) ? _wp_array_get( $block_type->supports, array( 'layout', 'default' ), array() ) : _wp_array_get( $block_type->supports, array( '__experimentalLayout', 'default' ), array() ); + $used_layout = isset( $block['attrs']['layout'] ) ? $block['attrs']['layout'] : $fallback_layout; $class_names = array(); - $layout_definitions = _wp_array_get( $global_layout_settings, array( 'definitions' ), array() ); + $layout_definitions = gutenberg_get_layout_definitions(); $container_class = wp_unique_id( 'wp-container-' ); $layout_classname = ''; diff --git a/lib/block-supports/typography.php b/lib/block-supports/typography.php index f1d29217e38830..469b429f9b3ddf 100644 --- a/lib/block-supports/typography.php +++ b/lib/block-supports/typography.php @@ -381,6 +381,7 @@ function gutenberg_get_computed_fluid_typography_value( $args = array() ) { 'coerce_to' => $font_size_unit, ) ); + $minimum_viewport_width = gutenberg_get_typography_value_and_unit( $minimum_viewport_width_raw, array( @@ -388,6 +389,11 @@ function gutenberg_get_computed_fluid_typography_value( $args = array() ) { ) ); + // Protects against unsupported units in min and max viewport widths. + if ( ! $minimum_viewport_width || ! $maximum_viewport_width ) { + return null; + } + // Build CSS rule. // Borrowed from https://websemantics.uk/tools/responsive-font-calculator/. $view_port_width_offset = round( $minimum_viewport_width['value'] / 100, 3 ) . $font_size_unit; diff --git a/lib/class-wp-duotone-gutenberg.php b/lib/class-wp-duotone-gutenberg.php index b18121086bae0e..816f7e414ad793 100644 --- a/lib/class-wp-duotone-gutenberg.php +++ b/lib/class-wp-duotone-gutenberg.php @@ -530,10 +530,19 @@ private static function get_filter_svg( $filter_id, $colors ) { foreach ( $colors as $color_str ) { $color = self::colord_parse( $color_str ); - $duotone_values['r'][] = $color['r'] / 255; - $duotone_values['g'][] = $color['g'] / 255; - $duotone_values['b'][] = $color['b'] / 255; - $duotone_values['a'][] = $color['a']; + if ( null === $color ) { + $error_message = sprintf( + /* translators: %s: duotone colors */ + __( '"%s" in theme.json settings.color.duotone is not a hex or rgb string.', 'gutenberg' ), + $color_str + ); + _doing_it_wrong( __METHOD__, $error_message, '6.3.0' ); + } else { + $duotone_values['r'][] = $color['r'] / 255; + $duotone_values['g'][] = $color['g'] / 255; + $duotone_values['b'][] = $color['b'] / 255; + $duotone_values['a'][] = $color['a']; + } } ob_start(); diff --git a/lib/class-wp-theme-json-gutenberg.php b/lib/class-wp-theme-json-gutenberg.php index 5cb11c2d7aaf94..2e372fc32c1702 100644 --- a/lib/class-wp-theme-json-gutenberg.php +++ b/lib/class-wp-theme-json-gutenberg.php @@ -313,10 +313,12 @@ class WP_Theme_JSON_Gutenberg { * @since 5.8.0 As `ALLOWED_TOP_LEVEL_KEYS`. * @since 5.9.0 Renamed from `ALLOWED_TOP_LEVEL_KEYS` to `VALID_TOP_LEVEL_KEYS`, * added the `customTemplates` and `templateParts` values. + * @since 6.3.0 Added the `description` value. * @var string[] */ const VALID_TOP_LEVEL_KEYS = array( 'customTemplates', + 'description', 'patterns', 'settings', 'styles', @@ -337,6 +339,7 @@ class WP_Theme_JSON_Gutenberg { * @since 6.1.0 Added `layout.definitions` and `useRootPaddingAwareAlignments`. * @since 6.2.0 Added `dimensions.minHeight`, 'shadow.presets', 'shadow.defaultPresets', * `position.fixed` and `position.sticky`. + * @since 6.3.0 Removed `layout.definitions`. * @var array */ const VALID_SETTINGS = array( @@ -371,7 +374,6 @@ class WP_Theme_JSON_Gutenberg { ), 'layout' => array( 'contentSize' => null, - 'definitions' => null, 'wideSize' => null, ), 'position' => array( @@ -1263,7 +1265,7 @@ protected function get_layout_styles( $block_metadata ) { if ( isset( $block_metadata['name'] ) ) { $block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block_metadata['name'] ); - if ( ! block_has_support( $block_type, array( '__experimentalLayout' ), false ) ) { + if ( ! block_has_support( $block_type, array( 'layout' ), false ) && ! block_has_support( $block_type, array( '__experimentalLayout' ), false ) ) { return $block_rules; } } @@ -1272,7 +1274,7 @@ protected function get_layout_styles( $block_metadata ) { $has_block_gap_support = _wp_array_get( $this->theme_json, array( 'settings', 'spacing', 'blockGap' ) ) !== null; $has_fallback_gap_support = ! $has_block_gap_support; // This setting isn't useful yet: it exists as a placeholder for a future explicit fallback gap styles support. $node = _wp_array_get( $this->theme_json, $block_metadata['path'], array() ); - $layout_definitions = _wp_array_get( $this->theme_json, array( 'settings', 'layout', 'definitions' ), array() ); + $layout_definitions = gutenberg_get_layout_definitions(); $layout_selector_pattern = '/^[a-zA-Z0-9\-\.\ *+>:\(\)]*$/'; // Allow alphanumeric classnames, spaces, wildcard, sibling, child combinator and pseudo class selectors. // Gap styles will only be output if the theme has block gap support, or supports a fallback gap. diff --git a/lib/compat/wordpress-6.2/rest-api.php b/lib/compat/wordpress-6.2/rest-api.php index 58597e16d99282..b648ba9bae015e 100644 --- a/lib/compat/wordpress-6.2/rest-api.php +++ b/lib/compat/wordpress-6.2/rest-api.php @@ -139,3 +139,13 @@ function filter_block_pattern_response( $response, $raw_pattern ) { return $response; } add_filter( 'rest_prepare_block_pattern', 'filter_block_pattern_response', 10, 2 ); + + +/** + * Registers the block pattern directory. + */ +function gutenberg_register_rest_pattern_directory() { + $pattern_directory_controller = new Gutenberg_REST_Pattern_Directory_Controller_6_2(); + $pattern_directory_controller->register_routes(); +} +add_action( 'rest_api_init', 'gutenberg_register_rest_pattern_directory' ); diff --git a/lib/experimental/class-gutenberg-rest-global-styles-revisions-controller.php b/lib/compat/wordpress-6.3/class-gutenberg-rest-global-styles-revisions-controller-6-3.php similarity index 85% rename from lib/experimental/class-gutenberg-rest-global-styles-revisions-controller.php rename to lib/compat/wordpress-6.3/class-gutenberg-rest-global-styles-revisions-controller-6-3.php index c5d5a5f0dff1a4..356b435b71f1e8 100644 --- a/lib/experimental/class-gutenberg-rest-global-styles-revisions-controller.php +++ b/lib/compat/wordpress-6.3/class-gutenberg-rest-global-styles-revisions-controller-6-3.php @@ -14,7 +14,7 @@ * * @see WP_REST_Controller */ -class Gutenberg_REST_Global_Styles_Revisions_Controller extends WP_REST_Controller { +class Gutenberg_REST_Global_Styles_Revisions_Controller_6_3 extends WP_REST_Controller { /** * Parent post type. * @@ -107,19 +107,42 @@ public function get_items( $request ) { return rest_ensure_response( $response ); } + /** + * A direct copy of WP_REST_Revisions_Controller->prepare_date_response(). + * Checks the post_date_gmt or modified_gmt and prepare any post or + * modified date for single post output. + * + * @since 6.3.0 + * + * @param string $date_gmt GMT publication time. + * @param string|null $date Optional. Local publication time. Default null. + * @return string|null ISO8601/RFC3339 formatted datetime, otherwise null. + */ + protected function prepare_date_response( $date_gmt, $date = null ) { + if ( '0000-00-00 00:00:00' === $date_gmt ) { + return null; + } + + if ( isset( $date ) ) { + return mysql_to_rfc3339( $date ); + } + + return mysql_to_rfc3339( $date_gmt ); + } + /** * Prepares the revision for the REST response. * * @since 6.3.0 * - * @param WP_Post $item Post revision object. + * @param WP_Post $post Post revision object. * @param WP_REST_Request $request Request object. * @return WP_REST_Response Response object. */ - public function prepare_item_for_response( $item, $request ) { + public function prepare_item_for_response( $post, $request ) { $parent = $this->get_parent( $request['parent'] ); // Retrieves global styles config as JSON. - $raw_revision_config = json_decode( $item->post_content, true ); + $raw_revision_config = json_decode( $post->post_content, true ); $config = ( new WP_Theme_JSON_Gutenberg( $raw_revision_config, 'custom' ) )->get_raw_data(); // Prepares item data. @@ -127,27 +150,27 @@ public function prepare_item_for_response( $item, $request ) { $fields = $this->get_fields_for_response( $request ); if ( rest_is_field_included( 'author', $fields ) ) { - $data['author'] = (int) $item->post_author; + $data['author'] = (int) $post->post_author; } if ( rest_is_field_included( 'date', $fields ) ) { - $data['date'] = $item->post_date; + $data['date'] = $this->prepare_date_response( $post->post_date_gmt, $post->post_date ); } if ( rest_is_field_included( 'date_gmt', $fields ) ) { - $data['date_gmt'] = $item->post_date_gmt; + $data['date_gmt'] = $this->prepare_date_response( $post->post_date_gmt ); } if ( rest_is_field_included( 'id', $fields ) ) { - $data['id'] = (int) $item->ID; + $data['id'] = (int) $post->ID; } if ( rest_is_field_included( 'modified', $fields ) ) { - $data['modified'] = $item->post_modified; + $data['modified'] = $this->prepare_date_response( $post->post_modified_gmt, $post->post_modified ); } if ( rest_is_field_included( 'modified_gmt', $fields ) ) { - $data['modified_gmt'] = $item->post_modified_gmt; + $data['modified_gmt'] = $this->prepare_date_response( $post->post_modified_gmt ); } if ( rest_is_field_included( 'parent', $fields ) ) { diff --git a/lib/compat/wordpress-6.3/class-gutenberg-rest-pattern-directory-controller-6-3.php b/lib/compat/wordpress-6.3/class-gutenberg-rest-pattern-directory-controller-6-3.php deleted file mode 100644 index 1d1ba16571bc42..00000000000000 --- a/lib/compat/wordpress-6.3/class-gutenberg-rest-pattern-directory-controller-6-3.php +++ /dev/null @@ -1,133 +0,0 @@ -namespace, - '/' . $this->rest_base . '/categories', - array( - array( - 'methods' => WP_REST_Server::READABLE, - 'callback' => array( $this, 'get_pattern_categories' ), - 'permission_callback' => array( $this, 'get_items_permissions_check' ), - ), - ) - ); - - parent::register_routes(); - } - - /** - * Retrieve block patterns categories. - * - * @since 6.3.0 - * - * @param WP_REST_Request $request Full details about the request. - * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. - */ - public function get_pattern_categories( $request ) { - $query_args = array( 'locale' => get_user_locale() ); - $transient_key = 'wp_remote_block_pattern_categories_' . md5( serialize( $query_args ) ); - - /** - * Use network-wide transient to improve performance. The locale is the only site - * configuration that affects the response, and it's included in the transient key. - */ - $raw_pattern_categories = get_site_transient( $transient_key ); - - if ( ! $raw_pattern_categories ) { - $api_url = 'http://api.wordpress.org/patterns/1.0/?categories&' . build_query( $query_args ); - if ( wp_http_supports( array( 'ssl' ) ) ) { - $api_url = set_url_scheme( $api_url, 'https' ); - } - - /** - * Default to a short TTL, to mitigate cache stampedes on high-traffic sites. - * This assumes that most errors will be short-lived, e.g., packet loss that causes the - * first request to fail, but a follow-up one will succeed. The value should be high - * enough to avoid stampedes, but low enough to not interfere with users manually - * re-trying a failed request. - */ - $cache_ttl = 5; - $wporg_response = wp_remote_get( $api_url ); - $raw_pattern_categories = json_decode( wp_remote_retrieve_body( $wporg_response ) ); - if ( is_wp_error( $wporg_response ) ) { - $raw_pattern_categories = $wporg_response; - - } elseif ( ! is_array( $raw_pattern_categories ) ) { - // HTTP request succeeded, but response data is invalid. - $raw_pattern_categories = new WP_Error( - 'pattern_directory_api_failed', - sprintf( - /* translators: %s: Support forums URL. */ - __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums.', 'gutenberg' ), - __( 'https://wordpress.org/support/forums/', 'gutenberg' ) - ), - array( - 'response' => wp_remote_retrieve_body( $wporg_response ), - ) - ); - - } else { - // Response has valid data. - $cache_ttl = HOUR_IN_SECONDS; - } - - set_site_transient( $transient_key, $raw_pattern_categories, $cache_ttl ); - } - - if ( is_wp_error( $raw_pattern_categories ) ) { - $raw_pattern_categories->add_data( array( 'status' => 500 ) ); - - return $raw_pattern_categories; - } - - $response = array(); - - if ( $raw_pattern_categories ) { - foreach ( $raw_pattern_categories as $category ) { - $response[] = $this->prepare_response_for_collection( - $this->prepare_pattern_category_for_response( $category, $request ) - ); - } - } - - return new WP_REST_Response( $response ); - } - - /** - * Prepare a raw block pattern category before it gets output in a REST API response. - * - * @since 6.3.0 - * - * @param object $item Raw pattern category from api.wordpress.org, before any changes. - * @param WP_REST_Request $request Request object. - * @return WP_REST_Response - */ - public function prepare_pattern_category_for_response( $item, $request ) { - $raw_pattern_category = array( - 'id' => absint( $item->id ), - 'name' => sanitize_text_field( $item->name ), - 'slug' => sanitize_title_with_dashes( $item->slug ), - ); - - $prepared_pattern_category = $this->add_additional_fields_to_object( $raw_pattern_category, $request ); - - return new WP_REST_Response( $prepared_pattern_category ); - } -} diff --git a/lib/compat/wordpress-6.3/class-gutenberg-rest-templates-controller-6-3.php b/lib/compat/wordpress-6.3/class-gutenberg-rest-templates-controller-6-3.php index cbe9b5242a248e..7d59ccc9c71fc1 100644 --- a/lib/compat/wordpress-6.3/class-gutenberg-rest-templates-controller-6-3.php +++ b/lib/compat/wordpress-6.3/class-gutenberg-rest-templates-controller-6-3.php @@ -69,6 +69,8 @@ public function get_template_fallback( $request ) { /** * Add revisions to the response. * + * @since 6.3.0 Added prepare_revision_links() method to get revision links. + * * @param WP_Block_Template $item Template instance. * @param WP_REST_Request $request Request object. * @return WP_REST_Response Response object. @@ -98,7 +100,7 @@ public function prepare_item_for_response( $item, $request ) { // phpcs:ignore V /** * Adds revisions to links. * - * @since 6.2.0 + * @since 6.3.0 * * @param WP_Block_Template $template Template instance. * @return array Links for the given post. diff --git a/lib/experimental/class-wp-classic-to-block-menu-converter.php b/lib/compat/wordpress-6.3/class-wp-classic-to-block-menu-converter.php similarity index 94% rename from lib/experimental/class-wp-classic-to-block-menu-converter.php rename to lib/compat/wordpress-6.3/class-wp-classic-to-block-menu-converter.php index 77232bee2ac8c8..65c8a6d5bcba74 100644 --- a/lib/experimental/class-wp-classic-to-block-menu-converter.php +++ b/lib/compat/wordpress-6.3/class-wp-classic-to-block-menu-converter.php @@ -20,8 +20,20 @@ class WP_Classic_To_Block_Menu_Converter { * @return string the serialized and normalized parsed blocks. */ public static function convert( $menu ) { + + if ( ! is_nav_menu( $menu ) ) { + return new WP_Error( + 'invalid_menu', + __( 'The menu provided is not a valid menu.', 'gutenberg' ) + ); + } + $menu_items = wp_get_nav_menu_items( $menu->term_id, array( 'update_post_term_cache' => false ) ); + if ( empty( $menu_items ) ) { + return array(); + } + // Set up the $menu_item variables. // Adds the class property classes for the current context, if applicable. _wp_menu_item_classes_by_context( $menu_items ); diff --git a/lib/experimental/class-wp-navigation-fallback-gutenberg.php b/lib/compat/wordpress-6.3/class-wp-navigation-fallback-gutenberg.php similarity index 100% rename from lib/experimental/class-wp-navigation-fallback-gutenberg.php rename to lib/compat/wordpress-6.3/class-wp-navigation-fallback-gutenberg.php diff --git a/lib/experimental/class-wp-rest-navigation-fallback-controller.php b/lib/compat/wordpress-6.3/class-wp-rest-navigation-fallback-controller.php similarity index 100% rename from lib/experimental/class-wp-rest-navigation-fallback-controller.php rename to lib/compat/wordpress-6.3/class-wp-rest-navigation-fallback-controller.php diff --git a/lib/compat/wordpress-6.3/link-template.php b/lib/compat/wordpress-6.3/link-template.php index 366dedba2b5aaf..19d703839125e0 100644 --- a/lib/compat/wordpress-6.3/link-template.php +++ b/lib/compat/wordpress-6.3/link-template.php @@ -28,7 +28,33 @@ function gutenberg_update_get_edit_post_link( $link, $post_id ) { $slug = urlencode( get_stylesheet() . '//' . $post->post_name ); $link = admin_url( sprintf( $post_type_object->_edit_link, $slug ) ); } + return $link; } add_filter( 'get_edit_post_link', 'gutenberg_update_get_edit_post_link', 10, 2 ); + + + +/** + * Modifies the edit link for the `wp_navigation` custom post type. + * + * This has not been backported to Core. + * + * @param string $link The edit link. + * @param int $post_id Post ID. + * @return string|null The edit post link for the given post. Null if the post type does not exist + * or does not allow an editing UI. + */ +function gutenberg_update_navigation_get_edit_post_link( $link, $post_id ) { + $post = get_post( $post_id ); + + if ( 'wp_navigation' === $post->post_type ) { + $post_type_object = get_post_type_object( $post->post_type ); + $id = $post->ID; + $link = admin_url( sprintf( $post_type_object->_edit_link, $id ) ); + } + + return $link; +} +add_filter( 'get_edit_post_link', 'gutenberg_update_navigation_get_edit_post_link', 10, 2 ); diff --git a/lib/experimental/navigation-fallback.php b/lib/compat/wordpress-6.3/navigation-fallback.php similarity index 100% rename from lib/experimental/navigation-fallback.php rename to lib/compat/wordpress-6.3/navigation-fallback.php diff --git a/lib/compat/wordpress-6.3/rest-api.php b/lib/compat/wordpress-6.3/rest-api.php index 757bd317dcd548..a2dd66c5e922f8 100644 --- a/lib/compat/wordpress-6.3/rest-api.php +++ b/lib/compat/wordpress-6.3/rest-api.php @@ -5,21 +5,18 @@ * @package gutenberg */ -/** - * Registers the block pattern directory. - */ -function gutenberg_register_rest_pattern_directory() { - $pattern_directory_controller = new Gutenberg_REST_Pattern_Directory_Controller_6_3(); - $pattern_directory_controller->register_routes(); -} -add_action( 'rest_api_init', 'gutenberg_register_rest_pattern_directory' ); - /** * Updates `wp_template` and `wp_template_part` post types to use * Gutenberg's REST controllers * - * Adds `_edit_link` to the `wp_global_styles`, `wp_template`, - * and `wp_template_part` post type schemata. See https://github.com/WordPress/gutenberg/issues/48065 + * Adds `_edit_link` to the following post type schemata: + * + * - wp_global_styles + * - wp_template + * - wp_template_part + * - wp_navigation + * + * See https://github.com/WordPress/gutenberg/issues/48065 * * @param array $args Array of arguments for registering a post type. * @param string $post_type Post type key. @@ -40,6 +37,18 @@ function gutenberg_update_templates_template_parts_rest_controller( $args, $post if ( in_array( $post_type, array( 'wp_global_styles' ), true ) ) { $args['_edit_link'] = '/site-editor.php?canvas=edit'; } + + if ( 'wp_navigation' === $post_type ) { + $navigation_edit_link = 'site-editor.php?' . build_query( + array( + 'postId' => '%s', + 'postType' => 'wp_navigation', + 'canvas' => 'edit', + ) + ); + $args['_edit_link'] = $navigation_edit_link; + } + return $args; } add_filter( 'register_post_type_args', 'gutenberg_update_templates_template_parts_rest_controller', 10, 2 ); @@ -48,7 +57,7 @@ function gutenberg_update_templates_template_parts_rest_controller( $args, $post * 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(); + $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' ); @@ -63,16 +72,32 @@ function gutenberg_register_global_styles_endpoints() { add_action( 'rest_api_init', 'gutenberg_register_global_styles_endpoints' ); /** - * Update `wp_global_styles` post type to use Gutenberg's REST controller. + * Add the `modified` value to the `wp_template` schema. * - * @param array $args Array of arguments for registering a post type. - * @param string $post_type Post type key. + * @since 6.3.0 Added 'modified' property and response value. */ -function gutenberg_update_global_styles_rest_controller( $args, $post_type ) { - if ( in_array( $post_type, array( 'wp_global_styles' ), true ) ) { - $args['rest_controller_class'] = 'Gutenberg_REST_Templates_Controller_6_3'; - $args['rest_base'] = 'global-styles'; - } - return $args; +function add_modified_wp_template_schema() { + register_rest_field( + array( 'wp_template', 'wp_template_part' ), + 'modified', + array( + 'schema' => array( + 'description' => __( "The date the template was last modified, in the site's timezone.", 'gutenberg' ), + 'type' => 'string', + 'format' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'get_callback' => function( $object ) { + if ( ! empty( $object['wp_id'] ) ) { + $post = get_post( $object['wp_id'] ); + if ( $post && isset( $post->post_modified ) ) { + return mysql_to_rfc3339( $post->post_modified ); + } + } + return null; + }, + ) + ); } -add_filter( 'register_post_type_args', 'gutenberg_update_global_styles_rest_controller', 10, 2 ); +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 5a6f282d301bc5..d5334b319ff8a2 100644 --- a/lib/compat/wordpress-6.3/theme-previews.php +++ b/lib/compat/wordpress-6.3/theme-previews.php @@ -17,7 +17,7 @@ function gutenberg_get_theme_preview_path( $current_stylesheet = null ) { return $current_stylesheet; } - $preview_stylesheet = ! empty( $_GET['theme_preview'] ) ? $_GET['theme_preview'] : null; + $preview_stylesheet = ! empty( $_GET['gutenberg_theme_preview'] ) ? $_GET['gutenberg_theme_preview'] : null; $wp_theme = wp_get_theme( $preview_stylesheet ); if ( ! is_wp_error( $wp_theme->errors() ) ) { if ( current_filter() === 'template' ) { @@ -45,7 +45,7 @@ function gutenberg_attach_theme_preview_middleware() { 'wp-api-fetch', sprintf( 'wp.apiFetch.use( wp.apiFetch.createThemePreviewMiddleware( %s ) );', - wp_json_encode( sanitize_text_field( $_GET['theme_preview'] ) ) + wp_json_encode( sanitize_text_field( $_GET['gutenberg_theme_preview'] ) ) ), 'after' ); @@ -88,7 +88,7 @@ function addLivePreviewButton() { livePreviewButton.setAttribute('class', 'button button-primary'); livePreviewButton.setAttribute( 'href', - `/wp-admin/site-editor.php?theme_preview=${themePath}&return=themes.php` + `/wp-admin/site-editor.php?gutenberg_theme_preview=${themePath}&return=themes.php` ); livePreviewButton.innerHTML = ''; themeInfo.querySelector('.theme-actions').appendChild(livePreviewButton); @@ -112,18 +112,15 @@ function block_theme_activate_nonce() { attributes['displayPreview'] ) ) { - return $block_content; - } - $processor = new WP_HTML_Tag_Processor( $block_content ); - $processor->next_tag(); - $processor->set_attribute( 'data-wp-interactive', '' ); - $processor->next_tag( 'object' ); - $processor->set_attribute( 'data-wp-bind--hidden', '!selectors.core.file.hasPdfPreview' ); - $processor->set_attribute( 'hidden', true ); - return $processor->get_updated_html(); -} -add_filter( 'render_block_core/file', 'gutenberg_block_core_file_add_directives_to_content', 10, 3 ); - -/** - * Add Interactivity API directives to the navigation block markup using the Tag Processor - * The final HTML of the navigation block will look similar to this: - * - * - * - * @param string $block_content Markup of the navigation block. - * @param array $block Block object. - * - * @return string Navigation block markup with the proper directives - */ -function gutenberg_block_core_navigation_add_directives_to_markup( $block_content, $block ) { - $w = new WP_HTML_Tag_Processor( $block_content ); - // Add directives to the `