get_link()
云策文档标注
概述
get_link() 是一个已弃用的 WordPress 函数,用于根据 ID 检索书签数据。它已被 get_bookmark() 替代,自 2.1.0 版本起标记为弃用。
关键要点
- 函数功能:基于书签 ID 检索数据,返回对象或数组。
- 弃用状态:自 WordPress 2.1.0 起弃用,推荐使用 get_bookmark()。
- 参数说明:$bookmark_id(必需,整数),$output(可选,指定输出类型如 OBJECT、ARRAY_N、ARRAY_A),$filter(可选,指定过滤方式如 'raw'、'edit')。
- 返回值:根据 $output 参数返回书签对象或数组。
代码示例
function get_link( $bookmark_id, $output = OBJECT, $filter = 'raw' ) {
_deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmark()' );
return get_bookmark($bookmark_id, $output, $filter);
}注意事项
- 此函数已弃用,新代码应使用 get_bookmark() 以避免兼容性问题。
- 调用时,_deprecated_function() 会触发弃用通知,提醒开发者更新代码。
原文内容
Retrieves bookmark data based on ID.
Description
See also
Parameters
$bookmark_idintrequired-
ID of link
$outputstringoptional-
Type of output. Accepts OBJECT, ARRAY_N, or ARRAY_A.
Default:
OBJECT $filterstringoptional-
How to filter the link for output. Accepts
'raw','edit','attribute','js','db', or'display'. Default'raw'.
Source
function get_link( $bookmark_id, $output = OBJECT, $filter = 'raw' ) {
_deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmark()' );
return get_bookmark($bookmark_id, $output, $filter);
}
Changelog
| Version | Description |
|---|---|
| 2.1.0 | Deprecated. Use get_bookmark() |
| 2.0.0 | Introduced. |