acf_pro_has_license_url_changed()ACF 6.2.2

Checks if the home_url changed since license activation.

Хуков нет.

Возвращает

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

Использование

acf_pro_has_license_url_changed( $license, $url );
$license(массив)
Optional ACF license array.
По умолчанию: array()
$url(строка)
An optional URL to provide.
По умолчанию: ''

Список изменений

С версии 6.2.2 Введена.

Код acf_pro_has_license_url_changed() ACF 6.4.2

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