清理所有书签字段

原型

sanitize_bookmark( stdClass|array $bookmark, string $context = 'display' )

参数

$bookmark (stdClass|array) (Required) 书签行

$context (string) (Optional)   如何过滤字段

返回值

(stdClass|array)  与$ bookmark相同,但字段已清理。

源文件

路径:wp-includes/bookmark.php

<?php
...
function sanitize_bookmark($bookmark, $context = 'display') {
	$fields = array('link_id', 'link_url', 'link_name', 'link_image', 'link_target', 'link_category',
		'link_description', 'link_visible', 'link_owner', 'link_rating', 'link_updated',
		'link_rel', 'link_notes', 'link_rss', );
	if ( is_object($bookmark) ) {
		$do_object = true;
		$link_id = $bookmark->link_id;
	} else {
		$do_object = false;
		$link_id = $bookmark['link_id'];
	}
	foreach ( $fields as $field ) {
		if ( $do_object ) {
			if ( isset($bookmark->$field) )
				$bookmark->$field = sanitize_bookmark_field($field, $bookmark->$field, $link_id, $context);
		} else {
			if ( isset($bookmark[$field]) )
				$bookmark[$field] = sanitize_bookmark_field($field, $bookmark[$field], $link_id, $context);
		}
	}
	return $bookmark;
}
...
?>

其他

英文文档:https://developer.wordpress.org/reference/functions/sanitize_bookmark/