BP_XProfile_Field_Type_Telephone::display_filter( string $field_value, string|int $field_id = '' )

Format URL values for display.

Description

Parameters

$field_value

(string) (Required) The URL value, as saved in the database.

$field_id

(string|int) (Optional) ID of the field.

Default value: ''

Return

(string) URL converted to a link.

Source

File: bp-xprofile/classes/class-bp-xprofile-field-type-telephone.php

	public static function display_filter( $field_value, $field_id = '' ) {
		$url   = wp_strip_all_tags( $field_value );
		$parts = parse_url( $url );

		// Add the tel:// protocol to the field value.
		if ( isset( $parts['scheme'] ) ) {
			if ( strtolower( $parts['scheme'] ) !== 'tel' ) {
				$scheme = preg_quote( $parts['scheme'], '#' );
				$url    = preg_replace( '#^' . $scheme . '#i', 'tel', $url );
			}

			$url_text = preg_replace( '#^tel://#i', '', $url );

		} else {
			$url_text = $url;
			$url      = 'tel://' . $url;
		}

		return sprintf(
			'<a href="%1$s" rel="nofollow">%2$s</a>',
			esc_url( $url, array( 'tel' ) ),
			esc_html( $url_text )
		);
	}

Changelog

Changelog
Version Description
BuddyPress 3.0.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.