origin_of( $base_url ) . $location; } return $this->origin_of( $base_url ) . $this->directory_of( $base_url ) . $location; } private function origin_of( string $base_url ): string { return (string) preg_replace( self::ORIGIN_PATTERN, '$1', $base_url ); } private function directory_of( string $base_url ): string { $path = (string) wp_parse_url( $base_url, PHP_URL_PATH ); $last_separator = (int) strrpos( $path, self::PATH_SEPARATOR ); $directory = substr( $path, 0, $last_separator + 1 ); return self::PATH_SEPARATOR . ltrim( $directory, self::PATH_SEPARATOR ); } }