diff --git a/backport-changelog/6.9/9702.md b/backport-changelog/6.9/9702.md index 310cbe927f68a1..ef70aadbc09def 100644 --- a/backport-changelog/6.9/9702.md +++ b/backport-changelog/6.9/9702.md @@ -1,3 +1,3 @@ https://github.com/WordPress/wordpress-develop/pull/9702 -* https://github.com/WordPress/gutenberg/pull/71483 \ No newline at end of file +* https://github.com/WordPress/gutenberg/pull/71483 diff --git a/backport-changelog/6.9/9990.md b/backport-changelog/6.9/9990.md new file mode 100644 index 00000000000000..1c376034c372f4 --- /dev/null +++ b/backport-changelog/6.9/9990.md @@ -0,0 +1,3 @@ +https://github.com/WordPress/wordpress-develop/pull/9990 + +* https://github.com/WordPress/gutenberg/pull/70975 diff --git a/lib/compat/wordpress-6.9/block-bindings.php b/lib/compat/wordpress-6.9/block-bindings.php index f46a2dce398ce6..f65a8937ad6158 100644 --- a/lib/compat/wordpress-6.9/block-bindings.php +++ b/lib/compat/wordpress-6.9/block-bindings.php @@ -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', @@ -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, diff --git a/packages/block-editor/src/utils/block-bindings.js b/packages/block-editor/src/utils/block-bindings.js index f7f44e2f599430..41d7f5d4ba5c5c 100644 --- a/packages/block-editor/src/utils/block-bindings.js +++ b/packages/block-editor/src/utils/block-bindings.js @@ -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' ], }; /** diff --git a/packages/block-library/src/pullquote/save.js b/packages/block-library/src/pullquote/save.js index 19fa49a3fa8345..843e0be23b8714 100644 --- a/packages/block-library/src/pullquote/save.js +++ b/packages/block-library/src/pullquote/save.js @@ -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 (
- { shouldShowCitation && ( + { displayCitation && ( ) }
diff --git a/packages/block-library/src/utils/get-transformed-metadata.js b/packages/block-library/src/utils/get-transformed-metadata.js index 53d79d3c1e42ac..8554866fce5505 100644 --- a/packages/block-library/src/utils/get-transformed-metadata.js +++ b/packages/block-library/src/utils/get-transformed-metadata.js @@ -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 = []; diff --git a/packages/patterns/src/constants.js b/packages/patterns/src/constants.js index 99563a1a16787f..ac3f5ad9a8f72c 100644 --- a/packages/patterns/src/constants.js +++ b/packages/patterns/src/constants.js @@ -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' ], + 'core/button': [ 'url', 'text', 'linkTarget', 'rel' ], + 'core/post-date': [ 'datetime' ], + 'core/pullquote': [ 'citation', 'value' ], }; export const PATTERN_OVERRIDES_BINDING_SOURCE = 'core/pattern-overrides'; diff --git a/test/integration/fixtures/blocks/core__pullquote__citation-block-bindings.html b/test/integration/fixtures/blocks/core__pullquote__citation-block-bindings.html new file mode 100644 index 00000000000000..f7efe093ad12bc --- /dev/null +++ b/test/integration/fixtures/blocks/core__pullquote__citation-block-bindings.html @@ -0,0 +1,7 @@ + +
+
+

Testing pullquote block...

+
+
+ diff --git a/test/integration/fixtures/blocks/core__pullquote__citation-block-bindings.json b/test/integration/fixtures/blocks/core__pullquote__citation-block-bindings.json new file mode 100644 index 00000000000000..860e15758dbc48 --- /dev/null +++ b/test/integration/fixtures/blocks/core__pullquote__citation-block-bindings.json @@ -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": [] + } +] diff --git a/test/integration/fixtures/blocks/core__pullquote__citation-block-bindings.parsed.json b/test/integration/fixtures/blocks/core__pullquote__citation-block-bindings.parsed.json new file mode 100644 index 00000000000000..e3ddefa17143f1 --- /dev/null +++ b/test/integration/fixtures/blocks/core__pullquote__citation-block-bindings.parsed.json @@ -0,0 +1,22 @@ +[ + { + "blockName": "core/pullquote", + "attrs": { + "metadata": { + "bindings": { + "citation": { + "source": "core/post-data", + "args": { + "key": "date" + } + } + } + } + }, + "innerBlocks": [], + "innerHTML": "\n
\n
\n

Testing pullquote block...

\n
\n
\n", + "innerContent": [ + "\n
\n
\n

Testing pullquote block...

\n
\n
\n" + ] + } +] diff --git a/test/integration/fixtures/blocks/core__pullquote__citation-block-bindings.serialized.html b/test/integration/fixtures/blocks/core__pullquote__citation-block-bindings.serialized.html new file mode 100644 index 00000000000000..33e6d1ee29f9d2 --- /dev/null +++ b/test/integration/fixtures/blocks/core__pullquote__citation-block-bindings.serialized.html @@ -0,0 +1,3 @@ + +

Testing pullquote block...

+