From d14d5a2d1c5891547e6222e0976172a88594ad65 Mon Sep 17 00:00:00 2001 From: Kelly Dwan Date: Mon, 3 Jun 2024 15:20:25 -0400 Subject: [PATCH] Content parser: Parse out the `href` from the Link Wrapper block The link destination of this block should be translatable. See https://github.com/WordPress/wporg-main-2022/pull/446#discussion_r1624663941 --- env/export-content/includes/parser.php | 7 +++++- .../tests/block-parser-test.php | 5 +++++ .../patterns/data-liberation.php | 22 +++++++++---------- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/env/export-content/includes/parser.php b/env/export-content/includes/parser.php index d6480a83..26088f6d 100644 --- a/env/export-content/includes/parser.php +++ b/env/export-content/includes/parser.php @@ -35,7 +35,6 @@ public function __construct( string $content = '' ) { // Generic shortcode handler. 'core/shortcode' => new Parsers\ShortcodeBlock(), - 'core/spacer' => new Parsers\Noop(), // These contain other blocks to be parsed. 'core/column' => new Parsers\Noop(), 'core/columns' => new Parsers\Noop(), @@ -47,8 +46,14 @@ public function __construct( string $content = '' ) { 'core/code' => new Parsers\Noop(), 'core/embed' => new Parsers\Noop(), + // No content. + 'core/spacer' => new Parsers\Noop(), + // Common core blocks that use the default parser. 'core/media-text' => new Parsers\BasicText(), + + // Shared custom blocks. + 'wporg/link-wrapper' => new Parsers\HTMLParser( 'a', [ 'href' ] ), ]; } diff --git a/env/export-content/tests/block-parser-test.php b/env/export-content/tests/block-parser-test.php index eec879bd..8570c2d2 100644 --- a/env/export-content/tests/block-parser-test.php +++ b/env/export-content/tests/block-parser-test.php @@ -140,6 +140,11 @@ public function data_block_content_i18n() { "\n
CookieLogged-in Users Only?
welcome-{blog_id}No
showCommentsNo
\n", "\n
\n", ], + [ + // Link Wrapper block with child content. + '

Matt Mullenweg at WordCamp Europe—streaming live June 15

', + '

', + ], ]; } diff --git a/source/wp-content/themes/wporg-main-2022/patterns/data-liberation.php b/source/wp-content/themes/wporg-main-2022/patterns/data-liberation.php index 80563172..a82ac4d0 100644 --- a/source/wp-content/themes/wporg-main-2022/patterns/data-liberation.php +++ b/source/wp-content/themes/wporg-main-2022/patterns/data-liberation.php @@ -46,49 +46,49 @@
- +

Squarespace to WordPress', 'wporg' ); ?>

- +

Tumblr to WordPress', 'wporg' ); ?>

- +

- +

- +

Wix to WordPress', 'wporg' ); ?>

- +

Drupal to WordPress', 'wporg' ); ?>

- +

- +

@@ -112,19 +112,19 @@
- +

Figma to Blocks', 'wporg' ); ?>

- +

Divi to Blocks', 'wporg' ); ?>

- +

Classic Editor to Blocks', 'wporg' ); ?>