Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backport-changelog/6.9/9702.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
https://github.com/WordPress/wordpress-develop/pull/9702

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

* https://github.com/WordPress/gutenberg/pull/70975
9 changes: 8 additions & 1 deletion lib/compat/wordpress-6.9/block-bindings.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* @subpackage Block Bindings
*/


// The following filter can be removed once the minimum required WordPress version is 6.9 or newer.
add_filter(
'block_bindings_supported_attributes',
Expand All @@ -18,6 +17,14 @@ function ( $attributes, $block_type ) {
if ( 'core/post-date' === $block_type && ! in_array( 'datetime', $attributes, true ) ) {
$attributes[] = 'datetime';
}
if ( 'core/pullquote' === $block_type ) {
if ( ! in_array( 'value', $attributes, true ) ) {
$attributes[] = 'value';
}
if ( ! in_array( 'citation', $attributes, true ) ) {
$attributes[] = 'citation';
}
}
return $attributes;
},
10,
Expand Down
1 change: 1 addition & 0 deletions packages/block-editor/src/utils/block-bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const BLOCK_BINDINGS_ALLOWED_BLOCKS = {
'core/image': [ 'id', 'url', 'title', 'alt', 'caption' ],
'core/button': [ 'url', 'text', 'linkTarget', 'rel' ],
'core/post-date': [ 'datetime' ],
'core/pullquote': [ 'citation', 'value' ],
};

/**
Expand Down
14 changes: 11 additions & 3 deletions packages/block-library/src/pullquote/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,16 @@ import clsx from 'clsx';
import { RichText, useBlockProps } from '@wordpress/block-editor';

export default function save( { attributes } ) {
const { textAlign, citation, value } = attributes;
const shouldShowCitation = ! RichText.isEmpty( citation );
const {
textAlign,
citation,
value,
metadata: { bindings = {} } = {},
} = attributes;
const displayCitation =
! RichText.isEmpty( citation ) ||
!! bindings.citation ||
bindings.__default?.source === 'core/pattern-overrides';

return (
<figure
Expand All @@ -22,7 +30,7 @@ export default function save( { attributes } ) {
>
<blockquote>
<RichText.Content tagName="p" value={ value } />
{ shouldShowCitation && (
{ displayCitation && (
<RichText.Content tagName="cite" value={ citation } />
) }
</blockquote>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export function getTransformedMetadata(
'core/heading',
'core/image',
'core/button',
'core/pullquote',
];
// The metadata properties that should be preserved after the transform.
const transformSupportedProps = [];
Expand Down
6 changes: 4 additions & 2 deletions packages/patterns/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ export const PATTERN_SYNC_TYPES = {
export const PARTIAL_SYNCING_SUPPORTED_BLOCKS = {
'core/paragraph': [ 'content' ],
'core/heading': [ 'content' ],
'core/button': [ 'text', 'url', 'linkTarget', 'rel' ],
'core/image': [ 'id', 'url', 'title', 'alt' ],
'core/image': [ 'id', 'url', 'title', 'alt', 'caption' ],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@talldan, any reason this list should differ from bindable attributes?

@ockham, perhaps we should eliminate this list in a follow-up and replicate the same check as on the server with some filtering capabilities when consuming BLOCK_BINDINGS_ALLOWED_BLOCKS?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't think of a reason, as long as the blocks/attributes work correctly for users should be fine to support them.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ockham, perhaps we should eliminate this list in a follow-up and replicate the same check as on the server with some filtering capabilities when consuming BLOCK_BINDINGS_ALLOWED_BLOCKS?

Yeah, right now, the list is duplicated in way too many places.

I think my preferred option would be to make the server-side list the source of truth (since it already supports filtering), and communicate it to the client. I just haven't decided yet how to do that; I couldn't think of an existing REST API endpoint to add it to, and introducing a dedicated one seemed overblown.

Maybe I'll just add it to $editor_settings 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drafted a Core PR: WordPress/wordpress-develop#9992.

Will continue work on that (and a GB counterpart) later today.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GB counterpart: #71820

Both are ready for review!

'core/button': [ 'url', 'text', 'linkTarget', 'rel' ],
'core/post-date': [ 'datetime' ],
'core/pullquote': [ 'citation', 'value' ],
};

export const PATTERN_OVERRIDES_BINDING_SOURCE = 'core/pattern-overrides';
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!-- wp:core/pullquote {"metadata":{"bindings":{"citation":{"source":"core/post-data","args":{"key":"date"}}}}} -->
<figure class="wp-block-pullquote">
<blockquote>
<p>Testing pullquote block...</p><cite></cite>
</blockquote>
</figure>
<!-- /wp:core/pullquote -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[
{
"name": "core/pullquote",
"isValid": true,
"attributes": {
"value": "Testing pullquote block...",
"citation": "",
"metadata": {
"bindings": {
"citation": {
"source": "core/post-data",
"args": {
"key": "date"
}
}
}
}
},
"innerBlocks": []
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[
{
"blockName": "core/pullquote",
"attrs": {
"metadata": {
"bindings": {
"citation": {
"source": "core/post-data",
"args": {
"key": "date"
}
}
}
}
},
"innerBlocks": [],
"innerHTML": "\n<figure class=\"wp-block-pullquote\">\n <blockquote>\n <p>Testing pullquote block...</p><cite></cite>\n </blockquote>\n</figure>\n",
"innerContent": [
"\n<figure class=\"wp-block-pullquote\">\n <blockquote>\n <p>Testing pullquote block...</p><cite></cite>\n </blockquote>\n</figure>\n"
]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<!-- wp:pullquote {"metadata":{"bindings":{"citation":{"source":"core/post-data","args":{"key":"date"}}}}} -->
<figure class="wp-block-pullquote"><blockquote><p>Testing pullquote block...</p><cite></cite></blockquote></figure>
<!-- /wp:pullquote -->
Loading