Skip to content

Commit

Permalink
prep build 2/4
Browse files Browse the repository at this point in the history
  • Loading branch information
bph committed Feb 4, 2025
2 parents d2fdb05 + 06379a3 commit 5dfa315
Show file tree
Hide file tree
Showing 37 changed files with 352 additions and 73 deletions.
2 changes: 2 additions & 0 deletions backport-changelog/6.8/7903.md
Original file line number Diff line number Diff line change
@@ -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

3 changes: 3 additions & 0 deletions backport-changelog/6.8/8245.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/WordPress/wordpress-develop/pull/8245

* https://github.com/WordPress/gutenberg/pull/68983
4 changes: 2 additions & 2 deletions docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -811,7 +811,7 @@ Display entries from any RSS or Atom feed. ([Source](https://github.com/WordPres

- **Name:** core/rss
- **Category:** widgets
- **Supports:** align, color (background, gradients, link, text), interactivity (clientNavigation), ~~html~~
- **Supports:** align, color (background, gradients, link, text), interactivity (clientNavigation), spacing (margin, padding), ~~html~~
- **Attributes:** blockLayout, columns, displayAuthor, displayDate, displayExcerpt, excerptLength, feedURL, itemsToShow

## Search
Expand Down
17 changes: 17 additions & 0 deletions lib/compat/wordpress-6.8/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,20 @@ function gutenberg_update_ignored_hooked_blocks_postmeta( $post ) {
add_filter( 'rest_pre_insert_page', 'gutenberg_update_ignored_hooked_blocks_postmeta' );
add_filter( 'rest_pre_insert_post', 'gutenberg_update_ignored_hooked_blocks_postmeta' );
add_filter( 'rest_pre_insert_wp_block', 'gutenberg_update_ignored_hooked_blocks_postmeta' );

/**
* Update Query `parents` argument validation for hierarchical post types.
* A zero is a valid parent ID for hierarchical post types. Used to display top-level items.
*
* @param array $query The query vars.
* @param WP_Block $block Block instance.
* @return array The filtered query vars.
*/
function gutenberg_parents_query_vars_from_query_block( $query, $block ) {
if ( ! empty( $block->context['query']['parents'] ) && is_post_type_hierarchical( $query['post_type'] ) ) {
$query['post_parent__in'] = array_unique( array_map( 'intval', $block->context['query']['parents'] ) );
}

return $query;
}
add_filter( 'query_loop_block_query_vars', 'gutenberg_parents_query_vars_from_query_block', 10, 2 );
15 changes: 14 additions & 1 deletion lib/compat/wordpress-6.8/site-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] ) {
Expand Down Expand Up @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<>
<div className="block-editor-inserter__no-results">
<Icon
className="block-editor-inserter__no-results-icon"
icon={ blockDefault }
/>
<p>{ __( 'No results found.' ) }</p>
</div>
<div className="block-editor-inserter__tips">
Expand Down
9 changes: 7 additions & 2 deletions packages/block-editor/src/components/block-list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ function Items( {
getDefaultBlockName(),
rootClientId
) );
const hasSelectedRoot = !! (
rootClientId &&
selectedBlockClientId &&
rootClientId === selectedBlockClientId
);

return {
order: _order,
Expand All @@ -214,8 +219,8 @@ function Items( {
hasAppender &&
! _isZoomOut() &&
( hasCustomAppender ||
showRootAppender ||
rootClientId === selectedBlockClientId ),
hasSelectedRoot ||
showRootAppender ),
};
},
[ rootClientId, hasAppender, hasCustomAppender ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -119,7 +119,7 @@ export function ShadowPopover( { shadow, onShadowChange, settings } ) {
<Dropdown
popoverProps={ popoverProps }
className="block-editor-global-styles__shadow-dropdown"
renderToggle={ renderShadowToggle() }
renderToggle={ renderShadowToggle( shadow, onShadowChange ) }
renderContent={ () => (
<DropdownContentWrapper paddingSize="medium">
<ShadowPopoverContainer
Expand All @@ -133,25 +133,54 @@ export function ShadowPopover( { shadow, onShadowChange, settings } ) {
);
}

function renderShadowToggle() {
function renderShadowToggle( shadow, onShadowChange ) {
return ( { onToggle, isOpen } ) => {
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 (
<Button __next40pxDefaultSize { ...toggleProps }>
<HStack justify="flex-start">
<Icon
className="block-editor-global-styles__toggle-icon"
icon={ shadowIcon }
size={ 24 }
<>
<Button __next40pxDefaultSize { ...toggleProps }>
<HStack justify="flex-start">
<Icon
className="block-editor-global-styles__toggle-icon"
icon={ shadowIcon }
size={ 24 }
/>
<FlexItem>{ __( 'Drop shadow' ) }</FlexItem>
</HStack>
</Button>
{ !! shadow && (
<Button
__next40pxDefaultSize
size="small"
icon={ reset }
{ ...removeButtonProps }
/>
<FlexItem>{ __( 'Drop shadow' ) }</FlexItem>
</HStack>
</Button>
) }
</>
);
};
}
Expand Down
23 changes: 23 additions & 0 deletions packages/block-editor/src/components/global-styles/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
.block-editor-global-styles__shadow-dropdown {
display: block;
padding: 0;
position: relative;

button {
width: 100%;
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions packages/block-editor/src/components/inner-blocks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 0 additions & 5 deletions packages/block-editor/src/components/inserter/no-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { Icon, blockDefault } from '@wordpress/icons';

function InserterNoResults() {
return (
<div className="block-editor-inserter__no-results">
<Icon
className="block-editor-inserter__no-results-icon"
icon={ blockDefault }
/>
<p>{ __( 'No results found.' ) }</p>
</div>
);
Expand Down
11 changes: 3 additions & 8 deletions packages/block-editor/src/hooks/aria-label.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@
import { addFilter } from '@wordpress/hooks';
import { hasBlockSupport } from '@wordpress/blocks';

const ARIA_LABEL_SCHEMA = {
type: 'string',
source: 'attribute',
attribute: 'aria-label',
selector: '*',
};

/**
* Filters registered block settings, extending attributes with ariaLabel using aria-label
* of the first node.
Expand All @@ -28,7 +21,9 @@ export function addAttribute( settings ) {
// Gracefully handle if settings.attributes is undefined.
settings.attributes = {
...settings.attributes,
ariaLabel: ARIA_LABEL_SCHEMA,
ariaLabel: {
type: 'string',
},
};
}

Expand Down
9 changes: 9 additions & 0 deletions packages/block-library/src/archives/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@
"fontSize": true
}
},
"color": {
"gradients": true,
"link": true,
"__experimentalDefaultControls": {
"background": true,
"text": true,
"link": true
}
},
"interactivity": {
"clientNavigation": true
}
Expand Down
14 changes: 14 additions & 0 deletions packages/block-library/src/rss/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@
"interactivity": {
"clientNavigation": true
},
"__experimentalBorder": {
"radius": true,
"color": true,
"width": true,
"style": true
},
"spacing": {
"margin": true,
"padding": true,
"__experimentalDefaultControls": {
"padding": false,
"margin": false
}
},
"color": {
"background": true,
"text": true,
Expand Down
15 changes: 14 additions & 1 deletion packages/block-library/src/rss/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,19 @@ export default function RSSEdit( { attributes, setAttributes } ) {
},
];

/*
* This function merges the existing attributes with additional style properties.
* The `border` and `spacing` properties are set to `undefined` to ensure that
* these styles are reset and not applied on the server side.
*/
const serverSideAttributes = {
...attributes,
style: {
...attributes?.style,
border: undefined,
spacing: undefined,
},
};
return (
<>
<BlockControls>
Expand Down Expand Up @@ -190,7 +203,7 @@ export default function RSSEdit( { attributes, setAttributes } ) {
<Disabled>
<ServerSideRender
block="core/rss"
attributes={ attributes }
attributes={ serverSideAttributes }
/>
</Disabled>
</div>
Expand Down
7 changes: 7 additions & 0 deletions packages/block-library/src/rss/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@
.wp-block-rss__placeholder-form .wp-block-rss__placeholder-input {
flex: 1 1 auto;
}
// Reset all styles when skipping block supports while server-side rendering.
// This prevents issues such as duplicate padding, borders etc.
.wp-block-rss .wp-block-rss {
all: inherit;
margin: 0;
padding: 0;
}
Loading

0 comments on commit 5dfa315

Please sign in to comment.