wp_make_link_relative()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
wp_make_link_relative( string $link ): string
Описание
Удаляет протоколы http или https и домен. Сохраняет ‘/’ в начале пути, поэтому это не настоящая относительная ссылка, а ссылка от корня сайта.
Оригинал (английский)
Removes the http or https protocols and the domain. Keeps the path ‘/’ at the beginning, so it isn’t a true relative link, but from the web root base.
Параметры
$link
string
обязательный
Возвращаемое значение
string
Исходный код
wp-includes/formatting.php:4834
function wp_make_link_relative( $link ) {
return preg_replace( '|^(https?:)?//[^/]+(/?.*)|i', '$2', $link );
}
История изменений
| Версия | Описание |
|---|---|
| 4.1.0 | Support was added for relative URLs. |
| 2.1.0 | Introduced. |

