Automattic\WooCommerce\Internal\ProductDownloads\ApprovedDirectories
Register::prepare_url_for_upsert
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.
Returns
String
.
Usage
// 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() Register::prepare url for upsert code WC 9.9.4
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; }