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

Format URL values for display.


Parameters Parameters

$field_value

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

$field_id

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

Default value: ''


Top ↑

Return Return

(string) URL converted to a link.


Source 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 )
		);
	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.