WordPress Version: 6.2
/**
* Retrieves single bookmark data item or field.
*
* @since 2.3.0
*
* @param string $field The name of the data field to return.
* @param int $bookmark The bookmark ID to get field.
* @param string $context Optional. The context of how the field will be used. Default 'display'.
* @return string|WP_Error
*/
function get_bookmark_field($field, $bookmark, $context = 'display')
{
$bookmark = (int) $bookmark;
$bookmark = get_bookmark($bookmark);
if (is_wp_error($bookmark)) {
return $bookmark;
}
if (!is_object($bookmark)) {
return '';
}
if (!isset($bookmark->{$field})) {
return '';
}
return sanitize_bookmark_field($field, $bookmark->{$field}, $bookmark->link_id, $context);
}