Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

_links_add_base() WordPress Function

The links_add_base() function allows you to add a base URL to relative links in WordPress. This can be useful if you want to ensure that all links on your site are absolute URLs.

_links_add_base( string $m ) #

Callback to add a base URL to relative links in passed content.


Parameters

$m

(string)(Required)The matched link.


Top ↑

Return

(string) The processed link.


Top ↑

Source

File: wp-includes/formatting.php

function _links_add_base( $m ) {
	global $_links_add_base;
	// 1 = attribute name  2 = quotation mark  3 = URL.
	return $m[1] . '=' . $m[2] .
		( preg_match( '#^(\w{1,20}):#', $m[3], $protocol ) && in_array( $protocol[1], wp_allowed_protocols(), true ) ?
			$m[3] :
			WP_Http::make_absolute_url( $m[3], $_links_add_base )
		)
		. $m[2];
}


Top ↑

Changelog

Changelog
VersionDescription
2.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.