get_bookmark_field()

最后更新于:2021-11-26 06:41:20

get_bookmark_field( string$field, int$bookmark, string$context=’display’)

Retrieve single bookmark data item or field.

参数

$field

(string) (Required) The name of the data field to return.

$bookmark

(int) (Required) The bookmark ID to get field.

$context

(string) (Optional) The context of how the field will be used.

Default value: ‘display’

响应

(string|GC_Error)

源文件

文件: gc-includes/bookmark.php

function get_bookmark_field( $field, $bookmark, $context = 'display' ) {
	$bookmark = (int) $bookmark;
	$bookmark = get_bookmark( $bookmark );

	if ( is_gc_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 );
}