From 2dd6aa1f7bdf98f83cd5bdd6e894e89a873ddc7e Mon Sep 17 00:00:00 2001 From: Aki Hamano <54422211+t-hamano@users.noreply.github.com> Date: Sat, 1 Feb 2025 01:59:05 +0900 Subject: [PATCH 01/10] Regenerate block fixtures (#68982) Co-authored-by: t-hamano Co-authored-by: Mamaduka --- test/integration/fixtures/blocks/core__separator-color.json | 4 ++-- .../fixtures/blocks/core__separator-custom-color.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/integration/fixtures/blocks/core__separator-color.json b/test/integration/fixtures/blocks/core__separator-color.json index d66a8b2e1a242e..d53b7287428038 100644 --- a/test/integration/fixtures/blocks/core__separator-color.json +++ b/test/integration/fixtures/blocks/core__separator-color.json @@ -4,8 +4,8 @@ "isValid": true, "attributes": { "opacity": "alpha-channel", - "backgroundColor": "accent", - "tagName": "hr" + "tagName": "hr", + "backgroundColor": "accent" }, "innerBlocks": [] } diff --git a/test/integration/fixtures/blocks/core__separator-custom-color.json b/test/integration/fixtures/blocks/core__separator-custom-color.json index 9b126f2b5be6c7..444cf3cf9b19b4 100644 --- a/test/integration/fixtures/blocks/core__separator-custom-color.json +++ b/test/integration/fixtures/blocks/core__separator-custom-color.json @@ -4,12 +4,12 @@ "isValid": true, "attributes": { "opacity": "alpha-channel", + "tagName": "hr", "style": { "color": { "background": "#5da54c" } - }, - "tagName": "hr" + } }, "innerBlocks": [] } From f2ea441ec7bda6dad4fdb43aac509fcee4a56abc Mon Sep 17 00:00:00 2001 From: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> Date: Sat, 1 Feb 2025 11:53:16 +1100 Subject: [PATCH 02/10] Site Editor: Use temporary redirects for deprecated URLs. (#68971) Modifies the redirects from deprecated site-editor URLs to use 302 temporary redirects rather than 301 permanent redirects. This prevents the browser from caching the redirect as the destination will differ for logged in and logged out users. This also switches from using `wp_redirect()` to `wp_safe_redirect()` in accordance with best practices when redirecting within a WordPress site. Follow up to #67199 Incorporating changes in https://github.com/WordPress/wordpress-develop/pull/7903 See https://core.trac.wordpress.org/ticket/62585 Co-authored-by: peterwilsoncc Co-authored-by: Mamaduka --- backport-changelog/6.8/7903.md | 2 ++ lib/compat/wordpress-6.8/site-editor.php | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/backport-changelog/6.8/7903.md b/backport-changelog/6.8/7903.md index cb20d8d2dd2b1b..60703831a8e391 100644 --- a/backport-changelog/6.8/7903.md +++ b/backport-changelog/6.8/7903.md @@ -1,3 +1,5 @@ https://github.com/WordPress/wordpress-develop/pull/7903 * https://github.com/WordPress/gutenberg/pull/67199 +* https://github.com/WordPress/gutenberg/pull/68971 + diff --git a/lib/compat/wordpress-6.8/site-editor.php b/lib/compat/wordpress-6.8/site-editor.php index 9b2575676047d1..82ac118b013c16 100644 --- a/lib/compat/wordpress-6.8/site-editor.php +++ b/lib/compat/wordpress-6.8/site-editor.php @@ -15,6 +15,16 @@ function ( $settings ) { } ); +/** + * Maps old site editor urls to the new updated ones. + * + * @since 6.8.0 + * @access private + * + * @global string $pagenow The filename of the current screen. + * + * @return string|false The new URL to redirect to, or false if no redirection is needed. + */ function gutenberg_get_site_editor_redirection() { global $pagenow; if ( 'site-editor.php' !== $pagenow || isset( $_REQUEST['p'] ) || ! $_SERVER['QUERY_STRING'] ) { @@ -96,10 +106,13 @@ function gutenberg_get_site_editor_redirection() { return add_query_arg( array( 'p' => '/' ) ); } +/** + * Redirect old site editor urls to the new updated ones. + */ function gutenberg_redirect_site_editor_deprecated_urls() { $redirection = gutenberg_get_site_editor_redirection(); if ( false !== $redirection ) { - wp_redirect( $redirection, 301 ); + wp_safe_redirect( $redirection ); exit; } } From 24fad40a6915c4ac1b7cb1403d9930b962fd5176 Mon Sep 17 00:00:00 2001 From: Shail Mehta Date: Sat, 1 Feb 2025 15:13:27 +0530 Subject: [PATCH 03/10] Changed Inline Document Order (#68992) Co-authored-by: shail-mehta Co-authored-by: Mamaduka --- packages/block-editor/src/components/inner-blocks/index.js | 4 ++-- .../block-editor/src/components/inner-blocks/index.native.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/block-editor/src/components/inner-blocks/index.js b/packages/block-editor/src/components/inner-blocks/index.js index ae587720278200..58faf9f9a34e1a 100644 --- a/packages/block-editor/src/components/inner-blocks/index.js +++ b/packages/block-editor/src/components/inner-blocks/index.js @@ -174,11 +174,11 @@ const ForwardedInnerBlocks = forwardRef( ( props, ref ) => { * returns. Optionally, you can also pass any other props through this hook, and * they will be merged and returned. * + * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md + * * @param {Object} props Optional. Props to pass to the element. Must contain * the ref if one is defined. * @param {Object} options Optional. Inner blocks options. - * - * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md */ export function useInnerBlocksProps( props = {}, options = {} ) { const { diff --git a/packages/block-editor/src/components/inner-blocks/index.native.js b/packages/block-editor/src/components/inner-blocks/index.native.js index 1398a5abd51e4b..635c44d2e085c5 100644 --- a/packages/block-editor/src/components/inner-blocks/index.native.js +++ b/packages/block-editor/src/components/inner-blocks/index.native.js @@ -35,11 +35,11 @@ import { MAX_NESTING_DEPTH } from './constants'; * returns. Optionally, you can also pass any other props through this hook, and * they will be merged and returned. * + * @see https://github.com/WordPress/gutenberg/blob/master/packages/block-editor/src/components/inner-blocks/README.md + * * @param {Object} props Optional. Props to pass to the element. Must contain * the ref if one is defined. * @param {Object} options Optional. Inner blocks options. - * - * @see https://github.com/WordPress/gutenberg/blob/master/packages/block-editor/src/components/inner-blocks/README.md */ export function useInnerBlocksProps( props = {}, options = {} ) { const fallbackRef = useRef(); From c9b256927a60011bc7bce1371c673972f84835f8 Mon Sep 17 00:00:00 2001 From: George Garside <191085+grgar@users.noreply.github.com> Date: Sun, 2 Feb 2025 06:17:15 +0000 Subject: [PATCH 04/10] Add optional chain to sizes indexing of media details in edit-site (#68995) This optional chaining is already present in 21 other lines in Gutenberg where `sizes` (in `media_details`) is indexed, but is missing on these two lines. For some reason, `media_details` is an empty object for some of my attachments on my site, so this throws a TypeError. This change resolves this issue. Co-authored-by: grgar Co-authored-by: Mamaduka --- packages/edit-site/src/components/media/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/edit-site/src/components/media/index.js b/packages/edit-site/src/components/media/index.js index e103e6bcddb5b2..0e0c7abaae4644 100644 --- a/packages/edit-site/src/components/media/index.js +++ b/packages/edit-site/src/components/media/index.js @@ -6,11 +6,11 @@ import { useEntityRecord } from '@wordpress/core-data'; function Media( { id, size = [ 'large', 'medium', 'thumbnail' ], ...props } ) { const { record: media } = useEntityRecord( 'root', 'media', id ); const currentSize = size.find( - ( s ) => !! media?.media_details?.sizes[ s ] + ( s ) => !! media?.media_details?.sizes?.[ s ] ); const mediaUrl = - media?.media_details?.sizes[ currentSize ]?.source_url || + media?.media_details?.sizes?.[ currentSize ]?.source_url || media?.source_url; if ( ! mediaUrl ) { From 36690dc8b264f0434d8786b648cac8b2a31e3582 Mon Sep 17 00:00:00 2001 From: Sainath Poojary <53347682+SainathPoojary@users.noreply.github.com> Date: Mon, 3 Feb 2025 10:25:25 +0530 Subject: [PATCH 05/10] Inserter: Remove block default icon from no results message (#68693) Co-authored-by: SainathPoojary Co-authored-by: afercia --- .../src/components/downloadable-blocks-panel/no-results.js | 5 ----- packages/block-editor/src/components/inserter/no-results.js | 5 ----- 2 files changed, 10 deletions(-) diff --git a/packages/block-directory/src/components/downloadable-blocks-panel/no-results.js b/packages/block-directory/src/components/downloadable-blocks-panel/no-results.js index f2344061f95660..e4d04cd244687d 100644 --- a/packages/block-directory/src/components/downloadable-blocks-panel/no-results.js +++ b/packages/block-directory/src/components/downloadable-blocks-panel/no-results.js @@ -2,17 +2,12 @@ * WordPress dependencies */ import { __ } from '@wordpress/i18n'; -import { Icon, blockDefault } from '@wordpress/icons'; import { Tip, ExternalLink } from '@wordpress/components'; function DownloadableBlocksNoResults() { return ( <>
-

{ __( 'No results found.' ) }

diff --git a/packages/block-editor/src/components/inserter/no-results.js b/packages/block-editor/src/components/inserter/no-results.js index 3ca6569dc14ea4..e005622f3cf3dc 100644 --- a/packages/block-editor/src/components/inserter/no-results.js +++ b/packages/block-editor/src/components/inserter/no-results.js @@ -2,15 +2,10 @@ * WordPress dependencies */ import { __ } from '@wordpress/i18n'; -import { Icon, blockDefault } from '@wordpress/icons'; function InserterNoResults() { return (
-

{ __( 'No results found.' ) }

); From 0feca715013b985b2cd7761c253fb3be5556870b Mon Sep 17 00:00:00 2001 From: Himanshu Pathak Date: Mon, 3 Feb 2025 12:59:34 +0530 Subject: [PATCH 06/10] Social Links: Remove redundant reduce-motion mixin (#69000) Co-authored-by: himanshupathak95 Co-authored-by: mirka <0mirka00@git.wordpress.org> Co-authored-by: Mayank-Tripathi32 Co-authored-by: t-hamano --- packages/block-library/src/social-links/editor.scss | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/block-library/src/social-links/editor.scss b/packages/block-library/src/social-links/editor.scss index 11f1ed86d11220..54a4154659eb2d 100644 --- a/packages/block-library/src/social-links/editor.scss +++ b/packages/block-library/src/social-links/editor.scss @@ -89,7 +89,6 @@ // Unconfigured placeholder links are semitransparent. .wp-social-link.wp-social-link__is-incomplete { opacity: 0.5; - @include reduce-motion("transition"); } .wp-block-social-links .is-selected .wp-social-link__is-incomplete, From be0e151a4d775a801c1fe9ab8047acefef5dbacb Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Mon, 3 Feb 2025 12:33:09 +0400 Subject: [PATCH 07/10] Editor: Display error message when loading current post fails (#68999) Co-authored-by: Mamaduka Co-authored-by: t-hamano --- .../editor/src/components/editor/index.js | 37 ++++++++++++------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/packages/editor/src/components/editor/index.js b/packages/editor/src/components/editor/index.js index 21becea43cd7ee..80c5419caf9975 100644 --- a/packages/editor/src/components/editor/index.js +++ b/packages/editor/src/components/editor/index.js @@ -31,12 +31,17 @@ function Editor( { extraSidebarPanels, ...props } ) { - const { post, template, hasLoadedPost } = useSelect( + const { post, template, hasLoadedPost, error } = useSelect( ( select ) => { - const { getEntityRecord, hasFinishedResolution } = - select( coreStore ); + const { + getEntityRecord, + getResolutionError, + hasFinishedResolution, + } = select( coreStore ); + + const postArgs = [ 'postType', postType, postId ]; return { - post: getEntityRecord( 'postType', postType, postId ), + post: getEntityRecord( ...postArgs ), template: templateId ? getEntityRecord( 'postType', @@ -44,11 +49,12 @@ function Editor( { templateId ) : undefined, - hasLoadedPost: hasFinishedResolution( 'getEntityRecord', [ - 'postType', - postType, - postId, - ] ), + hasLoadedPost: hasFinishedResolution( + 'getEntityRecord', + postArgs + ), + error: getResolutionError( 'getEntityRecord', postArgs ) + ?.message, }; }, [ postType, postId, templateId ] @@ -57,10 +63,15 @@ function Editor( { return ( <> { hasLoadedPost && ! post && ( - - { __( - "You attempted to edit an item that doesn't exist. Perhaps it was deleted?" - ) } + + { ! error + ? __( + "You attempted to edit an item that doesn't exist. Perhaps it was deleted?" + ) + : error } ) } { !! post && ( From 14955603b46957a00af95f31ca5a89b75e2c05ad Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Mon, 3 Feb 2025 13:52:07 +0400 Subject: [PATCH 08/10] Block Editor: Fix regression for root appender logic (#68994) Co-authored-by: Mamaduka Co-authored-by: t-hamano --- packages/block-editor/src/components/block-list/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/block-editor/src/components/block-list/index.js b/packages/block-editor/src/components/block-list/index.js index d3a2f0ae0795c8..61c5cc277c1355 100644 --- a/packages/block-editor/src/components/block-list/index.js +++ b/packages/block-editor/src/components/block-list/index.js @@ -201,6 +201,11 @@ function Items( { getDefaultBlockName(), rootClientId ) ); + const hasSelectedRoot = !! ( + rootClientId && + selectedBlockClientId && + rootClientId === selectedBlockClientId + ); return { order: _order, @@ -214,8 +219,8 @@ function Items( { hasAppender && ! _isZoomOut() && ( hasCustomAppender || - showRootAppender || - rootClientId === selectedBlockClientId ), + hasSelectedRoot || + showRootAppender ), }; }, [ rootClientId, hasAppender, hasCustomAppender ] From ebbe466a31807bb74509589859fd0ec391c2d1b8 Mon Sep 17 00:00:00 2001 From: Shail Mehta Date: Mon, 3 Feb 2025 15:27:57 +0530 Subject: [PATCH 09/10] Archives: Add Color Support (#68685) * Archives: Add Color Support Co-authored-by: shail-mehta Co-authored-by: carolinan --- docs/reference-guides/core-blocks.md | 2 +- packages/block-library/src/archives/block.json | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/reference-guides/core-blocks.md b/docs/reference-guides/core-blocks.md index 3579b9b81bf48f..6a8f3255297c46 100644 --- a/docs/reference-guides/core-blocks.md +++ b/docs/reference-guides/core-blocks.md @@ -14,7 +14,7 @@ Display a date archive of your posts. ([Source](https://github.com/WordPress/gut - **Name:** core/archives - **Category:** widgets -- **Supports:** align, interactivity (clientNavigation), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ +- **Supports:** align, color (background, gradients, link, text), interactivity (clientNavigation), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ - **Attributes:** displayAsDropdown, showLabel, showPostCounts, type ## Audio diff --git a/packages/block-library/src/archives/block.json b/packages/block-library/src/archives/block.json index 7fe956a994ed5a..0351a4b694c002 100644 --- a/packages/block-library/src/archives/block.json +++ b/packages/block-library/src/archives/block.json @@ -54,6 +54,15 @@ "fontSize": true } }, + "color": { + "gradients": true, + "link": true, + "__experimentalDefaultControls": { + "background": true, + "text": true, + "link": true + } + }, "interactivity": { "clientNavigation": true } From 693e315bd00ac36828364bc0b0d8f1fe22b5963c Mon Sep 17 00:00:00 2001 From: Yogesh Bhutkar Date: Mon, 3 Feb 2025 15:31:45 +0530 Subject: [PATCH 10/10] Shadow Panel: Add reset button (#68981) * feat: add remove button for block editor shadow panel * refactor: simplify the markup * refactor: revert `toggle` markup and use consistent wording * a11y: return focus to parent button on reset Co-authored-by: yogeshbhutkar Co-authored-by: t-hamano Co-authored-by: Mamaduka --- .../global-styles/shadow-panel-components.js | 55 ++++++++++++++----- .../src/components/global-styles/style.scss | 23 ++++++++ 2 files changed, 65 insertions(+), 13 deletions(-) diff --git a/packages/block-editor/src/components/global-styles/shadow-panel-components.js b/packages/block-editor/src/components/global-styles/shadow-panel-components.js index 1cfdff0be286ee..c335ef29384f4d 100644 --- a/packages/block-editor/src/components/global-styles/shadow-panel-components.js +++ b/packages/block-editor/src/components/global-styles/shadow-panel-components.js @@ -13,8 +13,8 @@ import { Composite, Tooltip, } from '@wordpress/components'; -import { useMemo } from '@wordpress/element'; -import { shadow as shadowIcon, Icon, check } from '@wordpress/icons'; +import { useMemo, useRef } from '@wordpress/element'; +import { shadow as shadowIcon, Icon, check, reset } from '@wordpress/icons'; /** * External dependencies @@ -119,7 +119,7 @@ export function ShadowPopover( { shadow, onShadowChange, settings } ) { ( { + const shadowButtonRef = useRef( undefined ); + const toggleProps = { onClick: onToggle, className: clsx( { 'is-open': isOpen } ), 'aria-expanded': isOpen, + ref: shadowButtonRef, + }; + + const removeButtonProps = { + onClick: () => { + if ( isOpen ) { + onToggle(); + } + onShadowChange( undefined ); + // Return focus to parent button. + shadowButtonRef.current?.focus(); + }, + className: clsx( + 'block-editor-global-styles__shadow-editor__remove-button', + { 'is-open': isOpen } + ), + label: __( 'Remove' ), }; return ( - + { !! shadow && ( + + ) } + ); }; } diff --git a/packages/block-editor/src/components/global-styles/style.scss b/packages/block-editor/src/components/global-styles/style.scss index c51ffa3116d9f0..5684cf9c0d3034 100644 --- a/packages/block-editor/src/components/global-styles/style.scss +++ b/packages/block-editor/src/components/global-styles/style.scss @@ -24,6 +24,7 @@ .block-editor-global-styles__shadow-dropdown { display: block; padding: 0; + position: relative; button { width: 100%; @@ -35,6 +36,28 @@ } } +.block-editor-global-styles__shadow-editor__remove-button { + position: absolute; + right: 0; + top: $grid-unit; + margin: auto $grid-unit auto; + opacity: 0; + @media not (prefers-reduced-motion) { + transition: opacity 0.1s ease-in-out; + } + + .block-editor-global-styles__shadow-dropdown:hover &, + &:focus, + &:hover { + opacity: 1; + } + + @media (hover: none) { + // Show reset button on devices that do not support hover. + opacity: 1; + } +} + // These styles are similar to the color palette. .block-editor-global-styles__shadow-indicator { appearance: none;