links_add_base_url()WP 2.7.0

Adds a base URL to relative links in passed content.

By default, this function supports the 'src' and 'href' attributes. However, this can be modified via the $attrs parameter.

Хуков нет.

Возвращает

Строку. The processed content.

Использование

links_add_base_url( $content, $base, $attrs, fooo ) );
$content(строка) (обязательный)
String to search for links in.
$base(строка) (обязательный)
The base URL to prefix to links.
$attrs(массив)
The attributes which should be processed.
По умолчанию: array( foo
fooo ) (обязательный)
-

Заметки

  • Global. Строка. $_links_add_base

Список изменений

С версии 2.7.0 Введена.

Код links_add_base_url() WP 6.5.2

function links_add_base_url( $content, $base, $attrs = array( 'src', 'href' ) ) {
	global $_links_add_base;
	$_links_add_base = $base;
	$attrs           = implode( '|', (array) $attrs );
	return preg_replace_callback( "!($attrs)=(['\"])(.+?)\\2!i", '_links_add_base', $content );
}