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.

Method of the class: Register{}

No Hooks.




// private - for code of main (parent) class only
$result = $this->prepare_url_for_upsert( $url ): string;
$url(string) (required)
The string URL to be normalized and trailing-slashed.

Register::prepare_url_for_upsert() code WC 8.7.0

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;