Outil de recherche WordPress pour les développeurs et auteurs de thèmes



sanitize_bookmark ›

Depuis2.3.0
Dépréciéen/a
sanitize_bookmark ( $bookmark, $context = 'display' )
Paramètres: (2)
  • (stdClass|array) $bookmark Bookmark row
    Requis: Oui
  • (string) $context Optional, default is 'display'. How to filter the fields
    Requis: Non
    Défaut: 'display'
Retourne:
  • (stdClass|array) Same type as $bookmark but with fields sanitized.
Défini(e) dans:
Codex:

Sanitizes all bookmark fields



Source

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