Automattic\WooCommerce\Internal\ProductDownloads\ApprovedDirectories

Register::prepare_url_for_upsert()privateWC 1.0

Used when a URL string is prepared before potentially adding it to the database.

It will be normalized and trailing-slashed; a length check will also be performed.

Метод класса: Register{}

Хуков нет.

Возвращает

Строку.

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

// private - только в коде основоного (родительского) класса
$result = $this->prepare_url_for_upsert( $url ): string;
$url(строка) (обязательный)
The string URL to be normalized and trailing-slashed.

Код Register::prepare_url_for_upsert() WC 9.4.2

private function prepare_url_for_upsert( string $url ): string {
	$url = trailingslashit( $this->normalize_url( $url ) );

	if ( mb_strlen( $url ) > 256 ) {
		throw new ApprovedDirectoriesException( __( 'Approved directory URLs cannot be longer than 256 characters.', 'woocommerce' ), ApprovedDirectoriesException::INVALID_URL );
	}

	return $url;
}