From 4a26fa4eb54c1673b1ef9f1e7ca8f6d0f5c1ae04 Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Wed, 13 Mar 2024 07:57:28 +0000 Subject: [PATCH 01/21] Update PHP Sync Issue generation script to ignore PRs with given labels (#59549) * Fetch full PR data and interogate labels * Revert change to const * Remove redundant comments * Remove debugging * Remove redundant arg * Add new script --- bin/generate-php-sync-issue.mjs | 60 ++++++--------------------------- package.json | 1 + 2 files changed, 12 insertions(+), 49 deletions(-) diff --git a/bin/generate-php-sync-issue.mjs b/bin/generate-php-sync-issue.mjs index a45d77d354107c..bd627aeb65107c 100644 --- a/bin/generate-php-sync-issue.mjs +++ b/bin/generate-php-sync-issue.mjs @@ -21,14 +21,18 @@ const MAX_MONTHS_TO_QUERY = 4; // The following paths will be ignored when generating the issue content. const IGNORED_PATHS = [ + 'init.php', // plugin specific code. 'lib/load.php', // plugin specific code. 'lib/experiments-page.php', // experiments are plugin specific. 'packages/e2e-tests/plugins', // PHP files related to e2e tests only. - 'packages/block-library', // this is handled automatically. + 'packages/block-library', // packages are synced to WP Core via npm packages. ]; // PRs containing the following labels will be ignored when generating the issue content. -const LABELS_TO_IGNORE = [ 'Backport from WordPress Core' ]; +const LABELS_TO_IGNORE = [ + 'Backport from WordPress Core', // PRs made "upstream" in Core that were synced back into Gutenberg. + 'Backported to WP Core', // PRs that were synced into Core during a previous release. +]; const MAX_NESTING_LEVEL = 3; @@ -72,28 +76,6 @@ async function main() { process.exit( 1 ); } - const lastRcDateArg = getArg( 'lastrcdate' ); - let lastRcDate; - - if ( lastRcDateArg ) { - if ( - validateDate( lastRcDateArg ) && - isAfter( lastRcDateArg, since ) - ) { - lastRcDate = lastRcDateArg; - } else { - console.error( - `Error: The --lastrcdate argument must be a date after the --since date.` - ); - process.exit( 1 ); - } - } else { - console.error( - `Error: The --lastrcdate argument is required (e.g. YYYY-MM-DD).` - ); - process.exit( 1 ); - } - console.log( 'Welcome to the PHP Sync Issue Generator!' ); console.log( '--------------------------------' ); @@ -126,11 +108,7 @@ async function main() { commits.map( async ( commit ) => { const commitData = await fetchCommit( commit.sha ); - // In the future we will want to exclude PRs based on label - // so we will need to fetch the full PR data for each commit. - // For now we can just set this to null. - const fullPRData = null; - // const fullPRData = getPullRequestDataForCommit( commit.sha ); + const fullPRData = await getPullRequestDataForCommit( commit.sha ); // Our Issue links to the PRs associated with the commits so we must // provide this data. We could also get the PR data from the commit data, @@ -156,18 +134,6 @@ async function main() { return null; } - // This is temporarily required because PRs merged between Beta 1 (since) - // and the final RC may have already been manually backported to Core. - // This is however no reliable way to identify these PRs as the `Backport to WP beta/RC` - // label is manually removed once the PR has been backported. - // In future releases we will add a **new** label `Backported` - // to indicate the PR was backported to Core. - // As a result, in the future we will be able to exclude any PRs that have - // already been backported using the `Backported` label. - if ( isAfter( lastRcDate, commitData.commit.committer.date ) ) { - commitData.isBeforeLastRCDate = true; - } - return commitData; } ) ); @@ -426,12 +392,8 @@ function processCommits( commits ) { return result; } -function formatPRLine( { pullRequest: pr, isBeforeLastRCDate } ) { - return `- [ ] ${ pr.url } - @${ - pr.creator - } | Trac ticket | Core backport PR ${ - isBeforeLastRCDate ? '(⚠️ Check for existing WP Core backport)' : '' - }\n`; +function formatPRLine( { pullRequest: pr } ) { + return `- [ ] ${ pr.url } - @${ pr.creator } | Trac ticket | Core backport PR \n`; } function formatHeading( level, key ) { @@ -466,7 +428,7 @@ function generateIssueContent( result, level = 1 ) { } async function fetchAllCommits( since, path ) { - return await octokitPaginate( 'GET /repos/{owner}/{repo}/commits', { + return octokitPaginate( 'GET /repos/{owner}/{repo}/commits', { since, per_page: 30, path, @@ -481,7 +443,7 @@ async function fetchCommit( sha ) { // eslint-disable-next-line no-unused-vars async function getPullRequestDataForCommit( commitSha ) { - const pullRequests = octokitRequest( + const pullRequests = await octokitRequest( 'GET /repos/{owner}/{repo}/commits/{commit_sha}/pulls', { commit_sha: commitSha, diff --git a/package.json b/package.json index a4c907bb0067bf..a0a197cc8cd78f 100644 --- a/package.json +++ b/package.json @@ -306,6 +306,7 @@ "preother:check-local-changes": "npm run docs:build", "other:check-local-changes": "node ./bin/check-local-changes.js", "other:cherry-pick": "node ./bin/cherry-pick.mjs", + "other:generate-php-sync-issue": "node ./bin/generate-php-sync-issue.mjs", "other:update-packages:php": "wp-env run --env-cwd='wp-content/plugins/gutenberg' cli composer update --no-interaction", "postinstall": "patch-package && node ./patches/patch-xcode.js", "prepare": "husky install", From 95cc88fccbad71371802f6ad03f90e2974b17ef5 Mon Sep 17 00:00:00 2001 From: Ramon Date: Wed, 13 Mar 2024 19:25:29 +1100 Subject: [PATCH 02/21] Site editor: find font families for typography presets crashes editor (#59806) * fontFamilies can be undefined. Use `! Array.isArray( fontFamilies )` to check. Co-authored-by: ramonjd Co-authored-by: scruffian --- packages/edit-site/src/components/global-styles/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/edit-site/src/components/global-styles/utils.js b/packages/edit-site/src/components/global-styles/utils.js index cb4644695df59d..7e7948147b170a 100644 --- a/packages/edit-site/src/components/global-styles/utils.js +++ b/packages/edit-site/src/components/global-styles/utils.js @@ -12,7 +12,7 @@ export function getVariationClassName( variation ) { } function getFontFamilyFromSetting( fontFamilies, setting ) { - if ( ! setting ) { + if ( ! Array.isArray( fontFamilies ) || ! setting ) { return null; } From 8f2fad4c0aac7483624d7ab32be7499ce78e6998 Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Wed, 13 Mar 2024 10:03:03 +0100 Subject: [PATCH 03/21] Add tooltip to several Back buttons. (#59760) Co-authored-by: afercia Co-authored-by: alexstine --- .../inserter/mobile-tab-navigation.js | 2 +- packages/e2e-test-utils/src/site-editor.js | 2 +- .../font-library-modal/font-collection.js | 2 +- .../font-library-modal/installed-fonts.js | 2 +- .../src/components/global-styles/header.js | 2 +- .../preferences-modal-tabs/index.js | 4 +--- test/e2e/specs/site-editor/style-book.spec.js | 6 +++--- .../site-editor/style-variations.spec.js | 20 +++++-------------- .../user-global-styles-revisions.spec.js | 2 +- 9 files changed, 15 insertions(+), 27 deletions(-) diff --git a/packages/block-editor/src/components/inserter/mobile-tab-navigation.js b/packages/block-editor/src/components/inserter/mobile-tab-navigation.js index 0efc739fac6571..fa8191cc5eaaa0 100644 --- a/packages/block-editor/src/components/inserter/mobile-tab-navigation.js +++ b/packages/block-editor/src/components/inserter/mobile-tab-navigation.js @@ -32,7 +32,7 @@ function ScreenHeader( { title } ) { } icon={ isRTL() ? chevronRight : chevronLeft } size="small" - aria-label={ __( 'Navigate to the previous view' ) } + label={ __( 'Back' ) } /> { title } diff --git a/packages/e2e-test-utils/src/site-editor.js b/packages/e2e-test-utils/src/site-editor.js index 02c3d05f74cc16..4f6cf1773134fb 100644 --- a/packages/e2e-test-utils/src/site-editor.js +++ b/packages/e2e-test-utils/src/site-editor.js @@ -117,7 +117,7 @@ export async function openGlobalStylesPanel( panelName ) { */ export async function openPreviousGlobalStylesPanel() { await page.click( - 'div[aria-label="Editor settings"] button[aria-label="Navigate to the previous view"]' + 'div[aria-label="Editor settings"] button[aria-label="Back"]' ); } diff --git a/packages/edit-site/src/components/global-styles/font-library-modal/font-collection.js b/packages/edit-site/src/components/global-styles/font-library-modal/font-collection.js index 81198cdbd05424..bc8d99091ad7f9 100644 --- a/packages/edit-site/src/components/global-styles/font-library-modal/font-collection.js +++ b/packages/edit-site/src/components/global-styles/font-library-modal/font-collection.js @@ -345,7 +345,7 @@ function FontCollection( { slug } ) { onClick={ () => { setSelectedFont( null ); } } - aria-label={ __( 'Navigate to the previous view' ) } + label={ __( 'Back' ) } /> { handleSetLibraryFontSelected( null ); } } - aria-label={ __( 'Navigate to the previous view' ) } + label={ __( 'Back' ) } /> diff --git a/packages/preferences/src/components/preferences-modal-tabs/index.js b/packages/preferences/src/components/preferences-modal-tabs/index.js index f48d715dc1bf8a..f70430367cc617 100644 --- a/packages/preferences/src/components/preferences-modal-tabs/index.js +++ b/packages/preferences/src/components/preferences-modal-tabs/index.js @@ -157,9 +157,7 @@ export default function PreferencesModalTabs( { sections } ) { ? chevronRight : chevronLeft } - aria-label={ __( - 'Navigate to the previous view' - ) } + label={ __( 'Back' ) } /> { section.tabLabel } diff --git a/test/e2e/specs/site-editor/style-book.spec.js b/test/e2e/specs/site-editor/style-book.spec.js index a832e06f6a6391..e06f90f0cf9859 100644 --- a/test/e2e/specs/site-editor/style-book.spec.js +++ b/test/e2e/specs/site-editor/style-book.spec.js @@ -116,8 +116,8 @@ test.describe( 'Style Book', () => { } ) .click(); - await page.click( 'role=button[name="Navigate to the previous view"]' ); - await page.click( 'role=button[name="Navigate to the previous view"]' ); + await page.click( 'role=button[name="Back"]' ); + await page.click( 'role=button[name="Back"]' ); await expect( page.locator( 'role=button[name="Blocks styles"]' ) @@ -172,7 +172,7 @@ test.describe( 'Style Book', () => { 'style book should be visible' ).toBeVisible(); - await page.click( 'role=button[name="Navigate to the previous view"]' ); + await page.click( 'role=button[name="Back"]' ); await page .getByRole( 'region', { name: 'Editor settings' } ) diff --git a/test/e2e/specs/site-editor/style-variations.spec.js b/test/e2e/specs/site-editor/style-variations.spec.js index 8868c733006687..9b12f37c0baa6b 100644 --- a/test/e2e/specs/site-editor/style-variations.spec.js +++ b/test/e2e/specs/site-editor/style-variations.spec.js @@ -79,9 +79,7 @@ test.describe( 'Global styles variations', () => { await editor.canvas.locator( 'body' ).click(); await siteEditorStyleVariations.browseStyles(); await page.click( 'role=button[name="pink"i]' ); - await page.click( - 'role=button[name="Navigate to the previous view"i]' - ); + await page.click( 'role=button[name="Back"i]' ); await page.click( 'role=button[name="Colors styles"i]' ); await expect( @@ -96,9 +94,7 @@ test.describe( 'Global styles variations', () => { ) ).toHaveCSS( 'background', /rgb\(74, 7, 74\)/ ); - await page.click( - 'role=button[name="Navigate to the previous view"i]' - ); + await page.click( 'role=button[name="Back"i]' ); await page.click( 'role=button[name="Typography styles"i]' ); await page.click( 'role=button[name="Typography Text styles"i]' ); @@ -120,9 +116,7 @@ test.describe( 'Global styles variations', () => { await editor.canvas.locator( 'body' ).click(); await siteEditorStyleVariations.browseStyles(); await page.click( 'role=button[name="yellow"i]' ); - await page.click( - 'role=button[name="Navigate to the previous view"i]' - ); + await page.click( 'role=button[name="Back"i]' ); await page.click( 'role=button[name="Colors styles"i]' ); await expect( @@ -137,9 +131,7 @@ test.describe( 'Global styles variations', () => { ) ).toHaveCSS( 'background', /rgb\(25, 25, 17\)/ ); - await page.click( - 'role=button[name="Navigate to the previous view"i]' - ); + await page.click( 'role=button[name="Back"i]' ); await page.click( 'role=button[name="Typography styles"i]' ); await page.click( 'role=button[name="Typography Text styles"i]' ); @@ -167,9 +159,7 @@ test.describe( 'Global styles variations', () => { await editor.canvas.locator( 'body' ).click(); await siteEditorStyleVariations.browseStyles(); await page.click( 'role=button[name="pink"i]' ); - await page.click( - 'role=button[name="Navigate to the previous view"i]' - ); + await page.click( 'role=button[name="Back"i]' ); await page.click( 'role=button[name="Colors styles"i]' ); await page.click( 'role=button[name="Color palettes"i]' ); diff --git a/test/e2e/specs/site-editor/user-global-styles-revisions.spec.js b/test/e2e/specs/site-editor/user-global-styles-revisions.spec.js index b4848fe9401c4b..666e80eb5eb8b5 100644 --- a/test/e2e/specs/site-editor/user-global-styles-revisions.spec.js +++ b/test/e2e/specs/site-editor/user-global-styles-revisions.spec.js @@ -212,7 +212,7 @@ test.describe( 'Style Revisions', () => { page.getByLabel( 'Global styles revisions list' ) ).toBeVisible(); - await page.click( 'role=button[name="Navigate to the previous view"]' ); + await page.click( 'role=button[name="Back"]' ); await expect( page.getByLabel( 'Global styles revisions list' ) From 614598f4ded52147821b7c58a89e3caf50c00907 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Wed, 13 Mar 2024 12:04:32 +0100 Subject: [PATCH 04/21] DataViews: Add default getValue for fields (#59810) Co-authored-by: youknowriad Co-authored-by: oandregal Co-authored-by: ntsekouras --- packages/dataviews/README.md | 5 +---- packages/dataviews/src/dataviews.js | 14 ++++++++++---- packages/dataviews/src/stories/index.story.js | 3 --- .../edit-site/src/components/page-pages/index.js | 1 - .../src/components/page-patterns/index.js | 1 - .../page-templates-template-parts/index.js | 1 - 6 files changed, 11 insertions(+), 14 deletions(-) diff --git a/packages/dataviews/README.md b/packages/dataviews/README.md index 32135bc65eba2c..cf6032a56acdf9 100644 --- a/packages/dataviews/README.md +++ b/packages/dataviews/README.md @@ -71,13 +71,11 @@ const fields = [ { id: 'title', header: 'Title', - getValue: ({ item }) => item.title, enableHiding: false, }, { id: 'date', header: 'Date', - getValue: ( { item } ) => item.date, render: ( { item } ) => { return ( @@ -87,7 +85,6 @@ const fields = [ { id: 'author', header: __( 'Author' ), - getValue: ( { item } ) => item.author, render: ( { item } ) => { return ( { item.author } @@ -123,7 +120,7 @@ Each field is an object with the following properties: - `id`: identifier for the field. Unique. - `header`: the field's name to be shown in the UI. -- `getValue`: function that returns the value of the field. +- `getValue`: function that returns the value of the field, defaults to `field[id]`. - `render`: function that renders the field. Optional, `getValue` will be used if `render` is not defined. - `elements`: the set of valid values for the field's value. - `type`: the type of the field. Used to generate the proper filters. Only `enumeration` available at the moment. See "Field types". diff --git a/packages/dataviews/src/dataviews.js b/packages/dataviews/src/dataviews.js index 4ddaf2c2cca8cd..ca541064ab043a 100644 --- a/packages/dataviews/src/dataviews.js +++ b/packages/dataviews/src/dataviews.js @@ -77,10 +77,16 @@ export default function DataViews( { ( v ) => v.type === view.type ).component; const _fields = useMemo( () => { - return fields.map( ( field ) => ( { - ...field, - render: field.render || field.getValue, - } ) ); + return fields.map( ( field ) => { + const getValue = + field.getValue || ( ( { item } ) => item[ field.id ] ); + + return { + ...field, + getValue, + render: field.render || getValue, + }; + } ); }, [ fields ] ); const hasPossibleBulkAction = useSomeItemHasAPossibleBulkAction( diff --git a/packages/dataviews/src/stories/index.story.js b/packages/dataviews/src/stories/index.story.js index 042547af84b04d..f064098fefef51 100644 --- a/packages/dataviews/src/stories/index.story.js +++ b/packages/dataviews/src/stories/index.story.js @@ -50,14 +50,12 @@ const fields = [ { header: 'Title', id: 'title', - getValue: ( { item } ) => item.title, maxWidth: 400, enableHiding: false, }, { header: 'Type', id: 'type', - getValue: ( { item } ) => item.type, maxWidth: 400, enableHiding: false, type: 'enumeration', @@ -71,7 +69,6 @@ const fields = [ { header: 'Description', id: 'description', - getValue: ( { item } ) => item.description, maxWidth: 200, enableSorting: false, }, diff --git a/packages/edit-site/src/components/page-pages/index.js b/packages/edit-site/src/components/page-pages/index.js index b8b735c4bfcf69..93ea23cbf0949f 100644 --- a/packages/edit-site/src/components/page-pages/index.js +++ b/packages/edit-site/src/components/page-pages/index.js @@ -337,7 +337,6 @@ export default function PagePages() { { header: __( 'Date' ), id: 'date', - getValue: ( { item } ) => item.date, render: ( { item } ) => { const formattedDate = dateI18n( getSettings().formats.datetimeAbbreviated, diff --git a/packages/edit-site/src/components/page-patterns/index.js b/packages/edit-site/src/components/page-patterns/index.js index d4cedaf27dee54..9b200b48982d5f 100644 --- a/packages/edit-site/src/components/page-patterns/index.js +++ b/packages/edit-site/src/components/page-patterns/index.js @@ -296,7 +296,6 @@ export default function DataviewsPatterns() { { header: __( 'Title' ), id: 'title', - getValue: ( { item } ) => item.title, render: ( { item } ) => ( ), diff --git a/packages/edit-site/src/components/page-templates-template-parts/index.js b/packages/edit-site/src/components/page-templates-template-parts/index.js index 0b7deb1d6688ec..3ea08d0eb65a23 100644 --- a/packages/edit-site/src/components/page-templates-template-parts/index.js +++ b/packages/edit-site/src/components/page-templates-template-parts/index.js @@ -309,7 +309,6 @@ export default function PageTemplatesTemplateParts( { postType } ) { _fields.push( { header: __( 'Description' ), id: 'description', - getValue: ( { item } ) => item.description, render: ( { item } ) => { return item.description ? ( <span className="page-templates-description"> From 2515c834ef4844ce63b8a9baca43e83a39a58784 Mon Sep 17 00:00:00 2001 From: Jayanth Parthsarathy <jparthaa@gmail.com> Date: Wed, 13 Mar 2024 20:07:14 +0530 Subject: [PATCH 05/21] Add inline comment denoting version for Ruby setup (#59640) Co-authored-by: Jayanth-Parthsarathy <jayanthparthsarathy@git.wordpress.org> Co-authored-by: desrosj <desrosj@git.wordpress.org> --- .github/workflows/rnmobile-ios-runner.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rnmobile-ios-runner.yml b/.github/workflows/rnmobile-ios-runner.yml index 49c3b5b07b5ae4..80b651709045e7 100644 --- a/.github/workflows/rnmobile-ios-runner.yml +++ b/.github/workflows/rnmobile-ios-runner.yml @@ -27,7 +27,7 @@ jobs: with: show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - - uses: ruby/setup-ruby@22fdc77bf4148f810455b226c90fb81b5cbc00a7 + - uses: ruby/setup-ruby@22fdc77bf4148f810455b226c90fb81b5cbc00a7 # v1.171.0 with: # `.ruby-version` file location working-directory: packages/react-native-editor/ios From dc648e56de18dd81326a0dd8f11e728169f59751 Mon Sep 17 00:00:00 2001 From: Carlos Bravo <37012961+c4rl0sbr4v0@users.noreply.github.com> Date: Wed, 13 Mar 2024 16:48:30 +0100 Subject: [PATCH 06/21] Interactivity API: Fix interactivity api e2e tests. (#59836) * Use same prioprity than in Core * Backport priority filter * Add argument Co-authored-by: c4rl0sbr4v0 <cbravobernal@git.wordpress.org> Co-authored-by: sirreal <jonsurrell@git.wordpress.org> --- .../interactivity-api/interactivity-api.php | 14 +++++++++----- packages/e2e-tests/plugins/interactive-blocks.php | 3 ++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/compat/wordpress-6.5/interactivity-api/interactivity-api.php b/lib/compat/wordpress-6.5/interactivity-api/interactivity-api.php index e532fe24447132..c4c0ac37519f41 100644 --- a/lib/compat/wordpress-6.5/interactivity-api/interactivity-api.php +++ b/lib/compat/wordpress-6.5/interactivity-api/interactivity-api.php @@ -58,16 +58,20 @@ function wp_interactivity_process_directives_of_interactive_blocks( array $parse }; /* - * Uses a priority of 20 to ensure that other filters can add additional - * directives before the processing starts. - */ - add_filter( 'render_block_' . $block_name, $process_interactive_blocks, 20, 2 ); + * Uses a priority of 100 to ensure that other filters can add additional + * directives before the processing starts. + */ + add_filter( 'render_block_' . $block_name, $process_interactive_blocks, 100, 2 ); } } return $parsed_block; } - add_filter( 'render_block_data', 'wp_interactivity_process_directives_of_interactive_blocks' ); + /* + * Uses a priority of 100 to ensure that other filters can edit $parsed_block + * without crashing the SSR. + */ + add_filter( 'render_block_data', 'wp_interactivity_process_directives_of_interactive_blocks', 100, 1 ); } if ( ! function_exists( 'wp_interactivity' ) ) { diff --git a/packages/e2e-tests/plugins/interactive-blocks.php b/packages/e2e-tests/plugins/interactive-blocks.php index 0d35cc827d6da3..ab2f85156e3b3e 100644 --- a/packages/e2e-tests/plugins/interactive-blocks.php +++ b/packages/e2e-tests/plugins/interactive-blocks.php @@ -31,7 +31,8 @@ function () { // But remove the server directive processing. remove_filter( 'render_block_data', - 'wp_interactivity_process_directives_of_interactive_blocks' + 'wp_interactivity_process_directives_of_interactive_blocks', + 100 ); } } From fe3f484c7d7d9fadb958680ff60317b53a0bd8f7 Mon Sep 17 00:00:00 2001 From: Carlos Garcia <fluiddot@gmail.com> Date: Wed, 13 Mar 2024 18:04:53 +0100 Subject: [PATCH 07/21] Improve UI of error boundary component (#59823) --- .../components/error-boundary/index.native.js | 130 ++++++++++++++---- .../error-boundary/style.native.scss | 102 ++++++++++++-- 2 files changed, 189 insertions(+), 43 deletions(-) diff --git a/packages/editor/src/components/error-boundary/index.native.js b/packages/editor/src/components/error-boundary/index.native.js index 9255c61307ae23..6f76a4fbdccfe5 100644 --- a/packages/editor/src/components/error-boundary/index.native.js +++ b/packages/editor/src/components/error-boundary/index.native.js @@ -1,8 +1,9 @@ /** * External dependencies */ -import { Text, TouchableOpacity, View } from 'react-native'; +import { ScrollView, Text, TouchableOpacity, View } from 'react-native'; import Clipboard from '@react-native-clipboard/clipboard'; +import { SafeAreaView } from 'react-native-safe-area-context'; /** * WordPress dependencies @@ -10,9 +11,13 @@ import Clipboard from '@react-native-clipboard/clipboard'; import { Component } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { select } from '@wordpress/data'; -import { Warning } from '@wordpress/block-editor'; import { logException } from '@wordpress/react-native-bridge'; -import { usePreferredColorSchemeStyle } from '@wordpress/compose'; +import { + usePreferredColorSchemeStyle, + withPreferredColorScheme, +} from '@wordpress/compose'; +import { warning } from '@wordpress/icons'; +import { Icon } from '@wordpress/components'; /** * Internal dependencies @@ -32,21 +37,38 @@ function getContent() { } catch ( error ) {} } -function CopyButton( { text, label, accessibilityLabel, accessibilityHint } ) { +function CopyButton( { + text, + label, + accessibilityLabel, + accessibilityHint, + secondary = false, +} ) { const containerStyle = usePreferredColorSchemeStyle( styles[ 'copy-button__container' ], styles[ 'copy-button__container--dark' ] ); + + const containerSecondaryStyle = usePreferredColorSchemeStyle( + styles[ 'copy-button__container--secondary' ], + styles[ 'copy-button__container--secondary-dark' ] + ); + const textStyle = usePreferredColorSchemeStyle( styles[ 'copy-button__text' ], styles[ 'copy-button__text--dark' ] ); + const textSecondaryStyle = usePreferredColorSchemeStyle( + styles[ 'copy-button__text--secondary' ], + styles[ 'copy-button__text--secondary-dark' ] + ); + return ( <TouchableOpacity activeOpacity={ 0.5 } accessibilityLabel={ accessibilityLabel } - style={ containerStyle } + style={ [ containerStyle, secondary && containerSecondaryStyle ] } accessibilityRole={ 'button' } accessibilityHint={ accessibilityHint } onPress={ () => { @@ -55,7 +77,9 @@ function CopyButton( { text, label, accessibilityLabel, accessibilityHint } ) { ); } } > - <Text style={ textStyle }>{ label }</Text> + <Text style={ [ textStyle, secondary && textSecondaryStyle ] }> + { label } + </Text> </TouchableOpacity> ); } @@ -89,34 +113,80 @@ class ErrorBoundary extends Component { return this.props.children; } - const actions = ( - <View style={ styles[ 'error-boundary__actions-container' ] }> - <CopyButton - label={ __( 'Copy Post Text' ) } - accessibilityLabel={ __( 'Button to copy post text' ) } - accessibilityHint={ __( 'Tap here to copy post text' ) } - text={ getContent } - /> - <CopyButton - label={ __( 'Copy Error' ) } - accessibilityLabel={ __( 'Button to copy error' ) } - accessibilityHint={ __( 'Tap here to copy error' ) } - text={ error.stack } - /> - </View> + const { getStylesFromColorScheme } = this.props; + + const iconContainerStyle = getStylesFromColorScheme( + styles[ 'error-boundary__icon-container' ], + styles[ 'error-boundary__icon-container--dark' ] + ); + + const titleStyle = getStylesFromColorScheme( + styles[ 'error-boundary__title' ], + styles[ 'error-boundary__title--dark' ] + ); + + const messageStyle = getStylesFromColorScheme( + styles[ 'error-boundary__message' ], + styles[ 'error-boundary__message--dark' ] ); return ( - <Warning - actions={ actions } - message={ __( - 'The editor has encountered an unexpected error.' - ) } - containerStyle={ styles[ 'error-boundary__container' ] } - messageStyle={ styles[ 'error-boundary__message' ] } - /> + <SafeAreaView> + <ScrollView + style={ styles[ 'error-boundary__scroll' ] } + contentContainerStyle={ + styles[ 'error-boundary__scroll-container' ] + } + > + <View style={ styles[ 'error-boundary__container' ] }> + <View style={ iconContainerStyle }> + <Icon + icon={ warning } + { ...styles[ 'error-boundary__icon' ] } + /> + </View> + <Text style={ titleStyle }> + { __( + 'The editor has encountered an unexpected error.' + ) } + </Text> + <Text style={ messageStyle }> + { __( + 'You can copy your post text in case your content is impacted. Copy error details to debug and share with support.' + ) } + </Text> + <View + style={ + styles[ 'error-boundary__actions-container' ] + } + > + <CopyButton + label={ __( 'Copy post text' ) } + accessibilityLabel={ __( + 'Button to copy post text' + ) } + accessibilityHint={ __( + 'Tap here to copy post text' + ) } + text={ getContent } + /> + <CopyButton + label={ __( 'Copy error details' ) } + accessibilityLabel={ __( + 'Button to copy error details' + ) } + accessibilityHint={ __( + 'Tap here to copy error details' + ) } + text={ error.stack } + secondary + /> + </View> + </View> + </ScrollView> + </SafeAreaView> ); } } -export default ErrorBoundary; +export default withPreferredColorScheme( ErrorBoundary ); diff --git a/packages/editor/src/components/error-boundary/style.native.scss b/packages/editor/src/components/error-boundary/style.native.scss index 76c23491f09e9c..6c461207768679 100644 --- a/packages/editor/src/components/error-boundary/style.native.scss +++ b/packages/editor/src/components/error-boundary/style.native.scss @@ -1,39 +1,115 @@ -.error-boundary__container { +.error-boundary__scroll { + height: 100%; + width: 100%; +} + +.error-boundary__scroll-container { flex-grow: 1; - justify-content: flex-start; + max-height: 580px; + align-items: center; + justify-content: center; +} + + +.error-boundary__container { + width: 100%; + max-width: 600px; + justify-content: center; + align-items: center; + padding: 0 24px; +} + +.error-boundary__icon-container { + $size: 40px; + + width: $size; + height: $size; + align-items: center; + justify-content: center; + margin-bottom: 8px; + background-color: rgba(60, 60, 67, 0.3); + border-radius: $size/2; +} + +.error-boundary__icon-container--dark { + background-color: $gray-20; +} + +.error-boundary__icon { + width: 24px; + height: 24px; + fill: $white; +} + +.error-boundary__title { + font-size: 20px; + font-weight: 600; + line-height: 25px; + color: $black; + text-align: center; + margin-bottom: 8px; +} + +.error-boundary__title--dark { + color: $white; } .error-boundary__message { - font-size: 16; + font-size: 16px; + font-weight: 400; + line-height: 21px; + color: rgba(60, 60, 67, 0.6); + text-align: center; + margin-bottom: 16px; +} + +.error-boundary__message--dark { + color: $white; } .error-boundary__actions-container { - margin-top: 16px; + width: 100%; + max-width: 400px; justify-content: center; - flex-direction: row; + gap: 12px; + padding-top: 16px; } .copy-button__container { - background-color: $light-primary; - border-radius: 3px; + border-radius: 5px; padding: $grid-unit $grid-unit-20; - margin-top: 8px; - margin-left: 8px; - margin-right: 8px; + background-color: $light-primary; } .copy-button__container--dark { - color: $background-dark-secondary; background-color: $gray-20; } +.copy-button__container--secondary { + border: 1px #c6c6c8; + background-color: $white; +} + +.copy-button__container--secondary-dark { + background-color: $black; +} + .copy-button__text { + font-size: 17px; + font-weight: 400; + line-height: 22px; text-align: center; color: $white; - font-size: 16; - font-weight: 400; } .copy-button__text--dark { + color: $background-dark-secondary; +} + +.copy-button__text--secondary { color: $black; } + +.copy-button__text--secondary-dark { + color: $white; +} From 86b166c95c0f5da37e344d6152531b4fb1699747 Mon Sep 17 00:00:00 2001 From: Anton Vlasenko <43744263+anton-vlasenko@users.noreply.github.com> Date: Wed, 13 Mar 2024 19:01:15 +0100 Subject: [PATCH 08/21] Enforce @since tags in block-library/src/*/*.php files (#59700) * Enforce @since tags in block-library/src/*/*.php files Co-authored-by: anton-vlasenko <antonvlasenko@git.wordpress.org> Co-authored-by: gziolo <gziolo@git.wordpress.org> Co-authored-by: youknowriad <youknowriad@git.wordpress.org> Co-authored-by: getdave <get_dave@git.wordpress.org> --- packages/block-library/src/archives/index.php | 4 + packages/block-library/src/avatar/index.php | 6 + packages/block-library/src/block/index.php | 4 + packages/block-library/src/calendar/index.php | 12 ++ .../block-library/src/categories/index.php | 6 + .../src/comment-author-name/index.php | 4 + .../src/comment-content/index.php | 4 + .../block-library/src/comment-date/index.php | 4 + .../src/comment-edit-link/index.php | 4 + .../src/comment-reply-link/index.php | 4 + .../src/comment-template/index.php | 4 + .../src/comments-pagination-next/index.php | 4 + .../src/comments-pagination-numbers/index.php | 4 + .../comments-pagination-previous/index.php | 4 + .../src/comments-pagination/index.php | 4 + .../src/comments-title/index.php | 4 + packages/block-library/src/comments/index.php | 10 ++ packages/block-library/src/cover/index.php | 4 + packages/block-library/src/file/index.php | 4 + packages/block-library/src/gallery/index.php | 6 + packages/block-library/src/heading/index.php | 4 + .../block-library/src/home-link/index.php | 10 ++ packages/block-library/src/image/index.php | 13 +- .../src/latest-comments/index.php | 4 + .../block-library/src/latest-posts/index.php | 8 + packages/block-library/src/loginout/index.php | 4 + .../block-library/src/media-text/index.php | 4 + .../src/navigation-link/index.php | 14 ++ .../src/navigation-submenu/index.php | 8 + .../block-library/src/navigation/index.php | 50 ++++++ .../src/page-list-item/index.php | 2 + .../block-library/src/page-list/index.php | 12 ++ packages/block-library/src/pattern/index.php | 2 + .../src/post-author-biography/index.php | 4 + .../src/post-author-name/index.php | 4 + .../block-library/src/post-author/index.php | 4 + .../src/post-comments-form/index.php | 6 + .../block-library/src/post-content/index.php | 4 + .../block-library/src/post-date/index.php | 4 + .../block-library/src/post-excerpt/index.php | 4 + .../src/post-featured-image/index.php | 8 + .../src/post-navigation-link/index.php | 4 + .../block-library/src/post-template/index.php | 4 + .../block-library/src/post-terms/index.php | 6 + .../block-library/src/post-title/index.php | 2 + .../src/query-no-results/index.php | 4 + .../src/query-pagination-next/index.php | 4 + .../src/query-pagination-numbers/index.php | 4 + .../src/query-pagination-previous/index.php | 4 + .../src/query-pagination/index.php | 4 + .../block-library/src/query-title/index.php | 4 + packages/block-library/src/query/index.php | 2 + .../block-library/src/read-more/index.php | 4 + packages/block-library/src/rss/index.php | 4 + packages/block-library/src/search/index.php | 20 ++- .../block-library/src/shortcode/index.php | 4 + .../block-library/src/site-logo/index.php | 20 +++ .../block-library/src/site-tagline/index.php | 4 + .../block-library/src/site-title/index.php | 4 + .../block-library/src/social-link/index.php | 14 ++ .../block-library/src/tag-cloud/index.php | 4 + .../block-library/src/template-part/index.php | 10 ++ .../src/term-description/index.php | 4 + phpcs.xml.dist | 4 + .../FunctionCommentSinceTagSniff.php | 162 ++++++++++++++++++ .../FunctionCommentSinceTagUnitTest.inc | 39 +++++ .../FunctionCommentSinceTagUnitTest.php | 42 +++++ 67 files changed, 652 insertions(+), 2 deletions(-) create mode 100644 test/php/gutenberg-coding-standards/Gutenberg/Sniffs/Commenting/FunctionCommentSinceTagSniff.php create mode 100644 test/php/gutenberg-coding-standards/Gutenberg/Tests/Commenting/FunctionCommentSinceTagUnitTest.inc create mode 100644 test/php/gutenberg-coding-standards/Gutenberg/Tests/Commenting/FunctionCommentSinceTagUnitTest.php diff --git a/packages/block-library/src/archives/index.php b/packages/block-library/src/archives/index.php index 695affde760a8a..2846b6ca1a03e1 100644 --- a/packages/block-library/src/archives/index.php +++ b/packages/block-library/src/archives/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/archives` block on server. * + * @since 5.0.0 + * * @see WP_Widget_Archives * * @param array $attributes The block attributes. @@ -106,6 +108,8 @@ function render_block_core_archives( $attributes ) { /** * Register archives block. + * + * @since 5.0.0 */ function register_block_core_archives() { register_block_type_from_metadata( diff --git a/packages/block-library/src/avatar/index.php b/packages/block-library/src/avatar/index.php index 303b35458eb1ae..b2f8ecace75a69 100644 --- a/packages/block-library/src/avatar/index.php +++ b/packages/block-library/src/avatar/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/avatar` block on the server. * + * @since 6.0.0 + * * @param array $attributes Block attributes. * @param string $content Block default content. * @param WP_Block $block Block instance. @@ -99,6 +101,8 @@ function render_block_core_avatar( $attributes, $content, $block ) { * Generates class names and styles to apply the border support styles for * the Avatar block. * + * @since 6.3.0 + * * @param array $attributes The block attributes. * @return array The border-related classnames and styles for the block. */ @@ -149,6 +153,8 @@ function get_block_core_avatar_border_attributes( $attributes ) { /** * Registers the `core/avatar` block on the server. + * + * @since 6.0.0 */ function register_block_core_avatar() { register_block_type_from_metadata( diff --git a/packages/block-library/src/block/index.php b/packages/block-library/src/block/index.php index 49b5786eacc79f..9403205c186596 100644 --- a/packages/block-library/src/block/index.php +++ b/packages/block-library/src/block/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/block` block on server. * + * @since 5.0.0 + * * @global WP_Embed $wp_embed * * @param array $attributes The block attributes. @@ -97,6 +99,8 @@ function render_block_core_block( $attributes ) { /** * Registers the `core/block` block. + * + * @since 5.3.0 */ function register_block_core_block() { register_block_type_from_metadata( diff --git a/packages/block-library/src/calendar/index.php b/packages/block-library/src/calendar/index.php index fd2914a7e88691..44b56af25e4662 100644 --- a/packages/block-library/src/calendar/index.php +++ b/packages/block-library/src/calendar/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/calendar` block on server. * + * @since 5.2.0 + * * @global int $monthnum. * @global int $year. * @@ -79,6 +81,8 @@ function render_block_core_calendar( $attributes ) { /** * Registers the `core/calendar` block on server. + * + * @since 5.2.0 */ function register_block_core_calendar() { register_block_type_from_metadata( @@ -97,6 +101,8 @@ function register_block_core_calendar() { * Used to hide the calendar block when there are no published posts. * This compensates for a known Core bug: https://core.trac.wordpress.org/ticket/12016 * + * @since 5.9.0 + * * @return bool Has any published posts or not. */ function block_core_calendar_has_published_posts() { @@ -120,6 +126,8 @@ function block_core_calendar_has_published_posts() { * Queries the database for any published post and saves * a flag whether any published post exists or not. * + * @since 5.9.0 + * * @global wpdb $wpdb WordPress database abstraction object. * * @return bool Has any published posts or not. @@ -137,6 +145,8 @@ function block_core_calendar_update_has_published_posts() { /** * Handler for updating the has published posts flag when a post is deleted. * + * @since 5.9.0 + * * @param int $post_id Deleted post ID. */ function block_core_calendar_update_has_published_post_on_delete( $post_id ) { @@ -152,6 +162,8 @@ function block_core_calendar_update_has_published_post_on_delete( $post_id ) { /** * Handler for updating the has published posts flag when a post status changes. * + * @since 5.9.0 + * * @param string $new_status The status the post is changing to. * @param string $old_status The status the post is changing from. * @param WP_Post $post Post object. diff --git a/packages/block-library/src/categories/index.php b/packages/block-library/src/categories/index.php index c35376505b134f..1a6e6f43b1d939 100644 --- a/packages/block-library/src/categories/index.php +++ b/packages/block-library/src/categories/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/categories` block on server. * + * @since 5.0.0 + * * @param array $attributes The block attributes. * * @return string Returns the categories list/dropdown markup. @@ -63,6 +65,8 @@ function render_block_core_categories( $attributes ) { /** * Generates the inline script for a categories dropdown field. * + * @since 5.0.0 + * * @param string $dropdown_id ID of the dropdown field. * * @return string Returns the dropdown onChange redirection script. @@ -87,6 +91,8 @@ function onCatChange() { /** * Registers the `core/categories` block on server. + * + * @since 5.0.0 */ function register_block_core_categories() { register_block_type_from_metadata( diff --git a/packages/block-library/src/comment-author-name/index.php b/packages/block-library/src/comment-author-name/index.php index d3cd68c0dfbfc6..2f9227964ad448 100644 --- a/packages/block-library/src/comment-author-name/index.php +++ b/packages/block-library/src/comment-author-name/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/comment-author-name` block on the server. * + * @since 6.0.0 + * * @param array $attributes Block attributes. * @param string $content Block default content. * @param WP_Block $block Block instance. @@ -53,6 +55,8 @@ function render_block_core_comment_author_name( $attributes, $content, $block ) /** * Registers the `core/comment-author-name` block on the server. + * + * @since 6.0.0 */ function register_block_core_comment_author_name() { register_block_type_from_metadata( diff --git a/packages/block-library/src/comment-content/index.php b/packages/block-library/src/comment-content/index.php index 50bca402acf034..3f7f5e1f4083ba 100644 --- a/packages/block-library/src/comment-content/index.php +++ b/packages/block-library/src/comment-content/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/comment-content` block on the server. * + * @since 6.0.0 + * * @param array $attributes Block attributes. * @param string $content Block default content. * @param WP_Block $block Block instance. @@ -69,6 +71,8 @@ function render_block_core_comment_content( $attributes, $content, $block ) { /** * Registers the `core/comment-content` block on the server. + * + * @since 6.0.0 */ function register_block_core_comment_content() { register_block_type_from_metadata( diff --git a/packages/block-library/src/comment-date/index.php b/packages/block-library/src/comment-date/index.php index 0f9c18bf2c0068..f5876bb237b67d 100644 --- a/packages/block-library/src/comment-date/index.php +++ b/packages/block-library/src/comment-date/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/comment-date` block on the server. * + * @since 6.0.0 + * * @param array $attributes Block attributes. * @param string $content Block default content. * @param WP_Block $block Block instance. @@ -46,6 +48,8 @@ function render_block_core_comment_date( $attributes, $content, $block ) { /** * Registers the `core/comment-date` block on the server. + * + * @since 6.0.0 */ function register_block_core_comment_date() { register_block_type_from_metadata( diff --git a/packages/block-library/src/comment-edit-link/index.php b/packages/block-library/src/comment-edit-link/index.php index ce7ad9bf207d43..53eaf9a2cda6c6 100644 --- a/packages/block-library/src/comment-edit-link/index.php +++ b/packages/block-library/src/comment-edit-link/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/comment-edit-link` block on the server. * + * @since 6.0.0 + * * @param array $attributes Block attributes. * @param string $content Block default content. * @param WP_Block $block Block instance. @@ -48,6 +50,8 @@ function render_block_core_comment_edit_link( $attributes, $content, $block ) { /** * Registers the `core/comment-edit-link` block on the server. + * + * @since 6.0.0 */ function register_block_core_comment_edit_link() { register_block_type_from_metadata( diff --git a/packages/block-library/src/comment-reply-link/index.php b/packages/block-library/src/comment-reply-link/index.php index 3f7b6e48b617c8..7121b6f25a195e 100644 --- a/packages/block-library/src/comment-reply-link/index.php +++ b/packages/block-library/src/comment-reply-link/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/comment-reply-link` block on the server. * + * @since 6.0.0 + * * @param array $attributes Block attributes. * @param string $content Block default content. * @param WP_Block $block Block instance. @@ -70,6 +72,8 @@ function render_block_core_comment_reply_link( $attributes, $content, $block ) { /** * Registers the `core/comment-reply-link` block on the server. + * + * @since 6.0.0 */ function register_block_core_comment_reply_link() { register_block_type_from_metadata( diff --git a/packages/block-library/src/comment-template/index.php b/packages/block-library/src/comment-template/index.php index 915c5880a8f962..ec462e6a050de2 100644 --- a/packages/block-library/src/comment-template/index.php +++ b/packages/block-library/src/comment-template/index.php @@ -92,6 +92,8 @@ function block_core_comment_template_render_comments( $comments, $block ) { /** * Renders the `core/comment-template` block on the server. * + * @since 6.0.0 + * * @param array $attributes Block attributes. * @param string $content Block default content. * @param WP_Block $block Block instance. @@ -136,6 +138,8 @@ function render_block_core_comment_template( $attributes, $content, $block ) { /** * Registers the `core/comment-template` block on the server. + * + * @since 6.0.0 */ function register_block_core_comment_template() { register_block_type_from_metadata( diff --git a/packages/block-library/src/comments-pagination-next/index.php b/packages/block-library/src/comments-pagination-next/index.php index 51d1f75c58d477..cb8350e561b6e4 100644 --- a/packages/block-library/src/comments-pagination-next/index.php +++ b/packages/block-library/src/comments-pagination-next/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/comments-pagination-next` block on the server. * + * @since 6.0.0 + * * @param array $attributes Block attributes. * @param string $content Block default content. * @param WP_Block $block Block instance. @@ -48,6 +50,8 @@ function render_block_core_comments_pagination_next( $attributes, $content, $blo /** * Registers the `core/comments-pagination-next` block on the server. + * + * @since 6.0.0 */ function register_block_core_comments_pagination_next() { register_block_type_from_metadata( diff --git a/packages/block-library/src/comments-pagination-numbers/index.php b/packages/block-library/src/comments-pagination-numbers/index.php index b172e0c8d43f86..093a6450930f12 100644 --- a/packages/block-library/src/comments-pagination-numbers/index.php +++ b/packages/block-library/src/comments-pagination-numbers/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/comments-pagination-numbers` block on the server. * + * @since 6.0.0 + * * @param array $attributes Block attributes. * @param string $content Block default content. * @param WP_Block $block Block instance. @@ -50,6 +52,8 @@ function render_block_core_comments_pagination_numbers( $attributes, $content, $ /** * Registers the `core/comments-pagination-numbers` block on the server. + * + * @since 6.0.0 */ function register_block_core_comments_pagination_numbers() { register_block_type_from_metadata( diff --git a/packages/block-library/src/comments-pagination-previous/index.php b/packages/block-library/src/comments-pagination-previous/index.php index f194e8ab517f57..092a28da677922 100644 --- a/packages/block-library/src/comments-pagination-previous/index.php +++ b/packages/block-library/src/comments-pagination-previous/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/comments-pagination-previous` block on the server. * + * @since 6.0.0 + * * @param array $attributes Block attributes. * @param string $content Block default content. * @param WP_Block $block Block instance. @@ -40,6 +42,8 @@ function render_block_core_comments_pagination_previous( $attributes, $content, /** * Registers the `core/comments-pagination-previous` block on the server. + * + * @since 6.0.0 */ function register_block_core_comments_pagination_previous() { register_block_type_from_metadata( diff --git a/packages/block-library/src/comments-pagination/index.php b/packages/block-library/src/comments-pagination/index.php index 2f9cef27f78cf6..1543fc04027eef 100644 --- a/packages/block-library/src/comments-pagination/index.php +++ b/packages/block-library/src/comments-pagination/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/comments-pagination` block on the server. * + * @since 6.0.0 + * * @param array $attributes Block attributes. * @param string $content Block default content. * @@ -34,6 +36,8 @@ function render_block_core_comments_pagination( $attributes, $content ) { /** * Registers the `core/comments-pagination` block on the server. + * + * @since 6.0.0 */ function register_block_core_comments_pagination() { register_block_type_from_metadata( diff --git a/packages/block-library/src/comments-title/index.php b/packages/block-library/src/comments-title/index.php index 62119fc0c2ca88..130132ec3fa527 100644 --- a/packages/block-library/src/comments-title/index.php +++ b/packages/block-library/src/comments-title/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/comments-title` block on the server. * + * @since 6.0.0 + * * @param array $attributes Block attributes. * * @return string Return the post comments title. @@ -84,6 +86,8 @@ function render_block_core_comments_title( $attributes ) { /** * Registers the `core/comments-title` block on the server. + * + * @since 6.0.0 */ function register_block_core_comments_title() { register_block_type_from_metadata( diff --git a/packages/block-library/src/comments/index.php b/packages/block-library/src/comments/index.php index 69e0fec8108578..e776db9b18d9d5 100644 --- a/packages/block-library/src/comments/index.php +++ b/packages/block-library/src/comments/index.php @@ -16,6 +16,8 @@ * the block is in legacy mode. If not, the HTML generated in the editor is * returned instead. * + * @since 6.1.0 + * * @global WP_Post $post Global post object. * * @param array $attributes Block attributes. @@ -85,6 +87,8 @@ function render_block_core_comments( $attributes, $content, $block ) { /** * Registers the `core/comments` block on the server. + * + * @since 6.1.0 */ function register_block_core_comments() { register_block_type_from_metadata( @@ -100,6 +104,8 @@ function register_block_core_comments() { /** * Use the button block classes for the form-submit button. * + * @since 6.1.0 + * * @param array $fields The default comment form arguments. * * @return array Returns the modified fields. @@ -118,6 +124,8 @@ function comments_block_form_defaults( $fields ) { * Enqueues styles from the legacy `core/post-comments` block. These styles are * required only by the block's fallback. * + * @since 6.1.0 + * * @param string $block_name Name of the new block type. */ function enqueue_legacy_post_comments_block_styles( $block_name ) { @@ -143,6 +151,8 @@ function enqueue_legacy_post_comments_block_styles( $block_name ) { * The same approach was followed when core/query-loop was renamed to * core/post-template. * + * @since 6.1.0 + * * @see https://github.com/WordPress/gutenberg/pull/41807 * @see https://github.com/WordPress/gutenberg/pull/32514 */ diff --git a/packages/block-library/src/cover/index.php b/packages/block-library/src/cover/index.php index 5f6b2cadaaa570..2fca0b0374dd29 100644 --- a/packages/block-library/src/cover/index.php +++ b/packages/block-library/src/cover/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/cover` block on server. * + * @since 6.0.0 + * * @param array $attributes The block attributes. * @param string $content The block rendered content. * @@ -66,6 +68,8 @@ function render_block_core_cover( $attributes, $content ) { /** * Registers the `core/cover` block renderer on server. + * + * @since 6.0.0 */ function register_block_core_cover() { register_block_type_from_metadata( diff --git a/packages/block-library/src/file/index.php b/packages/block-library/src/file/index.php index ba0343ae6b25c6..df19052b4dad6c 100644 --- a/packages/block-library/src/file/index.php +++ b/packages/block-library/src/file/index.php @@ -8,6 +8,8 @@ /** * When the `core/file` block is rendering, check if we need to enqueue the `wp-block-file-view` script. * + * @since 5.8.0 + * * @param array $attributes The block attributes. * @param string $content The block content. * @param WP_Block $block The parsed block. @@ -65,6 +67,8 @@ static function ( $matches ) { /** * Registers the `core/file` block on server. + * + * @since 5.8.0 */ function register_block_core_file() { register_block_type_from_metadata( diff --git a/packages/block-library/src/gallery/index.php b/packages/block-library/src/gallery/index.php index 292ddeaf32ee2b..10237b6bfe39c6 100644 --- a/packages/block-library/src/gallery/index.php +++ b/packages/block-library/src/gallery/index.php @@ -13,6 +13,8 @@ * we add a custom `data-id` attribute before rendering the gallery * so that the Image Block can pick it up in its render_callback. * + * @since 5.9.0 + * * @param array $parsed_block The block being rendered. * @return array The migrated block object. */ @@ -35,6 +37,8 @@ function block_core_gallery_data_id_backcompatibility( $parsed_block ) { /** * Renders the `core/gallery` block on the server. * + * @since 6.0.0 + * * @param array $attributes Attributes of the block being rendered. * @param string $content Content of the block being rendered. * @return string The content of the block being rendered. @@ -164,6 +168,8 @@ static function () use ( $image_blocks, &$i ) { } /** * Registers the `core/gallery` block on server. + * + * @since 5.9.0 */ function register_block_core_gallery() { register_block_type_from_metadata( diff --git a/packages/block-library/src/heading/index.php b/packages/block-library/src/heading/index.php index 5a7e8dbaab43cf..471e31f19f2ee9 100644 --- a/packages/block-library/src/heading/index.php +++ b/packages/block-library/src/heading/index.php @@ -14,6 +14,8 @@ * Would be transformed to: * <h2 class="align-left wp-block-heading">Hello World</h2> * + * @since 6.2.0 + * * @param array $attributes Attributes of the block being rendered. * @param string $content Content of the block being rendered. * @@ -39,6 +41,8 @@ function block_core_heading_render( $attributes, $content ) { /** * Registers the `core/heading` block on server. + * + * @since 6.2.0 */ function register_block_core_heading() { register_block_type_from_metadata( diff --git a/packages/block-library/src/home-link/index.php b/packages/block-library/src/home-link/index.php index 9ec0c185872c0f..fb7235834459d0 100644 --- a/packages/block-library/src/home-link/index.php +++ b/packages/block-library/src/home-link/index.php @@ -9,6 +9,8 @@ * Build an array with CSS classes and inline styles defining the colors * which will be applied to the home link markup in the front-end. * + * @since 6.0.0 + * * @param array $context home link block context. * @return array Colors CSS classes and inline styles. */ @@ -61,6 +63,8 @@ function block_core_home_link_build_css_colors( $context ) { * Build an array with CSS classes and inline styles defining the font sizes * which will be applied to the home link markup in the front-end. * + * @since 6.0.0 + * * @param array $context Home link block context. * @return array Font size CSS classes and inline styles. */ @@ -88,6 +92,8 @@ function block_core_home_link_build_css_font_sizes( $context ) { /** * Builds an array with classes and style for the li wrapper * + * @since 6.0.0 + * * @param array $context Home link block context. * @return string The li wrapper attributes. */ @@ -121,6 +127,8 @@ function block_core_home_link_build_li_wrapper_attributes( $context ) { /** * Renders the `core/home-link` block. * + * @since 6.0.0 + * * @param array $attributes The block attributes. * @param string $content The saved content. * @param WP_Block $block The parsed block. @@ -155,6 +163,8 @@ function render_block_core_home_link( $attributes, $content, $block ) { /** * Register the home block * + * @since 6.0.0 + * * @uses render_block_core_home_link() * @throws WP_Error An WP_Error exception parsing the block definition. */ diff --git a/packages/block-library/src/image/index.php b/packages/block-library/src/image/index.php index 0b75bf95a7d4ce..2351f6aad6c46c 100644 --- a/packages/block-library/src/image/index.php +++ b/packages/block-library/src/image/index.php @@ -9,6 +9,8 @@ * Renders the `core/image` block on the server, * adding a data-id attribute to the element if core/gallery has added on pre-render. * + * @since 5.9.0 + * * @param array $attributes The block attributes. * @param string $content The block content. * @param WP_Block $block The block object. @@ -85,6 +87,8 @@ function render_block_core_image( $attributes, $content, $block ) { * * This is used to determine whether the lightbox should be rendered or not. * + * @since 6.4.0 + * * @param array $block Block data. * * @return array Filtered block data. @@ -115,6 +119,8 @@ function block_core_image_get_lightbox_settings( $block ) { /** * Adds the directives and layout needed for the lightbox behavior. * + * @since 6.4.0 + * * @param string $block_content Rendered block content. * @param array $block Block object. * @@ -219,6 +225,9 @@ class="lightbox-trigger" return $body_content; } +/** + * @since 6.5.0 + */ function block_core_image_print_lightbox_overlay() { $close_button_label = esc_attr__( 'Close' ); @@ -238,7 +247,7 @@ function block_core_image_print_lightbox_overlay() { } echo <<<HTML - <div + <div class="wp-lightbox-overlay zoom" data-wp-interactive="core/image" data-wp-context='{}' @@ -278,6 +287,8 @@ class="wp-lightbox-overlay zoom" /** * Registers the `core/image` block on server. + * + * @since 5.9.0 */ function register_block_core_image() { register_block_type_from_metadata( diff --git a/packages/block-library/src/latest-comments/index.php b/packages/block-library/src/latest-comments/index.php index 830e22ac339c07..5b6023cc46e58f 100644 --- a/packages/block-library/src/latest-comments/index.php +++ b/packages/block-library/src/latest-comments/index.php @@ -36,6 +36,8 @@ function wp_latest_comments_draft_or_post_title( $post = 0 ) { /** * Renders the `core/latest-comments` block on server. * + * @since 5.1.0 + * * @param array $attributes The block attributes. * * @return string Returns the post content with latest comments added. @@ -145,6 +147,8 @@ function render_block_core_latest_comments( $attributes = array() ) { /** * Registers the `core/latest-comments` block. + * + * @since 5.3.0 */ function register_block_core_latest_comments() { register_block_type_from_metadata( diff --git a/packages/block-library/src/latest-posts/index.php b/packages/block-library/src/latest-posts/index.php index adc51d0c4fecb9..6bff971beef576 100644 --- a/packages/block-library/src/latest-posts/index.php +++ b/packages/block-library/src/latest-posts/index.php @@ -18,6 +18,8 @@ * Callback for the excerpt_length filter used by * the Latest Posts block at render time. * + * @since 5.4.0 + * * @return int Returns the global $block_core_latest_posts_excerpt_length variable * to allow the excerpt_length filter respect the Latest Block setting. */ @@ -29,6 +31,8 @@ function block_core_latest_posts_get_excerpt_length() { /** * Renders the `core/latest-posts` block on server. * + * @since 5.0.0 + * * @param array $attributes The block attributes. * * @return string Returns the post content with latest posts added. @@ -218,6 +222,8 @@ function render_block_core_latest_posts( $attributes ) { /** * Registers the `core/latest-posts` block on server. + * + * @since 5.0.0 */ function register_block_core_latest_posts() { register_block_type_from_metadata( @@ -241,6 +247,8 @@ function register_block_core_latest_posts() { * TODO: Remove when and if the bottom client-side deprecation for this block * is removed. * + * @since 5.5.0 + * * @param array $block A single parsed block object. * * @return array The migrated block object. diff --git a/packages/block-library/src/loginout/index.php b/packages/block-library/src/loginout/index.php index ac10ced20f3d1b..de90ebc12e379a 100644 --- a/packages/block-library/src/loginout/index.php +++ b/packages/block-library/src/loginout/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/loginout` block on server. * + * @since 5.8.0 + * * @param array $attributes The block attributes. * * @return string Returns the login-out link or form. @@ -39,6 +41,8 @@ function render_block_core_loginout( $attributes ) { /** * Registers the `core/loginout` block on server. + * + * @since 5.8.0 */ function register_block_core_loginout() { register_block_type_from_metadata( diff --git a/packages/block-library/src/media-text/index.php b/packages/block-library/src/media-text/index.php index 9f5e334d145715..eff4bb1ddaeabb 100644 --- a/packages/block-library/src/media-text/index.php +++ b/packages/block-library/src/media-text/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/media-text` block on server. * + * @since 6.6.0 + * * @param array $attributes The block attributes. * @param string $content The block rendered content. * @@ -54,6 +56,8 @@ function render_block_core_media_text( $attributes, $content ) { /** * Registers the `core/media-text` block renderer on server. + * + * @since 6.6.0 */ function register_block_core_media_text() { register_block_type_from_metadata( diff --git a/packages/block-library/src/navigation-link/index.php b/packages/block-library/src/navigation-link/index.php index 4ed54fcc09bf40..ffeea51996a02c 100644 --- a/packages/block-library/src/navigation-link/index.php +++ b/packages/block-library/src/navigation-link/index.php @@ -9,6 +9,8 @@ * Build an array with CSS classes and inline styles defining the colors * which will be applied to the navigation markup in the front-end. * + * @since 5.9.0 + * * @param array $context Navigation block context. * @param array $attributes Block attributes. * @param bool $is_sub_menu Whether the link is part of a sub-menu. @@ -79,6 +81,8 @@ function block_core_navigation_link_build_css_colors( $context, $attributes, $is * Build an array with CSS classes and inline styles defining the font sizes * which will be applied to the navigation markup in the front-end. * + * @since 5.9.0 + * * @param array $context Navigation block context. * @return array Font size CSS classes and inline styles. */ @@ -113,6 +117,8 @@ function block_core_navigation_link_build_css_font_sizes( $context ) { /** * Returns the top-level submenu SVG chevron icon. * + * @since 5.9.0 + * * @return string */ function block_core_navigation_link_render_submenu_icon() { @@ -122,6 +128,8 @@ function block_core_navigation_link_render_submenu_icon() { /** * Decodes a url if it's encoded, returning the same url if not. * + * @since 6.2.0 + * * @param string $url The url to decode. * * @return string $url Returns the decoded url. @@ -153,6 +161,8 @@ function block_core_navigation_link_maybe_urldecode( $url ) { /** * Renders the `core/navigation-link` block. * + * @since 5.9.0 + * * @param array $attributes The block attributes. * @param string $content The saved content. * @param WP_Block $block The parsed block. @@ -269,6 +279,8 @@ function render_block_core_navigation_link( $attributes, $content, $block ) { /** * Returns a navigation link variation * + * @since 5.9.0 + * * @param WP_Taxonomy|WP_Post_Type $entity post type or taxonomy entity. * @param string $kind string of value 'taxonomy' or 'post-type'. * @@ -391,6 +403,8 @@ function block_core_navigation_link_build_variations() { /** * Registers the navigation link block. * + * @since 5.9.0 + * * @uses render_block_core_navigation_link() * @throws WP_Error An WP_Error exception parsing the block definition. */ diff --git a/packages/block-library/src/navigation-submenu/index.php b/packages/block-library/src/navigation-submenu/index.php index 2ae23a92b69c45..b67f5ead8651ee 100644 --- a/packages/block-library/src/navigation-submenu/index.php +++ b/packages/block-library/src/navigation-submenu/index.php @@ -9,6 +9,8 @@ * Build an array with CSS classes and inline styles defining the font sizes * which will be applied to the navigation markup in the front-end. * + * @since 5.9.0 + * * @param array $context Navigation block context. * @return array Font size CSS classes and inline styles. */ @@ -43,6 +45,8 @@ function block_core_navigation_submenu_build_css_font_sizes( $context ) { /** * Returns the top-level submenu SVG chevron icon. * + * @since 5.9.0 + * * @return string */ function block_core_navigation_submenu_render_submenu_icon() { @@ -52,6 +56,8 @@ function block_core_navigation_submenu_render_submenu_icon() { /** * Renders the `core/navigation-submenu` block. * + * @since 5.9.0 + * * @param array $attributes The block attributes. * @param string $content The saved content. * @param WP_Block $block The parsed block. @@ -238,6 +244,8 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) { /** * Register the navigation submenu block. * + * @since 5.9.0 + * * @uses render_block_core_navigation_submenu() * @throws WP_Error An WP_Error exception parsing the block definition. */ diff --git a/packages/block-library/src/navigation/index.php b/packages/block-library/src/navigation/index.php index f28f017f0238c1..ca146868f4bbde 100644 --- a/packages/block-library/src/navigation/index.php +++ b/packages/block-library/src/navigation/index.php @@ -676,6 +676,8 @@ public static function render( $attributes, $content, $block ) { /** * Returns the menu items for a WordPress menu location. * + * @since 5.9.0 + * * @param string $location The menu location. * @return array Menu items for the location. */ @@ -712,6 +714,8 @@ function block_core_navigation_get_menu_items_at_location( $location ) { * Sorts a standard array of menu items into a nested structure keyed by the * id of the parent menu. * + * @since 5.9.0 + * * @param array $menu_items Menu items to sort. * @return array An array keyed by the id of the parent menu where each element * is an array of menu items that belong to that parent. @@ -734,6 +738,8 @@ function block_core_navigation_sort_menu_items_by_parent_id( $menu_items ) { /** * Gets the inner blocks for the navigation block from the unstable location attribute. * + * @since 6.5.0 + * * @param array $attributes The block attributes. * @return WP_Block_List Returns the inner blocks for the navigation block. */ @@ -753,6 +759,8 @@ function block_core_navigation_get_inner_blocks_from_unstable_location( $attribu * Add Interactivity API directives to the navigation-submenu and page-list * blocks markup using the Tag Processor. * + * @since 6.3.0 + * * @param WP_HTML_Tag_Processor $tags Markup of the navigation block. * @param array $block_attributes Block attributes. * @@ -814,6 +822,8 @@ function block_core_navigation_add_directives_to_submenu( $tags, $block_attribut * Build an array with CSS classes and inline styles defining the colors * which will be applied to the navigation markup in the front-end. * + * @since 5.9.0 + * * @param array $attributes Navigation block attributes. * * @return array Colors CSS classes and inline styles. @@ -905,6 +915,8 @@ function block_core_navigation_build_css_colors( $attributes ) { * Build an array with CSS classes and inline styles defining the font sizes * which will be applied to the navigation markup in the front-end. * + * @since 5.9.0 + * * @param array $attributes Navigation block attributes. * * @return array Font size CSS classes and inline styles. @@ -933,6 +945,8 @@ function block_core_navigation_build_css_font_sizes( $attributes ) { /** * Returns the top-level submenu SVG chevron icon. * + * @since 5.9.0 + * * @return string */ function block_core_navigation_render_submenu_icon() { @@ -945,6 +959,8 @@ function block_core_navigation_render_submenu_icon() { * it encounters whitespace. This is not a bug but rather how the parser * is designed. * + * @since 5.9.0 + * * @param array $parsed_blocks the parsed blocks to be normalized. * @return array the normalized parsed blocks. */ @@ -963,6 +979,8 @@ static function ( $block ) { /** * Returns true if the navigation block contains a nested navigation block. * + * @since 6.2.0 + * * @param WP_Block_List $inner_blocks Inner block instance to be normalized. * @return bool true if the navigation block contains a nested navigation block. */ @@ -986,6 +1004,8 @@ function block_core_navigation_block_contains_core_navigation( $inner_blocks ) { * This aims to mirror how the fallback mechanic for wp_nav_menu works. * See https://developer.wordpress.org/reference/functions/wp_nav_menu/#more-information. * + * @since 5.9.0 + * * @return array the array of blocks to be used as a fallback. */ function block_core_navigation_get_fallback_blocks() { @@ -1041,6 +1061,8 @@ function block_core_navigation_get_fallback_blocks() { /** * Iterate through all inner blocks recursively and get navigation link block's post IDs. * + * @since 6.0.0 + * * @param WP_Block_List $inner_blocks Block list class instance. * * @return array Array of post IDs. @@ -1053,6 +1075,8 @@ function block_core_navigation_get_post_ids( $inner_blocks ) { /** * Get post IDs from a navigation link block instance. * + * @since 6.0.0 + * * @param WP_Block $block Instance of a block. * * @return array Array of post IDs. @@ -1076,6 +1100,8 @@ function block_core_navigation_from_block_get_post_ids( $block ) { /** * Renders the `core/navigation` block on server. * + * @since 5.9.0 + * * @param array $attributes The block attributes. * @param string $content The saved content. * @param WP_Block $block The parsed block. @@ -1089,6 +1115,8 @@ function render_block_core_navigation( $attributes, $content, $block ) { /** * Register the navigation block. * + * @since 5.9.0 + * * @uses render_block_core_navigation() * @throws WP_Error An WP_Error exception parsing the block definition. */ @@ -1106,6 +1134,8 @@ function register_block_core_navigation() { /** * Filter that changes the parsed attribute values of navigation blocks contain typographic presets to contain the values directly. * + * @since 5.9.0 + * * @param array $parsed_block The block being rendered. * * @return array The block being rendered without typographic presets. @@ -1140,6 +1170,8 @@ function block_core_navigation_typographic_presets_backcompatibility( $parsed_bl /** * Turns menu item data into a nested array of parsed blocks * + * @since 5.9.0 + * * @deprecated 6.3.0 Use WP_Navigation_Fallback::parse_blocks_from_menu_items() instead. * * @param array $menu_items An array of menu items that represent @@ -1197,6 +1229,8 @@ function block_core_navigation_parse_blocks_from_menu_items( $menu_items, $menu_ /** * Get the classic navigation menu to use as a fallback. * + * @since 6.2.0 + * * @deprecated 6.3.0 Use WP_Navigation_Fallback::get_classic_menu_fallback() instead. * * @return object WP_Term The classic navigation. @@ -1241,6 +1275,8 @@ static function ( $a, $b ) { /** * Converts a classic navigation to blocks. * + * @since 6.2.0 + * * @deprecated 6.3.0 Use WP_Navigation_Fallback::get_classic_menu_fallback_blocks() instead. * * @param object $classic_nav_menu WP_Term The classic navigation object to convert. @@ -1283,6 +1319,8 @@ function block_core_navigation_get_classic_menu_fallback_blocks( $classic_nav_me /** * If there's a classic menu then use it as a fallback. * + * @since 6.2.0 + * * @deprecated 6.3.0 Use WP_Navigation_Fallback::create_classic_menu_fallback() instead. * * @return array the normalized parsed blocks. @@ -1328,6 +1366,8 @@ function block_core_navigation_maybe_use_classic_menu_fallback() { /** * Finds the most recently published `wp_navigation` Post. * + * @since 6.1.0 + * * @deprecated 6.3.0 Use WP_Navigation_Fallback::get_most_recently_published_navigation() instead. * * @return WP_Post|null the first non-empty Navigation or null. @@ -1359,6 +1399,8 @@ function block_core_navigation_get_most_recently_published_navigation() { /** * Accepts the serialized markup of a block and its inner blocks, and returns serialized markup of the inner blocks. * + * @since 6.5.0 + * * @param string $serialized_block The serialized markup of a block and its inner blocks. * @return string */ @@ -1372,6 +1414,8 @@ function block_core_navigation_remove_serialized_parent_block( $serialized_block * Mock a parsed block for the Navigation block given its inner blocks and the `wp_navigation` post object. * The `wp_navigation` post's `_wp_ignored_hooked_blocks` meta is queried to add the `metadata.ignoredHookedBlocks` attribute. * + * @since 6.5.0 + * * @param array $inner_blocks Parsed inner blocks of a Navigation block. * @param WP_Post $post `wp_navigation` post object corresponding to the block. * @@ -1411,6 +1455,8 @@ function block_core_navigation_mock_parsed_block( $inner_blocks, $post ) { * children, the `wp_navigation` post's `_wp_ignored_hooked_blocks` meta is checked to see if any * of those hooked blocks should be exempted from insertion. * + * @since 6.5.0 + * * @param array $inner_blocks Parsed inner blocks of a Navigation block. * @param WP_Post $post `wp_navigation` post object corresponding to the block. * @return string Serialized inner blocks in mock Navigation block wrapper, with hooked blocks inserted, if any. @@ -1436,6 +1482,8 @@ function block_core_navigation_insert_hooked_blocks( $inner_blocks, $post ) { * this function inserts ignoredHookedBlocks meta into it, and returns the serialized inner blocks in a * mock Navigation block wrapper. * + * @since 6.5.0 + * * @param array $inner_blocks Parsed inner blocks of a Navigation block. * @param WP_Post $post `wp_navigation` post object corresponding to the block. * @return string Serialized inner blocks in mock Navigation block wrapper, with hooked blocks inserted, if any. @@ -1523,6 +1571,8 @@ function block_core_navigation_update_ignore_hooked_blocks_meta( $post ) { /** * Hooks into the REST API response for the core/navigation block and adds the first and last inner blocks. * + * @since 6.5.0 + * * @param WP_REST_Response $response The response object. * @param WP_Post $post Post object. * @return WP_REST_Response The response object. diff --git a/packages/block-library/src/page-list-item/index.php b/packages/block-library/src/page-list-item/index.php index 2955c795aec2b7..121d2dbbb97051 100644 --- a/packages/block-library/src/page-list-item/index.php +++ b/packages/block-library/src/page-list-item/index.php @@ -7,6 +7,8 @@ /** * Registers the `core/page-list-item` block on server. + * + * @since 6.3.0 */ function register_block_core_page_list_item() { register_block_type_from_metadata( __DIR__ . '/page-list-item' ); diff --git a/packages/block-library/src/page-list/index.php b/packages/block-library/src/page-list/index.php index b9ef8bf745a733..4ff57e1a36a23e 100644 --- a/packages/block-library/src/page-list/index.php +++ b/packages/block-library/src/page-list/index.php @@ -9,6 +9,8 @@ * Build an array with CSS classes and inline styles defining the colors * which will be applied to the pages markup in the front-end when it is a descendant of navigation. * + * @since 5.8.0 + * * @param array $attributes Block attributes. * @param array $context Navigation block context. * @return array Colors CSS classes and inline styles. @@ -101,6 +103,8 @@ function block_core_page_list_build_css_colors( $attributes, $context ) { * Build an array with CSS classes and inline styles defining the font sizes * which will be applied to the pages markup in the front-end when it is a descendant of navigation. * + * @since 5.8.0 + * * @param array $context Navigation block context. * @return array Font size CSS classes and inline styles. */ @@ -135,6 +139,8 @@ function block_core_page_list_build_css_font_sizes( $context ) { /** * Outputs Page list markup from an array of pages with nested children. * + * @since 5.8.0 + * * @param boolean $open_submenus_on_click Whether to open submenus on click instead of hover. * @param boolean $show_submenu_icons Whether to show submenu indicator icons. * @param boolean $is_navigation_child If block is a child of Navigation block. @@ -220,6 +226,8 @@ function block_core_page_list_render_nested_page_list( $open_submenus_on_click, /** * Outputs nested array of pages * + * @since 5.8.0 + * * @param array $current_level The level being iterated through. * @param array $children The children grouped by parent post ID. * @@ -240,6 +248,8 @@ function block_core_page_list_nest_pages( $current_level, $children ) { /** * Renders the `core/page-list` block on server. * + * @since 5.8.0 + * * @param array $attributes The block attributes. * @param string $content The saved content. * @param WP_Block $block The parsed block. @@ -345,6 +355,8 @@ function render_block_core_page_list( $attributes, $content, $block ) { /** * Registers the `core/pages` block on server. + * + * @since 5.8.0 */ function register_block_core_page_list() { register_block_type_from_metadata( diff --git a/packages/block-library/src/pattern/index.php b/packages/block-library/src/pattern/index.php index 9a4d4c01b5bcd6..5595818a2271b7 100644 --- a/packages/block-library/src/pattern/index.php +++ b/packages/block-library/src/pattern/index.php @@ -7,6 +7,8 @@ /** * Registers the `core/pattern` block on the server. + * + * @since 5.9.0 */ function register_block_core_pattern() { register_block_type_from_metadata( diff --git a/packages/block-library/src/post-author-biography/index.php b/packages/block-library/src/post-author-biography/index.php index 23f5f16cbcf450..bd983f79e76092 100644 --- a/packages/block-library/src/post-author-biography/index.php +++ b/packages/block-library/src/post-author-biography/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/post-author-biography` block on the server. * + * @since 6.0.0 + * * @param array $attributes Block attributes. * @param string $content Block default content. * @param WP_Block $block Block instance. @@ -37,6 +39,8 @@ function render_block_core_post_author_biography( $attributes, $content, $block /** * Registers the `core/post-author-biography` block on the server. + * + * @since 6.0.0 */ function register_block_core_post_author_biography() { register_block_type_from_metadata( diff --git a/packages/block-library/src/post-author-name/index.php b/packages/block-library/src/post-author-name/index.php index a5fadfcbf33c1c..effc83962a3547 100644 --- a/packages/block-library/src/post-author-name/index.php +++ b/packages/block-library/src/post-author-name/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/post-author-name` block on the server. * + * @since 6.2.0 + * * @param array $attributes Block attributes. * @param string $content Block default content. * @param WP_Block $block Block instance. @@ -43,6 +45,8 @@ function render_block_core_post_author_name( $attributes, $content, $block ) { /** * Registers the `core/post-author-name` block on the server. + * + * @since 6.2.0 */ function register_block_core_post_author_name() { register_block_type_from_metadata( diff --git a/packages/block-library/src/post-author/index.php b/packages/block-library/src/post-author/index.php index 898d9478283bc8..faf894d997d732 100644 --- a/packages/block-library/src/post-author/index.php +++ b/packages/block-library/src/post-author/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/post-author` block on the server. * + * @since 5.9.0 + * * @param array $attributes Block attributes. * @param string $content Block default content. * @param WP_Block $block Block instance. @@ -61,6 +63,8 @@ function render_block_core_post_author( $attributes, $content, $block ) { /** * Registers the `core/post-author` block on the server. + * + * @since 5.9.0 */ function register_block_core_post_author() { register_block_type_from_metadata( diff --git a/packages/block-library/src/post-comments-form/index.php b/packages/block-library/src/post-comments-form/index.php index 644b02ae0f1498..dfbf4c59f264ad 100644 --- a/packages/block-library/src/post-comments-form/index.php +++ b/packages/block-library/src/post-comments-form/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/post-comments-form` block on the server. * + * @since 6.0.0 + * * @param array $attributes Block attributes. * @param string $content Block default content. * @param WP_Block $block Block instance. @@ -54,6 +56,8 @@ function render_block_core_post_comments_form( $attributes, $content, $block ) { /** * Registers the `core/post-comments-form` block on the server. + * + * @since 6.0.0 */ function register_block_core_post_comments_form() { register_block_type_from_metadata( @@ -68,6 +72,8 @@ function register_block_core_post_comments_form() { /** * Use the button block classes for the form-submit button. * + * @since 6.0.0 + * * @param array $fields The default comment form arguments. * * @return array Returns the modified fields. diff --git a/packages/block-library/src/post-content/index.php b/packages/block-library/src/post-content/index.php index dd84574fdea658..25be880cc47887 100644 --- a/packages/block-library/src/post-content/index.php +++ b/packages/block-library/src/post-content/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/post-content` block on the server. * + * @since 5.8.0 + * * @param array $attributes Block attributes. * @param string $content Block default content. * @param WP_Block $block Block instance. @@ -63,6 +65,8 @@ function render_block_core_post_content( $attributes, $content, $block ) { /** * Registers the `core/post-content` block on the server. + * + * @since 5.8.0 */ function register_block_core_post_content() { register_block_type_from_metadata( diff --git a/packages/block-library/src/post-date/index.php b/packages/block-library/src/post-date/index.php index b59db80b242cd1..bcfff02fc178d7 100644 --- a/packages/block-library/src/post-date/index.php +++ b/packages/block-library/src/post-date/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/post-date` block on the server. * + * @since 5.8.0 + * * @param array $attributes Block attributes. * @param string $content Block default content. * @param WP_Block $block Block instance. @@ -60,6 +62,8 @@ function render_block_core_post_date( $attributes, $content, $block ) { /** * Registers the `core/post-date` block on the server. + * + * @since 5.8.0 */ function register_block_core_post_date() { register_block_type_from_metadata( diff --git a/packages/block-library/src/post-excerpt/index.php b/packages/block-library/src/post-excerpt/index.php index 09d6b6f003d34b..c8882b4062ac00 100644 --- a/packages/block-library/src/post-excerpt/index.php +++ b/packages/block-library/src/post-excerpt/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/post-excerpt` block on the server. * + * @since 5.8.0 + * * @param array $attributes Block attributes. * @param string $content Block default content. * @param WP_Block $block Block instance. @@ -66,6 +68,8 @@ function render_block_core_post_excerpt( $attributes, $content, $block ) { /** * Registers the `core/post-excerpt` block on the server. + * + * @since 5.8.0 */ function register_block_core_post_excerpt() { register_block_type_from_metadata( diff --git a/packages/block-library/src/post-featured-image/index.php b/packages/block-library/src/post-featured-image/index.php index 9a1fd315bb9524..347425c23a4a08 100644 --- a/packages/block-library/src/post-featured-image/index.php +++ b/packages/block-library/src/post-featured-image/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/post-featured-image` block on the server. * + * @since 5.8.0 + * * @param array $attributes Block attributes. * @param string $content Block default content. * @param WP_Block $block Block instance. @@ -125,6 +127,8 @@ function render_block_core_post_featured_image( $attributes, $content, $block ) /** * Generate markup for the HTML element that will be used for the overlay. * + * @since 6.1.0 + * * @param array $attributes Block attributes. * * @return string HTML markup in string format. @@ -191,6 +195,8 @@ function get_block_core_post_featured_image_overlay_element_markup( $attributes * Generates class names and styles to apply the border support styles for * the Post Featured Image block. * + * @since 6.1.0 + * * @param array $attributes The block attributes. * @return array The border-related classnames and styles for the block. */ @@ -241,6 +247,8 @@ function get_block_core_post_featured_image_border_attributes( $attributes ) { /** * Registers the `core/post-featured-image` block on the server. + * + * @since 5.8.0 */ function register_block_core_post_featured_image() { register_block_type_from_metadata( diff --git a/packages/block-library/src/post-navigation-link/index.php b/packages/block-library/src/post-navigation-link/index.php index 5bbc87ef537710..8162b74d8af17f 100644 --- a/packages/block-library/src/post-navigation-link/index.php +++ b/packages/block-library/src/post-navigation-link/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/post-navigation-link` block on the server. * + * @since 5.9.0 + * * @param array $attributes Block attributes. * @param string $content Block default content. * @@ -123,6 +125,8 @@ function render_block_core_post_navigation_link( $attributes, $content ) { /** * Registers the `core/post-navigation-link` block on the server. + * + * @since 5.9.0 */ function register_block_core_post_navigation_link() { register_block_type_from_metadata( diff --git a/packages/block-library/src/post-template/index.php b/packages/block-library/src/post-template/index.php index df287acae7b58b..9126355c096a57 100644 --- a/packages/block-library/src/post-template/index.php +++ b/packages/block-library/src/post-template/index.php @@ -8,6 +8,8 @@ /** * Determines whether a block list contains a block that uses the featured image. * + * @since 6.0.0 + * * @param WP_Block_List $inner_blocks Inner block instance. * * @return bool Whether the block list contains a block that uses the featured image. @@ -145,6 +147,8 @@ function render_block_core_post_template( $attributes, $content, $block ) { /** * Registers the `core/post-template` block on the server. + * + * @since 5.8.0 */ function register_block_core_post_template() { register_block_type_from_metadata( diff --git a/packages/block-library/src/post-terms/index.php b/packages/block-library/src/post-terms/index.php index c919db9cda2e4c..69d7b04b096b53 100644 --- a/packages/block-library/src/post-terms/index.php +++ b/packages/block-library/src/post-terms/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/post-terms` block on the server. * + * @since 5.8.0 + * * @param array $attributes Block attributes. * @param string $content Block default content. * @param WP_Block $block Block instance. @@ -61,6 +63,8 @@ function render_block_core_post_terms( $attributes, $content, $block ) { /** * Returns the available variations for the `core/post-terms` block. * + * @since 6.5.0 + * * @return array The available variations for the block. */ function block_core_post_terms_build_variations() { @@ -110,6 +114,8 @@ function block_core_post_terms_build_variations() { /** * Registers the `core/post-terms` block on the server. + * + * @since 5.8.0 */ function register_block_core_post_terms() { register_block_type_from_metadata( diff --git a/packages/block-library/src/post-title/index.php b/packages/block-library/src/post-title/index.php index d0eef8572ba139..f4a91a6891ea81 100644 --- a/packages/block-library/src/post-title/index.php +++ b/packages/block-library/src/post-title/index.php @@ -60,6 +60,8 @@ function render_block_core_post_title( $attributes, $content, $block ) { /** * Registers the `core/post-title` block on the server. + * + * @since 5.8.0 */ function register_block_core_post_title() { register_block_type_from_metadata( diff --git a/packages/block-library/src/query-no-results/index.php b/packages/block-library/src/query-no-results/index.php index a6f4bd14d01972..da16bde86ce893 100644 --- a/packages/block-library/src/query-no-results/index.php +++ b/packages/block-library/src/query-no-results/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/query-no-results` block on the server. * + * @since 6.0.0 + * * @param array $attributes Block attributes. * @param string $content Block default content. * @param WP_Block $block Block instance. @@ -47,6 +49,8 @@ function render_block_core_query_no_results( $attributes, $content, $block ) { /** * Registers the `core/query-no-results` block on the server. + * + * @since 6.0.0 */ function register_block_core_query_no_results() { register_block_type_from_metadata( diff --git a/packages/block-library/src/query-pagination-next/index.php b/packages/block-library/src/query-pagination-next/index.php index ca134f62192f9e..39fc1df63d9371 100644 --- a/packages/block-library/src/query-pagination-next/index.php +++ b/packages/block-library/src/query-pagination-next/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/query-pagination-next` block on the server. * + * @since 5.8.0 + * * @param array $attributes Block attributes. * @param string $content Block default content. * @param WP_Block $block Block instance. @@ -84,6 +86,8 @@ function render_block_core_query_pagination_next( $attributes, $content, $block /** * Registers the `core/query-pagination-next` block on the server. + * + * @since 5.8.0 */ function register_block_core_query_pagination_next() { register_block_type_from_metadata( diff --git a/packages/block-library/src/query-pagination-numbers/index.php b/packages/block-library/src/query-pagination-numbers/index.php index e6f8b461110407..bb78cbf0cf6ef7 100644 --- a/packages/block-library/src/query-pagination-numbers/index.php +++ b/packages/block-library/src/query-pagination-numbers/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/query-pagination-numbers` block on the server. * + * @since 5.8.0 + * * @param array $attributes Block attributes. * @param string $content Block default content. * @param WP_Block $block Block instance. @@ -115,6 +117,8 @@ function render_block_core_query_pagination_numbers( $attributes, $content, $blo /** * Registers the `core/query-pagination-numbers` block on the server. + * + * @since 5.8.0 */ function register_block_core_query_pagination_numbers() { register_block_type_from_metadata( diff --git a/packages/block-library/src/query-pagination-previous/index.php b/packages/block-library/src/query-pagination-previous/index.php index b49130a44d8ddf..95ed54075a7c54 100644 --- a/packages/block-library/src/query-pagination-previous/index.php +++ b/packages/block-library/src/query-pagination-previous/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/query-pagination-previous` block on the server. * + * @since 5.8.0 + * * @param array $attributes Block attributes. * @param string $content Block default content. * @param WP_Block $block Block instance. @@ -72,6 +74,8 @@ function render_block_core_query_pagination_previous( $attributes, $content, $bl /** * Registers the `core/query-pagination-previous` block on the server. + * + * @since 5.8.0 */ function register_block_core_query_pagination_previous() { register_block_type_from_metadata( diff --git a/packages/block-library/src/query-pagination/index.php b/packages/block-library/src/query-pagination/index.php index 9b7289ec22e0fa..acafe968c0bec2 100644 --- a/packages/block-library/src/query-pagination/index.php +++ b/packages/block-library/src/query-pagination/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/query-pagination` block on the server. * + * @since 5.9.0 + * * @param array $attributes Block attributes. * @param string $content Block default content. * @@ -35,6 +37,8 @@ function render_block_core_query_pagination( $attributes, $content ) { /** * Registers the `core/query-pagination` block on the server. + * + * @since 5.8.0 */ function register_block_core_query_pagination() { register_block_type_from_metadata( diff --git a/packages/block-library/src/query-title/index.php b/packages/block-library/src/query-title/index.php index 29793e5227a79f..88a945535a22d9 100644 --- a/packages/block-library/src/query-title/index.php +++ b/packages/block-library/src/query-title/index.php @@ -10,6 +10,8 @@ * For now it only supports Archive title, * using queried object information * + * @since 5.8.0 + * * @param array $attributes Block attributes. * * @return string Returns the query title based on the queried object. @@ -60,6 +62,8 @@ function render_block_core_query_title( $attributes ) { /** * Registers the `core/query-title` block on the server. + * + * @since 5.8.0 */ function register_block_core_query_title() { register_block_type_from_metadata( diff --git a/packages/block-library/src/query/index.php b/packages/block-library/src/query/index.php index b6c34eb71d0703..c9f9d1ab9431fb 100644 --- a/packages/block-library/src/query/index.php +++ b/packages/block-library/src/query/index.php @@ -77,6 +77,8 @@ function render_block_core_query( $attributes, $content, $block ) { /** * Registers the `core/query` block on the server. + * + * @since 5.8.0 */ function register_block_core_query() { register_block_type_from_metadata( diff --git a/packages/block-library/src/read-more/index.php b/packages/block-library/src/read-more/index.php index c59dd2bf3d408c..c01a0a377fc938 100644 --- a/packages/block-library/src/read-more/index.php +++ b/packages/block-library/src/read-more/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/read-more` block on the server. * + * @since 6.0.0 + * * @param array $attributes Block attributes. * @param string $content Block default content. * @param WP_Block $block Block instance. @@ -47,6 +49,8 @@ function render_block_core_read_more( $attributes, $content, $block ) { /** * Registers the `core/read-more` block on the server. + * + * @since 6.0.0 */ function register_block_core_read_more() { register_block_type_from_metadata( diff --git a/packages/block-library/src/rss/index.php b/packages/block-library/src/rss/index.php index 91cdab3f589e06..3e8231d259e700 100644 --- a/packages/block-library/src/rss/index.php +++ b/packages/block-library/src/rss/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/rss` block on server. * + * @since 5.2.0 + * * @param array $attributes The block attributes. * * @return string Returns the block content with received rss items. @@ -107,6 +109,8 @@ function render_block_core_rss( $attributes ) { /** * Registers the `core/rss` block on server. + * + * @since 5.2.0 */ function register_block_core_rss() { register_block_type_from_metadata( diff --git a/packages/block-library/src/search/index.php b/packages/block-library/src/search/index.php index ca8c70edfa907d..9d4c61f4163127 100644 --- a/packages/block-library/src/search/index.php +++ b/packages/block-library/src/search/index.php @@ -207,6 +207,8 @@ function render_block_core_search( $attributes ) { /** * Registers the `core/search` block on the server. + * + * @since 5.2.0 */ function register_block_core_search() { register_block_type_from_metadata( @@ -221,6 +223,8 @@ function register_block_core_search() { /** * Builds the correct top level classnames for the 'core/search' block. * + * @since 5.6.0 + * * @param array $attributes The block attributes. * * @return string The classnames used in the block. @@ -265,6 +269,8 @@ function classnames_for_block_core_search( $attributes ) { * or not, the generated rule is injected into the appropriate collection of * styles for later application in the block's markup. * + * @since 6.1.0 + * * @param array $attributes The block attributes. * @param string $property Border property to generate rule for e.g. width or color. * @param string $side Optional side border. The dictates the value retrieved and final CSS property. @@ -310,6 +316,8 @@ function apply_block_core_search_border_style( $attributes, $property, $side, &$ * injects rules into the provided wrapper, button and input style arrays for * uniform "flat" borders or those with individual sides configured. * + * @since 6.1.0 + * * @param array $attributes The block attributes. * @param string $property Border property to generate rule for e.g. width or color. * @param array $wrapper_styles Current collection of wrapper styles. @@ -331,6 +339,8 @@ function apply_block_core_search_border_styles( $attributes, $property, &$wrappe * inner input or button and a second for the inner wrapper should the block * be positioning the button "inside". * + * @since 5.8.0 + * * @param array $attributes The block attributes. * * @return array Style HTML attribute. @@ -457,7 +467,9 @@ function styles_for_block_core_search( $attributes ) { } /** - * Returns typography classnames depending on whether there are named font sizes/families . + * Returns typography classnames depending on whether there are named font sizes/families. + * + * @since 6.1.0 * * @param array $attributes The block attributes. * @@ -483,6 +495,8 @@ function get_typography_classes_for_block_core_search( $attributes ) { * Returns typography styles to be included in an HTML style tag. * This excludes text-decoration, which is applied only to the label and button elements of the search block. * + * @since 6.1.0 + * * @param array $attributes The block attributes. * * @return string A string of typography CSS declarations. @@ -533,6 +547,8 @@ function get_typography_styles_for_block_core_search( $attributes ) { /** * Returns border color classnames depending on whether there are named or custom border colors. * + * @since 5.9.0 + * * @param array $attributes The block attributes. * * @return string The border color classnames to be applied to the block elements. @@ -556,6 +572,8 @@ function get_border_color_classes_for_block_core_search( $attributes ) { /** * Returns color classnames depending on whether there are named or custom text and background colors. * + * @since 5.9.0 + * * @param array $attributes The block attributes. * * @return string The color classnames to be applied to the block elements. diff --git a/packages/block-library/src/shortcode/index.php b/packages/block-library/src/shortcode/index.php index 97a40b386d9c92..d96acfc55fa64d 100644 --- a/packages/block-library/src/shortcode/index.php +++ b/packages/block-library/src/shortcode/index.php @@ -8,6 +8,8 @@ /** * Performs wpautop() on the shortcode block content. * + * @since 5.0.0 + * * @param array $attributes The block attributes. * @param string $content The block content. * @@ -19,6 +21,8 @@ function render_block_core_shortcode( $attributes, $content ) { /** * Registers the `core/shortcode` block on server. + * + * @since 5.0.0 */ function register_block_core_shortcode() { register_block_type_from_metadata( diff --git a/packages/block-library/src/site-logo/index.php b/packages/block-library/src/site-logo/index.php index f1819fcaac8d03..f82644e4b91889 100644 --- a/packages/block-library/src/site-logo/index.php +++ b/packages/block-library/src/site-logo/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/site-logo` block on the server. * + * @since 5.8.0 + * * @param array $attributes The block attributes. * * @return string The render. @@ -60,6 +62,8 @@ function render_block_core_site_logo( $attributes ) { /** * Register a core site setting for a site logo + * + * @since 5.8.0 */ function register_block_core_site_logo_setting() { register_setting( @@ -79,6 +83,8 @@ function register_block_core_site_logo_setting() { /** * Register a core site setting for a site icon + * + * @since 5.9.0 */ function register_block_core_site_icon_setting() { register_setting( @@ -96,6 +102,8 @@ function register_block_core_site_icon_setting() { /** * Registers the `core/site-logo` block on the server. + * + * @since 5.8.0 */ function register_block_core_site_logo() { register_block_type_from_metadata( @@ -111,6 +119,8 @@ function register_block_core_site_logo() { /** * Overrides the custom logo with a site logo, if the option is set. * + * @since 5.8.0 + * * @param string $custom_logo The custom logo set by a theme. * * @return string The site logo if set. @@ -125,6 +135,8 @@ function _override_custom_logo_theme_mod( $custom_logo ) { /** * Updates the site_logo option when the custom_logo theme-mod gets updated. * + * @since 5.8.0 + * * @param mixed $value Attachment ID of the custom logo or an empty value. * @return mixed */ @@ -143,6 +155,8 @@ function _sync_custom_logo_to_site_logo( $value ) { /** * Deletes the site_logo when the custom_logo theme mod is removed. * + * @since 5.8.0 + * * @param array $old_value Previous theme mod settings. * @param array $value Updated theme mod settings. */ @@ -161,6 +175,8 @@ function _delete_site_logo_on_remove_custom_logo( $old_value, $value ) { /** * Deletes the site logo when all theme mods are being removed. + * + * @since 5.8.0 */ function _delete_site_logo_on_remove_theme_mods() { global $_ignore_site_logo_changes; @@ -179,6 +195,8 @@ function _delete_site_logo_on_remove_theme_mods() { * Hooks `_delete_site_logo_on_remove_theme_mods` in `delete_option_theme_mods_$theme`. * * Runs on `setup_theme` to account for dynamically-switched themes in the Customizer. + * + * @since 5.8.0 */ function _delete_site_logo_on_remove_custom_logo_on_setup_theme() { $theme = get_option( 'stylesheet' ); @@ -189,6 +207,8 @@ function _delete_site_logo_on_remove_custom_logo_on_setup_theme() { /** * Removes the custom_logo theme-mod when the site_logo option gets deleted. + * + * @since 5.9.0 */ function _delete_custom_logo_on_remove_site_logo() { global $_ignore_site_logo_changes; diff --git a/packages/block-library/src/site-tagline/index.php b/packages/block-library/src/site-tagline/index.php index 75375e5bb1e792..840ba79762ce5f 100644 --- a/packages/block-library/src/site-tagline/index.php +++ b/packages/block-library/src/site-tagline/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/site-tagline` block on the server. * + * @since 5.8.0 + * * @param array $attributes The block attributes. * * @return string The render. @@ -29,6 +31,8 @@ function render_block_core_site_tagline( $attributes ) { /** * Registers the `core/site-tagline` block on the server. + * + * @since 5.8.0 */ function register_block_core_site_tagline() { register_block_type_from_metadata( diff --git a/packages/block-library/src/site-title/index.php b/packages/block-library/src/site-title/index.php index 255615b3a4e450..f90c3a6ac3a6a0 100644 --- a/packages/block-library/src/site-title/index.php +++ b/packages/block-library/src/site-title/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/site-title` block on the server. * + * @since 5.8.0 + * * @param array $attributes The block attributes. * * @return string The render. @@ -53,6 +55,8 @@ function render_block_core_site_title( $attributes ) { /** * Registers the `core/site-title` block on the server. + * + * @since 5.8.0 */ function register_block_core_site_title() { register_block_type_from_metadata( diff --git a/packages/block-library/src/social-link/index.php b/packages/block-library/src/social-link/index.php index a297e0b84f525f..ccde6acfef3c6a 100644 --- a/packages/block-library/src/social-link/index.php +++ b/packages/block-library/src/social-link/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/social-link` block on server. * + * @since 5.4.0 + * * @param Array $attributes The block attributes. * @param String $content InnerBlocks content of the Block. * @param WP_Block $block Block object. @@ -72,6 +74,8 @@ function render_block_core_social_link( $attributes, $content, $block ) { /** * Registers the `core/social-link` blocks. + * + * @since 5.4.0 */ function register_block_core_social_link() { register_block_type_from_metadata( @@ -87,6 +91,8 @@ function register_block_core_social_link() { /** * Returns the SVG for social link. * + * @since 5.4.0 + * * @param string $service The service icon. * * @return string SVG Element for service icon. @@ -103,6 +109,8 @@ function block_core_social_link_get_icon( $service ) { /** * Returns the brand name for social link. * + * @since 5.4.0 + * * @param string $service The service icon. * * @return string Brand label. @@ -119,6 +127,8 @@ function block_core_social_link_get_name( $service ) { /** * Returns the SVG for social link. * + * @since 5.4.0 + * * @param string $service The service slug to extract data from. * @param string $field The field ('name', 'icon', etc) to extract for a service. * @@ -332,6 +342,8 @@ function block_core_social_link_services( $service = '', $field = '' ) { /** * Returns CSS styles for icon and icon background colors. * + * @since 5.7.0 + * * @param array $context Block context passed to Social Link. * * @return string Inline CSS styles for link's icon and background colors. @@ -353,6 +365,8 @@ function block_core_social_link_get_color_styles( $context ) { /** * Returns CSS classes for icon and icon background colors. * + * @since 6.3.0 + * * @param array $context Block context passed to Social Sharing Link. * * @return string CSS classes for link's icon and background colors. diff --git a/packages/block-library/src/tag-cloud/index.php b/packages/block-library/src/tag-cloud/index.php index 7ff5f78400db64..69b8c25ec87209 100644 --- a/packages/block-library/src/tag-cloud/index.php +++ b/packages/block-library/src/tag-cloud/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/tag-cloud` block on server. * + * @since 5.2.0 + * * @param array $attributes The block attributes. * * @return string Returns the tag cloud for selected taxonomy. @@ -42,6 +44,8 @@ function render_block_core_tag_cloud( $attributes ) { /** * Registers the `core/tag-cloud` block on server. + * + * @since 5.2.0 */ function register_block_core_tag_cloud() { register_block_type_from_metadata( diff --git a/packages/block-library/src/template-part/index.php b/packages/block-library/src/template-part/index.php index 8c01c5a4bc5d9f..435fa02dbb8d9b 100644 --- a/packages/block-library/src/template-part/index.php +++ b/packages/block-library/src/template-part/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/template-part` block on the server. * + * @since 5.9.0 + * * @param array $attributes The block attributes. * * @return string The render. @@ -174,6 +176,8 @@ function render_block_core_template_part( $attributes ) { /** * Returns an array of area variation objects for the template part block. * + * @since 6.1.0 + * * @param array $instance_variations The variations for instances. * * @return array Array containing the block variation objects. @@ -212,6 +216,8 @@ function build_template_part_block_area_variations( $instance_variations ) { /** * Returns an array of instance variation objects for the template part block * + * @since 6.1.0 + * * @return array Array containing the block variation objects. */ function build_template_part_block_instance_variations() { @@ -266,6 +272,8 @@ function build_template_part_block_instance_variations() { /** * Returns an array of all template part block variations. * + * @since 5.9.0 + * * @return array Array containing the block variation objects. */ function build_template_part_block_variations() { @@ -276,6 +284,8 @@ function build_template_part_block_variations() { /** * Registers the `core/template-part` block on the server. + * + * @since 5.9.0 */ function register_block_core_template_part() { register_block_type_from_metadata( diff --git a/packages/block-library/src/term-description/index.php b/packages/block-library/src/term-description/index.php index 011ec28f2e5e63..925b37f34f98a8 100644 --- a/packages/block-library/src/term-description/index.php +++ b/packages/block-library/src/term-description/index.php @@ -8,6 +8,8 @@ /** * Renders the `core/term-description` block on the server. * + * @since 5.9.0 + * * @param array $attributes Block attributes. * * @return string Returns the description of the current taxonomy term, if available @@ -37,6 +39,8 @@ function render_block_core_term_description( $attributes ) { /** * Registers the `core/term-description` block on the server. + * + * @since 5.9.0 */ function register_block_core_term_description() { register_block_type_from_metadata( diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 279ed611bf4bd6..63fa5373c1c138 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -172,4 +172,8 @@ </property> </properties> </rule> + <rule ref="Gutenberg.Commenting.FunctionCommentSinceTag"> + <!-- The sniff ensures that functions have a valid @since tag but skips checking experimental blocks. --> + <include-pattern>/packages/block-library/src/.+/*\.php$</include-pattern> + </rule> </ruleset> diff --git a/test/php/gutenberg-coding-standards/Gutenberg/Sniffs/Commenting/FunctionCommentSinceTagSniff.php b/test/php/gutenberg-coding-standards/Gutenberg/Sniffs/Commenting/FunctionCommentSinceTagSniff.php new file mode 100644 index 00000000000000..54b8b367560fc5 --- /dev/null +++ b/test/php/gutenberg-coding-standards/Gutenberg/Sniffs/Commenting/FunctionCommentSinceTagSniff.php @@ -0,0 +1,162 @@ +<?php +/** + * Gutenberg Coding Standards. + * + * @package gutenberg/gutenberg-coding-standards + * @link https://github.com/WordPress/gutenberg + * @license https://opensource.org/licenses/MIT MIT + */ + +namespace GutenbergCS\Gutenberg\Sniffs\Commenting; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Util\Tokens; + +/** + * This sniff ensures that PHP functions have a valid `@since` tag in the docblock. + * The sniff skips checking files in __experimental block-library blocks. + */ +class FunctionCommentSinceTagSniff implements Sniff { + + /** + * This property is used to store results returned + * by the static::is_experimental_block() method. + * + * @var array + */ + private static $cache = array(); + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array<int|string> + */ + public function register() { + return array( T_FUNCTION ); + } + + /** + * Processes the tokens that this sniff is interested in. + * + * @param File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token in the stack passed in $tokens. + */ + public function process( File $phpcsFile, $stackPtr ) { + if ( static::is_experimental_block( $phpcsFile ) ) { + // The "@since" tag is not required for experimental blocks since they are not yet included in WordPress Core. + return; + } + + $tokens = $phpcsFile->getTokens(); + $function_name = $phpcsFile->getDeclarationName( $stackPtr ); + + $wrapping_tokens_to_check = array( + T_CLASS, + T_INTERFACE, + T_TRAIT, + ); + + foreach ( $wrapping_tokens_to_check as $wrapping_token_to_check ) { + if ( false !== $phpcsFile->getCondition( $stackPtr, $wrapping_token_to_check, false ) ) { + // This sniff only processes functions, not class methods. + return; + } + } + + $missing_since_tag_error_message = sprintf( '@since tag is missing for the "%s()" function.', $function_name ); + + // All these tokens could be present before the docblock. + $tokens_before_the_docblock = array( + T_PUBLIC, + T_PROTECTED, + T_PRIVATE, + T_STATIC, + T_FINAL, + T_ABSTRACT, + T_WHITESPACE, + ); + + $doc_block_end_token = $phpcsFile->findPrevious( $tokens_before_the_docblock, ( $stackPtr - 1 ), null, true, null, true ); + if ( ( false === $doc_block_end_token ) || ( T_DOC_COMMENT_CLOSE_TAG !== $tokens[ $doc_block_end_token ]['code'] ) ) { + $phpcsFile->addError( $missing_since_tag_error_message, $stackPtr, 'MissingSinceTag' ); + return; + } + + // The sniff intentionally doesn't check if the docblock has a valid open tag. + // Its only job is to make sure that the @since tag is present and has a valid version value. + $doc_block_start_token = $phpcsFile->findPrevious( Tokens::$commentTokens, ( $doc_block_end_token - 1 ), null, true, null, true ); + if ( false === $doc_block_start_token ) { + $phpcsFile->addError( $missing_since_tag_error_message, $stackPtr, 'MissingSinceTag' ); + return; + } + + // This is the first non-docblock token, so the next token should be used. + ++$doc_block_start_token; + + $since_tag_token = $phpcsFile->findNext( T_DOC_COMMENT_TAG, $doc_block_start_token, $doc_block_end_token, false, '@since', true ); + if ( false === $since_tag_token ) { + $phpcsFile->addError( $missing_since_tag_error_message, $stackPtr, 'MissingSinceTag' ); + return; + } + + $version_token = $phpcsFile->findNext( T_DOC_COMMENT_WHITESPACE, $since_tag_token + 1, null, true, null, true ); + if ( ( false === $version_token ) || ( T_DOC_COMMENT_STRING !== $tokens[ $version_token ]['code'] ) ) { + $phpcsFile->addError( $missing_since_tag_error_message, $since_tag_token, 'MissingSinceTag' ); + return; + } + + $version_value = $tokens[ $version_token ]['content']; + + if ( version_compare( $version_value, '0.0.1', '>=' ) ) { + // Validate the version value. + return; + } + + $phpcsFile->addError( + 'Invalid @since version value for the "%s()" function: "%s". Version value must be greater than or equal to 0.0.1.', + $version_token, + 'InvalidSinceTagVersionValue', + array( + $function_name, + $version_value, + ) + ); + } + + /** + * Checks if the current block is experimental. + * + * @param File $phpcsFile The file being scanned. + * @return bool Returns true if the current block is experimental. + */ + private static function is_experimental_block( File $phpcsFile ) { + $block_json_filepath = dirname( $phpcsFile->getFilename() ) . DIRECTORY_SEPARATOR . 'block.json'; + + if ( isset( static::$cache[ $block_json_filepath ] ) ) { + return static::$cache[ $block_json_filepath ]; + } + + if ( ! is_file( $block_json_filepath ) || ! is_readable( $block_json_filepath ) ) { + static::$cache[ $block_json_filepath ] = false; + return static::$cache[ $block_json_filepath ]; + } + + // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- this Composer package doesn't depend on WordPress. + $block_metadata = file_get_contents( $block_json_filepath ); + if ( false === $block_metadata ) { + static::$cache[ $block_json_filepath ] = false; + return static::$cache[ $block_json_filepath ]; + } + + $block_metadata = json_decode( $block_metadata, true ); + if ( ! is_array( $block_metadata ) ) { + static::$cache[ $block_json_filepath ] = false; + return static::$cache[ $block_json_filepath ]; + } + + $experimental_flag = '__experimental'; + static::$cache[ $block_json_filepath ] = array_key_exists( $experimental_flag, $block_metadata ) && ( false !== $block_metadata[ $experimental_flag ] ); + return static::$cache[ $block_json_filepath ]; + } +} diff --git a/test/php/gutenberg-coding-standards/Gutenberg/Tests/Commenting/FunctionCommentSinceTagUnitTest.inc b/test/php/gutenberg-coding-standards/Gutenberg/Tests/Commenting/FunctionCommentSinceTagUnitTest.inc new file mode 100644 index 00000000000000..43d11694bb25eb --- /dev/null +++ b/test/php/gutenberg-coding-standards/Gutenberg/Tests/Commenting/FunctionCommentSinceTagUnitTest.inc @@ -0,0 +1,39 @@ +<?php +/** + * @since 1.2.3 + */ +function foo() { +} + +/** + * @since invalid value + */ +function bar() { +} + +$result = array_map( function ( $value ) { + return $value * 2; // Doubling each value +}, array( 1, 2, 3, 4, 5 ) ); + +/** + * @since 0.0 + */ +function qux() { +} + +function spam() { +} + +class Foo { + public function bar() { + } +} + +interface Bar { + public function bar(); +} + +trait Baz { + public function bar() { + } +} diff --git a/test/php/gutenberg-coding-standards/Gutenberg/Tests/Commenting/FunctionCommentSinceTagUnitTest.php b/test/php/gutenberg-coding-standards/Gutenberg/Tests/Commenting/FunctionCommentSinceTagUnitTest.php new file mode 100644 index 00000000000000..b41e794d072fd3 --- /dev/null +++ b/test/php/gutenberg-coding-standards/Gutenberg/Tests/Commenting/FunctionCommentSinceTagUnitTest.php @@ -0,0 +1,42 @@ +<?php +/** + * Unit test class for Gutenberg Coding Standard. + * + * @package gutenberg-coding-standards/gbc + * @link https://github.com/WordPress/gutenberg + * @license https://opensource.org/licenses/MIT MIT + */ + +namespace GutenbergCS\Gutenberg\Tests\Commenting; + +use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +use PHP_CodeSniffer\Ruleset; + +/** + * Unit test class for the FunctionCommentSinceTagSniff sniff. + */ +final class FunctionCommentSinceTagUnitTest extends AbstractSniffUnitTest { + + /** + * Returns the lines where errors should occur. + * + * @return array <int line number> => <int number of errors> + */ + public function getErrorList() { + // The sniff only supports PHP functions for now; it ignores class, trait, and interface methods. + return array( + 9 => 1, + 19 => 1, + 24 => 1, + ); + } + + /** + * Returns the lines where warnings should occur. + * + * @return array <int line number> => <int number of warnings> + */ + public function getWarningList() { + return array(); + } +} From fde2dd507d97e61f90ee454745b17855cdbe0309 Mon Sep 17 00:00:00 2001 From: David Calhoun <github@davidcalhoun.me> Date: Wed, 13 Mar 2024 14:44:39 -0400 Subject: [PATCH 09/21] build: Improve iOS Demo app build configuration (#59791) * build: Remove unused package script This script is not references anywhere and likely is now unnecessary given the current Xcode version is Xcore 14. https://github.com/wordpress-mobile/gutenberg-mobile/commit/16c6a60cda841747c8859f70a8cf3a02e480518d * build: Address iOS Demo app build warnings The `$(inherited)` value was added to address the following warnings. The additional `swift` path was added during subsequent app builds. ``` [!] The `GutenbergDemo [Debug]` target overrides the `LIBRARY_SEARCH_PATHS` build setting defined in `Pods/Target Support Files/Pods-GutenbergDemo/Pods-GutenbergDemo.debug.xcconfig'. This can lead to problems with the CocoaPods installation - Use the `$(inherited)` flag, or - Remove the build settings from the target. [!] The `GutenbergDemo [Release]` target overrides the `LIBRARY_SEARCH_PATHS` build setting defined in `Pods/Target Support Files/Pods-GutenbergDemo/Pods-GutenbergDemo.release.xcconfig'. This can lead to problems with the CocoaPods installation - Use the `$(inherited)` flag, or - Remove the build settings from the target. ``` --- .../ios/GutenbergDemo.xcodeproj/project.pbxproj | 12 ++++++++++-- packages/react-native-editor/package.json | 1 - 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/react-native-editor/ios/GutenbergDemo.xcodeproj/project.pbxproj b/packages/react-native-editor/ios/GutenbergDemo.xcodeproj/project.pbxproj index d030a192e1afd1..4b6938198c9423 100644 --- a/packages/react-native-editor/ios/GutenbergDemo.xcodeproj/project.pbxproj +++ b/packages/react-native-editor/ios/GutenbergDemo.xcodeproj/project.pbxproj @@ -617,7 +617,11 @@ INFOPLIST_FILE = GutenbergDemo/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - LIBRARY_SEARCH_PATHS = "$(SDKROOT)/usr/lib/swift$(PROJECT_DIR)"; + LIBRARY_SEARCH_PATHS = ( + "$(SDKROOT)/usr/lib/swift", + "$(inherited)", + "$(SDKROOT)/usr/lib/swift$(PROJECT_DIR)", + ); MARKETING_VERSION = 1.0; OTHER_LDFLAGS = ( "$(inherited)", @@ -651,7 +655,11 @@ INFOPLIST_FILE = GutenbergDemo/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - LIBRARY_SEARCH_PATHS = "$(SDKROOT)/usr/lib/swift$(PROJECT_DIR)"; + LIBRARY_SEARCH_PATHS = ( + "$(SDKROOT)/usr/lib/swift", + "$(inherited)", + "$(SDKROOT)/usr/lib/swift$(PROJECT_DIR)", + ); MARKETING_VERSION = 1.0; OTHER_LDFLAGS = ( "$(inherited)", diff --git a/packages/react-native-editor/package.json b/packages/react-native-editor/package.json index a8c4f0fd2d4bf8..38d973b0a62abc 100644 --- a/packages/react-native-editor/package.json +++ b/packages/react-native-editor/package.json @@ -100,7 +100,6 @@ "preios": "cd ios && (bundle check > /dev/null || bundle install) && bundle exec pod install --repo-update", "preios:carthage": "cd ../react-native-aztec && npm run install-aztec-ios", "preios:carthage:update": "cd ../react-native-aztec && npm run update-aztec-ios", - "preios:xcode10": "cd ../../node_modules/react-native && ./scripts/ios-install-third-party.sh && cd third-party/glog-0.3.5 && [ -f libglog.pc ] || ../../scripts/ios-configure-glog.sh", "ios": "react-native run-ios", "ios:fast": "react-native run-ios", "device-tests": "cross-env NODE_ENV=test jest --forceExit --detectOpenHandles --no-cache --maxWorkers=3 --testPathIgnorePatterns='canary|gutenberg-editor-rendering' --config ./jest_ui.config.js", From b4017dc5486af868de189c1284a7ea72014257dd Mon Sep 17 00:00:00 2001 From: Siobhan Bamber <siobhan@automattic.com> Date: Wed, 13 Mar 2024 21:21:41 +0000 Subject: [PATCH 10/21] [RNMobile] Prevent `react-native-video` crash that happens when an `src` changes quickly after first being set (#59841) Unlinked contributors: crazytonyli. Co-authored-by: SiobhyB <siobhyb@git.wordpress.org> Co-authored-by: jhnstn <jsnjohnston@git.wordpress.org> Co-authored-by: staskus <povilasstaskus@git.wordpress.org> --- packages/block-library/src/video/edit.native.js | 2 ++ packages/react-native-editor/CHANGELOG.md | 1 + 2 files changed, 3 insertions(+) diff --git a/packages/block-library/src/video/edit.native.js b/packages/block-library/src/video/edit.native.js index ffa6c80d60569c..f6960f0888617d 100644 --- a/packages/block-library/src/video/edit.native.js +++ b/packages/block-library/src/video/edit.native.js @@ -290,8 +290,10 @@ class VideoEdit extends Component { } ) => { const showVideo = isURL( src ) && + getProtocol( attributes.src ) !== 'file:' && ! isUploadInProgress && ! isUploadFailed; + const icon = this.getIcon( isUploadFailed ? ICON_TYPE.RETRY diff --git a/packages/react-native-editor/CHANGELOG.md b/packages/react-native-editor/CHANGELOG.md index a7980626ac3946..70c636da4dccbd 100644 --- a/packages/react-native-editor/CHANGELOG.md +++ b/packages/react-native-editor/CHANGELOG.md @@ -14,6 +14,7 @@ For each user feature we should also add a importance categorization label to i - [*] Gallery block items with in-progress, paused, or failed media uploads correctly display an highlight outline when selected [#59423] - [**] [internal] Upgrade React Native to version 0.73.3 [#58475] - [**] Add error boundary components and exception logging [#59221] +- [**] Fix crash occurring when the URL associated with a Video block is changed too quickly [#59841] ## 1.114.1 - [**] Fix a crash produced when the content of a synced pattern is updated [#59632] From 641a40741f60668ea51fc632cbc09335ddf4e0ee Mon Sep 17 00:00:00 2001 From: Jerry Jones <jones.jeremydavid@gmail.com> Date: Wed, 13 Mar 2024 17:25:03 -0500 Subject: [PATCH 11/21] Close navigation link ui on escape (#59838) --- packages/block-library/src/navigation-link/edit.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/block-library/src/navigation-link/edit.js b/packages/block-library/src/navigation-link/edit.js index e091b52c68a5c4..afac50a5d4d75d 100644 --- a/packages/block-library/src/navigation-link/edit.js +++ b/packages/block-library/src/navigation-link/edit.js @@ -570,6 +570,7 @@ export default function NavigationLinkEdit( { // Need to handle refocusing the Nav block or the inserter? onReplace( [] ); } + setIsLinkOpen( false ); } } anchor={ popoverAnchor } onRemove={ removeLink } From 43169696cbbfb6fce623f6fd3e02cdd1921e63b2 Mon Sep 17 00:00:00 2001 From: Jerry Jones <jones.jeremydavid@gmail.com> Date: Wed, 13 Mar 2024 17:25:21 -0500 Subject: [PATCH 12/21] Prevent default on primary+k to prevent command center from opening (#59845) The command center shortcut checks for defaultPrevented to see if it should open or not. To prevent the command center from opening, we need to add event.preventDefault when primary+k is used. --- packages/block-library/src/navigation-link/edit.js | 1 + packages/block-library/src/navigation-submenu/edit.js | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/block-library/src/navigation-link/edit.js b/packages/block-library/src/navigation-link/edit.js index afac50a5d4d75d..e2a18c4bec8d23 100644 --- a/packages/block-library/src/navigation-link/edit.js +++ b/packages/block-library/src/navigation-link/edit.js @@ -333,6 +333,7 @@ export default function NavigationLinkEdit( { isKeyboardEvent.primary( event, 'k' ) || ( ( ! url || isDraft || isInvalid ) && event.keyCode === ENTER ) ) { + event.preventDefault(); setIsLinkOpen( true ); } } diff --git a/packages/block-library/src/navigation-submenu/edit.js b/packages/block-library/src/navigation-submenu/edit.js index 507ea64940c3a6..401d9512797b09 100644 --- a/packages/block-library/src/navigation-submenu/edit.js +++ b/packages/block-library/src/navigation-submenu/edit.js @@ -279,6 +279,7 @@ export default function NavigationSubmenuEdit( { function onKeyDown( event ) { if ( isKeyboardEvent.primary( event, 'k' ) ) { + event.preventDefault(); setIsLinkOpen( true ); } } From 01eb7eb138f7762145b99111134ed31d6ee454a3 Mon Sep 17 00:00:00 2001 From: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> Date: Thu, 14 Mar 2024 11:14:16 +1000 Subject: [PATCH 13/21] Global Styles: Fix retrieval of referenced preset values in editor (#59811) --- .../test/use-global-styles-output.js | 31 +++++++++++++++++++ .../global-styles/use-global-styles-output.js | 4 ++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/packages/block-editor/src/components/global-styles/test/use-global-styles-output.js b/packages/block-editor/src/components/global-styles/test/use-global-styles-output.js index f7655f099544a3..aa161388e7066b 100644 --- a/packages/block-editor/src/components/global-styles/test/use-global-styles-output.js +++ b/packages/block-editor/src/components/global-styles/test/use-global-styles-output.js @@ -968,6 +968,37 @@ describe( 'global styles renderer', () => { 'font-size: 15px', ] ); } ); + + it( 'should correctly resolve referenced values', () => { + const stylesWithRef = { + typography: { + fontSize: { + ref: 'styles.elements.h1.typography.fontSize', + }, + letterSpacing: { + ref: 'styles.elements.h1.typography.letterSpacing', + }, + }, + }; + const tree = { + styles: { + elements: { + h1: { + typography: { + fontSize: 'var:preset|font-size|xx-large', + letterSpacing: '2px', + }, + }, + }, + }, + }; + expect( + getStylesDeclarations( stylesWithRef, '.wp-block', false, tree ) + ).toEqual( [ + 'font-size: var(--wp--preset--font-size--xx-large)', + 'letter-spacing: 2px', + ] ); + } ); } ); describe( 'processCSSNesting', () => { diff --git a/packages/block-editor/src/components/global-styles/use-global-styles-output.js b/packages/block-editor/src/components/global-styles/use-global-styles-output.js index e752b49efeb9cd..ad7d33bcb779ae 100644 --- a/packages/block-editor/src/components/global-styles/use-global-styles-output.js +++ b/packages/block-editor/src/components/global-styles/use-global-styles-output.js @@ -409,7 +409,9 @@ export function getStylesDeclarations( let ruleValue = rule.value; if ( typeof ruleValue !== 'string' && ruleValue?.ref ) { const refPath = ruleValue.ref.split( '.' ); - ruleValue = getValueFromObjectPath( tree, refPath ); + ruleValue = compileStyleValue( + getValueFromObjectPath( tree, refPath ) + ); // Presence of another ref indicates a reference to another dynamic value. // Pointing to another dynamic value is not supported. if ( ! ruleValue || ruleValue?.ref ) { From 9c213e9aa5e504e7f5131f89eb7269e8942abfe1 Mon Sep 17 00:00:00 2001 From: Robert Anderson <robert@noisysocks.com> Date: Thu, 14 Mar 2024 13:05:34 +1100 Subject: [PATCH 14/21] Add Column Start and Row Start controls to Grid children (#59483) * Separate flex child controls so each has its own reset. * Output grid-start styling * Add Column Start and Row Start controls to block inspector * Simplify php array access * Remove a few more issets * Adjust container query to take columnStart into account. * Reset grid spans together * Add max to column/row inputs * Adjust copy * Don't show Grid position by default * Use 'Grid placement' * Simplify input control labels for now * Put placement behind the Grid interactivity experimental flag for now * Fix input width issue in webkit * Show placement after span --------- Co-authored-by: tellthemachines <isabel@tellthemachines.com> Co-authored-by: tellthemachines <isabel_brison@git.wordpress.org> Co-authored-by: noisysocks <noisysocks@git.wordpress.org> Co-authored-by: andrewserong <andrewserong@git.wordpress.org> --- lib/block-supports/layout.php | 46 +++-- .../components/child-layout-control/index.js | 182 ++++++++++++++---- .../global-styles/dimensions-panel.js | 43 +---- .../block-editor/src/hooks/layout-child.js | 52 ++++- 4 files changed, 233 insertions(+), 90 deletions(-) diff --git a/lib/block-supports/layout.php b/lib/block-supports/layout.php index 30b5d8d02084a8..b53a90cde21855 100644 --- a/lib/block-supports/layout.php +++ b/lib/block-supports/layout.php @@ -581,28 +581,46 @@ function gutenberg_render_layout_support_flag( $block_content, $block ) { $child_layout_declarations['flex-grow'] = '1'; } - if ( isset( $block['attrs']['style']['layout']['columnSpan'] ) ) { - $column_span = $block['attrs']['style']['layout']['columnSpan']; + $column_start = isset( $block['attrs']['style']['layout']['columnStart'] ) ? $block['attrs']['style']['layout']['columnStart'] : null; + $column_span = isset( $block['attrs']['style']['layout']['columnSpan'] ) ? $block['attrs']['style']['layout']['columnSpan'] : null; + if ( $column_start && $column_span ) { + $child_layout_declarations['grid-column'] = "$column_start / span $column_span"; + } elseif ( $column_start ) { + $child_layout_declarations['grid-column'] = "$column_start"; + } elseif ( $column_span ) { $child_layout_declarations['grid-column'] = "span $column_span"; } - if ( isset( $block['attrs']['style']['layout']['rowSpan'] ) ) { - $row_span = $block['attrs']['style']['layout']['rowSpan']; + + $row_start = isset( $block['attrs']['style']['layout']['rowStart'] ) ? $block['attrs']['style']['layout']['rowStart'] : null; + $row_span = isset( $block['attrs']['style']['layout']['rowSpan'] ) ? $block['attrs']['style']['layout']['rowSpan'] : null; + if ( $row_start && $row_span ) { + $child_layout_declarations['grid-row'] = "$row_start / span $row_span"; + } elseif ( $row_start ) { + $child_layout_declarations['grid-row'] = "$row_start"; + } elseif ( $row_span ) { $child_layout_declarations['grid-row'] = "span $row_span"; } + $child_layout_styles[] = array( 'selector' => ".$container_content_class", 'declarations' => $child_layout_declarations, ); + $minimum_column_width = isset( $block['attrs']['style']['layout']['minimumColumnWidth'] ) ? $block['attrs']['style']['layout']['minimumColumnWidth'] : null; + $column_count = isset( $block['attrs']['style']['layout']['columnCount'] ) ? $block['attrs']['style']['layout']['columnCount'] : null; + /* - * If columnSpan is set, and the parent grid is responsive, i.e. if it has a minimumColumnWidth set, - * the columnSpan should be removed on small grids. If there's a minimumColumnWidth, the grid is responsive. - * But if the minimumColumnWidth value wasn't changed, it won't be set. In that case, if columnCount doesn't - * exist, we can assume that the grid is responsive. + * If columnSpan or columnStart is set, and the parent grid is responsive, i.e. if it has a minimumColumnWidth set, + * the columnSpan should be removed once the grid is smaller than the span, and columnStart should be removed + * once the grid has less columns than the start. + * If there's a minimumColumnWidth, the grid is responsive. But if the minimumColumnWidth value wasn't changed, it won't be set. + * In that case, if columnCount doesn't exist, we can assume that the grid is responsive. */ - if ( isset( $block['attrs']['style']['layout']['columnSpan'] ) && ( isset( $block['parentLayout']['minimumColumnWidth'] ) || ! isset( $block['parentLayout']['columnCount'] ) ) ) { - $column_span_number = floatval( $block['attrs']['style']['layout']['columnSpan'] ); - $parent_column_width = isset( $block['parentLayout']['minimumColumnWidth'] ) ? $block['parentLayout']['minimumColumnWidth'] : '12rem'; + if ( ( $column_span || $column_start ) && ( $minimum_column_width || ! $column_count ) ) { + $column_span_number = floatval( $column_span ); + $column_start_number = floatval( $column_start ); + $highest_number = max( $column_span_number, $column_start_number ); + $parent_column_width = $minimum_column_width ? $minimum_column_width : '12rem'; $parent_column_value = floatval( $parent_column_width ); $parent_column_unit = explode( $parent_column_value, $parent_column_width ); @@ -627,14 +645,16 @@ function gutenberg_render_layout_support_flag( $block_content, $block ) { * viable to use in the computation of the container query value. */ $default_gap_value = 'px' === $parent_column_unit ? 24 : 1.5; - $container_query_value = $column_span_number * $parent_column_value + ( $column_span_number - 1 ) * $default_gap_value; + $container_query_value = $highest_number * $parent_column_value + ( $highest_number - 1 ) * $default_gap_value; $container_query_value = $container_query_value . $parent_column_unit; + // If a span is set we want to preserve it as long as possible, otherwise we just reset the value. + $grid_column_value = $column_span ? '1/-1' : 'auto'; $child_layout_styles[] = array( 'rules_group' => "@container (max-width: $container_query_value )", 'selector' => ".$container_content_class", 'declarations' => array( - 'grid-column' => '1/-1', + 'grid-column' => $grid_column_value, ), ); } diff --git a/packages/block-editor/src/components/child-layout-control/index.js b/packages/block-editor/src/components/child-layout-control/index.js index fcdbc4369f33e9..e0af72c238ad53 100644 --- a/packages/block-editor/src/components/child-layout-control/index.js +++ b/packages/block-editor/src/components/child-layout-control/index.js @@ -7,6 +7,10 @@ import { __experimentalUnitControl as UnitControl, __experimentalInputControl as InputControl, __experimentalHStack as HStack, + __experimentalVStack as VStack, + __experimentalToolsPanelItem as ToolsPanelItem, + Flex, + FlexItem, } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; import { useEffect } from '@wordpress/element'; @@ -28,25 +32,62 @@ function helpText( selfStretch, parentLayout ) { /** * Form to edit the child layout value. * - * @param {Object} props Props. - * @param {Object} props.value The child layout value. - * @param {Function} props.onChange Function to update the child layout value. - * @param {Object} props.parentLayout The parent layout value. + * @param {Object} props Props. + * @param {Object} props.value The child layout value. + * @param {Function} props.onChange Function to update the child layout value. + * @param {Object} props.parentLayout The parent layout value. * + * @param {boolean} props.isShownByDefault + * @param {string} props.panelId * @return {Element} child layout edit element. */ export default function ChildLayoutControl( { value: childLayout = {}, onChange, parentLayout, + isShownByDefault, + panelId, } ) { - const { selfStretch, flexSize, columnSpan, rowSpan } = childLayout; + const { + selfStretch, + flexSize, + columnStart, + rowStart, + columnSpan, + rowSpan, + } = childLayout; const { type: parentType, default: { type: defaultParentType = 'default' } = {}, + orientation = 'horizontal', } = parentLayout ?? {}; const parentLayoutType = parentType || defaultParentType; + const hasFlexValue = () => !! selfStretch; + const flexResetLabel = + orientation === 'horizontal' ? __( 'Width' ) : __( 'Height' ); + const resetFlex = () => { + onChange( { + selfStretch: undefined, + flexSize: undefined, + } ); + }; + + const hasStartValue = () => !! columnStart || !! rowStart; + const hasSpanValue = () => !! columnSpan || !! rowSpan; + const resetGridStarts = () => { + onChange( { + columnStart: undefined, + rowStart: undefined, + } ); + }; + const resetGridSpans = () => { + onChange( { + columnSpan: undefined, + rowSpan: undefined, + } ); + }; + useEffect( () => { if ( selfStretch === 'fixed' && ! flexSize ) { onChange( { @@ -59,7 +100,15 @@ export default function ChildLayoutControl( { return ( <> { parentLayoutType === 'flex' && ( - <> + <VStack + as={ ToolsPanelItem } + spacing={ 2 } + hasValue={ hasFlexValue } + label={ flexResetLabel } + onDeselect={ resetFlex } + isShownByDefault={ isShownByDefault } + panelId={ panelId } + > <ToggleGroupControl __nextHasNoMarginBottom size={ '__unstable-large' } @@ -104,37 +153,100 @@ export default function ChildLayoutControl( { value={ flexSize } /> ) } - </> + </VStack> ) } { parentLayoutType === 'grid' && ( - <HStack> - <InputControl - size={ '__unstable-large' } - label={ __( 'Column Span' ) } - type="number" - onChange={ ( value ) => { - onChange( { - rowSpan, - columnSpan: value, - } ); - } } - value={ columnSpan } - min={ 1 } - /> - <InputControl - size={ '__unstable-large' } - label={ __( 'Row Span' ) } - type="number" - onChange={ ( value ) => { - onChange( { - columnSpan, - rowSpan: value, - } ); - } } - value={ rowSpan } - min={ 1 } - /> - </HStack> + <> + <HStack + as={ ToolsPanelItem } + hasValue={ hasSpanValue } + label={ __( 'Grid span' ) } + onDeselect={ resetGridSpans } + isShownByDefault={ isShownByDefault } + panelId={ panelId } + > + <InputControl + size={ '__unstable-large' } + label={ __( 'Column span' ) } + type="number" + onChange={ ( value ) => { + onChange( { + columnStart, + rowStart, + rowSpan, + columnSpan: value, + } ); + } } + value={ columnSpan } + min={ 1 } + /> + <InputControl + size={ '__unstable-large' } + label={ __( 'Row span' ) } + type="number" + onChange={ ( value ) => { + onChange( { + columnStart, + rowStart, + columnSpan, + rowSpan: value, + } ); + } } + value={ rowSpan } + min={ 1 } + /> + </HStack> + { window.__experimentalEnableGridInteractivity && ( + // Use Flex with an explicit width on the FlexItem instead of HStack to + // work around an issue in webkit where inputs with a max attribute are + // sized incorrectly. + <Flex + as={ ToolsPanelItem } + hasValue={ hasStartValue } + label={ __( 'Grid placement' ) } + onDeselect={ resetGridStarts } + isShownByDefault={ false } + panelId={ panelId } + > + <FlexItem style={ { width: '50%' } }> + <InputControl + size={ '__unstable-large' } + label={ __( 'Column' ) } + type="number" + onChange={ ( value ) => { + onChange( { + columnStart: value, + rowStart, + columnSpan, + rowSpan, + } ); + } } + value={ columnStart } + min={ 1 } + max={ parentLayout?.columnCount } + /> + </FlexItem> + <FlexItem style={ { width: '50%' } }> + <InputControl + size={ '__unstable-large' } + label={ __( 'Row' ) } + type="number" + onChange={ ( value ) => { + onChange( { + columnStart, + rowStart: value, + columnSpan, + rowSpan, + } ); + } } + value={ rowStart } + min={ 1 } + max={ parentLayout?.columnCount } + /> + </FlexItem> + </Flex> + ) } + </> ) } </> ); diff --git a/packages/block-editor/src/components/global-styles/dimensions-panel.js b/packages/block-editor/src/components/global-styles/dimensions-panel.js index 1386df0dfe2894..94e53eec163721 100644 --- a/packages/block-editor/src/components/global-styles/dimensions-panel.js +++ b/packages/block-editor/src/components/global-styles/dimensions-panel.js @@ -12,7 +12,6 @@ import { __experimentalToolsPanelItem as ToolsPanelItem, __experimentalBoxControl as BoxControl, __experimentalHStack as HStack, - __experimentalVStack as VStack, __experimentalUnitControl as UnitControl, __experimentalUseCustomUnits as useCustomUnits, __experimentalView as View, @@ -396,16 +395,7 @@ export default function DimensionsPanel( { // Child Layout const showChildLayoutControl = useHasChildLayout( settings ); const childLayout = inheritedValue?.layout; - const { orientation = 'horizontal' } = settings?.parentLayout ?? {}; - const { - type: parentType, - default: { type: defaultParentType = 'default' } = {}, - } = settings?.parentLayout ?? {}; - const parentLayoutType = parentType || defaultParentType; - const flexResetLabel = - orientation === 'horizontal' ? __( 'Width' ) : __( 'Height' ); - const childLayoutResetLabel = - parentLayoutType === 'flex' ? flexResetLabel : __( 'Grid spans' ); + const setChildLayout = ( newChildLayout ) => { onChange( { ...value, @@ -414,15 +404,6 @@ export default function DimensionsPanel( { }, } ); }; - const resetChildLayoutValue = () => { - setChildLayout( { - selfStretch: undefined, - flexSize: undefined, - columnSpan: undefined, - rowSpan: undefined, - } ); - }; - const hasChildLayoutValue = () => !! value?.layout; const resetAllFilter = useCallback( ( previousValue ) => { return { @@ -433,6 +414,8 @@ export default function DimensionsPanel( { wideSize: undefined, selfStretch: undefined, flexSize: undefined, + columnStart: undefined, + rowStart: undefined, columnSpan: undefined, rowSpan: undefined, } ), @@ -650,24 +633,16 @@ export default function DimensionsPanel( { </ToolsPanelItem> ) } { showChildLayoutControl && ( - <VStack - as={ ToolsPanelItem } - spacing={ 2 } - hasValue={ hasChildLayoutValue } - label={ childLayoutResetLabel } - onDeselect={ resetChildLayoutValue } + <ChildLayoutControl + value={ childLayout } + onChange={ setChildLayout } + parentLayout={ settings?.parentLayout } + panelId={ panelId } isShownByDefault={ defaultControls.childLayout ?? DEFAULT_CONTROLS.childLayout } - panelId={ panelId } - > - <ChildLayoutControl - value={ childLayout } - onChange={ setChildLayout } - parentLayout={ settings?.parentLayout } - /> - </VStack> + /> ) } { showMinHeightControl && ( <ToolsPanelItem diff --git a/packages/block-editor/src/hooks/layout-child.js b/packages/block-editor/src/hooks/layout-child.js index d8333e8e0e830f..4fa641bff203ae 100644 --- a/packages/block-editor/src/hooks/layout-child.js +++ b/packages/block-editor/src/hooks/layout-child.js @@ -17,7 +17,14 @@ function useBlockPropsChildLayoutStyles( { style } ) { return ! select( blockEditorStore ).getSettings().disableLayoutStyles; } ); const layout = style?.layout ?? {}; - const { selfStretch, flexSize, columnSpan, rowSpan } = layout; + const { + selfStretch, + flexSize, + columnStart, + rowStart, + columnSpan, + rowSpan, + } = layout; const parentLayout = useLayout() || {}; const { columnCount, minimumColumnWidth } = parentLayout; const id = useInstanceId( useBlockPropsChildLayoutStyles ); @@ -34,6 +41,14 @@ function useBlockPropsChildLayoutStyles( { style } ) { css = `${ selector } { flex-grow: 1; }`; + } else if ( columnStart && columnSpan ) { + css = `${ selector } { + grid-column: ${ columnStart } / span ${ columnSpan }; + }`; + } else if ( columnStart ) { + css = `${ selector } { + grid-column: ${ columnStart }; + }`; } else if ( columnSpan ) { css = `${ selector } { grid-column: span ${ columnSpan }; @@ -44,9 +59,20 @@ function useBlockPropsChildLayoutStyles( { style } ) { * columnCount is set, the grid is responsive so a * container query is needed for the span to resize. */ - if ( columnSpan && ( minimumColumnWidth || ! columnCount ) ) { - // Calculate the container query value. - const columnSpanNumber = parseInt( columnSpan ); + if ( + ( columnSpan || columnStart ) && + ( minimumColumnWidth || ! columnCount ) + ) { + // Check if columnSpan and columnStart are numbers so Math.max doesn't break. + const columnSpanNumber = columnSpan ? parseInt( columnSpan ) : null; + const columnStartNumber = columnStart + ? parseInt( columnStart ) + : null; + const highestNumber = Math.max( + columnSpanNumber, + columnStartNumber + ); + let parentColumnValue = parseFloat( minimumColumnWidth ); /** * 12rem is the default minimumColumnWidth value. @@ -70,16 +96,26 @@ function useBlockPropsChildLayoutStyles( { style } ) { const defaultGapValue = parentColumnUnit === 'px' ? 24 : 1.5; const containerQueryValue = - columnSpanNumber * parentColumnValue + - ( columnSpanNumber - 1 ) * defaultGapValue; + highestNumber * parentColumnValue + + ( highestNumber - 1 ) * defaultGapValue; + // If a span is set we want to preserve it as long as possible, otherwise we just reset the value. + const gridColumnValue = columnSpan ? '1/-1' : 'auto'; css += `@container (max-width: ${ containerQueryValue }${ parentColumnUnit }) { ${ selector } { - grid-column: 1 / -1; + grid-column: ${ gridColumnValue }; } }`; } - if ( rowSpan ) { + if ( rowStart && rowSpan ) { + css += `${ selector } { + grid-row: ${ rowStart } / span ${ rowSpan }; + }`; + } else if ( rowStart ) { + css += `${ selector } { + grid-row: ${ rowStart }; + }`; + } else if ( rowSpan ) { css += `${ selector } { grid-row: span ${ rowSpan }; }`; From e725d87a7826d5f9e5b22d73a868810bbce131b3 Mon Sep 17 00:00:00 2001 From: Pascal Birchler <pascalb@google.com> Date: Thu, 14 Mar 2024 03:26:04 +0100 Subject: [PATCH 15/21] Template Parts: Fix typo in translatable string (#59816) Co-authored-by: swissspidy <swissspidy@git.wordpress.org> Co-authored-by: talldan <talldanwp@git.wordpress.org> --- packages/block-library/src/template-part/edit/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-library/src/template-part/edit/index.js b/packages/block-library/src/template-part/edit/index.js index 77e247b68a12b1..34a60e2659bf0d 100644 --- a/packages/block-library/src/template-part/edit/index.js +++ b/packages/block-library/src/template-part/edit/index.js @@ -205,7 +205,7 @@ export default function TemplatePartEdit( { createSuccessNotice( sprintf( /* translators: %s: template part title. */ - __( 'Template Part "%s" replaceed.' ), + __( 'Template Part "%s" replaced.' ), templatePart.title?.rendered || templatePart.slug ), { From 78829110e633368c312f10850e9944617aeb5b87 Mon Sep 17 00:00:00 2001 From: Ramon <ramonjd@users.noreply.github.com> Date: Thu, 14 Mar 2024 13:49:17 +1100 Subject: [PATCH 16/21] E2E theme switch: match incoming theme slug, then optional folder (#59851) * Test for incoming theme slug first. The `optionalFolder` regex part matches paths with a folder, so it will return the first match, which might contain a folder. First try to honor the including theme slug, that is, without a folder, the look for the optional folder path, if any. Co-authored-by: ramonjd <ramonopoly@git.wordpress.org> Co-authored-by: andrewserong <andrewserong@git.wordpress.org> --- .../src/request-utils/themes.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/e2e-test-utils-playwright/src/request-utils/themes.ts b/packages/e2e-test-utils-playwright/src/request-utils/themes.ts index 6b4fd175887371..1f56814346d6ed 100644 --- a/packages/e2e-test-utils-playwright/src/request-utils/themes.ts +++ b/packages/e2e-test-utils-playwright/src/request-utils/themes.ts @@ -13,12 +13,25 @@ async function activateTheme( let response = await this.request.get( THEMES_URL ); const html = await response.text(); const optionalFolder = '([a-z0-9-]+%2F)?'; - const matchGroup = html.match( - `action=activate&stylesheet=${ optionalFolder }${ encodeURIComponent( + + // The `optionalFolder` regex part matches paths with a folder, + // so it will return the first match, which might contain a folder. + // First try to honor the included theme slug, that is, without a folder. + let matchGroup = html.match( + `action=activate&stylesheet=${ encodeURIComponent( themeSlug ) }&_wpnonce=[a-z0-9]+` ); + // If the theme is not found, try to match the theme slug with a folder. + if ( ! matchGroup ) { + matchGroup = html.match( + `action=activate&stylesheet=${ optionalFolder }${ encodeURIComponent( + themeSlug + ) }&_wpnonce=[a-z0-9]+` + ); + } + if ( ! matchGroup ) { if ( html.includes( `data-slug="${ themeSlug }"` ) ) { // The theme is already activated. From 26ac81daceef0879c5c5d7f6e91a2fe31a8676d7 Mon Sep 17 00:00:00 2001 From: tellthemachines <tellthemachines@users.noreply.github.com> Date: Thu, 14 Mar 2024 16:22:36 +1100 Subject: [PATCH 17/21] Allow blocks to be grouped as a Grid (#59853) Co-authored-by: tellthemachines <isabel_brison@git.wordpress.org> Co-authored-by: andrewserong <andrewserong@git.wordpress.org> --- .../components/convert-to-group-buttons/toolbar.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/block-editor/src/components/convert-to-group-buttons/toolbar.js b/packages/block-editor/src/components/convert-to-group-buttons/toolbar.js index 38405fe3ee6abb..21934bfd603f52 100644 --- a/packages/block-editor/src/components/convert-to-group-buttons/toolbar.js +++ b/packages/block-editor/src/components/convert-to-group-buttons/toolbar.js @@ -4,7 +4,7 @@ import { useDispatch, useSelect } from '@wordpress/data'; import { switchToBlockType, store as blocksStore } from '@wordpress/blocks'; import { ToolbarButton, ToolbarGroup } from '@wordpress/components'; -import { group, row, stack } from '@wordpress/icons'; +import { group, row, stack, grid } from '@wordpress/icons'; import { _x } from '@wordpress/i18n'; /** @@ -17,6 +17,7 @@ const layouts = { group: { type: 'constrained' }, row: { type: 'flex', flexWrap: 'nowrap' }, stack: { type: 'flex', orientation: 'vertical' }, + grid: { type: 'grid' }, }; function BlockGroupToolbar() { @@ -60,6 +61,7 @@ function BlockGroupToolbar() { const onConvertToRow = () => onConvertToGroup( 'row' ); const onConvertToStack = () => onConvertToGroup( 'stack' ); + const onConvertToGrid = () => onConvertToGroup( 'grid' ); // Don't render the button if the current selection cannot be grouped. // A good example is selecting multiple button blocks within a Buttons block: @@ -75,6 +77,9 @@ function BlockGroupToolbar() { const canInsertStack = !! variations.find( ( { name } ) => name === 'group-stack' ); + const canInsertGrid = !! variations.find( + ( { name } ) => name === 'group-grid' + ); return ( <ToolbarGroup> @@ -97,6 +102,13 @@ function BlockGroupToolbar() { onClick={ onConvertToStack } /> ) } + { canInsertGrid && ( + <ToolbarButton + icon={ grid } + label={ _x( 'Grid', 'verb' ) } + onClick={ onConvertToGrid } + /> + ) } </ToolbarGroup> ); } From 44cccd665602db61d93df2b9d5e7e427966e129c Mon Sep 17 00:00:00 2001 From: George Mamadashvili <georgemamadashvili@gmail.com> Date: Thu, 14 Mar 2024 13:49:18 +0800 Subject: [PATCH 18/21] Upgrade Playwright to v1.42 (#59339) Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: kevin940726 <kevin940726@git.wordpress.org> --- package-lock.json | 78 +++++++------------ package.json | 2 +- packages/scripts/package.json | 3 +- packages/scripts/scripts/test-playwright.js | 18 +---- .../editor/various/block-switcher.spec.js | 5 +- 5 files changed, 35 insertions(+), 71 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6036781cb0c9e2..76920212bf4a4c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -99,7 +99,7 @@ "@octokit/rest": "16.26.0", "@octokit/types": "6.34.0", "@octokit/webhooks-types": "5.6.0", - "@playwright/test": "1.39.0", + "@playwright/test": "1.42.1", "@pmmmwh/react-refresh-webpack-plugin": "0.5.11", "@react-native/babel-preset": "0.73.10", "@react-native/metro-babel-transformer": "0.73.10", @@ -7179,12 +7179,12 @@ } }, "node_modules/@playwright/test": { - "version": "1.39.0", - "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.39.0.tgz", - "integrity": "sha512-3u1iFqgzl7zr004bGPYiN/5EZpRUSFddQBra8Rqll5N0/vfpqlP9I9EXqAoGacuAbX6c9Ulg/Cjqglp5VkK6UQ==", + "version": "1.42.1", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.42.1.tgz", + "integrity": "sha512-Gq9rmS54mjBL/7/MvBaNOBwbfnh7beHvS6oS4srqXFcQHpQCV1+c8JXWE8VLPyRDhgS3H8x8A7hztqI9VnwrAQ==", "dev": true, "dependencies": { - "playwright": "1.39.0" + "playwright": "1.42.1" }, "bin": { "playwright": "cli.js" @@ -43858,12 +43858,12 @@ "dev": true }, "node_modules/playwright": { - "version": "1.39.0", - "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.39.0.tgz", - "integrity": "sha512-naE5QT11uC/Oiq0BwZ50gDmy8c8WLPRTEWuSSFVG2egBka/1qMoSqYQcROMT9zLwJ86oPofcTH2jBY/5wWOgIw==", + "version": "1.42.1", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.42.1.tgz", + "integrity": "sha512-PgwB03s2DZBcNRoW+1w9E+VkLBxweib6KTXM0M3tkiT4jVxKSi6PmVJ591J+0u10LUrgxB7dLRbiJqO5s2QPMg==", "dev": true, "dependencies": { - "playwright-core": "1.39.0" + "playwright-core": "1.42.1" }, "bin": { "playwright": "cli.js" @@ -43875,10 +43875,10 @@ "fsevents": "2.3.2" } }, - "node_modules/playwright/node_modules/playwright-core": { - "version": "1.39.0", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.39.0.tgz", - "integrity": "sha512-+k4pdZgs1qiM+OUkSjx96YiKsXsmb59evFoqv8SKO067qBA+Z2s/dCzJij/ZhdQcs2zlTAgRKfeiiLm8PQ2qvw==", + "node_modules/playwright-core": { + "version": "1.42.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.42.1.tgz", + "integrity": "sha512-mxz6zclokgrke9p1vtdy/COWBH+eOZgYUVVU34C73M+4j4HLlQJHtfcqiqqxpP0o8HhMkflvfbquLX5dg6wlfA==", "dev": true, "bin": { "playwright-core": "cli.js" @@ -57088,7 +57088,6 @@ "minimist": "^1.2.0", "npm-package-json-lint": "^6.4.0", "npm-packlist": "^3.0.0", - "playwright-core": "1.39.0", "postcss": "^8.4.5", "postcss-loader": "^6.2.1", "prettier": "npm:wp-prettier@3.0.3", @@ -57115,7 +57114,7 @@ "npm": ">=6.14.4" }, "peerDependencies": { - "@playwright/test": "^1.39.0", + "@playwright/test": "^1.42.1", "react": "^18.0.0", "react-dom": "^18.0.0" } @@ -57187,18 +57186,6 @@ "@sideway/pinpoint": "^2.0.0" } }, - "packages/scripts/node_modules/playwright-core": { - "version": "1.39.0", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.39.0.tgz", - "integrity": "sha512-+k4pdZgs1qiM+OUkSjx96YiKsXsmb59evFoqv8SKO067qBA+Z2s/dCzJij/ZhdQcs2zlTAgRKfeiiLm8PQ2qvw==", - "dev": true, - "bin": { - "playwright-core": "cli.js" - }, - "engines": { - "node": ">=16" - } - }, "packages/scripts/node_modules/rxjs": { "version": "7.8.1", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz", @@ -62424,12 +62411,12 @@ } }, "@playwright/test": { - "version": "1.39.0", - "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.39.0.tgz", - "integrity": "sha512-3u1iFqgzl7zr004bGPYiN/5EZpRUSFddQBra8Rqll5N0/vfpqlP9I9EXqAoGacuAbX6c9Ulg/Cjqglp5VkK6UQ==", + "version": "1.42.1", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.42.1.tgz", + "integrity": "sha512-Gq9rmS54mjBL/7/MvBaNOBwbfnh7beHvS6oS4srqXFcQHpQCV1+c8JXWE8VLPyRDhgS3H8x8A7hztqI9VnwrAQ==", "dev": true, "requires": { - "playwright": "1.39.0" + "playwright": "1.42.1" } }, "@pmmmwh/react-refresh-webpack-plugin": { @@ -72497,7 +72484,6 @@ "minimist": "^1.2.0", "npm-package-json-lint": "^6.4.0", "npm-packlist": "^3.0.0", - "playwright-core": "1.39.0", "postcss": "^8.4.5", "postcss-loader": "^6.2.1", "prettier": "npm:wp-prettier@3.0.3", @@ -72572,12 +72558,6 @@ "@sideway/pinpoint": "^2.0.0" } }, - "playwright-core": { - "version": "1.39.0", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.39.0.tgz", - "integrity": "sha512-+k4pdZgs1qiM+OUkSjx96YiKsXsmb59evFoqv8SKO067qBA+Z2s/dCzJij/ZhdQcs2zlTAgRKfeiiLm8PQ2qvw==", - "dev": true - }, "rxjs": { "version": "7.8.1", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz", @@ -91323,23 +91303,21 @@ "dev": true }, "playwright": { - "version": "1.39.0", - "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.39.0.tgz", - "integrity": "sha512-naE5QT11uC/Oiq0BwZ50gDmy8c8WLPRTEWuSSFVG2egBka/1qMoSqYQcROMT9zLwJ86oPofcTH2jBY/5wWOgIw==", + "version": "1.42.1", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.42.1.tgz", + "integrity": "sha512-PgwB03s2DZBcNRoW+1w9E+VkLBxweib6KTXM0M3tkiT4jVxKSi6PmVJ591J+0u10LUrgxB7dLRbiJqO5s2QPMg==", "dev": true, "requires": { "fsevents": "2.3.2", - "playwright-core": "1.39.0" - }, - "dependencies": { - "playwright-core": { - "version": "1.39.0", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.39.0.tgz", - "integrity": "sha512-+k4pdZgs1qiM+OUkSjx96YiKsXsmb59evFoqv8SKO067qBA+Z2s/dCzJij/ZhdQcs2zlTAgRKfeiiLm8PQ2qvw==", - "dev": true - } + "playwright-core": "1.42.1" } }, + "playwright-core": { + "version": "1.42.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.42.1.tgz", + "integrity": "sha512-mxz6zclokgrke9p1vtdy/COWBH+eOZgYUVVU34C73M+4j4HLlQJHtfcqiqqxpP0o8HhMkflvfbquLX5dg6wlfA==", + "dev": true + }, "please-upgrade-node": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz", diff --git a/package.json b/package.json index a0a197cc8cd78f..5e738a40239eba 100644 --- a/package.json +++ b/package.json @@ -111,7 +111,7 @@ "@octokit/rest": "16.26.0", "@octokit/types": "6.34.0", "@octokit/webhooks-types": "5.6.0", - "@playwright/test": "1.39.0", + "@playwright/test": "1.42.1", "@pmmmwh/react-refresh-webpack-plugin": "0.5.11", "@react-native/babel-preset": "0.73.10", "@react-native/metro-babel-transformer": "0.73.10", diff --git a/packages/scripts/package.json b/packages/scripts/package.json index 5723c0bf81952a..e5931dc271d1a2 100644 --- a/packages/scripts/package.json +++ b/packages/scripts/package.json @@ -72,7 +72,6 @@ "minimist": "^1.2.0", "npm-package-json-lint": "^6.4.0", "npm-packlist": "^3.0.0", - "playwright-core": "1.39.0", "postcss": "^8.4.5", "postcss-loader": "^6.2.1", "prettier": "npm:wp-prettier@3.0.3", @@ -92,7 +91,7 @@ "webpack-dev-server": "^4.15.1" }, "peerDependencies": { - "@playwright/test": "^1.39.0", + "@playwright/test": "^1.42.1", "react": "^18.0.0", "react-dom": "^18.0.0" }, diff --git a/packages/scripts/scripts/test-playwright.js b/packages/scripts/scripts/test-playwright.js index 4a8b0762336abd..9657ef23bdfe70 100644 --- a/packages/scripts/scripts/test-playwright.js +++ b/packages/scripts/scripts/test-playwright.js @@ -12,7 +12,6 @@ process.on( 'unhandledRejection', ( err ) => { /** * External dependencies */ -const path = require( 'path' ); const { resolve } = require( 'node:path' ); const { sync: spawn } = require( 'cross-spawn' ); @@ -28,20 +27,9 @@ const { } = require( '../utils' ); if ( ! getAsBooleanFromENV( 'PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD' ) ) { - const result = spawn( - 'node', - [ - path.resolve( - require.resolve( 'playwright-core' ), - '..', - 'cli.js' - ), - 'install', - ], - { - stdio: 'inherit', - } - ); + const result = spawn( 'npx', [ 'playwright', 'install' ], { + stdio: 'inherit', + } ); if ( result.status > 0 ) { process.exit( result.status ); diff --git a/test/e2e/specs/editor/various/block-switcher.spec.js b/test/e2e/specs/editor/various/block-switcher.spec.js index 8ddbcaa906f6df..88d58651a715a4 100644 --- a/test/e2e/specs/editor/various/block-switcher.spec.js +++ b/test/e2e/specs/editor/various/block-switcher.spec.js @@ -123,6 +123,7 @@ test.describe( 'Block Switcher', () => { test( 'Should show Columns block only if selected blocks are between limits (1-6)', async ( { editor, page, + pageUtils, } ) => { await editor.canvas .getByRole( 'button', { name: 'Add default block' } ) @@ -131,9 +132,7 @@ test.describe( 'Block Switcher', () => { await page.keyboard.press( 'ArrowUp' ); await page.keyboard.press( 'Enter' ); await page.keyboard.type( '## I am a header' ); - await page.keyboard.down( 'Shift' ); - await page.keyboard.press( 'ArrowUp' ); - await page.keyboard.up( 'Shift' ); + await pageUtils.pressKeys( 'primary+a', { times: 2 } ); await page .getByRole( 'toolbar', { name: 'Block tools' } ) From db1cd316462e244cb06883b64cb89fd413eb9f8d Mon Sep 17 00:00:00 2001 From: Nik Tsekouras <ntsekouras@outlook.com> Date: Thu, 14 Mar 2024 09:04:52 +0200 Subject: [PATCH 19/21] [Site Editor]: Move featured image at the top of the inspector controls (#59783) Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org> Co-authored-by: jameskoster <jameskoster@git.wordpress.org> Co-authored-by: youknowriad <youknowriad@git.wordpress.org> Co-authored-by: oandregal <oandregal@git.wordpress.org> Co-authored-by: jasmussen <joen@git.wordpress.org> --- .../components/sidebar/post-status/index.js | 2 ++ .../sidebar/settings-sidebar/index.js | 2 -- .../sidebar-edit-mode/page-panels/index.js | 2 -- .../page-panels/page-summary.js | 2 ++ .../sidebar-edit-mode/sidebar-card/index.js | 28 +++++++++++-------- .../sidebar-edit-mode/sidebar-card/style.scss | 6 +--- .../sidebar-edit-mode/template-panel/index.js | 2 -- .../components/post-featured-image/index.js | 21 ++++---------- .../components/post-featured-image/panel.js | 12 ++++++-- .../components/post-featured-image/style.scss | 21 ++++++-------- .../editor/various/post-visibility.spec.js | 7 ++++- test/e2e/specs/editor/various/sidebar.spec.js | 1 - 12 files changed, 51 insertions(+), 55 deletions(-) diff --git a/packages/edit-post/src/components/sidebar/post-status/index.js b/packages/edit-post/src/components/sidebar/post-status/index.js index 45d749fee2c658..ed828e2d1d5570 100644 --- a/packages/edit-post/src/components/sidebar/post-status/index.js +++ b/packages/edit-post/src/components/sidebar/post-status/index.js @@ -14,6 +14,7 @@ import { PostSyncStatus, PostURLPanel, PostTemplatePanel, + PostFeaturedImagePanel, store as editorStore, } from '@wordpress/editor'; @@ -60,6 +61,7 @@ export default function PostStatus() { <PluginPostStatusInfo.Slot> { ( fills ) => ( <> + <PostFeaturedImagePanel withPanelBody={ false } /> <PostVisibility /> <PostSchedulePanel /> <PostTemplatePanel /> diff --git a/packages/edit-post/src/components/sidebar/settings-sidebar/index.js b/packages/edit-post/src/components/sidebar/settings-sidebar/index.js index 31381fad5a2c44..55a938a783a009 100644 --- a/packages/edit-post/src/components/sidebar/settings-sidebar/index.js +++ b/packages/edit-post/src/components/sidebar/settings-sidebar/index.js @@ -22,7 +22,6 @@ import { PageAttributesPanel, PostDiscussionPanel, PostExcerptPanel, - PostFeaturedImagePanel, PostLastRevisionPanel, PostTaxonomiesPanel, } from '@wordpress/editor'; @@ -117,7 +116,6 @@ const SidebarContent = ( { <PluginDocumentSettingPanel.Slot /> <PostLastRevisionPanel /> <PostTaxonomiesPanel /> - <PostFeaturedImagePanel /> <PostExcerptPanel /> <PostDiscussionPanel /> <PageAttributesPanel /> diff --git a/packages/edit-site/src/components/sidebar-edit-mode/page-panels/index.js b/packages/edit-site/src/components/sidebar-edit-mode/page-panels/index.js index 0d4dee97aad984..552367c5777c45 100644 --- a/packages/edit-site/src/components/sidebar-edit-mode/page-panels/index.js +++ b/packages/edit-site/src/components/sidebar-edit-mode/page-panels/index.js @@ -16,7 +16,6 @@ import { PageAttributesPanel, PostDiscussionPanel, PostExcerptPanel, - PostFeaturedImagePanel, PostLastRevisionPanel, PostTaxonomiesPanel, store as editorStore, @@ -104,7 +103,6 @@ export default function PagePanels() { ) } <PostLastRevisionPanel /> <PostTaxonomiesPanel /> - <PostFeaturedImagePanel /> <PostExcerptPanel /> <PostDiscussionPanel /> <PageAttributesPanel /> diff --git a/packages/edit-site/src/components/sidebar-edit-mode/page-panels/page-summary.js b/packages/edit-site/src/components/sidebar-edit-mode/page-panels/page-summary.js index fd10946fd989d0..f00740639e9ad5 100644 --- a/packages/edit-site/src/components/sidebar-edit-mode/page-panels/page-summary.js +++ b/packages/edit-site/src/components/sidebar-edit-mode/page-panels/page-summary.js @@ -7,6 +7,7 @@ import { PostURLPanel, PostSchedulePanel, PostTemplatePanel, + PostFeaturedImagePanel, } from '@wordpress/editor'; /** @@ -23,6 +24,7 @@ export default function PageSummary( { } ) { return ( <VStack spacing={ 0 }> + <PostFeaturedImagePanel withPanelBody={ false } /> <PageStatus status={ status } date={ date } diff --git a/packages/edit-site/src/components/sidebar-edit-mode/sidebar-card/index.js b/packages/edit-site/src/components/sidebar-edit-mode/sidebar-card/index.js index 04e8d5667a2c20..3cf303da4ebe44 100644 --- a/packages/edit-site/src/components/sidebar-edit-mode/sidebar-card/index.js +++ b/packages/edit-site/src/components/sidebar-edit-mode/sidebar-card/index.js @@ -6,7 +6,11 @@ import classnames from 'classnames'; /** * WordPress dependencies */ -import { Icon } from '@wordpress/components'; +import { + Icon, + __experimentalHStack as HStack, + __experimentalVStack as VStack, +} from '@wordpress/components'; export default function SidebarCard( { className, @@ -18,17 +22,19 @@ export default function SidebarCard( { } ) { return ( <div className={ classnames( 'edit-site-sidebar-card', className ) }> - <Icon className="edit-site-sidebar-card__icon" icon={ icon } /> - <div className="edit-site-sidebar-card__content"> - <div className="edit-site-sidebar-card__header"> - <h2 className="edit-site-sidebar-card__title">{ title }</h2> - { actions } - </div> - <div className="edit-site-sidebar-card__description"> - { description } - </div> + <HStack spacing={ 3 } className="edit-site-sidebar-card__header"> + <Icon className="edit-site-sidebar-card__icon" icon={ icon } /> + <h2 className="edit-site-sidebar-card__title">{ title }</h2> + { actions } + </HStack> + <VStack className="edit-site-sidebar-card__content"> + { description && ( + <div className="edit-site-sidebar-card__description"> + { description } + </div> + ) } { children } - </div> + </VStack> </div> ); } diff --git a/packages/edit-site/src/components/sidebar-edit-mode/sidebar-card/style.scss b/packages/edit-site/src/components/sidebar-edit-mode/sidebar-card/style.scss index 06212077f1ba87..ae49a7901cf563 100644 --- a/packages/edit-site/src/components/sidebar-edit-mode/sidebar-card/style.scss +++ b/packages/edit-site/src/components/sidebar-edit-mode/sidebar-card/style.scss @@ -1,15 +1,12 @@ .edit-site-sidebar-card { - display: flex; - align-items: flex-start; - &__content { flex-grow: 1; - margin-bottom: $grid-unit-05; } &__title { font-weight: 500; line-height: $icon-size; + flex-grow: 1; &.edit-site-sidebar-card__title { font-size: $default-font-size; line-height: $default-line-height; @@ -24,7 +21,6 @@ &__icon { flex: 0 0 $icon-size; - margin-right: $grid-unit-15; width: $icon-size; height: $icon-size; } diff --git a/packages/edit-site/src/components/sidebar-edit-mode/template-panel/index.js b/packages/edit-site/src/components/sidebar-edit-mode/template-panel/index.js index c5af0f2201088f..a888c258ec36bc 100644 --- a/packages/edit-site/src/components/sidebar-edit-mode/template-panel/index.js +++ b/packages/edit-site/src/components/sidebar-edit-mode/template-panel/index.js @@ -7,7 +7,6 @@ import { PageAttributesPanel, PostDiscussionPanel, PostExcerptPanel, - PostFeaturedImagePanel, PostLastRevisionPanel, PostTaxonomiesPanel, store as editorStore, @@ -142,7 +141,6 @@ export default function TemplatePanel() { ) } <PostLastRevisionPanel /> <PostTaxonomiesPanel /> - <PostFeaturedImagePanel /> <PostExcerptPanel /> <PostDiscussionPanel /> <PageAttributesPanel /> diff --git a/packages/editor/src/components/post-featured-image/index.js b/packages/editor/src/components/post-featured-image/index.js index a04701abd28095..b4f4bfe4ee151f 100644 --- a/packages/editor/src/components/post-featured-image/index.js +++ b/packages/editor/src/components/post-featured-image/index.js @@ -7,7 +7,6 @@ import { DropZone, Button, Spinner, - ResponsiveWrapper, withNotices, withFilters, __experimentalHStack as HStack, @@ -99,10 +98,7 @@ function PostFeaturedImage( { const toggleRef = useRef(); const [ isLoading, setIsLoading ] = useState( false ); const { getSettings } = useSelect( blockEditorStore ); - const { mediaWidth, mediaHeight, mediaSourceUrl } = getMediaDetails( - media, - currentPostId - ); + const { mediaSourceUrl } = getMediaDetails( media, currentPostId ); function onDropFiles( filesList ) { getSettings().mediaUpload( { @@ -183,16 +179,11 @@ function PostFeaturedImage( { } > { !! featuredImageId && media && ( - <ResponsiveWrapper - naturalWidth={ mediaWidth } - naturalHeight={ mediaHeight } - isInline - > - <img - src={ mediaSourceUrl } - alt="" - /> - </ResponsiveWrapper> + <img + className="editor-post-featured-image__preview-image" + src={ mediaSourceUrl } + alt="" + /> ) } { isLoading && <Spinner /> } { ! featuredImageId && diff --git a/packages/editor/src/components/post-featured-image/panel.js b/packages/editor/src/components/post-featured-image/panel.js index c53aa153514611..87d80dda4a7c1f 100644 --- a/packages/editor/src/components/post-featured-image/panel.js +++ b/packages/editor/src/components/post-featured-image/panel.js @@ -15,7 +15,7 @@ import PostFeaturedImageCheck from './check'; const PANEL_NAME = 'featured-image'; -function FeaturedImage() { +export default function PostFeaturedImagePanel( { withPanelBody = true } ) { const { postType, isEnabled, isOpened } = useSelect( ( select ) => { const { getEditedPostAttribute, @@ -37,6 +37,14 @@ function FeaturedImage() { return null; } + if ( ! withPanelBody ) { + return ( + <PostFeaturedImageCheck> + <PostFeaturedImage /> + </PostFeaturedImageCheck> + ); + } + return ( <PostFeaturedImageCheck> <PanelBody @@ -51,5 +59,3 @@ function FeaturedImage() { </PostFeaturedImageCheck> ); } - -export default FeaturedImage; diff --git a/packages/editor/src/components/post-featured-image/style.scss b/packages/editor/src/components/post-featured-image/style.scss index 3b14662bf1d427..c7a871750c8154 100644 --- a/packages/editor/src/components/post-featured-image/style.scss +++ b/packages/editor/src/components/post-featured-image/style.scss @@ -1,7 +1,6 @@ .editor-post-featured-image { padding: 0; - .components-spinner { position: absolute; top: 50%; @@ -9,17 +8,11 @@ margin-top: -9px; margin-left: -9px; } - - // This keeps images at their intrinsic size (eg. a 50px - // image will never be wider than 50px). - .components-responsive-wrapper__content { - max-width: 100%; - width: auto; - } } .editor-post-featured-image__container { position: relative; + aspect-ratio: 2/1; &:hover, &:focus, @@ -38,26 +31,28 @@ @include reduce-motion("transition"); box-shadow: 0 0 0 0 var(--wp-admin-theme-color); overflow: hidden; // Ensure the focus style properly encapsulates the image. + outline: $border-width solid rgba(0, 0, 0, 0.1); + outline-offset: -#{$border-width}; - // Apply a max-height. display: flex; justify-content: center; - max-height: 150px; } .editor-post-featured-image__preview { height: auto; - .components-responsive-wrapper { + .editor-post-featured-image__preview-image { + object-fit: cover; width: 100%; - background: $gray-100; + object-position: 50% 50%; + aspect-ratio: 2/1; } } .editor-post-featured-image__toggle { border-radius: $radius-block-ui; background-color: $gray-100; - min-height: 90px; + height: 100%; line-height: 20px; padding: $grid-unit-10 0; text-align: center; diff --git a/test/e2e/specs/editor/various/post-visibility.spec.js b/test/e2e/specs/editor/various/post-visibility.spec.js index 365209ef2e4e55..0c367fb94ef6ea 100644 --- a/test/e2e/specs/editor/various/post-visibility.spec.js +++ b/test/e2e/specs/editor/various/post-visibility.spec.js @@ -89,7 +89,12 @@ test.describe( 'Post visibility', () => { await page.click( 'role=button[name="View next month"i]' ); await page.click( 'role=application[name="Calendar"] >> text=15' ); - + await page + .locator( '.block-editor-publish-date-time-picker' ) + .getByRole( 'button', { + name: 'Close', + } ) + .click(); await page.click( 'role=button[name="Select visibility: Public"i]' ); await page.click( 'role=radio[name="Private"i]' ); diff --git a/test/e2e/specs/editor/various/sidebar.spec.js b/test/e2e/specs/editor/various/sidebar.spec.js index c1c9136a9afda2..af0d9c2a17f3c6 100644 --- a/test/e2e/specs/editor/various/sidebar.spec.js +++ b/test/e2e/specs/editor/various/sidebar.spec.js @@ -114,7 +114,6 @@ test.describe( 'Sidebar', () => { 'Summary', 'Categories', 'Tags', - 'Featured image', 'Excerpt', 'Discussion', ] ); From c913f35403a27f22b87ac0eaca44d7a3be821bda Mon Sep 17 00:00:00 2001 From: Nik Tsekouras <ntsekouras@outlook.com> Date: Thu, 14 Mar 2024 09:59:05 +0200 Subject: [PATCH 20/21] [Data Views]: Remove separator in item actions (#59822) Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org> Co-authored-by: jameskoster <jameskoster@git.wordpress.org> Co-authored-by: mcsf <mcsf@git.wordpress.org> --- packages/dataviews/src/dataviews.js | 2 +- packages/dataviews/src/item-actions.js | 64 +++++-------------- packages/dataviews/src/utils.js | 22 ------- packages/dataviews/src/view-table.js | 16 ++++- .../src/components/page-pages/index.js | 2 +- .../page-templates-template-parts/index.js | 2 +- 6 files changed, 35 insertions(+), 73 deletions(-) diff --git a/packages/dataviews/src/dataviews.js b/packages/dataviews/src/dataviews.js index ca541064ab043a..ff658ecebfeb60 100644 --- a/packages/dataviews/src/dataviews.js +++ b/packages/dataviews/src/dataviews.js @@ -33,7 +33,7 @@ export default function DataViews( { fields, search = true, searchLabel = undefined, - actions, + actions = [], data, getItemId = defaultGetItemId, isLoading = false, diff --git a/packages/dataviews/src/item-actions.js b/packages/dataviews/src/item-actions.js index 5027c95d0219bd..db4da0d4924896 100644 --- a/packages/dataviews/src/item-actions.js +++ b/packages/dataviews/src/item-actions.js @@ -15,7 +15,6 @@ import { moreVertical } from '@wordpress/icons'; * Internal dependencies */ import { unlock } from './lock-unlock'; -import { WithDropDownMenuSeparators } from './utils'; const { DropdownMenuV2: DropdownMenu, @@ -106,32 +105,22 @@ function ActionsDropdownMenuGroup( { actions, item } ) { } export default function ItemActions( { item, actions, isCompact } ) { - const { primaryActions, secondaryActions } = useMemo( () => { - return actions.reduce( - ( accumulator, action ) => { - // If an action is eligible for all items, doesn't need - // to provide the `isEligible` function. - if ( action.isEligible && ! action.isEligible( item ) ) { - return accumulator; - } - if ( action.isPrimary && !! action.icon ) { - accumulator.primaryActions.push( action ); - } else { - accumulator.secondaryActions.push( action ); - } - return accumulator; - }, - { primaryActions: [], secondaryActions: [] } + const { primaryActions, eligibleActions } = useMemo( () => { + // If an action is eligible for all items, doesn't need + // to provide the `isEligible` function. + const _eligibleActions = actions.filter( + ( action ) => ! action.isEligible || action.isEligible( item ) ); + const _primaryActions = _eligibleActions.filter( + ( action ) => action.isPrimary && !! action.icon + ); + return { + primaryActions: _primaryActions, + eligibleActions: _eligibleActions, + }; }, [ actions, item ] ); if ( isCompact ) { - return ( - <CompactItemActions - item={ item } - primaryActions={ primaryActions } - secondaryActions={ secondaryActions } - /> - ); + return <CompactItemActions item={ item } actions={ eligibleActions } />; } return ( <HStack @@ -163,16 +152,12 @@ export default function ItemActions( { item, actions, isCompact } ) { /> ); } ) } - <CompactItemActions - item={ item } - primaryActions={ primaryActions } - secondaryActions={ secondaryActions } - /> + <CompactItemActions item={ item } actions={ eligibleActions } /> </HStack> ); } -function CompactItemActions( { item, primaryActions, secondaryActions } ) { +function CompactItemActions( { item, actions } ) { return ( <DropdownMenu trigger={ @@ -180,28 +165,13 @@ function CompactItemActions( { item, primaryActions, secondaryActions } ) { size="compact" icon={ moreVertical } label={ __( 'Actions' ) } - disabled={ - ! primaryActions.length && ! secondaryActions.length - } + disabled={ ! actions.length } className="dataviews-all-actions-button" /> } placement="bottom-end" > - <WithDropDownMenuSeparators> - { !! primaryActions.length && ( - <ActionsDropdownMenuGroup - actions={ primaryActions } - item={ item } - /> - ) } - { !! secondaryActions.length && ( - <ActionsDropdownMenuGroup - actions={ secondaryActions } - item={ item } - /> - ) } - </WithDropDownMenuSeparators> + <ActionsDropdownMenuGroup actions={ actions } item={ item } /> </DropdownMenu> ); } diff --git a/packages/dataviews/src/utils.js b/packages/dataviews/src/utils.js index 3b7a193f3d1e07..979e4a505e57b2 100644 --- a/packages/dataviews/src/utils.js +++ b/packages/dataviews/src/utils.js @@ -1,9 +1,3 @@ -/** - * WordPress dependencies - */ -import { Children, Fragment } from '@wordpress/element'; -import { privateApis as componentsPrivateApis } from '@wordpress/components'; - /** * Internal dependencies */ @@ -14,11 +8,6 @@ import { OPERATOR_IS_ANY, OPERATOR_IS_NONE, } from './constants'; -import { unlock } from './lock-unlock'; - -const { DropdownMenuSeparatorV2: DropdownMenuSeparator } = unlock( - componentsPrivateApis -); /** * Helper util to sort data by text fields, when sorting is done client side. @@ -109,14 +98,3 @@ export const sanitizeOperators = ( field ) => { return operators; }; - -export function WithDropDownMenuSeparators( { children } ) { - return Children.toArray( children ) - .filter( Boolean ) - .map( ( child, i ) => ( - <Fragment key={ i }> - { i > 0 && <DropdownMenuSeparator /> } - { child } - </Fragment> - ) ); -} diff --git a/packages/dataviews/src/view-table.js b/packages/dataviews/src/view-table.js index aa91e6d9ef77bf..5ef9d612523a00 100644 --- a/packages/dataviews/src/view-table.js +++ b/packages/dataviews/src/view-table.js @@ -23,6 +23,8 @@ import { useRef, useState, useMemo, + Children, + Fragment, } from '@wordpress/element'; /** @@ -31,7 +33,7 @@ import { import SingleSelectionCheckbox from './single-selection-checkbox'; import { unlock } from './lock-unlock'; import ItemActions from './item-actions'; -import { sanitizeOperators, WithDropDownMenuSeparators } from './utils'; +import { sanitizeOperators } from './utils'; import { ENUMERATION_TYPE, SORTING_DIRECTIONS } from './constants'; import { useSomeItemHasAPossibleBulkAction, @@ -44,8 +46,20 @@ const { DropdownMenuItemV2: DropdownMenuItem, DropdownMenuRadioItemV2: DropdownMenuRadioItem, DropdownMenuItemLabelV2: DropdownMenuItemLabel, + DropdownMenuSeparatorV2: DropdownMenuSeparator, } = unlock( componentsPrivateApis ); +function WithDropDownMenuSeparators( { children } ) { + return Children.toArray( children ) + .filter( Boolean ) + .map( ( child, i ) => ( + <Fragment key={ i }> + { i > 0 && <DropdownMenuSeparator /> } + { child } + </Fragment> + ) ); +} + const sortArrows = { asc: '↑', desc: '↓' }; const HeaderMenu = forwardRef( function HeaderMenu( diff --git a/packages/edit-site/src/components/page-pages/index.js b/packages/edit-site/src/components/page-pages/index.js index 93ea23cbf0949f..143169107f3ffc 100644 --- a/packages/edit-site/src/components/page-pages/index.js +++ b/packages/edit-site/src/components/page-pages/index.js @@ -355,11 +355,11 @@ export default function PagePages() { const actions = useMemo( () => [ viewPostAction, - trashPostAction, restorePostAction, permanentlyDeletePostAction, editPostAction, postRevisionsAction, + trashPostAction, ], [ permanentlyDeletePostAction, restorePostAction, editPostAction ] ); diff --git a/packages/edit-site/src/components/page-templates-template-parts/index.js b/packages/edit-site/src/components/page-templates-template-parts/index.js index 3ea08d0eb65a23..0d8442948473c0 100644 --- a/packages/edit-site/src/components/page-templates-template-parts/index.js +++ b/packages/edit-site/src/components/page-templates-template-parts/index.js @@ -415,9 +415,9 @@ export default function PageTemplatesTemplateParts( { postType } ) { const actions = useMemo( () => [ resetTemplateAction, - deleteTemplateAction, renameTemplateAction, postRevisionsAction, + deleteTemplateAction, ], [ resetTemplateAction ] ); From 87d3d4f88770cc68bd9c49b348ff6ac647d64646 Mon Sep 17 00:00:00 2001 From: Andy Fragen <andy@thefragens.com> Date: Thu, 14 Mar 2024 02:11:31 -0700 Subject: [PATCH 21/21] Ensure consistent return type in `WP_Navigation_Block_Renderer::get_markup_for_inner_block()` (#59820) * Fix for #59814 Fixes get_markup_for_inner_block() * fix WPCS issues --- packages/block-library/src/navigation/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/block-library/src/navigation/index.php b/packages/block-library/src/navigation/index.php index ca146868f4bbde..1a8b523e9328bc 100644 --- a/packages/block-library/src/navigation/index.php +++ b/packages/block-library/src/navigation/index.php @@ -135,9 +135,9 @@ private static function get_markup_for_inner_block( $inner_block ) { if ( static::does_block_need_a_list_item_wrapper( $inner_block ) ) { return '<li class="wp-block-navigation-item">' . $inner_block_content . '</li>'; } - - return $inner_block_content; } + + return $inner_block_content; } /**