add_link()
云策文档标注
概述
add_link() 函数是一个包装函数,用于基于 $_POST 提供的值添加链接。它通过调用 edit_link() 函数实现,并返回整数或 WP_Error 对象。
关键要点
- 函数 add_link() 是 edit_link() 的包装器,直接调用 edit_link() 并返回其结果。
- 返回类型为 int|WP_Error:成功时返回链接 ID(整数),失败时返回 0 或 WP_Error 对象。
- 函数定义于 WordPress 2.0.0 版本引入,相关文件位于 wp-admin/includes/bookmark.php。
原文内容
Adds a link using values provided in $_POST.
Source
function add_link() {
return edit_link();
}
Changelog
| Version | Description |
|---|---|
| 2.0.0 | Introduced. |
Skip to note 2 content
Sakib MD Nazmush
add_link() : int|WP_Error This is a return-type declaration. It indicates that the add_link() function is expected to return either an integer or a WP_Error predefined object.
Function add_link() This is an implementation function. Inside this function, another function named edit_linik() is called.
And finally, the return edit_link() function is called. Its return value is immediately returned by the add_link() function.
In details, the add_link() function serves as a wrapper around the edit_link() function. The return type declaration specifies that the expected output of this function is either an integer or a WP_Error object. It suggests that the function is designed to handle either a successful integer result or an error condition represented by a WP_Error object, providing flexibility for error handling in the calling code. The specific details of what edit_link() does are not provided here, as it would depend on its implementation elsewhere in the codebase.