355 | | return esc_url_raw( $url, array( 'http', 'https' ) ); |
| 357 | if ( ! preg_match( '/^https?:/', $url ) && ! empty( $this->url ) ) { |
| 358 | if ( preg_match( '/^[\/]{1}[^\/]+/', $url ) ) { |
| 359 | // From root: /blah |
| 360 | $url = preg_replace( '/^(https?:\/\/[^\/]+)(\/.*)?$/', '\1', $this->url ) . $url; |
| 361 | } else if ( preg_match( '/^[\/]{2}[^\/]+/', $url ) ) { |
| 362 | // Protocol relative: //blah.com/blah |
| 363 | $url = preg_replace( '/^(https?:)\/\/.+$/', '\1', $this->url ) . $url; |
| 364 | } else { |
| 365 | // Relative, or different protocol than http, set to already valid $this->url |
| 366 | $url = $this->url; |
| 367 | } |
| 368 | } |
| 369 | |
| 370 | $url = esc_url_raw( $url, array( 'http', 'https' ) ); |
| 371 | |
| 372 | return $url; |