get_bookmark_field

函数


get_bookmark_field ( $field, $bookmark, $context = 'display' )
参数
  • (string)
    $field
    The name of the data field to return.
    Required:
  • (int)
    $bookmark
    The bookmark ID to get field.
    Required:
  • (string)
    $context
    Optional. The context of how the field will be used.
    Required:
    Default: ‘display’
返回值
  • (string|WP_Error)
定义位置
  • wp-includes/bookmark.php
    , line 77
引入
2.3.0
弃用

Retrieves single bookmark data item or field.

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