links_add_base_url() - WordPress 函数参考中文文档

返回介绍

links_add_base_url()

发布于 2017-09-11 字数1670 浏览 859 评论 0

links_add_base_url( string $content,  string $base,  array $attrs = array('src', 'href') )

Add a Base url to relative links in passed content.


描述

By default it supports the ‘src’ and ‘href’ attributes. However this can be changed via the 3rd param.


参数

$content

(string)
(Required)
String to search for links in.

$base

(string)
(Required)
The base URL to prefix to links.

$attrs

(array)
(Optional)
The attributes which should be processed.

Default value: array(‘src’, ‘href’)


返回值

(string) The processed content.


源代码

File: wp-includes/formatting.php

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 );
}

更新日志

Version 描述
2.7.0 Introduced.

相关函数

Used By

  • wp-admin/includes/plugin-install.php:
    install_plugin_information()

User Contributed Notes

上一篇:like_escape()

下一篇:links_add_target()

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!