On this page
links_add_base_url( string $content, string $base, array $attrs = array('src', 'href') ): string
Adds a base URL to relative links in passed content.
Description
By default it supports the ‘src’ and ‘href’ attributes. However this can be changed via the 3rd param.
Parameters
$contentstring Required-
String to search for links in.
$basestring Required-
The base URL to prefix to links.
$attrsarray Optional-
The attributes which should be processed.
Default:
array('src', 'href')
Return
string The processed content.
Source
File: wp-includes/formatting.php. View all references
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 );
}
Related
Used By
| Used By | Description |
|---|---|
| install_plugin_information() wp-admin/includes/plugin-install.php | Displays plugin information in dialog box form. |
Changelog
| Version | Description |
|---|---|
| 2.7.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/links_add_base_url