SimplePie_Item::get_id() public WP 2
Get the unique identifier for the item
This is usually used when writing code to check for new items in a feed.
Uses <atom:id>, <guid>, <dc:identifier> or the about attribute for RDF. If none of these are supplied (or $hash is true), creates an MD5 hash based on the permalink, title and content.
{} Это метод класса: SimplePie_Item{}
Хуков нет.
Возвращает
Строку/null
. Ничего.
Использование
$SimplePie_Item = new SimplePie_Item(); $SimplePie_Item->get_id( $hash, $fn );
- $hash(true|false)
- Should we force using a hash instead of the supplied ID?
- $fn(строка/false)
- User-supplied function to generate an hash
Список изменений
С версии 2 | Введена. |
Код SimplePie_Item::get_id() SimplePie Item::get id WP 5.7.1
public function get_id($hash = false, $fn = 'md5')
{
if (!$hash)
{
if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'id'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'id'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'identifier'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'identifier'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
elseif (isset($this->data['attribs'][SIMPLEPIE_NAMESPACE_RDF]['about']))
{
return $this->sanitize($this->data['attribs'][SIMPLEPIE_NAMESPACE_RDF]['about'], SIMPLEPIE_CONSTRUCT_TEXT);
}
}
if ($fn === false)
{
return null;
}
elseif (!is_callable($fn))
{
trigger_error('User-supplied function $fn must be callable', E_USER_WARNING);
$fn = 'md5';
}
return call_user_func($fn,
$this->get_permalink().$this->get_title().$this->get_content());
}