From 809fde7031eb12cb8af22f0ee985b361b3316f8a Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Wed, 6 Jul 2022 17:38:15 +0400 Subject: [PATCH 1/2] Social Link: Automatically prepend emails with mailto: --- packages/block-library/src/social-link/index.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/block-library/src/social-link/index.php b/packages/block-library/src/social-link/index.php index c1f5afcba4df0..4d48c8b9a98b7 100644 --- a/packages/block-library/src/social-link/index.php +++ b/packages/block-library/src/social-link/index.php @@ -27,6 +27,10 @@ function render_block_core_social_link( $attributes, $content, $block ) { return ''; } + if ( is_email( $url ) ) { + $url = 'mailto:' . $url; + } + /** * Prepend URL with https:// if it doesn't appear to contain a scheme * and it's not a relative link starting with //. From 7266dba842571c7e782942aa534408ffc2252b8d Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Wed, 6 Jul 2022 17:42:04 +0400 Subject: [PATCH 2/2] Add comment --- packages/block-library/src/social-link/index.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/block-library/src/social-link/index.php b/packages/block-library/src/social-link/index.php index 4d48c8b9a98b7..3b5e16ca33369 100644 --- a/packages/block-library/src/social-link/index.php +++ b/packages/block-library/src/social-link/index.php @@ -27,6 +27,10 @@ function render_block_core_social_link( $attributes, $content, $block ) { return ''; } + /** + * Prepend emails with `mailto:` if not set. + * The `is_email` returns false for emails with schema. + */ if ( is_email( $url ) ) { $url = 'mailto:' . $url; }