Skip to content

Commit

Permalink
Social Links: Set the default protocol to 'https' if not specified (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka authored Jul 6, 2022
1 parent 932e7eb commit 299b894
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/block-library/src/social-link/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ function render_block_core_social_link( $attributes, $content, $block ) {
return '';
}

/**
* Prepend URL with https:// if it doesn't appear to contain a scheme
* and it's not a relative link starting with //.
*/
if ( ! parse_url( $url, PHP_URL_SCHEME ) && ! str_starts_with( $url, '//' ) ) {
$url = 'https://' . $url;
}

$rel_target_attributes = '';
if ( $open_in_new_tab ) {
$rel_target_attributes = 'rel="noopener nofollow" target="_blank"';
Expand Down

0 comments on commit 299b894

Please sign in to comment.