PHP
6 days ago
class-convertedurl.php
6 days ago
class-cssurlprocessor.php
6 days ago
class-nativeurlintextprocessorwrapper.php
6 days ago
class-urlintextprocessor.php
6 days ago
class-urlrewritecache.php
6 days ago
class-wpurl.php
6 days ago
class-wpwhatwgurl.php
6 days ago
class-wpwhatwgurlsearchparams.php
6 days ago
functions.php
6 days ago
public-suffix-list.php
6 days ago
class-convertedurl.php
38 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WordPress\DataLiberation\URL; |
| 4 | |
| 5 | use Rowbot\URL\URL; |
| 6 | |
| 7 | /** |
| 8 | * Value object returned by WPURL::replace_base_url(). |
| 9 | * |
| 10 | * - Cast to string to get the updated URL as a string. |
| 11 | * - When the original URL was relative, casting returns a relative string against |
| 12 | * the new base. |
| 13 | */ |
| 14 | class ConvertedUrl { |
| 15 | |
| 16 | /** @var URL */ |
| 17 | public $new_url; |
| 18 | |
| 19 | /** @var string */ |
| 20 | public $new_raw_url; |
| 21 | |
| 22 | /** @var string|null */ |
| 23 | public $new_raw_relative_url; |
| 24 | |
| 25 | /** @var bool */ |
| 26 | public $was_relative = false; |
| 27 | |
| 28 | /** |
| 29 | * Returns the updated URL string. If the original was relative, returns a relative string. |
| 30 | */ |
| 31 | public function __toString(): string { |
| 32 | if ( $this->was_relative ) { |
| 33 | return $this->new_raw_relative_url; |
| 34 | } |
| 35 | return $this->new_raw_url; |
| 36 | } |
| 37 | } |
| 38 |