diff options
Diffstat (limited to 'plugins/jetpack/extensions/blocks/contact-info/class-jetpack-contact-info-block.php')
-rw-r--r-- | plugins/jetpack/extensions/blocks/contact-info/class-jetpack-contact-info-block.php | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/plugins/jetpack/extensions/blocks/contact-info/class-jetpack-contact-info-block.php b/plugins/jetpack/extensions/blocks/contact-info/class-jetpack-contact-info-block.php index 7a34cbbb..cecf6949 100644 --- a/plugins/jetpack/extensions/blocks/contact-info/class-jetpack-contact-info-block.php +++ b/plugins/jetpack/extensions/blocks/contact-info/class-jetpack-contact-info-block.php @@ -98,7 +98,8 @@ class Jetpack_Contact_Info_Block { } /** - * Adds phone schema attributes. + * Adds phone schema attributes. Also wraps the tel link in a span so that + * it's recognized as a telephone number in Google's Structured Data. * * @param array $attr Array containing the phone block attributes. * @param string $content String containing the phone block content. @@ -106,9 +107,14 @@ class Jetpack_Contact_Info_Block { * @return string */ public static function render_phone( $attr, $content ) { - $content = self::has_attributes( $attr, array( 'className' ) ) ? - str_replace( 'href="tel:', 'itemprop="telephone" href="tel:', $content ) : - ''; - return $content; + if ( self::has_attributes( $attr, array( 'className' ) ) ) { + return str_replace( + array( '<a href="tel:', '</a>' ), + array( '<span itemprop="telephone"><a href="tel:', '</a></span>' ), + $content + ); + } + + return ''; } } |