acf_pro_has_license_url_changed()ACF 6.2.2

Checks if the home_url changed since license activation.

No Hooks.

Returns

true|false. True if the URL has changed, false otherwise.

Usage

acf_pro_has_license_url_changed( $license, $url );
$license(array)
Optional ACF license array.
Default: array()
$url(string)
An optional URL to provide.
Default: ''

Changelog

Since 6.2.2 Introduced.

acf_pro_has_license_url_changed() code ACF 6.8.8

function acf_pro_has_license_url_changed( $license = array(), $url = '' ) {
	$license  = ! empty( $license ) ? $license : acf_pro_get_license();
	$home_url = ! empty( $url ) ? $url : acf_get_home_url();

	// We can't know without a license, so let's assume not.
	if ( ! is_array( $license ) || empty( $license['url'] ) ) {
		return false;
	}

	// We don't care if the protocol changed.
	$license_url = acf_strip_protocol( (string) $license['url'] );
	$home_url    = acf_strip_protocol( $home_url );

	// Treat www the same as non-www.
	if ( substr( $license_url, 0, 4 ) === 'www.' ) {
		$license_url = substr( $license_url, 4 );
	}

	if ( substr( $home_url, 0, 4 ) === 'www.' ) {
		$home_url = substr( $home_url, 4 );
	}

	// URLs do not match.
	if ( $license_url !== $home_url ) {
		return true;
	}

	return false;
}